@babylonlabs-io/wallet-connector 0.5.2 → 0.5.4
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 +2 -0
- package/dist/components/WalletProvider/components/WalletDialog.d.ts +2 -1
- package/dist/components/WalletProvider/index.d.ts +2 -1
- package/dist/context/Chain.context.d.ts +2 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/types.d.ts +1 -0
- package/dist/core/wallets/btc/keystone/provider.d.ts +9 -1
- package/dist/hooks/useWalletConnectors.d.ts +2 -1
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +279 -156
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -7,7 +7,8 @@ import { twMerge } from "tailwind-merge";
|
|
|
7
7
|
import { useState, useEffect, createContext, useContext, useMemo, useCallback, useLayoutEffect, memo } from "react";
|
|
8
8
|
import { initBTCCurve } from "@babylonlabs-io/btc-staking-ts";
|
|
9
9
|
import { viewSdk, SupportedResult, ReadStatus, PlayStatus } from "@keystonehq/sdk";
|
|
10
|
-
import
|
|
10
|
+
import * as bitcoin$1 from "bitcoinjs-lib";
|
|
11
|
+
import { networks as networks$1, payments as payments$2, Psbt, Transaction as Transaction$1, address as address$1 } from "bitcoinjs-lib";
|
|
11
12
|
function WalletButton({
|
|
12
13
|
className: e,
|
|
13
14
|
disabled: t = !1,
|
|
@@ -153,22 +154,23 @@ const defaultWalletGetter = (e) => (t) => t[e], createWallet = async ({ metadata
|
|
|
153
154
|
networks: [Network.MAINNET, Network.SIGNET],
|
|
154
155
|
provider: s
|
|
155
156
|
}), createWalletConnector = async ({
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
persistent: e,
|
|
158
|
+
metadata: t,
|
|
159
|
+
context: r,
|
|
160
|
+
config: s,
|
|
161
|
+
accountStorage: o
|
|
160
162
|
}) => {
|
|
161
|
-
const
|
|
162
|
-
for (const
|
|
163
|
-
|
|
163
|
+
const n = [], a = e ? o.get(t.chain) : void 0;
|
|
164
|
+
for (const p of t.wallets)
|
|
165
|
+
n.push(
|
|
164
166
|
await createWallet({
|
|
165
|
-
metadata:
|
|
166
|
-
context:
|
|
167
|
-
config:
|
|
167
|
+
metadata: p,
|
|
168
|
+
context: r,
|
|
169
|
+
config: s
|
|
168
170
|
})
|
|
169
171
|
);
|
|
170
|
-
const
|
|
171
|
-
return
|
|
172
|
+
const l = new WalletConnector(t.chain, t.name, t.icon, n, s);
|
|
173
|
+
return a && await l.connect(a), l;
|
|
172
174
|
}, icon$1 = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'?%3e%3csvg%20id='Layer_1'%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20800%20800'%3e%3cdefs%3e%3cstyle%3e.cls-1{fill:%23ce6533;fill-rule:evenodd;}%3c/style%3e%3c/defs%3e%3cpath%20class='cls-1'%20d='M66.5,198.56c-3.27-8.85-1.09-18.79,5.58-25.47l90.82-90.82c6.67-6.67,16.62-8.85,25.46-5.59l193.65,71.14c4.76,1.75,7.92,6.28,7.92,11.35v42.4c0,3.21-1.27,6.28-3.54,8.55l-47.14,47.13c-3.33,3.34-8.3,4.43-12.73,2.79l-52.02-19.18-57.16-21.09c-4.83-1.79-9.55,2.92-7.76,7.76l40.27,109.18c1.63,4.43,.55,9.4-2.79,12.73l-41.91,41.89c-4.72,4.72-4.72,12.38,0,17.1l42.13,42.13c3.34,3.34,4.43,8.31,2.79,12.73l-40.27,109.17c-1.79,4.84,2.92,9.55,7.76,7.76l109.18-40.28c4.43-1.63,9.4-.54,12.73,2.79l46.91,46.91c2.27,2.27,3.54,5.34,3.54,8.55v42.41c0,5.06-3.15,9.59-7.9,11.34l-193.42,71.36c-8.85,3.27-18.8,1.08-25.47-5.59l-90.83-90.83c-6.67-6.67-8.85-16.61-5.58-25.47l71.11-192.77c1.99-5.4,1.99-11.34,0-16.74L66.5,198.56Z'/%3e%3cpath%20class='cls-1'%20d='M733.5,601.44c3.27,8.85,1.09,18.79-5.58,25.47l-90.82,90.83c-6.67,6.67-16.61,8.85-25.46,5.59l-193.65-71.14c-4.76-1.75-7.92-6.28-7.92-11.35v-42.4c0-3.21,1.27-6.28,3.54-8.55l47.14-47.13c3.33-3.34,8.3-4.43,12.73-2.79l52.02,19.18,57.16,21.09c4.83,1.79,9.54-2.92,7.76-7.76l-40.27-109.18c-1.63-4.43-.55-9.4,2.79-12.73l41.91-41.89c4.72-4.72,4.72-12.38,0-17.1l-42.13-42.13c-3.34-3.34-4.43-8.31-2.79-12.73l40.27-109.17c1.79-4.84-2.92-9.55-7.76-7.76l-109.18,40.28c-4.43,1.63-9.4,.54-12.73-2.79l-46.91-46.91c-2.27-2.27-3.54-5.34-3.54-8.55v-42.41c0-5.06,3.15-9.59,7.9-11.34l193.42-71.36c8.85-3.27,18.79-1.08,25.47,5.59l90.82,90.83c6.68,6.67,8.86,16.61,5.59,25.47l-71.11,192.77c-2,5.4-2,11.34,0,16.74l71.34,193.37h0Z'/%3e%3c/svg%3e", metadata$b = {
|
|
173
175
|
id: "injectable",
|
|
174
176
|
name: (e) => {
|
|
@@ -81945,6 +81947,92 @@ function v4(e, t, r) {
|
|
|
81945
81947
|
throw new Error("Random bytes length must be >= 16");
|
|
81946
81948
|
return s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, unsafeStringify(s);
|
|
81947
81949
|
}
|
|
81950
|
+
class BIP322 {
|
|
81951
|
+
/**
|
|
81952
|
+
* Compute the message hash as specified in the BIP-322.
|
|
81953
|
+
* The standard is specified in BIP-340 as:
|
|
81954
|
+
* The function hashtag(x) where tag is a UTF-8 encoded tag name and x is a byte array returns the 32-byte hash SHA256(SHA256(tag) || SHA256(tag) || x).
|
|
81955
|
+
* @param message Message to be hashed
|
|
81956
|
+
* @returns Hashed message
|
|
81957
|
+
*/
|
|
81958
|
+
static hashMessage(t) {
|
|
81959
|
+
const { sha256: r } = bitcoin$1.crypto, s = r(this.TAG);
|
|
81960
|
+
return r(Buffer$e.concat([s, s, Buffer$e.from(t)]));
|
|
81961
|
+
}
|
|
81962
|
+
/**
|
|
81963
|
+
* Build a to_spend transaction using simple signature in accordance to the BIP-322.
|
|
81964
|
+
* @param message Message to be signed using BIP-322
|
|
81965
|
+
* @param scriptPublicKey The script public key for the signing wallet
|
|
81966
|
+
* @returns Bitcoin transaction that correspond to the to_spend transaction
|
|
81967
|
+
*/
|
|
81968
|
+
static buildToSpendTx(t, r) {
|
|
81969
|
+
const s = new bitcoin$1.Psbt();
|
|
81970
|
+
s.setVersion(0), s.setLocktime(0);
|
|
81971
|
+
const o = this.hashMessage(t), n = 0, a = 32, l = new Uint8Array([n, a]), p = new Uint8Array(l.length + o.length);
|
|
81972
|
+
return p.set(l), p.set(o, l.length), s.addInput({
|
|
81973
|
+
hash: "0".repeat(64),
|
|
81974
|
+
// vin[0].prevout.hash = 0000...000
|
|
81975
|
+
index: 4294967295,
|
|
81976
|
+
// vin[0].prevout.n = 0xFFFFFFFF
|
|
81977
|
+
sequence: 0,
|
|
81978
|
+
// vin[0].nSequence = 0
|
|
81979
|
+
finalScriptSig: Buffer$e.from(p),
|
|
81980
|
+
// vin[0].scriptSig = OP_0 PUSH32[ message_hash ]
|
|
81981
|
+
witnessScript: Buffer$e.from([])
|
|
81982
|
+
// vin[0].scriptWitness = []
|
|
81983
|
+
}), s.addOutput({
|
|
81984
|
+
value: 0,
|
|
81985
|
+
// vout[0].nValue = 0
|
|
81986
|
+
script: r
|
|
81987
|
+
// vout[0].scriptPubKey = message_challenge
|
|
81988
|
+
}), s.extractTransaction();
|
|
81989
|
+
}
|
|
81990
|
+
/**
|
|
81991
|
+
* Build a to_sign transaction using simple signature in accordance to the BIP-322.
|
|
81992
|
+
* @param toSpendTxId Transaction ID of the to_spend transaction as constructed by buildToSpendTx
|
|
81993
|
+
* @param witnessScript The script public key for the signing wallet, or the redeemScript for P2SH-P2WPKH address
|
|
81994
|
+
* @param isRedeemScript Set to true if the provided witnessScript is a redeemScript for P2SH-P2WPKH address, default to false
|
|
81995
|
+
* @param tapInternalKey Used to set the taproot internal public key of a taproot signing address when provided, default to undefined
|
|
81996
|
+
* @returns Ready-to-be-signed bitcoinjs.Psbt transaction
|
|
81997
|
+
*/
|
|
81998
|
+
static buildToSignTx(t, r, s = !1, o) {
|
|
81999
|
+
const n = new bitcoin$1.Psbt();
|
|
82000
|
+
return n.setVersion(0), n.setLocktime(0), n.addInput({
|
|
82001
|
+
hash: t,
|
|
82002
|
+
// vin[0].prevout.hash = to_spend.txid
|
|
82003
|
+
index: 0,
|
|
82004
|
+
// vin[0].prevout.n = 0
|
|
82005
|
+
sequence: 0,
|
|
82006
|
+
// vin[0].nSequence = 0
|
|
82007
|
+
witnessUtxo: {
|
|
82008
|
+
script: r,
|
|
82009
|
+
value: 0
|
|
82010
|
+
}
|
|
82011
|
+
}), s && n.updateInput(0, {
|
|
82012
|
+
redeemScript: r
|
|
82013
|
+
}), o && n.updateInput(0, {
|
|
82014
|
+
tapInternalKey: o
|
|
82015
|
+
}), n.addOutput({
|
|
82016
|
+
value: 0,
|
|
82017
|
+
// vout[0].nValue = 0
|
|
82018
|
+
script: Buffer$e.from([106])
|
|
82019
|
+
// vout[0].scriptPubKey = OP_RETURN
|
|
82020
|
+
}), n;
|
|
82021
|
+
}
|
|
82022
|
+
/**
|
|
82023
|
+
* Encode witness stack in a signed BIP-322 PSBT into its base-64 encoded format.
|
|
82024
|
+
* @param signedPsbt Signed PSBT
|
|
82025
|
+
* @returns Base-64 encoded witness data
|
|
82026
|
+
*/
|
|
82027
|
+
static encodeWitness(t) {
|
|
82028
|
+
const r = t.data.inputs[0].finalScriptWitness;
|
|
82029
|
+
if (!r)
|
|
82030
|
+
throw new Error("Cannot encode empty witness stack.");
|
|
82031
|
+
return r.toString("base64");
|
|
82032
|
+
}
|
|
82033
|
+
}
|
|
82034
|
+
// BIP322 message tag
|
|
82035
|
+
at(BIP322, "TAG", Buffer$e.from("BIP0322-signed-message"));
|
|
81948
82036
|
const COMPRESSED_PUBLIC_KEY_HEX_LENGTH = 66, NETWORKS = {
|
|
81949
82037
|
[Network.MAINNET]: {
|
|
81950
82038
|
name: "Mainnet",
|
|
@@ -82093,10 +82181,30 @@ class KeystoneProvider {
|
|
|
82093
82181
|
return r;
|
|
82094
82182
|
});
|
|
82095
82183
|
at(this, "getNetwork", async () => this.config.network);
|
|
82096
|
-
at(this, "signMessage", async (t, r) =>
|
|
82097
|
-
|
|
82098
|
-
|
|
82099
|
-
|
|
82184
|
+
at(this, "signMessage", async (t, r) => r === "bip322-simple" ? this.signMessageBIP322(t) : this.signMessageECDSA(t));
|
|
82185
|
+
/**
|
|
82186
|
+
* https://github.com/bitcoin/bips/blob/master/bip-0322.mediawiki
|
|
82187
|
+
* signMessageBIP322 signs a message using the BIP322 standard.
|
|
82188
|
+
* @param message
|
|
82189
|
+
* @returns signature
|
|
82190
|
+
*/
|
|
82191
|
+
at(this, "signMessageBIP322", async (t) => {
|
|
82192
|
+
var l, p;
|
|
82193
|
+
if (!((l = this.keystoneWaleltInfo) != null && l.scriptPubKeyHex) || !((p = this.keystoneWaleltInfo) != null && p.publicKeyHex))
|
|
82194
|
+
throw new Error("Keystone Wallet not connected");
|
|
82195
|
+
const r = Buffer$1$1.from(this.keystoneWaleltInfo.scriptPubKeyHex, "hex"), s = BIP322.buildToSpendTx(t, r), o = toXOnly_1(Buffer$1$1.from(this.keystoneWaleltInfo.publicKeyHex, "hex"));
|
|
82196
|
+
let n = BIP322.buildToSignTx(s.getId(), r, !1, o);
|
|
82197
|
+
n.updateInput(0, {
|
|
82198
|
+
sighashType: Transaction$1.SIGHASH_ALL
|
|
82199
|
+
}), n = this.enhancePsbt(n);
|
|
82200
|
+
const a = await this.sign(n.toHex());
|
|
82201
|
+
return BIP322.encodeWitness(a);
|
|
82202
|
+
});
|
|
82203
|
+
at(this, "signMessageECDSA", async (t) => {
|
|
82204
|
+
var l, p;
|
|
82205
|
+
if (!((l = this.keystoneWaleltInfo) != null && l.address) || !((p = this.keystoneWaleltInfo) != null && p.publicKeyHex))
|
|
82206
|
+
throw new Error("Keystone Wallet not connected");
|
|
82207
|
+
const r = this.dataSdk.btc.generateSignRequest({
|
|
82100
82208
|
requestId: v4(),
|
|
82101
82209
|
signData: Buffer$1$1.from(t, "utf-8").toString("hex"),
|
|
82102
82210
|
dataType: dist$v.KeystoneBitcoinSDK.DataType.message,
|
|
@@ -82108,8 +82216,8 @@ class KeystoneProvider {
|
|
|
82108
82216
|
}
|
|
82109
82217
|
],
|
|
82110
82218
|
origin: "babylon staking app"
|
|
82111
|
-
}),
|
|
82112
|
-
return Buffer$1$1.from(
|
|
82219
|
+
}), s = composeQRProcess(SupportedResult.UR_BTC_SIGNATURE), o = await this.viewSDK.getSdk(), n = await s(o, r), a = this.dataSdk.btc.parseSignature(n);
|
|
82220
|
+
return Buffer$1$1.from(a.signature, "hex").toString("base64");
|
|
82113
82221
|
});
|
|
82114
82222
|
at(this, "getInscriptions", async () => {
|
|
82115
82223
|
throw new Error("Method not implemented.");
|
|
@@ -82700,25 +82808,33 @@ const defaultState$1 = {
|
|
|
82700
82808
|
BTC: null,
|
|
82701
82809
|
BBN: null
|
|
82702
82810
|
}, Context$1 = createContext(defaultState$1);
|
|
82703
|
-
function ChainProvider({
|
|
82704
|
-
|
|
82705
|
-
|
|
82706
|
-
|
|
82707
|
-
|
|
82708
|
-
|
|
82709
|
-
|
|
82710
|
-
|
|
82811
|
+
function ChainProvider({
|
|
82812
|
+
persistent: e,
|
|
82813
|
+
storage: t,
|
|
82814
|
+
children: r,
|
|
82815
|
+
context: s,
|
|
82816
|
+
config: o,
|
|
82817
|
+
onError: n
|
|
82818
|
+
}) {
|
|
82819
|
+
const [a, l] = useState(defaultState$1), p = useCallback(async () => {
|
|
82820
|
+
const c = o.filter((w) => metadata[w.chain]).map(
|
|
82821
|
+
({ chain: w, config: b }) => createWalletConnector({
|
|
82822
|
+
persistent: e,
|
|
82823
|
+
metadata: metadata[w],
|
|
82824
|
+
context: s,
|
|
82825
|
+
config: b,
|
|
82826
|
+
accountStorage: t
|
|
82711
82827
|
})
|
|
82712
82828
|
);
|
|
82713
|
-
return (await Promise.all(
|
|
82714
|
-
}, []);
|
|
82829
|
+
return (await Promise.all(c)).reduce((w, b) => ({ ...w, [b.id]: b }), {});
|
|
82830
|
+
}, [e]);
|
|
82715
82831
|
useEffect(() => {
|
|
82716
|
-
|
|
82717
|
-
|
|
82718
|
-
}).catch(
|
|
82719
|
-
}, [
|
|
82720
|
-
const
|
|
82721
|
-
return /* @__PURE__ */ jsx(InscriptionProvider, { context:
|
|
82832
|
+
p().then((c) => {
|
|
82833
|
+
l(c);
|
|
82834
|
+
}).catch(n);
|
|
82835
|
+
}, [l, p, n]);
|
|
82836
|
+
const u = useMemo(() => Object.values(a).filter(Boolean), [a]);
|
|
82837
|
+
return /* @__PURE__ */ jsx(InscriptionProvider, { context: s, children: /* @__PURE__ */ jsx(StateProvider, { chains: u, children: /* @__PURE__ */ jsx(Context$1.Provider, { value: a, children: r }) }) });
|
|
82722
82838
|
}
|
|
82723
82839
|
const useChainProviders = () => useContext(Context$1), Context = createContext({});
|
|
82724
82840
|
function LifeCycleHooksProvider({ children: e, value: t }) {
|
|
@@ -82784,119 +82900,125 @@ function useWalletConnect() {
|
|
|
82784
82900
|
};
|
|
82785
82901
|
}
|
|
82786
82902
|
const ANIMATION_DELAY$1 = 1e3;
|
|
82787
|
-
function useWalletConnectors({
|
|
82788
|
-
const
|
|
82789
|
-
selectWallet:
|
|
82790
|
-
removeWallet:
|
|
82791
|
-
displayLoader:
|
|
82792
|
-
displayChains:
|
|
82793
|
-
displayInscriptions:
|
|
82794
|
-
displayError:
|
|
82795
|
-
confirm:
|
|
82796
|
-
close:
|
|
82797
|
-
reset:
|
|
82798
|
-
} = useWidgetState(), { showAgain:
|
|
82903
|
+
function useWalletConnectors({ persistent: e, accountStorage: t, onError: r }) {
|
|
82904
|
+
const s = useChainProviders(), {
|
|
82905
|
+
selectWallet: o,
|
|
82906
|
+
removeWallet: n,
|
|
82907
|
+
displayLoader: a,
|
|
82908
|
+
displayChains: l,
|
|
82909
|
+
displayInscriptions: p,
|
|
82910
|
+
displayError: u,
|
|
82911
|
+
confirm: c,
|
|
82912
|
+
close: v,
|
|
82913
|
+
reset: w
|
|
82914
|
+
} = useWidgetState(), { showAgain: b } = useInscriptionProvider(), { verifyBTCAddress: E, acceptTermsOfService: I } = useLifeCycleHooks();
|
|
82799
82915
|
useEffect(() => {
|
|
82800
|
-
const
|
|
82801
|
-
(
|
|
82802
|
-
|
|
82916
|
+
const q = Object.values(s).filter(Boolean).map(
|
|
82917
|
+
(k) => k.on("connecting", (F) => {
|
|
82918
|
+
a == null || a(F);
|
|
82803
82919
|
})
|
|
82804
82920
|
);
|
|
82805
|
-
return () =>
|
|
82806
|
-
}, [
|
|
82807
|
-
const
|
|
82808
|
-
BTC: (
|
|
82921
|
+
return () => q.forEach((k) => k());
|
|
82922
|
+
}, [a, s]), useEffect(() => {
|
|
82923
|
+
const M = Object.values(s).filter(Boolean), q = {
|
|
82924
|
+
BTC: (F) => async (j) => {
|
|
82809
82925
|
var y, T, D;
|
|
82810
|
-
|
|
82811
|
-
|
|
82812
|
-
|
|
82813
|
-
|
|
82814
|
-
|
|
82815
|
-
|
|
82816
|
-
((
|
|
82817
|
-
|
|
82818
|
-
|
|
82819
|
-
|
|
82820
|
-
|
|
82821
|
-
|
|
82822
|
-
|
|
82823
|
-
|
|
82824
|
-
|
|
82825
|
-
|
|
82826
|
-
|
|
82827
|
-
|
|
82828
|
-
|
|
82829
|
-
|
|
82830
|
-
|
|
82831
|
-
|
|
82832
|
-
|
|
82833
|
-
|
|
82834
|
-
|
|
82835
|
-
|
|
82836
|
-
|
|
82837
|
-
|
|
82838
|
-
|
|
82839
|
-
|
|
82840
|
-
|
|
82841
|
-
|
|
82842
|
-
|
|
82926
|
+
try {
|
|
82927
|
+
j && j.account && (o == null || o("BTC", j), e && t.set(F.id, j.id), await (I == null ? void 0 : I({
|
|
82928
|
+
address: j.account.address,
|
|
82929
|
+
public_key: j.account.publicKeyHex
|
|
82930
|
+
})));
|
|
82931
|
+
const L = () => void (b ? p == null ? void 0 : p() : l == null ? void 0 : l());
|
|
82932
|
+
if (!validateAddressWithPK(
|
|
82933
|
+
((y = j.account) == null ? void 0 : y.address) ?? "",
|
|
82934
|
+
((T = j.account) == null ? void 0 : T.publicKeyHex) ?? "",
|
|
82935
|
+
F.config.network
|
|
82936
|
+
)) {
|
|
82937
|
+
u == null || u({
|
|
82938
|
+
title: "Public Key Mismatch",
|
|
82939
|
+
description: "The Bitcoin address and Public Key for this wallet do not match. Please contact your wallet provider for support.",
|
|
82940
|
+
onSubmit: L,
|
|
82941
|
+
onCancel: () => {
|
|
82942
|
+
n == null || n(F.id), l == null || l();
|
|
82943
|
+
}
|
|
82944
|
+
});
|
|
82945
|
+
return;
|
|
82946
|
+
}
|
|
82947
|
+
if (E && !await E(((D = j.account) == null ? void 0 : D.address) ?? "")) {
|
|
82948
|
+
for (const C of M)
|
|
82949
|
+
await C.disconnect();
|
|
82950
|
+
u == null || u({
|
|
82951
|
+
title: "Connection Failed",
|
|
82952
|
+
description: "The wallet cannot be connected.",
|
|
82953
|
+
submitButton: "",
|
|
82954
|
+
cancelButton: "Done",
|
|
82955
|
+
onCancel: async () => {
|
|
82956
|
+
v == null || v(), setTimeout(() => void (w == null ? void 0 : w()), ANIMATION_DELAY$1);
|
|
82957
|
+
}
|
|
82958
|
+
});
|
|
82959
|
+
return;
|
|
82960
|
+
}
|
|
82961
|
+
L();
|
|
82962
|
+
} catch (L) {
|
|
82963
|
+
r == null || r(L);
|
|
82843
82964
|
}
|
|
82844
|
-
j();
|
|
82845
82965
|
},
|
|
82846
|
-
BBN: (
|
|
82847
|
-
|
|
82966
|
+
BBN: (F) => (j) => {
|
|
82967
|
+
j && (o == null || o(F.id, j), e && t.set(F.id, j.id)), l == null || l();
|
|
82848
82968
|
}
|
|
82849
|
-
},
|
|
82850
|
-
(
|
|
82851
|
-
var
|
|
82852
|
-
return
|
|
82969
|
+
}, k = M.map(
|
|
82970
|
+
(F) => {
|
|
82971
|
+
var j;
|
|
82972
|
+
return F.on("connect", (j = q[F.id]) == null ? void 0 : j.call(q, F));
|
|
82853
82973
|
}
|
|
82854
82974
|
);
|
|
82855
|
-
return
|
|
82856
|
-
|
|
82857
|
-
}), () =>
|
|
82975
|
+
return M.forEach((F) => {
|
|
82976
|
+
o == null || o(F.id, F.connectedWallet);
|
|
82977
|
+
}), () => k.forEach((F) => F());
|
|
82858
82978
|
}, [
|
|
82859
|
-
|
|
82979
|
+
r,
|
|
82860
82980
|
o,
|
|
82981
|
+
n,
|
|
82982
|
+
p,
|
|
82861
82983
|
l,
|
|
82862
|
-
|
|
82863
|
-
|
|
82984
|
+
E,
|
|
82985
|
+
w,
|
|
82864
82986
|
v,
|
|
82865
|
-
|
|
82866
|
-
|
|
82867
|
-
|
|
82987
|
+
s,
|
|
82988
|
+
b,
|
|
82989
|
+
e
|
|
82868
82990
|
]), useEffect(() => {
|
|
82869
|
-
const
|
|
82870
|
-
(
|
|
82871
|
-
|
|
82991
|
+
const q = Object.values(s).filter(Boolean).map(
|
|
82992
|
+
(k) => k.on("disconnect", (F) => {
|
|
82993
|
+
F && (n == null || n(k.id), l == null || l(), e && t.delete(k.id));
|
|
82872
82994
|
})
|
|
82873
82995
|
);
|
|
82874
|
-
return () =>
|
|
82875
|
-
}, [
|
|
82876
|
-
const
|
|
82877
|
-
(
|
|
82878
|
-
|
|
82996
|
+
return () => q.forEach((k) => k());
|
|
82997
|
+
}, [n, l, s, e]), useEffect(() => {
|
|
82998
|
+
const q = Object.values(s).filter(Boolean).map(
|
|
82999
|
+
(k) => k.on("error", (F) => {
|
|
83000
|
+
r == null || r(F), l == null || l();
|
|
82879
83001
|
})
|
|
82880
83002
|
);
|
|
82881
|
-
return () =>
|
|
82882
|
-
}, [
|
|
82883
|
-
const
|
|
82884
|
-
|
|
82885
|
-
}, [
|
|
82886
|
-
const
|
|
82887
|
-
async (
|
|
82888
|
-
const
|
|
82889
|
-
await (
|
|
83003
|
+
return () => q.forEach((k) => k());
|
|
83004
|
+
}, [r, l, s]), useEffect(() => {
|
|
83005
|
+
const M = Object.values(s).filter(Boolean);
|
|
83006
|
+
e && M.length && M.every((q) => t.has(q.id)) && (c == null || c(), l == null || l());
|
|
83007
|
+
}, [e, s, c, l]);
|
|
83008
|
+
const x = useCallback(
|
|
83009
|
+
async (M, q) => {
|
|
83010
|
+
const k = s[M.id];
|
|
83011
|
+
await (k == null ? void 0 : k.connect(q.id));
|
|
82890
83012
|
},
|
|
82891
|
-
[
|
|
82892
|
-
),
|
|
82893
|
-
async (
|
|
82894
|
-
const
|
|
82895
|
-
await (
|
|
83013
|
+
[s]
|
|
83014
|
+
), B = useCallback(
|
|
83015
|
+
async (M) => {
|
|
83016
|
+
const q = s[M];
|
|
83017
|
+
await (q == null ? void 0 : q.disconnect());
|
|
82896
83018
|
},
|
|
82897
|
-
[
|
|
83019
|
+
[s]
|
|
82898
83020
|
);
|
|
82899
|
-
return { connect:
|
|
83021
|
+
return { connect: x, disconnect: B };
|
|
82900
83022
|
}
|
|
82901
83023
|
function useWalletWidgets(e, t) {
|
|
82902
83024
|
const r = useCallback(
|
|
@@ -83330,31 +83452,31 @@ function Screen(e) {
|
|
|
83330
83452
|
return /* @__PURE__ */ jsx(t, { ...e });
|
|
83331
83453
|
}
|
|
83332
83454
|
const ANIMATION_DELAY = 1e3;
|
|
83333
|
-
function WalletDialog({
|
|
83334
|
-
const { visible:
|
|
83335
|
-
|
|
83336
|
-
}, [
|
|
83337
|
-
(
|
|
83338
|
-
|
|
83455
|
+
function WalletDialog({ persistent: e, storage: t, config: r, onError: s }) {
|
|
83456
|
+
const { visible: o, screen: n, confirmed: a, close: l, confirm: p, displayChains: u } = useWidgetState(), { toggleShowAgain: c, toggleLockInscriptions: v } = useInscriptionProvider(), w = useChainProviders(), b = useWalletWidgets(w, r), { connect: E, disconnect: I } = useWalletConnectors({ persistent: e, accountStorage: t, onError: s }), { disconnect: x } = useWalletConnect(), B = useCallback(() => {
|
|
83457
|
+
u == null || u();
|
|
83458
|
+
}, [u]), M = useCallback(
|
|
83459
|
+
(F, j) => {
|
|
83460
|
+
c == null || c(j), v == null || v(F), u == null || u();
|
|
83339
83461
|
},
|
|
83340
|
-
[
|
|
83341
|
-
),
|
|
83342
|
-
|
|
83343
|
-
}, [
|
|
83344
|
-
|
|
83345
|
-
}, [
|
|
83346
|
-
return /* @__PURE__ */ jsx(ResponsiveDialog, { className: "min-h-[80%]", open:
|
|
83462
|
+
[c, v, u]
|
|
83463
|
+
), q = useCallback(() => {
|
|
83464
|
+
l == null || l(), a || setTimeout(x, ANIMATION_DELAY);
|
|
83465
|
+
}, [l, x, a]), k = useCallback(() => {
|
|
83466
|
+
p == null || p(), l == null || l();
|
|
83467
|
+
}, [p]);
|
|
83468
|
+
return /* @__PURE__ */ jsx(ResponsiveDialog, { className: "min-h-[80%]", open: o, onClose: q, children: /* @__PURE__ */ jsx(
|
|
83347
83469
|
Screen,
|
|
83348
83470
|
{
|
|
83349
|
-
current:
|
|
83350
|
-
widgets:
|
|
83471
|
+
current: n,
|
|
83472
|
+
widgets: b,
|
|
83351
83473
|
className: "min-h-0 md:size-[600px]",
|
|
83352
|
-
onClose:
|
|
83353
|
-
onConfirm:
|
|
83354
|
-
onSelectWallet:
|
|
83355
|
-
onAccepTermsOfService:
|
|
83356
|
-
onToggleInscriptions:
|
|
83357
|
-
onDisconnectWallet:
|
|
83474
|
+
onClose: q,
|
|
83475
|
+
onConfirm: k,
|
|
83476
|
+
onSelectWallet: E,
|
|
83477
|
+
onAccepTermsOfService: B,
|
|
83478
|
+
onToggleInscriptions: M,
|
|
83479
|
+
onDisconnectWallet: I
|
|
83358
83480
|
}
|
|
83359
83481
|
) });
|
|
83360
83482
|
}
|
|
@@ -83412,15 +83534,16 @@ const BBN_TESTNET_RPC_URL = "https://rpc-dapp.testnet.babylonlabs.io/", BBN_TEST
|
|
|
83412
83534
|
Network.SIGNET, bbnTestnet.currencies[0].coinDenom, bbnTestnet.chainName, bbnTestnet.currencies[0].coinDenom, bbnTestnet.chainId;
|
|
83413
83535
|
const storage = createAccountStorage(ONE_HOUR);
|
|
83414
83536
|
function WalletProvider({
|
|
83415
|
-
|
|
83416
|
-
|
|
83417
|
-
|
|
83418
|
-
|
|
83419
|
-
|
|
83537
|
+
persistent: e = !1,
|
|
83538
|
+
lifecycleHooks: t,
|
|
83539
|
+
children: r,
|
|
83540
|
+
config: s,
|
|
83541
|
+
context: o = window,
|
|
83542
|
+
onError: n
|
|
83420
83543
|
}) {
|
|
83421
|
-
return /* @__PURE__ */ jsx(LifeCycleHooksProvider, { value:
|
|
83422
|
-
|
|
83423
|
-
/* @__PURE__ */ jsx(WalletDialog, { storage, config:
|
|
83544
|
+
return /* @__PURE__ */ jsx(LifeCycleHooksProvider, { value: t, children: /* @__PURE__ */ jsxs(ChainProvider, { persistent: e, storage, context: o, config: s, onError: n, children: [
|
|
83545
|
+
r,
|
|
83546
|
+
/* @__PURE__ */ jsx(WalletDialog, { persistent: e, storage, config: s, onError: n })
|
|
83424
83547
|
] }) });
|
|
83425
83548
|
}
|
|
83426
83549
|
function useChainConnector(e) {
|