@0xsquid/react-hooks 8.9.0 → 8.9.1-beta.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/core/connectors/bitcoin/bitcoinFeatures.d.ts +53 -0
- package/dist/core/connectors/bitcoin/errors/index.d.ts +3 -0
- package/dist/core/connectors/bitcoin/wallets/index.d.ts +1 -0
- package/dist/core/connectors/bitcoin/wallets/phantom.d.ts +10 -26
- package/dist/core/connectors/bitcoin/wallets/standard.d.ts +30 -0
- package/dist/{index-BL_AUWQg.js → index-Ypw6i6uY.js} +103 -39
- package/dist/index-Ypw6i6uY.js.map +1 -0
- package/dist/{index-DcBFug8t.js → index-sCLxPcqi.js} +103 -39
- package/dist/index-sCLxPcqi.js.map +1 -0
- package/dist/{index.es-1XEAWjab.js → index.es-B2QD8f3q.js} +3 -3
- package/dist/{index.es-1XEAWjab.js.map → index.es-B2QD8f3q.js.map} +1 -1
- package/dist/{index.es-DSQHpime.js → index.es-Bot12hgd.js} +3 -3
- package/dist/{index.es-DSQHpime.js.map → index.es-Bot12hgd.js.map} +1 -1
- package/dist/index.esm.js +2 -2
- package/dist/index.js +2 -2
- package/dist/{secretService-DxQ78j5I.js → secretService-BAK4sBb7.js} +3 -3
- package/dist/{secretService-DxQ78j5I.js.map → secretService-BAK4sBb7.js.map} +1 -1
- package/dist/{secretService-B1SDXLS1.js → secretService-C3jMjsK0.js} +3 -3
- package/dist/{secretService-B1SDXLS1.js.map → secretService-C3jMjsK0.js.map} +1 -1
- package/dist/{stellarService.client-CkP5ng2n.js → stellarService.client-DkJ6WAdl.js} +3 -3
- package/dist/{stellarService.client-CkP5ng2n.js.map → stellarService.client-DkJ6WAdl.js.map} +1 -1
- package/dist/{stellarService.client-C4TLBEpm.js → stellarService.client-SrhXgRGB.js} +3 -3
- package/dist/{stellarService.client-C4TLBEpm.js.map → stellarService.client-SrhXgRGB.js.map} +1 -1
- package/package.json +1 -1
- package/dist/index-BL_AUWQg.js.map +0 -1
- package/dist/index-DcBFug8t.js.map +0 -1
|
@@ -5,6 +5,7 @@ var viem = require('viem');
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var reactQuery = require('@tanstack/react-query');
|
|
7
7
|
var encoding = require('@cosmjs/encoding');
|
|
8
|
+
var core$1 = require('@wallet-standard/core');
|
|
8
9
|
var bitcoin = require('bitcoinjs-lib');
|
|
9
10
|
var ecc = require('@bitcoinerlab/secp256k1');
|
|
10
11
|
var axios = require('axios');
|
|
@@ -25,7 +26,6 @@ var zustand = require('zustand');
|
|
|
25
26
|
var middleware = require('zustand/middleware');
|
|
26
27
|
var wagmi = require('wagmi');
|
|
27
28
|
var SafeAppsSDK = require('@safe-global/safe-apps-sdk');
|
|
28
|
-
var core$1 = require('@wallet-standard/core');
|
|
29
29
|
var slushWallet = require('@mysten/slush-wallet');
|
|
30
30
|
var stargate = require('@cosmjs/stargate');
|
|
31
31
|
var client = require('@mysten/sui/client');
|
|
@@ -4730,6 +4730,11 @@ class BitcoinConnectorInvalidAccountError extends BitcoinConnectorError {
|
|
|
4730
4730
|
super("Bitcoin account is invalid");
|
|
4731
4731
|
}
|
|
4732
4732
|
}
|
|
4733
|
+
class BitcoinConnectorFeatureNotSupportedError extends BitcoinConnectorError {
|
|
4734
|
+
constructor(providerName, feature) {
|
|
4735
|
+
super(`Bitcoin provider ${providerName} does not support ${feature}`);
|
|
4736
|
+
}
|
|
4737
|
+
}
|
|
4733
4738
|
|
|
4734
4739
|
class KeplrConnector {
|
|
4735
4740
|
get getProvider() {
|
|
@@ -4758,6 +4763,20 @@ class KeplrConnector {
|
|
|
4758
4763
|
}
|
|
4759
4764
|
}
|
|
4760
4765
|
|
|
4766
|
+
const BitcoinConnect = "bitcoin:connect";
|
|
4767
|
+
const BitcoinSignTransaction = "bitcoin:signTransaction";
|
|
4768
|
+
const REQUIRED_BITCOIN_FEATURES = [
|
|
4769
|
+
BitcoinConnect,
|
|
4770
|
+
BitcoinSignTransaction,
|
|
4771
|
+
];
|
|
4772
|
+
/**
|
|
4773
|
+
* Type guard: the wallet exposes the Bitcoin features this SDK needs (connect +
|
|
4774
|
+
* signTransaction). Wallets advertising only a subset are treated as unsupported.
|
|
4775
|
+
*/
|
|
4776
|
+
function hasBitcoinFeatures(wallet) {
|
|
4777
|
+
return REQUIRED_BITCOIN_FEATURES.every((feature) => feature in wallet.features);
|
|
4778
|
+
}
|
|
4779
|
+
|
|
4761
4780
|
bitcoin__namespace.initEccLib(ecc__namespace);
|
|
4762
4781
|
const network = bitcoin__namespace.networks.bitcoin;
|
|
4763
4782
|
const fromHexString = (hexString) => {
|
|
@@ -4847,55 +4866,100 @@ async function getTransactionStatus$1(txHash) {
|
|
|
4847
4866
|
}
|
|
4848
4867
|
|
|
4849
4868
|
const MAINNET = bitcoin__namespace.networks.bitcoin;
|
|
4850
|
-
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4869
|
+
/**
|
|
4870
|
+
* Bitcoin connector backed by the Bitcoin Wallet Standard.
|
|
4871
|
+
*
|
|
4872
|
+
* Discovers the wallet from the Wallet Standard registry at call time (mirroring
|
|
4873
|
+
* how Solana/Sui wallets are resolved) and connects/signs through the
|
|
4874
|
+
* `bitcoin:connect` and `bitcoin:signTransaction` features instead of a
|
|
4875
|
+
* wallet-specific injected provider. Configure it with a `walletName` to support
|
|
4876
|
+
* any wallet exposing the Bitcoin Wallet Standard — Phantom is the first consumer.
|
|
4877
|
+
*/
|
|
4878
|
+
class BitcoinStandardConnector {
|
|
4879
|
+
walletName;
|
|
4880
|
+
constructor({ walletName }) {
|
|
4881
|
+
this.walletName = walletName;
|
|
4882
|
+
}
|
|
4883
|
+
getWallet() {
|
|
4884
|
+
const wallet = core$1.getWallets()
|
|
4885
|
+
.get()
|
|
4886
|
+
.find((candidate) => candidate.name.toLowerCase() === this.walletName.toLowerCase());
|
|
4887
|
+
if (!wallet) {
|
|
4888
|
+
throw new BitcoinConnectorProviderNotFoundError(this.walletName);
|
|
4855
4889
|
}
|
|
4856
|
-
|
|
4890
|
+
const bitcoinWallet = wallet;
|
|
4891
|
+
if (!hasBitcoinFeatures(bitcoinWallet)) {
|
|
4892
|
+
throw new BitcoinConnectorFeatureNotSupportedError(this.walletName, "Bitcoin Wallet Standard");
|
|
4893
|
+
}
|
|
4894
|
+
return bitcoinWallet;
|
|
4857
4895
|
}
|
|
4858
|
-
async
|
|
4859
|
-
const
|
|
4860
|
-
|
|
4861
|
-
|
|
4862
|
-
|
|
4863
|
-
|
|
4896
|
+
async connectAccount(purpose) {
|
|
4897
|
+
const wallet = this.getWallet();
|
|
4898
|
+
const connect = wallet.features[BitcoinConnect]?.connect;
|
|
4899
|
+
if (!connect) {
|
|
4900
|
+
throw new BitcoinConnectorFeatureNotSupportedError(this.walletName, BitcoinConnect);
|
|
4901
|
+
}
|
|
4902
|
+
const { accounts } = await connect({ purposes: [purpose] });
|
|
4903
|
+
// `purpose` is a user preference, not a guarantee (per Phantom's docs), but
|
|
4904
|
+
// requesting a single purpose returns the matching account first.
|
|
4905
|
+
const account = accounts[0];
|
|
4906
|
+
if (typeof account?.address !== "string") {
|
|
4864
4907
|
throw new BitcoinConnectorInvalidAccountError();
|
|
4865
4908
|
}
|
|
4909
|
+
return account;
|
|
4910
|
+
}
|
|
4911
|
+
async requestAccount() {
|
|
4912
|
+
const account = await this.connectAccount("payment");
|
|
4866
4913
|
return {
|
|
4867
|
-
address:
|
|
4914
|
+
address: account.address,
|
|
4868
4915
|
};
|
|
4869
4916
|
}
|
|
4870
4917
|
async sendBTC(to, amount) {
|
|
4871
|
-
const
|
|
4872
|
-
const { psbtHex } = await createSendBtcPsbt(address, to, amount);
|
|
4873
|
-
const
|
|
4918
|
+
const account = await this.connectAccount("payment");
|
|
4919
|
+
const { psbtHex } = await createSendBtcPsbt(account.address, to, amount);
|
|
4920
|
+
const txId = await this.signAndBroadcast(psbtHex, account);
|
|
4874
4921
|
if (!txId)
|
|
4875
4922
|
throw new BitcoinConnectorTransactionFailedError();
|
|
4876
4923
|
return { txHash: txId };
|
|
4877
4924
|
}
|
|
4878
|
-
async
|
|
4879
|
-
const
|
|
4880
|
-
const
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
const
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
4891
|
-
|
|
4892
|
-
|
|
4925
|
+
async signAndBroadcast(psbtHex, account) {
|
|
4926
|
+
const wallet = this.getWallet();
|
|
4927
|
+
const signTransaction = wallet.features[BitcoinSignTransaction]?.signTransaction;
|
|
4928
|
+
if (!signTransaction) {
|
|
4929
|
+
throw new BitcoinConnectorFeatureNotSupportedError(this.walletName, BitcoinSignTransaction);
|
|
4930
|
+
}
|
|
4931
|
+
const unsignedPsbt = bitcoin__namespace.Psbt.fromHex(psbtHex, { network: MAINNET });
|
|
4932
|
+
const signingIndexes = unsignedPsbt.data.inputs.map((_, index) => index);
|
|
4933
|
+
const [result] = await signTransaction({
|
|
4934
|
+
psbt: fromHexString(psbtHex),
|
|
4935
|
+
inputsToSign: [
|
|
4936
|
+
{
|
|
4937
|
+
// All inputs are funded from the payment account.
|
|
4938
|
+
account,
|
|
4939
|
+
signingIndexes,
|
|
4940
|
+
},
|
|
4941
|
+
],
|
|
4893
4942
|
});
|
|
4894
|
-
|
|
4943
|
+
if (!result?.signedPsbt) {
|
|
4944
|
+
throw new BitcoinConnectorTransactionFailedError();
|
|
4945
|
+
}
|
|
4946
|
+
const signedPsbt = bitcoin__namespace.Psbt.fromBuffer(result.signedPsbt);
|
|
4895
4947
|
signedPsbt.finalizeAllInputs();
|
|
4896
4948
|
const tx = signedPsbt.extractTransaction();
|
|
4897
|
-
|
|
4898
|
-
|
|
4949
|
+
return broadcastTx(tx.toHex());
|
|
4950
|
+
}
|
|
4951
|
+
}
|
|
4952
|
+
|
|
4953
|
+
/**
|
|
4954
|
+
* Phantom Bitcoin connector via the Bitcoin Wallet Standard.
|
|
4955
|
+
*
|
|
4956
|
+
* Phantom deprecated the injected `window.phantom.bitcoin` provider in favour of
|
|
4957
|
+
* the Wallet Standard; this resolves Phantom from the registry by name and signs
|
|
4958
|
+
* through the standard Bitcoin features. See {@link BitcoinStandardConnector}.
|
|
4959
|
+
*/
|
|
4960
|
+
class PhantomConnector extends BitcoinStandardConnector {
|
|
4961
|
+
constructor() {
|
|
4962
|
+
super({ walletName: "Phantom" });
|
|
4899
4963
|
}
|
|
4900
4964
|
}
|
|
4901
4965
|
|
|
@@ -23368,7 +23432,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23368
23432
|
};
|
|
23369
23433
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23370
23434
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23371
|
-
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-
|
|
23435
|
+
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-C3jMjsK0.js'); });
|
|
23372
23436
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23373
23437
|
};
|
|
23374
23438
|
function getTokenAssetsKey(token) {
|
|
@@ -26766,7 +26830,7 @@ function useStellarWallets() {
|
|
|
26766
26830
|
try {
|
|
26767
26831
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26768
26832
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
|
|
26769
|
-
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-
|
|
26833
|
+
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-SrhXgRGB.js'); });
|
|
26770
26834
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26771
26835
|
const promises = modules.map(async (module) => {
|
|
26772
26836
|
const isAvailable = await module.isAvailable();
|
|
@@ -30098,7 +30162,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30098
30162
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30099
30163
|
if (!optionalChains.length)
|
|
30100
30164
|
return;
|
|
30101
|
-
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-
|
|
30165
|
+
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-B2QD8f3q.js'); });
|
|
30102
30166
|
const rawProvider = await EthereumProvider.init({
|
|
30103
30167
|
...restParameters,
|
|
30104
30168
|
disableProviderPing: true,
|
|
@@ -37761,4 +37825,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
|
|
|
37761
37825
|
exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
|
|
37762
37826
|
exports.walletIconBaseUrl = walletIconBaseUrl;
|
|
37763
37827
|
exports.walletSupportsChainType = walletSupportsChainType;
|
|
37764
|
-
//# sourceMappingURL=index-
|
|
37828
|
+
//# sourceMappingURL=index-sCLxPcqi.js.map
|