@0xsquid/react-hooks 8.10.0 → 8.11.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/canton/cantonConnector.d.ts +2 -1
- package/dist/core/canton/injectedCantonProvider.d.ts +31 -0
- package/dist/core/connectors/bitcoin/wallets/keplr.d.ts +3 -0
- package/dist/core/connectors/bitcoin/wallets/phantom.d.ts +3 -1
- package/dist/core/connectors/bitcoin/wallets/unisat.d.ts +15 -0
- package/dist/core/index.d.ts +1 -1
- package/dist/core/types/bitcoin.d.ts +3 -0
- package/dist/hooks/canton/useCantonWallets.d.ts +4 -2
- package/dist/{index-Dzir2lUQ.js → index-BzTFES6t.js} +297 -115
- package/dist/index-BzTFES6t.js.map +1 -0
- package/dist/{index-BlB3yIoX.js → index-D5bkikGx.js} +297 -116
- package/dist/index-D5bkikGx.js.map +1 -0
- package/dist/{index.es-BPXYaraD.js → index.es-DaKI7v5_.js} +2 -2
- package/dist/{index.es-BPXYaraD.js.map → index.es-DaKI7v5_.js.map} +1 -1
- package/dist/{index.es-DwtZr7bN.js → index.es-wL3I3c3h.js} +2 -2
- package/dist/{index.es-DwtZr7bN.js.map → index.es-wL3I3c3h.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/{secretService-eiBnD7dI.js → secretService-BMH_eXJd.js} +2 -2
- package/dist/{secretService-eiBnD7dI.js.map → secretService-BMH_eXJd.js.map} +1 -1
- package/dist/{secretService-ICina23f.js → secretService-D70MRo5w.js} +2 -2
- package/dist/{secretService-ICina23f.js.map → secretService-D70MRo5w.js.map} +1 -1
- package/dist/services/internal/cantonService.d.ts +17 -1
- package/dist/{stellarService.client-VOmCOPzL.js → stellarService.client-BpCW1qZY.js} +2 -2
- package/dist/{stellarService.client-VOmCOPzL.js.map → stellarService.client-BpCW1qZY.js.map} +1 -1
- package/dist/{stellarService.client-Bjc92sC_.js → stellarService.client-DhwF4F1c.js} +2 -2
- package/dist/{stellarService.client-Bjc92sC_.js.map → stellarService.client-DhwF4F1c.js.map} +1 -1
- package/dist/tests/injectedCantonProvider.test.d.ts +1 -0
- package/package.json +1 -1
- package/dist/index-BlB3yIoX.js.map +0 -1
- package/dist/index-Dzir2lUQ.js.map +0 -1
|
@@ -3442,7 +3442,7 @@ function get$1(object, path, defaultValue) {
|
|
|
3442
3442
|
|
|
3443
3443
|
var get_1 = get$1;
|
|
3444
3444
|
|
|
3445
|
-
var
|
|
3445
|
+
var getProperty = /*@__PURE__*/getDefaultExportFromCjs(get_1);
|
|
3446
3446
|
|
|
3447
3447
|
/**
|
|
3448
3448
|
* The base implementation of `_.hasIn` without support for deep paths.
|
|
@@ -4718,33 +4718,6 @@ class BitcoinConnectorInvalidAccountError extends BitcoinConnectorError {
|
|
|
4718
4718
|
}
|
|
4719
4719
|
}
|
|
4720
4720
|
|
|
4721
|
-
class KeplrConnector {
|
|
4722
|
-
get getProvider() {
|
|
4723
|
-
const provider = window?.bitcoin_keplr;
|
|
4724
|
-
if (!provider) {
|
|
4725
|
-
throw new BitcoinConnectorProviderNotFoundError("Keplr");
|
|
4726
|
-
}
|
|
4727
|
-
return provider;
|
|
4728
|
-
}
|
|
4729
|
-
async sendBTC(to, amount) {
|
|
4730
|
-
const txHash = await this.getProvider.sendBitcoin(to, amount);
|
|
4731
|
-
if (!txHash) {
|
|
4732
|
-
throw new BitcoinConnectorTransactionFailedError();
|
|
4733
|
-
}
|
|
4734
|
-
return { txHash };
|
|
4735
|
-
}
|
|
4736
|
-
async requestAccount() {
|
|
4737
|
-
const accounts = await this.getProvider.requestAccounts();
|
|
4738
|
-
const account = accounts[0];
|
|
4739
|
-
if (typeof account !== "string") {
|
|
4740
|
-
throw new BitcoinConnectorInvalidAccountError();
|
|
4741
|
-
}
|
|
4742
|
-
return {
|
|
4743
|
-
address: account,
|
|
4744
|
-
};
|
|
4745
|
-
}
|
|
4746
|
-
}
|
|
4747
|
-
|
|
4748
4721
|
bitcoin.initEccLib(ecc);
|
|
4749
4722
|
const network = bitcoin.networks.bitcoin;
|
|
4750
4723
|
const fromHexString = (hexString) => {
|
|
@@ -4833,6 +4806,53 @@ async function getTransactionStatus$1(txHash) {
|
|
|
4833
4806
|
.then((response) => response.data);
|
|
4834
4807
|
}
|
|
4835
4808
|
|
|
4809
|
+
class KeplrConnector {
|
|
4810
|
+
get getProvider() {
|
|
4811
|
+
const provider = window?.bitcoin_keplr;
|
|
4812
|
+
if (!provider) {
|
|
4813
|
+
throw new BitcoinConnectorProviderNotFoundError("Keplr");
|
|
4814
|
+
}
|
|
4815
|
+
return provider;
|
|
4816
|
+
}
|
|
4817
|
+
async sendBTC(to, amount) {
|
|
4818
|
+
const txHash = await this.getProvider.sendBitcoin(to, amount);
|
|
4819
|
+
if (!txHash) {
|
|
4820
|
+
throw new BitcoinConnectorTransactionFailedError();
|
|
4821
|
+
}
|
|
4822
|
+
return { txHash };
|
|
4823
|
+
}
|
|
4824
|
+
async requestAccount() {
|
|
4825
|
+
const accounts = await this.getProvider.requestAccounts();
|
|
4826
|
+
const account = accounts[0];
|
|
4827
|
+
if (typeof account !== "string") {
|
|
4828
|
+
throw new BitcoinConnectorInvalidAccountError();
|
|
4829
|
+
}
|
|
4830
|
+
return {
|
|
4831
|
+
address: account,
|
|
4832
|
+
};
|
|
4833
|
+
}
|
|
4834
|
+
async signPsbt(psbtHex) {
|
|
4835
|
+
// Keplr follows the UniSat-style Bitcoin provider API: `signPsbt` signs and,
|
|
4836
|
+
// with `autoFinalized` (the default), finalizes every input, returning the
|
|
4837
|
+
// signed PSBT as a hex string.
|
|
4838
|
+
// https://docs.keplr.app/api/bitcoin
|
|
4839
|
+
const signedPsbtHex = await this.getProvider.signPsbt(psbtHex, {
|
|
4840
|
+
autoFinalized: true,
|
|
4841
|
+
});
|
|
4842
|
+
// Broadcast the finalized raw transaction directly rather than through
|
|
4843
|
+
// Keplr's `pushTx`, which proxies via Keplr's own Bitcoin indexer
|
|
4844
|
+
// (api-indexer-bitcoin.keplr.app) and fails when that service is down.
|
|
4845
|
+
const rawTxHex = bitcoin.Psbt.fromHex(signedPsbtHex)
|
|
4846
|
+
.extractTransaction()
|
|
4847
|
+
.toHex();
|
|
4848
|
+
const txHash = await broadcastTx(rawTxHex);
|
|
4849
|
+
if (!txHash) {
|
|
4850
|
+
throw new BitcoinConnectorTransactionFailedError();
|
|
4851
|
+
}
|
|
4852
|
+
return { txHash };
|
|
4853
|
+
}
|
|
4854
|
+
}
|
|
4855
|
+
|
|
4836
4856
|
const MAINNET = bitcoin.networks.bitcoin;
|
|
4837
4857
|
class PhantomConnector {
|
|
4838
4858
|
get getProvider() {
|
|
@@ -4857,10 +4877,8 @@ class PhantomConnector {
|
|
|
4857
4877
|
async sendBTC(to, amount) {
|
|
4858
4878
|
const { address } = await this.requestAccount();
|
|
4859
4879
|
const { psbtHex } = await createSendBtcPsbt(address, to, amount);
|
|
4860
|
-
const {
|
|
4861
|
-
|
|
4862
|
-
throw new BitcoinConnectorTransactionFailedError();
|
|
4863
|
-
return { txHash: txId };
|
|
4880
|
+
const { txHash } = await this.signPsbt(psbtHex);
|
|
4881
|
+
return { txHash };
|
|
4864
4882
|
}
|
|
4865
4883
|
async signPsbt(psbtHex) {
|
|
4866
4884
|
const { address: paymentAddress } = await this.requestAccount();
|
|
@@ -4881,8 +4899,10 @@ class PhantomConnector {
|
|
|
4881
4899
|
const signedPsbt = bitcoin.Psbt.fromBuffer(signedPsbtBytes);
|
|
4882
4900
|
signedPsbt.finalizeAllInputs();
|
|
4883
4901
|
const tx = signedPsbt.extractTransaction();
|
|
4884
|
-
const
|
|
4885
|
-
|
|
4902
|
+
const txHash = await broadcastTx(tx.toHex());
|
|
4903
|
+
if (!txHash)
|
|
4904
|
+
throw new BitcoinConnectorTransactionFailedError();
|
|
4905
|
+
return { txHash };
|
|
4886
4906
|
}
|
|
4887
4907
|
}
|
|
4888
4908
|
|
|
@@ -4911,6 +4931,21 @@ class UnisatConnector {
|
|
|
4911
4931
|
address: account,
|
|
4912
4932
|
};
|
|
4913
4933
|
}
|
|
4934
|
+
async signPsbt(psbtHex) {
|
|
4935
|
+
// UniSat signs and, with `autoFinalized` (the default), finalizes every
|
|
4936
|
+
// input, returning the signed PSBT as a hex string.
|
|
4937
|
+
// https://docs.unisat.io/dev/unisat-developer-center/unisat-wallet/api-list
|
|
4938
|
+
const signedPsbtHex = await this.getProvider.signPsbt(psbtHex, {
|
|
4939
|
+
autoFinalized: true,
|
|
4940
|
+
});
|
|
4941
|
+
// `pushPsbt` extracts the finalized transaction from the signed PSBT and
|
|
4942
|
+
// broadcasts it, returning the transaction id.
|
|
4943
|
+
const txHash = await this.getProvider.pushPsbt(signedPsbtHex);
|
|
4944
|
+
if (!txHash) {
|
|
4945
|
+
throw new BitcoinConnectorTransactionFailedError();
|
|
4946
|
+
}
|
|
4947
|
+
return { txHash };
|
|
4948
|
+
}
|
|
4914
4949
|
}
|
|
4915
4950
|
|
|
4916
4951
|
var XrplTransactionType;
|
|
@@ -20549,7 +20584,7 @@ const walletIconBaseUrl = "https://raw.githubusercontent.com/0xsquid/assets/main
|
|
|
20549
20584
|
* Returns the value of the property if found, otherwise undefined.
|
|
20550
20585
|
*/
|
|
20551
20586
|
const accessProperty = (object, path) => {
|
|
20552
|
-
const value =
|
|
20587
|
+
const value = getProperty(object, path);
|
|
20553
20588
|
if (value === undefined) {
|
|
20554
20589
|
console.error(`Property "${path}" not found while reading object`, object);
|
|
20555
20590
|
}
|
|
@@ -20877,6 +20912,16 @@ const fallbackWallets = [
|
|
|
20877
20912
|
chrome: "https://chromewebstore.google.com/detail/console-wallet/lpnfhpbpmlobjlgkdmnjieeihjmihhjd",
|
|
20878
20913
|
},
|
|
20879
20914
|
},
|
|
20915
|
+
{
|
|
20916
|
+
chainType: ChainType.CANTON,
|
|
20917
|
+
id: "nightly",
|
|
20918
|
+
name: "Nightly",
|
|
20919
|
+
connectorName: "Nightly",
|
|
20920
|
+
icon: `${walletIconBaseUrl}/nightly.webp`,
|
|
20921
|
+
links: {
|
|
20922
|
+
chrome: "https://chromewebstore.google.com/detail/nightly/fiikommddbeccaoicoejoniammnalkfa",
|
|
20923
|
+
},
|
|
20924
|
+
},
|
|
20880
20925
|
];
|
|
20881
20926
|
|
|
20882
20927
|
// Validation taken from Squid API repo
|
|
@@ -20898,6 +20943,32 @@ const isBitcoinAddressValid = (address$1) => {
|
|
|
20898
20943
|
}
|
|
20899
20944
|
};
|
|
20900
20945
|
|
|
20946
|
+
/**
|
|
20947
|
+
* Format a Canton connector into a Squid {@link CantonWallet}. Shared by the
|
|
20948
|
+
* announce-discovery and injected-provider paths.
|
|
20949
|
+
*/
|
|
20950
|
+
function formatCantonWallet({ connectorId, name, icon, connector, }) {
|
|
20951
|
+
return {
|
|
20952
|
+
name,
|
|
20953
|
+
connectorId,
|
|
20954
|
+
connectorName: name,
|
|
20955
|
+
icon,
|
|
20956
|
+
windowFlag: connectorId,
|
|
20957
|
+
skipInstallCheck: true,
|
|
20958
|
+
isInstalled: () => true,
|
|
20959
|
+
isMultiChain: false,
|
|
20960
|
+
type: ChainType.CANTON,
|
|
20961
|
+
connector,
|
|
20962
|
+
};
|
|
20963
|
+
}
|
|
20964
|
+
/**
|
|
20965
|
+
* Append injected wallets that aren't already covered by an announce-discovered
|
|
20966
|
+
* wallet with the same connectorId (in case a wallet later does both).
|
|
20967
|
+
*/
|
|
20968
|
+
function mergeInjectedCantonWallets(announced, injected) {
|
|
20969
|
+
const seen = new Set(announced.map((w) => w.connectorId));
|
|
20970
|
+
return [...announced, ...injected.filter((w) => !seen.has(w.connectorId))];
|
|
20971
|
+
}
|
|
20901
20972
|
// Canton PartyID = address
|
|
20902
20973
|
const CANTON_PARTY_ID_SEPARATOR = "::";
|
|
20903
20974
|
/** Canton Coin's well-known token-standard instrument id (its address carries no id prefix). */
|
|
@@ -22873,21 +22944,21 @@ const resolveChainIdFromAsset = (asset, chains) => {
|
|
|
22873
22944
|
};
|
|
22874
22945
|
const getConfigWithDefaults = (config) => {
|
|
22875
22946
|
return {
|
|
22876
|
-
integratorId:
|
|
22877
|
-
slippage:
|
|
22878
|
-
collectFees:
|
|
22879
|
-
apiUrl:
|
|
22880
|
-
priceImpactWarnings:
|
|
22881
|
-
initialAssets:
|
|
22882
|
-
defaultTokensPerChain:
|
|
22883
|
-
loadPreviousStateFromLocalStorage:
|
|
22884
|
-
availableChains:
|
|
22885
|
-
availableTokens:
|
|
22886
|
-
disabledChains:
|
|
22887
|
-
degenMode:
|
|
22888
|
-
preHook:
|
|
22889
|
-
postHook:
|
|
22890
|
-
overrideGasRefundAddress:
|
|
22947
|
+
integratorId: getProperty(config, "integratorId", defaultConfigValues.integratorId),
|
|
22948
|
+
slippage: getProperty(config, "slippage", defaultConfigValues.slippage),
|
|
22949
|
+
collectFees: getProperty(config, "collectFees", defaultConfigValues.collectFees),
|
|
22950
|
+
apiUrl: getProperty(config, "apiUrl", defaultConfigValues.apiUrl),
|
|
22951
|
+
priceImpactWarnings: getProperty(config, "priceImpactWarnings", defaultConfigValues.priceImpactWarnings),
|
|
22952
|
+
initialAssets: getProperty(config, "initialAssets", defaultConfigValues.initialAssets),
|
|
22953
|
+
defaultTokensPerChain: getProperty(config, "defaultTokensPerChain", defaultConfigValues.defaultTokensPerChain),
|
|
22954
|
+
loadPreviousStateFromLocalStorage: getProperty(config, "loadPreviousStateFromLocalStorage", defaultConfigValues.loadPreviousStateFromLocalStorage),
|
|
22955
|
+
availableChains: getProperty(config, "availableChains", defaultConfigValues.availableChains),
|
|
22956
|
+
availableTokens: getProperty(config, "availableTokens", defaultConfigValues.availableTokens),
|
|
22957
|
+
disabledChains: getProperty(config, "disabledChains", defaultConfigValues.disabledChains),
|
|
22958
|
+
degenMode: getProperty(config, "degenMode", defaultConfigValues.degenMode),
|
|
22959
|
+
preHook: getProperty(config, "preHook", defaultConfigValues.preHook),
|
|
22960
|
+
postHook: getProperty(config, "postHook", defaultConfigValues.postHook),
|
|
22961
|
+
overrideGasRefundAddress: getProperty(config, "overrideGasRefundAddress", defaultConfigValues.overrideGasRefundAddress),
|
|
22891
22962
|
};
|
|
22892
22963
|
};
|
|
22893
22964
|
const randomIntFromInterval = (min, max) => {
|
|
@@ -23584,7 +23655,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23584
23655
|
};
|
|
23585
23656
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23586
23657
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23587
|
-
const { fetchAllSecretBalances } = await import('./secretService-
|
|
23658
|
+
const { fetchAllSecretBalances } = await import('./secretService-BMH_eXJd.js');
|
|
23588
23659
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23589
23660
|
};
|
|
23590
23661
|
function getTokenAssetsKey(token) {
|
|
@@ -26815,14 +26886,16 @@ class CantonBrowserConnector {
|
|
|
26815
26886
|
client;
|
|
26816
26887
|
listeners = { connect: new Set(), disconnect: new Set() };
|
|
26817
26888
|
_accounts = [];
|
|
26818
|
-
constructor(provider, win = window) {
|
|
26889
|
+
constructor(provider, win = window, client) {
|
|
26819
26890
|
this.providerId = provider.id;
|
|
26820
26891
|
this.name = provider.name;
|
|
26821
26892
|
this.target = provider.target ?? provider.id;
|
|
26822
|
-
this.client =
|
|
26823
|
-
|
|
26824
|
-
|
|
26825
|
-
|
|
26893
|
+
this.client =
|
|
26894
|
+
client ??
|
|
26895
|
+
createCantonClient(new WindowTransport(win, {
|
|
26896
|
+
target: this.target,
|
|
26897
|
+
timeout: REQUEST_TIMEOUT_MS,
|
|
26898
|
+
}));
|
|
26826
26899
|
}
|
|
26827
26900
|
get accounts() {
|
|
26828
26901
|
return this._accounts;
|
|
@@ -26924,44 +26997,116 @@ async function discoverCantonProviders(timeoutMs = DEFAULT_DISCOVERY_TIMEOUT_MS,
|
|
|
26924
26997
|
}
|
|
26925
26998
|
|
|
26926
26999
|
/**
|
|
26927
|
-
*
|
|
26928
|
-
*
|
|
27000
|
+
* CIP-103 wallets that expose their provider as an injected `window` global
|
|
27001
|
+
* instead of participating in the `canton:announceProvider` discovery protocol.
|
|
27002
|
+
* Add an entry to support a new one.
|
|
27003
|
+
*/
|
|
27004
|
+
const INJECTED_CANTON_WALLETS = [
|
|
27005
|
+
{
|
|
27006
|
+
connectorId: "nightly",
|
|
27007
|
+
name: "Nightly",
|
|
27008
|
+
icon: `${walletIconBaseUrl}/nightly.webp`,
|
|
27009
|
+
windowPath: "nightly.canton",
|
|
27010
|
+
},
|
|
27011
|
+
];
|
|
27012
|
+
/**
|
|
27013
|
+
* Adapts an injected CIP-103 `SpliceProvider` (the normative `request` API) to
|
|
27014
|
+
* the {@link CantonClient} surface consumed by `CantonBrowserConnector`, so
|
|
27015
|
+
* injected wallets reuse the same connector as announce-discovered ones.
|
|
27016
|
+
*/
|
|
27017
|
+
function cantonClientFromSpliceProvider(provider) {
|
|
27018
|
+
return {
|
|
27019
|
+
status: () => provider.request({ method: "status" }),
|
|
27020
|
+
connect: () => provider.request({ method: "connect" }),
|
|
27021
|
+
disconnect: () => provider.request({ method: "disconnect" }),
|
|
27022
|
+
isConnected: () => provider.request({ method: "isConnected" }),
|
|
27023
|
+
getActiveNetwork: () => provider.request({ method: "getActiveNetwork" }),
|
|
27024
|
+
listAccounts: () => provider.request({ method: "listAccounts" }),
|
|
27025
|
+
getPrimaryAccount: () => provider.request({ method: "getPrimaryAccount" }),
|
|
27026
|
+
prepareExecute: (params) => provider.request({ method: "prepareExecute", params }),
|
|
27027
|
+
prepareExecuteAndWait: (params) => provider.request({ method: "prepareExecuteAndWait", params }),
|
|
27028
|
+
signMessage: (params) => provider.request({ method: "signMessage", params }),
|
|
27029
|
+
ledgerApi: (params) => provider.request({ method: "ledgerApi", params }),
|
|
27030
|
+
};
|
|
27031
|
+
}
|
|
27032
|
+
/**
|
|
27033
|
+
* Detect installed injected Canton wallets by walking each registered
|
|
27034
|
+
* `windowPath`, mirroring the `definedInWindow` install check used for other
|
|
27035
|
+
* non-autodiscovered wallets.
|
|
27036
|
+
*/
|
|
27037
|
+
function discoverInjectedCantonWallets(win) {
|
|
27038
|
+
const source = (typeof window !== "undefined" ? window : undefined);
|
|
27039
|
+
if (!source)
|
|
27040
|
+
return [];
|
|
27041
|
+
return INJECTED_CANTON_WALLETS.flatMap((config) => {
|
|
27042
|
+
const provider = getProperty(source, config.windowPath);
|
|
27043
|
+
if (!provider || typeof provider.request !== "function")
|
|
27044
|
+
return [];
|
|
27045
|
+
return [{ config, provider }];
|
|
27046
|
+
});
|
|
27047
|
+
}
|
|
27048
|
+
|
|
27049
|
+
/**
|
|
27050
|
+
* Discovers Canton browser-extension wallets and maps each to a
|
|
27051
|
+
* {@link CantonWallet}: CIP-103 announce-protocol wallets (on mount and on
|
|
27052
|
+
* window focus), plus injected wallets that ship the CIP-103 RPC surface as a
|
|
27053
|
+
* `window` global instead of announcing (see `INJECTED_CANTON_WALLETS`).
|
|
26929
27054
|
*/
|
|
26930
27055
|
function useCantonWallets() {
|
|
26931
27056
|
const [wallets, setWallets] = useState([]);
|
|
26932
|
-
const
|
|
26933
|
-
const
|
|
26934
|
-
|
|
27057
|
+
const announcedCache = useRef(new Map());
|
|
27058
|
+
const injectedCache = useRef(new Map());
|
|
27059
|
+
const toAnnouncedWallet = useCallback((provider) => {
|
|
27060
|
+
let connector = announcedCache.current.get(provider.id);
|
|
26935
27061
|
if (!connector) {
|
|
26936
27062
|
connector = new CantonBrowserConnector(provider);
|
|
26937
|
-
|
|
27063
|
+
announcedCache.current.set(provider.id, connector);
|
|
26938
27064
|
}
|
|
26939
|
-
return {
|
|
26940
|
-
name: provider.name,
|
|
27065
|
+
return formatCantonWallet({
|
|
26941
27066
|
connectorId: provider.id,
|
|
26942
|
-
|
|
27067
|
+
name: provider.name,
|
|
26943
27068
|
icon: provider.icon,
|
|
26944
|
-
windowFlag: provider.id,
|
|
26945
|
-
skipInstallCheck: true,
|
|
26946
|
-
isInstalled: () => true,
|
|
26947
|
-
isMultiChain: false,
|
|
26948
|
-
type: ChainType.CANTON,
|
|
26949
27069
|
connector,
|
|
26950
|
-
};
|
|
27070
|
+
});
|
|
27071
|
+
}, []);
|
|
27072
|
+
const toInjectedWallet = useCallback(({ config, provider }) => {
|
|
27073
|
+
// Rebuild if the wallet re-injects a new provider object (e.g. extension
|
|
27074
|
+
// reload): the cached connector closes over the previous provider.
|
|
27075
|
+
let entry = injectedCache.current.get(config.connectorId);
|
|
27076
|
+
if (!entry || entry.provider !== provider) {
|
|
27077
|
+
entry = {
|
|
27078
|
+
connector: new CantonBrowserConnector({ id: config.connectorId, name: config.name, icon: config.icon }, window, cantonClientFromSpliceProvider(provider)),
|
|
27079
|
+
provider,
|
|
27080
|
+
};
|
|
27081
|
+
injectedCache.current.set(config.connectorId, entry);
|
|
27082
|
+
}
|
|
27083
|
+
return formatCantonWallet({
|
|
27084
|
+
connectorId: config.connectorId,
|
|
27085
|
+
name: config.name,
|
|
27086
|
+
icon: config.icon,
|
|
27087
|
+
connector: entry.connector,
|
|
27088
|
+
});
|
|
26951
27089
|
}, []);
|
|
26952
27090
|
const refresh = useCallback(async () => {
|
|
26953
27091
|
if (typeof window === "undefined")
|
|
26954
27092
|
return;
|
|
26955
|
-
const
|
|
26956
|
-
|
|
26957
|
-
|
|
27093
|
+
const announced = (await discoverCantonProviders()).map(toAnnouncedWallet);
|
|
27094
|
+
const injected = discoverInjectedCantonWallets().map(toInjectedWallet);
|
|
27095
|
+
setWallets(mergeInjectedCantonWallets(announced, injected));
|
|
27096
|
+
}, [toAnnouncedWallet, toInjectedWallet]);
|
|
26958
27097
|
useEffect(() => {
|
|
26959
27098
|
refresh();
|
|
26960
27099
|
if (typeof window === "undefined")
|
|
26961
|
-
return;
|
|
27100
|
+
return undefined;
|
|
26962
27101
|
const onFocus = () => refresh();
|
|
26963
27102
|
window.addEventListener("focus", onFocus);
|
|
26964
|
-
|
|
27103
|
+
// Extensions may inject their global shortly after mount; re-check a couple
|
|
27104
|
+
// of times so late injection surfaces without a focus change.
|
|
27105
|
+
const retries = [500, 1500].map((ms) => window.setTimeout(refresh, ms));
|
|
27106
|
+
return () => {
|
|
27107
|
+
window.removeEventListener("focus", onFocus);
|
|
27108
|
+
retries.forEach((id) => window.clearTimeout(id));
|
|
27109
|
+
};
|
|
26965
27110
|
}, [refresh]);
|
|
26966
27111
|
return { wallets };
|
|
26967
27112
|
}
|
|
@@ -27258,7 +27403,7 @@ function useStellarWallets() {
|
|
|
27258
27403
|
try {
|
|
27259
27404
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
27260
27405
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
|
|
27261
|
-
const { formatStellarWallet } = await import('./stellarService.client-
|
|
27406
|
+
const { formatStellarWallet } = await import('./stellarService.client-BpCW1qZY.js');
|
|
27262
27407
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
27263
27408
|
const promises = modules.map(async (module) => {
|
|
27264
27409
|
const isAvailable = await module.isAvailable();
|
|
@@ -30717,7 +30862,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30717
30862
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30718
30863
|
if (!optionalChains.length)
|
|
30719
30864
|
return;
|
|
30720
|
-
const { EthereumProvider } = await import('./index.es-
|
|
30865
|
+
const { EthereumProvider } = await import('./index.es-wL3I3c3h.js');
|
|
30721
30866
|
const rawProvider = await EthereumProvider.init({
|
|
30722
30867
|
...restParameters,
|
|
30723
30868
|
disableProviderPing: true,
|
|
@@ -37444,47 +37589,83 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
37444
37589
|
}
|
|
37445
37590
|
});
|
|
37446
37591
|
const swapMutationBitcoin = useMutation(async ({ id, route }) => {
|
|
37447
|
-
|
|
37448
|
-
|
|
37449
|
-
throw new Error(`Invalid deposit address: ${depositAddress}`);
|
|
37450
|
-
}
|
|
37451
|
-
if (!sendAmount) {
|
|
37452
|
-
throw new Error(`Invalid send amount: ${sendAmount}`);
|
|
37592
|
+
if (!bitcoinSigner || !route?.transactionRequest) {
|
|
37593
|
+
throw new Error("Need all parameters");
|
|
37453
37594
|
}
|
|
37454
|
-
|
|
37455
|
-
|
|
37456
|
-
|
|
37457
|
-
|
|
37458
|
-
|
|
37459
|
-
|
|
37460
|
-
|
|
37595
|
+
switch (route.transactionRequest.type) {
|
|
37596
|
+
case SquidDataType.ChainflipDepositAddress: {
|
|
37597
|
+
const { depositAddress, amount: sendAmount, statusTrackingId, } = useDepositAddressStore.getState().deposit ?? {};
|
|
37598
|
+
const allParamsValid = route && bitcoinSigner && depositAddress && sendAmount;
|
|
37599
|
+
if (!allParamsValid) {
|
|
37600
|
+
throw new Error("Need all parameters");
|
|
37601
|
+
}
|
|
37602
|
+
await changeNetworkIfNeeded.mutateAsync();
|
|
37603
|
+
dispatchSignatureRequestEvent(route);
|
|
37604
|
+
const { txHash } = await bitcoinSigner.sendBTC(depositAddress, Number(sendAmount));
|
|
37605
|
+
if (txHash) {
|
|
37606
|
+
resetQueriesAfterTxSigned();
|
|
37607
|
+
}
|
|
37608
|
+
// Dispatch event so it can be listened from outside the widget
|
|
37609
|
+
WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
|
|
37610
|
+
if (route.transactionRequest) {
|
|
37611
|
+
const txParams = setTransactionState({
|
|
37612
|
+
route,
|
|
37613
|
+
txHash,
|
|
37614
|
+
// When bridging from Bitcoin we need to send the chainflipId to the status endpoint
|
|
37615
|
+
// instead of the Bitcoin transaction hash
|
|
37616
|
+
transactionIdForStatus: statusTrackingId,
|
|
37617
|
+
userAddress: sourceUserAddress,
|
|
37618
|
+
status: TransactionStatus.INITIAL_LOADING,
|
|
37619
|
+
sourceStatus: TransactionStatus.ONGOING,
|
|
37620
|
+
axelarUrl: undefined,
|
|
37621
|
+
id,
|
|
37622
|
+
});
|
|
37623
|
+
if (txParams) {
|
|
37624
|
+
addSwapTransaction({
|
|
37625
|
+
...txParams,
|
|
37626
|
+
params: route.params,
|
|
37627
|
+
estimate: route.estimate,
|
|
37628
|
+
});
|
|
37629
|
+
}
|
|
37630
|
+
}
|
|
37631
|
+
break;
|
|
37461
37632
|
}
|
|
37462
|
-
|
|
37463
|
-
|
|
37464
|
-
|
|
37465
|
-
|
|
37466
|
-
|
|
37467
|
-
|
|
37468
|
-
|
|
37469
|
-
|
|
37470
|
-
|
|
37471
|
-
|
|
37472
|
-
|
|
37473
|
-
|
|
37474
|
-
|
|
37475
|
-
|
|
37476
|
-
|
|
37477
|
-
|
|
37478
|
-
|
|
37479
|
-
|
|
37480
|
-
|
|
37481
|
-
|
|
37633
|
+
case SquidDataType.DepositAddressCalldata: {
|
|
37634
|
+
if (!isOnChainTxData(route.transactionRequest)) {
|
|
37635
|
+
throw new Error("Invalid route data");
|
|
37636
|
+
}
|
|
37637
|
+
const { data: transactionHex } = route.transactionRequest;
|
|
37638
|
+
await changeNetworkIfNeeded.mutateAsync();
|
|
37639
|
+
dispatchSignatureRequestEvent(route);
|
|
37640
|
+
const { txHash } = await bitcoinSigner.signPsbt(transactionHex);
|
|
37641
|
+
if (txHash) {
|
|
37642
|
+
resetQueriesAfterTxSigned();
|
|
37643
|
+
}
|
|
37644
|
+
// Dispatch event so it can be listened from outside the widget
|
|
37645
|
+
WidgetEvents.getInstance().dispatchSwapExecuteCall(route, txHash);
|
|
37646
|
+
if (route.transactionRequest) {
|
|
37647
|
+
const txParams = setTransactionState({
|
|
37648
|
+
route,
|
|
37649
|
+
txHash,
|
|
37650
|
+
userAddress: sourceUserAddress,
|
|
37651
|
+
status: TransactionStatus.INITIAL_LOADING,
|
|
37652
|
+
sourceStatus: TransactionStatus.ONGOING,
|
|
37653
|
+
axelarUrl: undefined,
|
|
37654
|
+
id,
|
|
37482
37655
|
});
|
|
37656
|
+
if (txParams) {
|
|
37657
|
+
addSwapTransaction({
|
|
37658
|
+
...txParams,
|
|
37659
|
+
params: route.params,
|
|
37660
|
+
estimate: route.estimate,
|
|
37661
|
+
});
|
|
37662
|
+
}
|
|
37483
37663
|
}
|
|
37664
|
+
break;
|
|
37665
|
+
}
|
|
37666
|
+
default: {
|
|
37667
|
+
throw new Error(`Unhandled route type ${route.transactionRequest.type}`);
|
|
37484
37668
|
}
|
|
37485
|
-
}
|
|
37486
|
-
else {
|
|
37487
|
-
throw new Error("Need all parameters");
|
|
37488
37669
|
}
|
|
37489
37670
|
});
|
|
37490
37671
|
const swapMutationXrpl = useMutation(async ({ id, route }) => {
|
|
@@ -38644,5 +38825,5 @@ const SquidProvider = ({ children, config, placeholder, }) => {
|
|
|
38644
38825
|
React.createElement(CosmosProvider, null, children))))))))))) : (placeholder);
|
|
38645
38826
|
};
|
|
38646
38827
|
|
|
38647
|
-
export {
|
|
38648
|
-
//# sourceMappingURL=index-
|
|
38828
|
+
export { useWalletStore as $, AxelarStatusResponseType as A, useHederaAccountActivation as B, CHAIN_IDS as C, DEFAULT_LOCALE as D, useHederaTokenAssociations as E, useKeyboardNavigation as F, useSquidQueryClient as G, HistoryTxType as H, useSquid as I, useStellarAccountActivation as J, useStellarTrustLine as K, useAddressBookStore as L, useAssetsColorsStore as M, Nr as N, useFavoriteTokensStore as O, useHistoryStore as P, QueryKeys as Q, useSendTransactionStore as R, SquidStatusErrorType as S, TransactionErrorType as T, useConfigStore as U, useSquidStore as V, Wo as W, XamanXrplNetwork as X, useSwapRoutePersistStore as Y, useTransactionStore as Z, ConnectingWalletStatus as _, WindowWalletFlag as a, useAvailableQuotes as a$, useDepositAddress as a0, useSwap as a1, buildUrlSearchParamsFromSwapEvent as a2, parseInitialAssetsFromUrl as a3, useUrlSwapParams as a4, useAllConnectedWalletBalances as a5, useAllTokensWithBalanceForChainType as a6, useCosmosBalance as a7, useEvmBalance as a8, useMultiChainBalance as a9, useRouteWarnings as aA, useSendTransactionStatus as aB, useSwapTransactionStatus as aC, useAvatar as aD, useHistory as aE, useDebouncedValue as aF, useAddToken as aG, useAutoConnect as aH, useEnsDataForAddress as aI, useEnsSearch as aJ, useGnosisContext as aK, useIsSameAddressAndGnosisContext as aL, useIntegratorContext as aM, useMultiChainWallet as aN, useSigner as aO, useWallet as aP, useWallets as aQ, useXrplTrustLine as aR, TX_STATUS_CONSTANTS as aS, FINAL_TRANSACTION_STATUSES as aT, useGetFiatQuote as aU, useGetOnRampConfig as aV, useExecuteFiatQuote as aW, useFiatOnRampTxStatus as aX, useFiatTransactions as aY, useCurrencyDetails as aZ, useCountryDetails as a_, useMultipleTokenPrices as aa, useBitcoinNativeBalance as ab, useCosmosNativeBalance as ac, useEvmNativeBalance as ad, useNativeBalance as ae, useSolanaNativeBalance as af, useStellarNativeBalance as ag, useSuiNativeBalance as ah, useXrplNativeBalance as ai, useNativeTokenForChain as aj, useSingleTokenPrice as ak, useSourceChainGasToken as al, useSquidTokens as am, useHistoricalData as an, useTokensData as ao, useEstimateSendTransaction as ap, useSendTransaction as aq, useSendTransactionGas as ar, useAllTransactionsStatus as as, useApproval as at, useDepositTransactionStatus as au, useEstimate as av, useEstimatePriceImpact as aw, useExecuteTransaction as ax, useGetRoute as ay, useGetRouteWrapper as az, DEFAULT_ROUTE_REFETCH_INTERVAL as b, addEthereumChain as b$, useRecommendedQuote as b0, useGetOnrampPaymentTypes as b1, useSuggestedFiatAmounts as b2, SquidProvider as b3, EnsService as b4, getXummClient as b5, isXamanXAppContext as b6, getQueryHeaders as b7, getStatusCode as b8, is404Error as b9, randomIntFromInterval as bA, getTokensForChain as bB, getFirstAvailableChainId as bC, fetchHighestBalanceToken as bD, getInitialOrDefaultTokenAddressForChain as bE, getInitialTokenAddressForChain as bF, filterTokensForDestination as bG, getInitialChainIdFromConfig as bH, getCosmosKey as bI, getKeysSettled as bJ, getAllKeysForSupportedCosmosChains as bK, isCosmosAddressValid as bL, getCosmosSigningClient as bM, getCosmosChainInfosObject as bN, connectCosmosWallet as bO, isFallbackAddressNeeded as bP, suggestChainOrThrow as bQ, normalizeError as bR, transactionErrorCode as bS, isUserRejectionError as bT, getTransactionError as bU, handleTransactionErrorEvents as bV, isSwapRouteError as bW, isStatusError as bX, createQuoteRequestParamsHash as bY, WidgetEvents as bZ, EvmNetworkNotSupportedErrorCode as b_, assetsBaseUrl as ba, shareSubgraphId as bb, sortTokensBySharedSubgraphIds as bc, getSupportedChainIdsForDirection as bd, filterChains as be, filterTokens as bf, getTokenImage as bg, getNewSwapParamsFromInput as bh, sortAllTokens as bi, findToken as bj, findNativeToken as bk, normalizeIbcAddress as bl, groupTokensBySymbol as bm, groupTokensByChainId as bn, filterViewableTokens as bo, getSecretNetworkBalances as bp, getTokenAssetsKey as bq, fetchAssetsColors as br, isSupportedChainType as bs, initializeSquidData as bt, isEmptyObject as bu, normalizeTokenSymbol as bv, areTokenSymbolsCompatible as bw, isEvmosChain as bx, resolveChainIdFromAsset as by, getConfigWithDefaults as bz, chainTypeToNativeTokenAddressMap as c, chainflipMultihopBridgeType as c$, parseEvmAddress as c0, formatEvmWallet as c1, filterWagmiConnector as c2, waitForReceiptWithRetry as c3, getUserCountry as c4, getCountryData as c5, getCurrencyData as c6, adaptiveRound as c7, getSuggestedAmountsForCurrency as c8, HederaExtensionHelper as c9, isStellarIssuedToken as cA, getStellarHorizonApiUrl as cB, isValidIssuedAsset as cC, isValidHorizonAsset as cD, formatTransactionHistoryDate as cE, getAxelarExplorerTxUrl as cF, getSourceExplorerTxUrl as cG, getMainExplorerUrl as cH, formatDistance as cI, formatSeconds as cJ, formatSwapTxStatusResponseForStorage as cK, simplifyRouteAction as cL, fetchSwapTransactionStatus as cM, compareTransactionIds as cN, isCoralBridgeAction as cO, isActionCompletedOnSourceTx as cP, sleep as cQ, isChainflipDepositRoute as cR, isChainflipBridgeTransaction as cS, isOnChainTxData as cT, isDepositAddressDirectTransferRoute as cU, getHistoryTransactionId as cV, getStepStatuses as cW, getHalfSuccessState as cX, getStepsInfos as cY, getSwapTxStatusRefetchInterval as cZ, getSendTxStatusRefetchInterval as c_, convertHederaAccountIdToEvmAddress as ca, convertEvmAddressToHederaAccountId as cb, scaleHbarToWei as cc, scaleWeiToHbar as cd, parseToBigInt as ce, roundNumericValue as cf, formatUnitsRounded as cg, formatTokenAmount as ch, formatUsdAmount as ci, trimExtraDecimals as cj, getNumericValue as ck, cleanAmount as cl, convertTokenAmountToUSD as cm, convertUSDToTokenAmount as cn, calculateTotal24hChange as co, getRouteExpiry as cp, searchTokens as cq, filterSolanaWallets as cr, isSolanaAddressValid as cs, executeSolanaSwap as ct, executeSolanaTransfer as cu, isStellarAddressValid as cv, getStellarNetwork as cw, stellarAddressToScVal as cx, getStellarTrustLineAsset as cy, isStellarToken as cz, definedInWindow as d, getBridgeType as d0, getTransactionStatus as d1, getTransactionEndStatus as d2, isHistoryTransactionPending as d3, isHistoryTransactionFailed as d4, isHistoryTransactionWarning as d5, isHistoryTransactionEnded as d6, formatHash as d7, isWalletAddressValid as d8, redirectToExtensionsStore as d9, populateWallets as da, buildFallbackWallets as db, getDefaultChain as dc, sortWallets as dd, areSameAddress as de, sortAddressBook as df, calculateTotalUsdBalanceUSD as dg, addTokenToWallet as dh, isEvmChainNotSupportedError as di, getWalletSupportedChainTypes as dj, getConnectorForChainType as dk, walletSupportsChainType as dl, connectWallet as dm, cancelConnectWallet as dn, isProblematicConnector as dp, mergeWallets as dq, isXionSmartContractAddress as dr, isXrplAddressValid as ds, buildXrplTrustSetTx as dt, getXrplNetwork as du, parseXrplPaymentTx as dv, parseXrplTokenAddress as dw, er as e, formatBNToReadable as f, chainTypeToZeroAddressMap as g, destinationAddressResetValue as h, fallbackAddressResetValue as i, nativeCantonTokenAddress as j, nativeCosmosTokenAddress as k, nativeEvmTokenAddress as l, nativeSolanaTokenAddress as m, nativeBitcoinTokenAddress as n, nativeStellarTokenAddress as o, nativeSuiTokenAddress as p, nativeXrplTokenAddress as q, CosmosProvider as r, SendTransactionStatus as s, TransactionStatus as t, useCosmosContext as u, useTrackSearchEmpty as v, walletIconBaseUrl as w, useSquidChains as x, useClient as y, useCosmosForChain as z };
|
|
38829
|
+
//# sourceMappingURL=index-D5bkikGx.js.map
|