@bestinslot/wallet-kit 0.13.6 → 0.13.8
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 +4 -0
- package/dist/{balances-Cko3S8nV.js → balances-BnXuM9CG.js} +2284 -2058
- package/dist/browser.js +55 -53
- package/dist/core.js +33 -29
- package/dist/{mint-C_wN10-d.js → mint-CHlWPuov.js} +201 -102
- package/dist/node.js +192 -190
- package/dist/react.js +5 -5
- package/dist/{register-browser-providers-J2bm6PEo.js → register-browser-providers-b9rpXGqV.js} +35 -35
- package/dist/types/api/brc20.d.ts +42 -0
- package/dist/types/api/wallet.d.ts +2 -2
- package/dist/types/core/bis.d.ts +2 -1
- package/dist/types/core/brc20-send.d.ts +96 -0
- package/dist/types/core/helpers.d.ts +39 -18
- package/dist/types/core/mint.d.ts +1 -0
- package/dist/types/core/store-network.d.ts +42 -0
- package/dist/types/core.d.ts +2 -1
- package/dist/vue.js +9 -9
- package/package.json +1 -1
|
@@ -41892,6 +41892,62 @@ function subscribeToNetwork(t) {
|
|
|
41892
41892
|
listeners.delete(t);
|
|
41893
41893
|
};
|
|
41894
41894
|
}
|
|
41895
|
+
const DEFAULT_ENDPOINTS = {
|
|
41896
|
+
mainnet: {
|
|
41897
|
+
indexer: "https://ts-proxy.bestinslot.xyz/v3/mainnet",
|
|
41898
|
+
tx: "https://ts-proxy.bestinslot.xyz/v3/mainnet",
|
|
41899
|
+
sequencerRead: "https://sa-proxy.bestinslot.xyz",
|
|
41900
|
+
sequencer: "https://sa-proxy.bestinslot.xyz",
|
|
41901
|
+
rpc: "https://rpc.brc20.build"
|
|
41902
|
+
},
|
|
41903
|
+
signet: {
|
|
41904
|
+
indexer: "https://ts-proxy.bestinslot.xyz/v3/signet",
|
|
41905
|
+
tx: "https://ts-proxy.bestinslot.xyz/v3/signet",
|
|
41906
|
+
sequencerRead: "https://sas-proxy.bestinslot.xyz",
|
|
41907
|
+
sequencer: "https://sas-proxy.bestinslot.xyz",
|
|
41908
|
+
rpc: "https://rpc-signet.brc20.build"
|
|
41909
|
+
},
|
|
41910
|
+
// Testnet has no swap sequencer or BRC2.0 RPC unless one is configured.
|
|
41911
|
+
testnet: {
|
|
41912
|
+
indexer: "https://ts-proxy.bestinslot.xyz/v3/testnet",
|
|
41913
|
+
tx: "https://ts-proxy.bestinslot.xyz/v3/testnet"
|
|
41914
|
+
}
|
|
41915
|
+
}, ENDPOINT_KEYS = [
|
|
41916
|
+
"indexer",
|
|
41917
|
+
"tx",
|
|
41918
|
+
"sequencerRead",
|
|
41919
|
+
"sequencer",
|
|
41920
|
+
"rpc"
|
|
41921
|
+
];
|
|
41922
|
+
let endpointOverrides = {};
|
|
41923
|
+
function setEndpoints(t) {
|
|
41924
|
+
const e = {};
|
|
41925
|
+
for (const [r, A] of Object.entries(t ?? {})) {
|
|
41926
|
+
if (!(r in DEFAULT_ENDPOINTS))
|
|
41927
|
+
throw new Error(`setEndpoints: unknown network '${r}'`);
|
|
41928
|
+
const s = {};
|
|
41929
|
+
for (const [n, o] of Object.entries(A ?? {})) {
|
|
41930
|
+
if (!ENDPOINT_KEYS.includes(n))
|
|
41931
|
+
throw new Error(`setEndpoints: unknown endpoint '${n}' for ${r}`);
|
|
41932
|
+
if (o === void 0)
|
|
41933
|
+
continue;
|
|
41934
|
+
let a;
|
|
41935
|
+
try {
|
|
41936
|
+
a = new URL(o);
|
|
41937
|
+
} catch {
|
|
41938
|
+
throw new Error(`setEndpoints: ${r}.${n} is not a valid URL: ${o}`);
|
|
41939
|
+
}
|
|
41940
|
+
if (a.protocol !== "https:" && a.protocol !== "http:")
|
|
41941
|
+
throw new Error(`setEndpoints: ${r}.${n} must be an http(s) URL: ${o}`);
|
|
41942
|
+
s[n] = o;
|
|
41943
|
+
}
|
|
41944
|
+
e[r] = s;
|
|
41945
|
+
}
|
|
41946
|
+
endpointOverrides = e;
|
|
41947
|
+
}
|
|
41948
|
+
function getEndpoints(t = currentNetwork) {
|
|
41949
|
+
return { ...DEFAULT_ENDPOINTS[t], ...endpointOverrides[t] };
|
|
41950
|
+
}
|
|
41895
41951
|
function handleNetworkChange() {
|
|
41896
41952
|
getWalletInfo()?.provider === "unisat" && PROVIDERS.unisat?.checkNetwork?.();
|
|
41897
41953
|
}
|
|
@@ -65523,8 +65579,55 @@ async function withdrawFromBrc20Prog(t, e, r, A, s, n, o, a) {
|
|
|
65523
65579
|
}
|
|
65524
65580
|
const txHexByIdCache = {};
|
|
65525
65581
|
let currentExtraTxHexes = [], currentExtraInscriptions = null;
|
|
65526
|
-
|
|
65527
|
-
|
|
65582
|
+
const SEQUENCER_READ_ROUTES = /* @__PURE__ */ new Set([
|
|
65583
|
+
"get_tokens",
|
|
65584
|
+
"get_table_data",
|
|
65585
|
+
"volume",
|
|
65586
|
+
"klines",
|
|
65587
|
+
"tvl",
|
|
65588
|
+
"pair-activity",
|
|
65589
|
+
"recent-activity",
|
|
65590
|
+
"wallet-activity",
|
|
65591
|
+
"get_token_decimals"
|
|
65592
|
+
]);
|
|
65593
|
+
function getEndpointBase(t) {
|
|
65594
|
+
const e = getNetwork(), r = getEndpoints(e)[t];
|
|
65595
|
+
if (!r)
|
|
65596
|
+
throw new Error(`No '${t}' endpoint configured for ${e}; set one with setEndpoints()`);
|
|
65597
|
+
return r.replace(/\/+$/, "");
|
|
65598
|
+
}
|
|
65599
|
+
function sequencerEndpointFor(t) {
|
|
65600
|
+
const e = t.split(/[/?]/, 1)[0] ?? "";
|
|
65601
|
+
return SEQUENCER_READ_ROUTES.has(e) ? "sequencerRead" : "sequencer";
|
|
65602
|
+
}
|
|
65603
|
+
const serviceInfoByOrigin = /* @__PURE__ */ new Map();
|
|
65604
|
+
async function assertServiceNetwork(t) {
|
|
65605
|
+
const e = new URL(t);
|
|
65606
|
+
if (!e.pathname.startsWith("/v1"))
|
|
65607
|
+
return;
|
|
65608
|
+
let r = serviceInfoByOrigin.get(e.origin);
|
|
65609
|
+
r || (r = fetchWithErrors(new URL("/v1/info", e).toString(), {
|
|
65610
|
+
method: "GET"
|
|
65611
|
+
}), serviceInfoByOrigin.set(e.origin, r), r.catch(() => serviceInfoByOrigin.delete(e.origin)));
|
|
65612
|
+
let A;
|
|
65613
|
+
try {
|
|
65614
|
+
A = (await r).network;
|
|
65615
|
+
} catch (n) {
|
|
65616
|
+
const o = n instanceof Error ? n.message : String(n);
|
|
65617
|
+
throw new Error(`Could not read ${e.origin}/v1/info: ${o}`);
|
|
65618
|
+
}
|
|
65619
|
+
const s = getNetwork();
|
|
65620
|
+
if (A !== s)
|
|
65621
|
+
throw new Error(
|
|
65622
|
+
`Endpoint ${e.origin} serves '${A}', but the selected network is '${s}'`
|
|
65623
|
+
);
|
|
65624
|
+
}
|
|
65625
|
+
async function getEndpointUrl(t, e) {
|
|
65626
|
+
const r = getEndpointBase(t);
|
|
65627
|
+
return await assertServiceNetwork(r), `${r}/${e}`;
|
|
65628
|
+
}
|
|
65629
|
+
function getSwapBackendUrl(t) {
|
|
65630
|
+
return getEndpointUrl(sequencerEndpointFor(t), t);
|
|
65528
65631
|
}
|
|
65529
65632
|
function createSigningInput(t, e) {
|
|
65530
65633
|
const r = [];
|
|
@@ -65738,34 +65841,34 @@ async function getCardinalUtxos(t, e) {
|
|
|
65738
65841
|
return fixCardinalUtxos(r, t);
|
|
65739
65842
|
}
|
|
65740
65843
|
async function fetchCardinalUtxos(t) {
|
|
65741
|
-
const e =
|
|
65844
|
+
const e = await getEndpointUrl("indexer", `cardinal_utxos/${t}`);
|
|
65742
65845
|
return (await fetchWithErrors(e, { method: "GET" })).data;
|
|
65743
65846
|
}
|
|
65744
65847
|
async function getCardinalBalance(t) {
|
|
65745
|
-
const e =
|
|
65848
|
+
const e = await getEndpointUrl("indexer", `cardinal_utxos/${t}`), r = await fetchWithErrors(e, { method: "GET" }), A = fixCardinalUtxos(r.data, t);
|
|
65746
65849
|
let s = 0;
|
|
65747
65850
|
for (const n of A)
|
|
65748
65851
|
s += n.value;
|
|
65749
65852
|
return s;
|
|
65750
65853
|
}
|
|
65751
65854
|
async function getAllBalanceDetails(t) {
|
|
65752
|
-
const e =
|
|
65855
|
+
const e = await getEndpointUrl("indexer", `all_balance_details/${t}`);
|
|
65753
65856
|
return fetchWithErrors(e, { method: "GET" });
|
|
65754
65857
|
}
|
|
65755
65858
|
async function getOrdinalUtxos(t) {
|
|
65756
|
-
const e =
|
|
65859
|
+
const e = await getEndpointUrl("indexer", `ordinal_utxos/${t}`), r = await fetchWithErrors(e, { method: "GET" });
|
|
65757
65860
|
return fixOrdinalUtxos(r.data, t);
|
|
65758
65861
|
}
|
|
65759
65862
|
async function getTxhex(t) {
|
|
65760
65863
|
if (!txHexByIdCache[t]) {
|
|
65761
|
-
const e =
|
|
65864
|
+
const e = await getEndpointUrl("indexer", `gettxhex/${t}`);
|
|
65762
65865
|
txHexByIdCache[t] = await fetchWithErrors(e, { method: "GET" });
|
|
65763
65866
|
}
|
|
65764
65867
|
return txHexByIdCache[t];
|
|
65765
65868
|
}
|
|
65766
65869
|
async function validateTxes(t) {
|
|
65870
|
+
const e = await getEndpointUrl("tx", "testmempoolaccept");
|
|
65767
65871
|
try {
|
|
65768
|
-
const e = getBackendUrl("testmempoolaccept");
|
|
65769
65872
|
return await (await fetch(e, {
|
|
65770
65873
|
method: "POST",
|
|
65771
65874
|
headers: {
|
|
@@ -65780,8 +65883,8 @@ async function validateTxes(t) {
|
|
|
65780
65883
|
async function broadcastTxes(t) {
|
|
65781
65884
|
if (currentExtraTxHexes.length > 0)
|
|
65782
65885
|
throw new Error("Cannot broadcast txes when extra txes are set");
|
|
65886
|
+
const e = await getEndpointUrl("tx", "sendrawtransactions");
|
|
65783
65887
|
try {
|
|
65784
|
-
const e = getBackendUrl("sendrawtransactions");
|
|
65785
65888
|
return await (await fetch(e, {
|
|
65786
65889
|
method: "POST",
|
|
65787
65890
|
headers: {
|
|
@@ -65794,8 +65897,9 @@ async function broadcastTxes(t) {
|
|
|
65794
65897
|
}
|
|
65795
65898
|
}
|
|
65796
65899
|
async function verifySignature(t, e, r) {
|
|
65900
|
+
const A = await getEndpointUrl("indexer", "brc20_verify_bip322");
|
|
65797
65901
|
try {
|
|
65798
|
-
const
|
|
65902
|
+
const s = getBitcoinNetwork();
|
|
65799
65903
|
return (await (await fetch(A, {
|
|
65800
65904
|
method: "POST",
|
|
65801
65905
|
headers: {
|
|
@@ -65843,16 +65947,12 @@ async function fetchWithErrors(t, e) {
|
|
|
65843
65947
|
throw new Error(`API Request Failed: ${A}`);
|
|
65844
65948
|
}
|
|
65845
65949
|
}
|
|
65846
|
-
function getPublicRpcUrl() {
|
|
65847
|
-
const t =
|
|
65848
|
-
|
|
65849
|
-
return "https://rpc-signet.brc20.build";
|
|
65850
|
-
if (t === "mainnet")
|
|
65851
|
-
return "https://rpc.brc20.build";
|
|
65852
|
-
throw new Error("Unsupported network for public RPC URL");
|
|
65950
|
+
async function getPublicRpcUrl() {
|
|
65951
|
+
const t = getEndpointBase("rpc");
|
|
65952
|
+
return await assertServiceNetwork(t), t;
|
|
65853
65953
|
}
|
|
65854
65954
|
async function ethCallOnPublicRpc(t, e, r, A) {
|
|
65855
|
-
const s = getPublicRpcUrl(), n = evmEncodeFunctionCall(e, r, A);
|
|
65955
|
+
const s = await getPublicRpcUrl(), n = evmEncodeFunctionCall(e, r, A);
|
|
65856
65956
|
return fetchWithErrors(s, {
|
|
65857
65957
|
method: "POST",
|
|
65858
65958
|
headers: {
|
|
@@ -65872,14 +65972,6 @@ async function ethCallOnPublicRpc(t, e, r, A) {
|
|
|
65872
65972
|
})
|
|
65873
65973
|
}).then((o) => o.result);
|
|
65874
65974
|
}
|
|
65875
|
-
function getSwapBackendUrl(t) {
|
|
65876
|
-
const e = getNetwork();
|
|
65877
|
-
if (e === "signet")
|
|
65878
|
-
return `https://sas-proxy.bestinslot.xyz/${t}`;
|
|
65879
|
-
if (e === "mainnet")
|
|
65880
|
-
return `https://sa-proxy.bestinslot.xyz/${t}`;
|
|
65881
|
-
throw new Error("Unsupported network for orderbook backend URL");
|
|
65882
|
-
}
|
|
65883
65975
|
const ENABLE_RBF_NO_LOCKTIME = 4294967293, DUST_VALUE_P2PKH = 546, DUST_VALUE_P2WPKH = 294, DUST_VALUE_P2SH = 540, DUST_VALUE_P2TR = 330, DUST_VALUE_MAX = Math.max(
|
|
65884
65976
|
DUST_VALUE_P2PKH,
|
|
65885
65977
|
DUST_VALUE_P2WPKH,
|
|
@@ -67535,7 +67627,9 @@ async function sendInscriptionToOpReturnWithExtraInputsAndExtraOutputAll(t, e, r
|
|
|
67535
67627
|
if (C.satpoint.split(":")[2] !== "0")
|
|
67536
67628
|
throw new Error("Inscription is not at the first sat of utxo");
|
|
67537
67629
|
if (!B.addr) throw new Error("Payer wallet address is not set.");
|
|
67538
|
-
const p = await getCardinalUtxos(B.addr)
|
|
67630
|
+
const p = await getCardinalUtxos(B.addr);
|
|
67631
|
+
(A <= 0 || A == null) && (A = 1);
|
|
67632
|
+
const v = [{
|
|
67539
67633
|
utxo: `${C.satpoint.split(":")[0]}:${C.satpoint.split(":")[1]}`,
|
|
67540
67634
|
value: C.value,
|
|
67541
67635
|
script_type: C.script_type,
|
|
@@ -67584,7 +67678,9 @@ async function sendInscriptionToOpReturnWithExtraInputsAndExtraOutputFeeRate(t,
|
|
|
67584
67678
|
if (l.satpoint.split(":")[2] !== "0")
|
|
67585
67679
|
throw new Error("Inscription is not at the first sat of utxo");
|
|
67586
67680
|
if (!I.addr) throw new Error("Payer wallet address is not set.");
|
|
67587
|
-
const C = await getCardinalUtxos(I.addr, o)
|
|
67681
|
+
const C = await getCardinalUtxos(I.addr, o);
|
|
67682
|
+
(A <= 0 || A == null) && (A = 1);
|
|
67683
|
+
const Q = [{
|
|
67588
67684
|
utxo: `${l.satpoint.split(":")[0]}:${l.satpoint.split(":")[1]}`,
|
|
67589
67685
|
value: l.value,
|
|
67590
67686
|
script_type: l.script_type,
|
|
@@ -67710,85 +67806,88 @@ async function mintWithExtraInputInCommitFeeRate(t, e, r, A, s, n, o) {
|
|
|
67710
67806
|
};
|
|
67711
67807
|
}
|
|
67712
67808
|
export {
|
|
67713
|
-
|
|
67714
|
-
|
|
67809
|
+
saveSwapWalletInfo as $,
|
|
67810
|
+
sha256$6 as A,
|
|
67715
67811
|
Buffer as B,
|
|
67716
|
-
|
|
67717
|
-
|
|
67718
|
-
|
|
67719
|
-
|
|
67720
|
-
|
|
67721
|
-
|
|
67722
|
-
|
|
67723
|
-
|
|
67724
|
-
|
|
67725
|
-
|
|
67726
|
-
|
|
67727
|
-
|
|
67728
|
-
|
|
67729
|
-
|
|
67730
|
-
|
|
67731
|
-
|
|
67732
|
-
|
|
67733
|
-
|
|
67734
|
-
|
|
67735
|
-
|
|
67812
|
+
writeUInt32 as C,
|
|
67813
|
+
concat as D,
|
|
67814
|
+
hexToBase64 as E,
|
|
67815
|
+
srcExports as F,
|
|
67816
|
+
finalizePsbtInputs as G,
|
|
67817
|
+
broadcastTxes as H,
|
|
67818
|
+
Buffer$1 as I,
|
|
67819
|
+
WalletInfo as J,
|
|
67820
|
+
getCardinalUtxos as K,
|
|
67821
|
+
buildTransaction as L,
|
|
67822
|
+
buildPsbtFromTx as M,
|
|
67823
|
+
validateTxes as N,
|
|
67824
|
+
distExports$2 as O,
|
|
67825
|
+
memoryStorage as P,
|
|
67826
|
+
getBitcoinNetwork as Q,
|
|
67827
|
+
saveWalletInfo as R,
|
|
67828
|
+
registerProvider as S,
|
|
67829
|
+
subscribeToNetwork as T,
|
|
67830
|
+
base64ToHex as U,
|
|
67831
|
+
createUnsecuredToken as V,
|
|
67736
67832
|
WalletAccountChangedError as W,
|
|
67737
|
-
|
|
67738
|
-
|
|
67739
|
-
|
|
67740
|
-
|
|
67833
|
+
getSignFn as X,
|
|
67834
|
+
sendInscriptionToOpReturnAll as Y,
|
|
67835
|
+
sendInscriptionInPaymentWalletToOpReturnAll as Z,
|
|
67836
|
+
sendInscriptionAll as _,
|
|
67741
67837
|
getAllBalanceDetails as a,
|
|
67742
|
-
|
|
67743
|
-
|
|
67744
|
-
|
|
67745
|
-
|
|
67746
|
-
|
|
67747
|
-
|
|
67748
|
-
|
|
67749
|
-
|
|
67750
|
-
|
|
67751
|
-
|
|
67752
|
-
|
|
67753
|
-
|
|
67754
|
-
|
|
67755
|
-
|
|
67756
|
-
|
|
67757
|
-
|
|
67758
|
-
|
|
67759
|
-
|
|
67760
|
-
|
|
67761
|
-
|
|
67762
|
-
|
|
67763
|
-
|
|
67764
|
-
|
|
67765
|
-
|
|
67766
|
-
|
|
67767
|
-
|
|
67768
|
-
|
|
67838
|
+
readSwapWalletInfo as a0,
|
|
67839
|
+
getSwapBackendUrl as a1,
|
|
67840
|
+
compressSmartContractData as a2,
|
|
67841
|
+
Buff$3 as a3,
|
|
67842
|
+
InscriptionDetails as a4,
|
|
67843
|
+
fetchCardinalUtxos as a5,
|
|
67844
|
+
resolveReclaimInputs as a6,
|
|
67845
|
+
mintWithReclaimsCheckFees as a7,
|
|
67846
|
+
mintAllCheckFees as a8,
|
|
67847
|
+
saveExtraUtxos as a9,
|
|
67848
|
+
Script as aa,
|
|
67849
|
+
sendInscriptionToOpReturnWithExtraInputsAndExtraOutputFeeRate as ab,
|
|
67850
|
+
clearExtraUtxos as ac,
|
|
67851
|
+
utxoOutputTypeFromOutputScript as ad,
|
|
67852
|
+
mintWithExtraInputInCommitFeeRate as ae,
|
|
67853
|
+
mintWithReclaimsAll as af,
|
|
67854
|
+
mintAll as ag,
|
|
67855
|
+
sendInscriptionToOpReturnWithExtraInputsAndExtraOutputAll as ah,
|
|
67856
|
+
mintWithExtraInputInCommitAll as ai,
|
|
67857
|
+
evmEncodeFunctionCall as aj,
|
|
67858
|
+
getDustValue as ak,
|
|
67859
|
+
callSmartContract as al,
|
|
67860
|
+
callSmartContractFromPaymentWallet as am,
|
|
67861
|
+
depositToBrc20Prog as an,
|
|
67862
|
+
withdrawFromBrc20Prog as ao,
|
|
67863
|
+
inscribeMultiple as ap,
|
|
67864
|
+
inscribeWithParent as aq,
|
|
67865
|
+
getInscribeMultipleFee as ar,
|
|
67866
|
+
fetchWithErrors as as,
|
|
67867
|
+
ethCallOnPublicRpc as at,
|
|
67769
67868
|
getCardinalBalance as b,
|
|
67770
67869
|
clearWalletInfo as c,
|
|
67771
|
-
|
|
67772
|
-
|
|
67773
|
-
|
|
67870
|
+
getEndpoints as d,
|
|
67871
|
+
getNetwork as e,
|
|
67872
|
+
getOrdinalsWallet as f,
|
|
67774
67873
|
getWallets as g,
|
|
67775
|
-
|
|
67776
|
-
|
|
67777
|
-
|
|
67778
|
-
|
|
67779
|
-
|
|
67780
|
-
|
|
67781
|
-
|
|
67782
|
-
|
|
67783
|
-
|
|
67784
|
-
|
|
67785
|
-
|
|
67874
|
+
getPaymentWallet as h,
|
|
67875
|
+
getWalletInfo as i,
|
|
67876
|
+
setEndpoints as j,
|
|
67877
|
+
setNetwork as k,
|
|
67878
|
+
signMessage as l,
|
|
67879
|
+
signMessageLocalVerify as m,
|
|
67880
|
+
signMessageLocalVerifyDeterministic as n,
|
|
67881
|
+
subscribeToAccountChanges as o,
|
|
67882
|
+
index$2 as p,
|
|
67883
|
+
module$1 as q,
|
|
67884
|
+
getEvmAddressFromBitcoinAddress as r,
|
|
67786
67885
|
sendBTC as s,
|
|
67787
|
-
|
|
67788
|
-
|
|
67789
|
-
|
|
67790
|
-
|
|
67791
|
-
|
|
67792
|
-
|
|
67793
|
-
|
|
67886
|
+
getEvmAddressFromPkScript as t,
|
|
67887
|
+
delegateInscription as u,
|
|
67888
|
+
jsonInscription as v,
|
|
67889
|
+
textInscription as w,
|
|
67890
|
+
addressWalletInfo as x,
|
|
67891
|
+
opReturnWalletInfo as y,
|
|
67892
|
+
requireBitcoinjsMessage as z
|
|
67794
67893
|
};
|