@0xsquid/react-hooks 8.10.1-beta-bitcoin-coralv2.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/index.d.ts +1 -1
- package/dist/hooks/canton/useCantonWallets.d.ts +4 -2
- package/dist/{index-Cw1rn5LQ.js → index-BzTFES6t.js} +204 -100
- package/dist/index-BzTFES6t.js.map +1 -0
- package/dist/{index-Dykfm_Bt.js → index-D5bkikGx.js} +204 -101
- package/dist/index-D5bkikGx.js.map +1 -0
- package/dist/{index.es-DQyW9YL5.js → index.es-DaKI7v5_.js} +2 -2
- package/dist/{index.es-DQyW9YL5.js.map → index.es-DaKI7v5_.js.map} +1 -1
- package/dist/{index.es-DspxF1i7.js → index.es-wL3I3c3h.js} +2 -2
- package/dist/{index.es-DspxF1i7.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-C_gWAduF.js → secretService-BMH_eXJd.js} +2 -2
- package/dist/{secretService-C_gWAduF.js.map → secretService-BMH_eXJd.js.map} +1 -1
- package/dist/{secretService-6H3XQVCV.js → secretService-D70MRo5w.js} +2 -2
- package/dist/{secretService-6H3XQVCV.js.map → secretService-D70MRo5w.js.map} +1 -1
- package/dist/services/internal/cantonService.d.ts +17 -1
- package/dist/{stellarService.client-BdMbbog4.js → stellarService.client-BpCW1qZY.js} +2 -2
- package/dist/{stellarService.client-BdMbbog4.js.map → stellarService.client-BpCW1qZY.js.map} +1 -1
- package/dist/{stellarService.client-CElL9N4g.js → stellarService.client-DhwF4F1c.js} +2 -2
- package/dist/{stellarService.client-CElL9N4g.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-Cw1rn5LQ.js.map +0 -1
- package/dist/index-Dykfm_Bt.js.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type CantonClient } from "@sigilry/dapp";
|
|
1
2
|
import type { CantonAccount, CantonConnectResult, CantonConnector, CantonConnectorEvent, CantonConnectorEventHandler, CantonLedgerApiParams, CantonPrepareExecuteAndWaitResult, CantonPrepareExecuteParams } from "../types/canton";
|
|
2
3
|
import { AnnouncedCantonProvider } from "./cip103Client";
|
|
3
4
|
/**
|
|
@@ -11,7 +12,7 @@ export declare class CantonBrowserConnector implements CantonConnector {
|
|
|
11
12
|
private readonly client;
|
|
12
13
|
private readonly listeners;
|
|
13
14
|
private _accounts;
|
|
14
|
-
constructor(provider: AnnouncedCantonProvider, win?: Window);
|
|
15
|
+
constructor(provider: AnnouncedCantonProvider, win?: Window, client?: CantonClient);
|
|
15
16
|
get accounts(): CantonAccount[];
|
|
16
17
|
get address(): string | undefined;
|
|
17
18
|
connect(): Promise<CantonConnectResult>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CantonClient, SpliceProvider } from "@sigilry/dapp";
|
|
2
|
+
import type { ConnectorID } from "../types/wallet";
|
|
3
|
+
export interface InjectedCantonWalletConfig {
|
|
4
|
+
connectorId: ConnectorID;
|
|
5
|
+
name: string;
|
|
6
|
+
icon?: string;
|
|
7
|
+
/** Dot-path to the injected CIP-103 provider on `window` (e.g. `nightly.canton`). */
|
|
8
|
+
windowPath: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* CIP-103 wallets that expose their provider as an injected `window` global
|
|
12
|
+
* instead of participating in the `canton:announceProvider` discovery protocol.
|
|
13
|
+
* Add an entry to support a new one.
|
|
14
|
+
*/
|
|
15
|
+
export declare const INJECTED_CANTON_WALLETS: InjectedCantonWalletConfig[];
|
|
16
|
+
export interface DiscoveredInjectedCantonWallet {
|
|
17
|
+
config: InjectedCantonWalletConfig;
|
|
18
|
+
provider: SpliceProvider;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Adapts an injected CIP-103 `SpliceProvider` (the normative `request` API) to
|
|
22
|
+
* the {@link CantonClient} surface consumed by `CantonBrowserConnector`, so
|
|
23
|
+
* injected wallets reuse the same connector as announce-discovered ones.
|
|
24
|
+
*/
|
|
25
|
+
export declare function cantonClientFromSpliceProvider(provider: SpliceProvider): CantonClient;
|
|
26
|
+
/**
|
|
27
|
+
* Detect installed injected Canton wallets by walking each registered
|
|
28
|
+
* `windowPath`, mirroring the `definedInWindow` install check used for other
|
|
29
|
+
* non-autodiscovered wallets.
|
|
30
|
+
*/
|
|
31
|
+
export declare function discoverInjectedCantonWallets(win?: Window): DiscoveredInjectedCantonWallet[];
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CHAIN_IDS,
|
|
1
|
+
export { CHAIN_IDS, DEFAULT_LOCALE, DEFAULT_ROUTE_REFETCH_INTERVAL, chainTypeToNativeTokenAddressMap, chainTypeToZeroAddressMap, destinationAddressResetValue, fallbackAddressResetValue, nativeBitcoinTokenAddress, nativeCantonTokenAddress, nativeCosmosTokenAddress, nativeEvmTokenAddress, nativeSolanaTokenAddress, nativeStellarTokenAddress, nativeSuiTokenAddress, nativeXrplTokenAddress, } from "./constants";
|
|
2
2
|
export { CosmosProvider, useCosmosContext } from "./providers/CosmosProvider";
|
|
3
3
|
export { QueryKeys } from "./queries/queries-keys";
|
|
4
4
|
export * from "./types";
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { CantonWallet } from "../../core/types/wallet";
|
|
2
2
|
/**
|
|
3
|
-
* Discovers Canton browser-extension wallets
|
|
4
|
-
* (on mount and on
|
|
3
|
+
* Discovers Canton browser-extension wallets and maps each to a
|
|
4
|
+
* {@link CantonWallet}: CIP-103 announce-protocol wallets (on mount and on
|
|
5
|
+
* window focus), plus injected wallets that ship the CIP-103 RPC surface as a
|
|
6
|
+
* `window` global instead of announcing (see `INJECTED_CANTON_WALLETS`).
|
|
5
7
|
*/
|
|
6
8
|
export declare function useCantonWallets(): {
|
|
7
9
|
wallets: CantonWallet[];
|
|
@@ -3463,7 +3463,7 @@ function get$1(object, path, defaultValue) {
|
|
|
3463
3463
|
|
|
3464
3464
|
var get_1 = get$1;
|
|
3465
3465
|
|
|
3466
|
-
var
|
|
3466
|
+
var getProperty = /*@__PURE__*/getDefaultExportFromCjs(get_1);
|
|
3467
3467
|
|
|
3468
3468
|
/**
|
|
3469
3469
|
* The base implementation of `_.hasIn` without support for deep paths.
|
|
@@ -4739,52 +4739,6 @@ class BitcoinConnectorInvalidAccountError extends BitcoinConnectorError {
|
|
|
4739
4739
|
}
|
|
4740
4740
|
}
|
|
4741
4741
|
|
|
4742
|
-
class KeplrConnector {
|
|
4743
|
-
get getProvider() {
|
|
4744
|
-
const provider = window?.bitcoin_keplr;
|
|
4745
|
-
if (!provider) {
|
|
4746
|
-
throw new BitcoinConnectorProviderNotFoundError("Keplr");
|
|
4747
|
-
}
|
|
4748
|
-
return provider;
|
|
4749
|
-
}
|
|
4750
|
-
async sendBTC(to, amount) {
|
|
4751
|
-
const txHash = await this.getProvider.sendBitcoin(to, amount);
|
|
4752
|
-
if (!txHash) {
|
|
4753
|
-
throw new BitcoinConnectorTransactionFailedError();
|
|
4754
|
-
}
|
|
4755
|
-
return { txHash };
|
|
4756
|
-
}
|
|
4757
|
-
async requestAccount() {
|
|
4758
|
-
const accounts = await this.getProvider.requestAccounts();
|
|
4759
|
-
const account = accounts[0];
|
|
4760
|
-
if (typeof account !== "string") {
|
|
4761
|
-
throw new BitcoinConnectorInvalidAccountError();
|
|
4762
|
-
}
|
|
4763
|
-
return {
|
|
4764
|
-
address: account,
|
|
4765
|
-
};
|
|
4766
|
-
}
|
|
4767
|
-
async signPsbt(psbtHex) {
|
|
4768
|
-
// Keplr follows the UniSat-style Bitcoin provider API: `signPsbt` signs and,
|
|
4769
|
-
// with `autoFinalized` (the default), finalizes every input, returning the
|
|
4770
|
-
// signed PSBT as a hex string.
|
|
4771
|
-
// https://docs.keplr.app/api/bitcoin
|
|
4772
|
-
const signedPsbtHex = await this.getProvider.signPsbt(psbtHex, {
|
|
4773
|
-
autoFinalized: true,
|
|
4774
|
-
});
|
|
4775
|
-
// Keplr only exposes `pushTx`, so extract the finalized raw transaction from
|
|
4776
|
-
// the signed PSBT before broadcasting it.
|
|
4777
|
-
const rawTxHex = bitcoin__namespace.Psbt.fromHex(signedPsbtHex)
|
|
4778
|
-
.extractTransaction()
|
|
4779
|
-
.toHex();
|
|
4780
|
-
const txHash = await this.getProvider.pushTx(rawTxHex);
|
|
4781
|
-
if (!txHash) {
|
|
4782
|
-
throw new BitcoinConnectorTransactionFailedError();
|
|
4783
|
-
}
|
|
4784
|
-
return { txHash };
|
|
4785
|
-
}
|
|
4786
|
-
}
|
|
4787
|
-
|
|
4788
4742
|
bitcoin__namespace.initEccLib(ecc__namespace);
|
|
4789
4743
|
const network = bitcoin__namespace.networks.bitcoin;
|
|
4790
4744
|
const fromHexString = (hexString) => {
|
|
@@ -4873,6 +4827,53 @@ async function getTransactionStatus$1(txHash) {
|
|
|
4873
4827
|
.then((response) => response.data);
|
|
4874
4828
|
}
|
|
4875
4829
|
|
|
4830
|
+
class KeplrConnector {
|
|
4831
|
+
get getProvider() {
|
|
4832
|
+
const provider = window?.bitcoin_keplr;
|
|
4833
|
+
if (!provider) {
|
|
4834
|
+
throw new BitcoinConnectorProviderNotFoundError("Keplr");
|
|
4835
|
+
}
|
|
4836
|
+
return provider;
|
|
4837
|
+
}
|
|
4838
|
+
async sendBTC(to, amount) {
|
|
4839
|
+
const txHash = await this.getProvider.sendBitcoin(to, amount);
|
|
4840
|
+
if (!txHash) {
|
|
4841
|
+
throw new BitcoinConnectorTransactionFailedError();
|
|
4842
|
+
}
|
|
4843
|
+
return { txHash };
|
|
4844
|
+
}
|
|
4845
|
+
async requestAccount() {
|
|
4846
|
+
const accounts = await this.getProvider.requestAccounts();
|
|
4847
|
+
const account = accounts[0];
|
|
4848
|
+
if (typeof account !== "string") {
|
|
4849
|
+
throw new BitcoinConnectorInvalidAccountError();
|
|
4850
|
+
}
|
|
4851
|
+
return {
|
|
4852
|
+
address: account,
|
|
4853
|
+
};
|
|
4854
|
+
}
|
|
4855
|
+
async signPsbt(psbtHex) {
|
|
4856
|
+
// Keplr follows the UniSat-style Bitcoin provider API: `signPsbt` signs and,
|
|
4857
|
+
// with `autoFinalized` (the default), finalizes every input, returning the
|
|
4858
|
+
// signed PSBT as a hex string.
|
|
4859
|
+
// https://docs.keplr.app/api/bitcoin
|
|
4860
|
+
const signedPsbtHex = await this.getProvider.signPsbt(psbtHex, {
|
|
4861
|
+
autoFinalized: true,
|
|
4862
|
+
});
|
|
4863
|
+
// Broadcast the finalized raw transaction directly rather than through
|
|
4864
|
+
// Keplr's `pushTx`, which proxies via Keplr's own Bitcoin indexer
|
|
4865
|
+
// (api-indexer-bitcoin.keplr.app) and fails when that service is down.
|
|
4866
|
+
const rawTxHex = bitcoin__namespace.Psbt.fromHex(signedPsbtHex)
|
|
4867
|
+
.extractTransaction()
|
|
4868
|
+
.toHex();
|
|
4869
|
+
const txHash = await broadcastTx(rawTxHex);
|
|
4870
|
+
if (!txHash) {
|
|
4871
|
+
throw new BitcoinConnectorTransactionFailedError();
|
|
4872
|
+
}
|
|
4873
|
+
return { txHash };
|
|
4874
|
+
}
|
|
4875
|
+
}
|
|
4876
|
+
|
|
4876
4877
|
const MAINNET = bitcoin__namespace.networks.bitcoin;
|
|
4877
4878
|
class PhantomConnector {
|
|
4878
4879
|
get getProvider() {
|
|
@@ -20604,7 +20605,7 @@ const walletIconBaseUrl = "https://raw.githubusercontent.com/0xsquid/assets/main
|
|
|
20604
20605
|
* Returns the value of the property if found, otherwise undefined.
|
|
20605
20606
|
*/
|
|
20606
20607
|
const accessProperty = (object, path) => {
|
|
20607
|
-
const value =
|
|
20608
|
+
const value = getProperty(object, path);
|
|
20608
20609
|
if (value === undefined) {
|
|
20609
20610
|
console.error(`Property "${path}" not found while reading object`, object);
|
|
20610
20611
|
}
|
|
@@ -20932,6 +20933,16 @@ const fallbackWallets = [
|
|
|
20932
20933
|
chrome: "https://chromewebstore.google.com/detail/console-wallet/lpnfhpbpmlobjlgkdmnjieeihjmihhjd",
|
|
20933
20934
|
},
|
|
20934
20935
|
},
|
|
20936
|
+
{
|
|
20937
|
+
chainType: squidTypes.ChainType.CANTON,
|
|
20938
|
+
id: "nightly",
|
|
20939
|
+
name: "Nightly",
|
|
20940
|
+
connectorName: "Nightly",
|
|
20941
|
+
icon: `${walletIconBaseUrl}/nightly.webp`,
|
|
20942
|
+
links: {
|
|
20943
|
+
chrome: "https://chromewebstore.google.com/detail/nightly/fiikommddbeccaoicoejoniammnalkfa",
|
|
20944
|
+
},
|
|
20945
|
+
},
|
|
20935
20946
|
];
|
|
20936
20947
|
|
|
20937
20948
|
// Validation taken from Squid API repo
|
|
@@ -20953,6 +20964,32 @@ const isBitcoinAddressValid = (address) => {
|
|
|
20953
20964
|
}
|
|
20954
20965
|
};
|
|
20955
20966
|
|
|
20967
|
+
/**
|
|
20968
|
+
* Format a Canton connector into a Squid {@link CantonWallet}. Shared by the
|
|
20969
|
+
* announce-discovery and injected-provider paths.
|
|
20970
|
+
*/
|
|
20971
|
+
function formatCantonWallet({ connectorId, name, icon, connector, }) {
|
|
20972
|
+
return {
|
|
20973
|
+
name,
|
|
20974
|
+
connectorId,
|
|
20975
|
+
connectorName: name,
|
|
20976
|
+
icon,
|
|
20977
|
+
windowFlag: connectorId,
|
|
20978
|
+
skipInstallCheck: true,
|
|
20979
|
+
isInstalled: () => true,
|
|
20980
|
+
isMultiChain: false,
|
|
20981
|
+
type: squidTypes.ChainType.CANTON,
|
|
20982
|
+
connector,
|
|
20983
|
+
};
|
|
20984
|
+
}
|
|
20985
|
+
/**
|
|
20986
|
+
* Append injected wallets that aren't already covered by an announce-discovered
|
|
20987
|
+
* wallet with the same connectorId (in case a wallet later does both).
|
|
20988
|
+
*/
|
|
20989
|
+
function mergeInjectedCantonWallets(announced, injected) {
|
|
20990
|
+
const seen = new Set(announced.map((w) => w.connectorId));
|
|
20991
|
+
return [...announced, ...injected.filter((w) => !seen.has(w.connectorId))];
|
|
20992
|
+
}
|
|
20956
20993
|
// Canton PartyID = address
|
|
20957
20994
|
const CANTON_PARTY_ID_SEPARATOR = "::";
|
|
20958
20995
|
/** Canton Coin's well-known token-standard instrument id (its address carries no id prefix). */
|
|
@@ -22928,21 +22965,21 @@ const resolveChainIdFromAsset = (asset, chains) => {
|
|
|
22928
22965
|
};
|
|
22929
22966
|
const getConfigWithDefaults = (config) => {
|
|
22930
22967
|
return {
|
|
22931
|
-
integratorId:
|
|
22932
|
-
slippage:
|
|
22933
|
-
collectFees:
|
|
22934
|
-
apiUrl:
|
|
22935
|
-
priceImpactWarnings:
|
|
22936
|
-
initialAssets:
|
|
22937
|
-
defaultTokensPerChain:
|
|
22938
|
-
loadPreviousStateFromLocalStorage:
|
|
22939
|
-
availableChains:
|
|
22940
|
-
availableTokens:
|
|
22941
|
-
disabledChains:
|
|
22942
|
-
degenMode:
|
|
22943
|
-
preHook:
|
|
22944
|
-
postHook:
|
|
22945
|
-
overrideGasRefundAddress:
|
|
22968
|
+
integratorId: getProperty(config, "integratorId", defaultConfigValues.integratorId),
|
|
22969
|
+
slippage: getProperty(config, "slippage", defaultConfigValues.slippage),
|
|
22970
|
+
collectFees: getProperty(config, "collectFees", defaultConfigValues.collectFees),
|
|
22971
|
+
apiUrl: getProperty(config, "apiUrl", defaultConfigValues.apiUrl),
|
|
22972
|
+
priceImpactWarnings: getProperty(config, "priceImpactWarnings", defaultConfigValues.priceImpactWarnings),
|
|
22973
|
+
initialAssets: getProperty(config, "initialAssets", defaultConfigValues.initialAssets),
|
|
22974
|
+
defaultTokensPerChain: getProperty(config, "defaultTokensPerChain", defaultConfigValues.defaultTokensPerChain),
|
|
22975
|
+
loadPreviousStateFromLocalStorage: getProperty(config, "loadPreviousStateFromLocalStorage", defaultConfigValues.loadPreviousStateFromLocalStorage),
|
|
22976
|
+
availableChains: getProperty(config, "availableChains", defaultConfigValues.availableChains),
|
|
22977
|
+
availableTokens: getProperty(config, "availableTokens", defaultConfigValues.availableTokens),
|
|
22978
|
+
disabledChains: getProperty(config, "disabledChains", defaultConfigValues.disabledChains),
|
|
22979
|
+
degenMode: getProperty(config, "degenMode", defaultConfigValues.degenMode),
|
|
22980
|
+
preHook: getProperty(config, "preHook", defaultConfigValues.preHook),
|
|
22981
|
+
postHook: getProperty(config, "postHook", defaultConfigValues.postHook),
|
|
22982
|
+
overrideGasRefundAddress: getProperty(config, "overrideGasRefundAddress", defaultConfigValues.overrideGasRefundAddress),
|
|
22946
22983
|
};
|
|
22947
22984
|
};
|
|
22948
22985
|
const randomIntFromInterval = (min, max) => {
|
|
@@ -23639,7 +23676,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23639
23676
|
};
|
|
23640
23677
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23641
23678
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23642
|
-
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-
|
|
23679
|
+
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-D70MRo5w.js'); });
|
|
23643
23680
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23644
23681
|
};
|
|
23645
23682
|
function getTokenAssetsKey(token) {
|
|
@@ -26870,14 +26907,16 @@ class CantonBrowserConnector {
|
|
|
26870
26907
|
client;
|
|
26871
26908
|
listeners = { connect: new Set(), disconnect: new Set() };
|
|
26872
26909
|
_accounts = [];
|
|
26873
|
-
constructor(provider, win = window) {
|
|
26910
|
+
constructor(provider, win = window, client) {
|
|
26874
26911
|
this.providerId = provider.id;
|
|
26875
26912
|
this.name = provider.name;
|
|
26876
26913
|
this.target = provider.target ?? provider.id;
|
|
26877
|
-
this.client =
|
|
26878
|
-
|
|
26879
|
-
|
|
26880
|
-
|
|
26914
|
+
this.client =
|
|
26915
|
+
client ??
|
|
26916
|
+
dapp.createCantonClient(new dapp.WindowTransport(win, {
|
|
26917
|
+
target: this.target,
|
|
26918
|
+
timeout: REQUEST_TIMEOUT_MS,
|
|
26919
|
+
}));
|
|
26881
26920
|
}
|
|
26882
26921
|
get accounts() {
|
|
26883
26922
|
return this._accounts;
|
|
@@ -26979,44 +27018,116 @@ async function discoverCantonProviders(timeoutMs = DEFAULT_DISCOVERY_TIMEOUT_MS,
|
|
|
26979
27018
|
}
|
|
26980
27019
|
|
|
26981
27020
|
/**
|
|
26982
|
-
*
|
|
26983
|
-
*
|
|
27021
|
+
* CIP-103 wallets that expose their provider as an injected `window` global
|
|
27022
|
+
* instead of participating in the `canton:announceProvider` discovery protocol.
|
|
27023
|
+
* Add an entry to support a new one.
|
|
27024
|
+
*/
|
|
27025
|
+
const INJECTED_CANTON_WALLETS = [
|
|
27026
|
+
{
|
|
27027
|
+
connectorId: "nightly",
|
|
27028
|
+
name: "Nightly",
|
|
27029
|
+
icon: `${walletIconBaseUrl}/nightly.webp`,
|
|
27030
|
+
windowPath: "nightly.canton",
|
|
27031
|
+
},
|
|
27032
|
+
];
|
|
27033
|
+
/**
|
|
27034
|
+
* Adapts an injected CIP-103 `SpliceProvider` (the normative `request` API) to
|
|
27035
|
+
* the {@link CantonClient} surface consumed by `CantonBrowserConnector`, so
|
|
27036
|
+
* injected wallets reuse the same connector as announce-discovered ones.
|
|
27037
|
+
*/
|
|
27038
|
+
function cantonClientFromSpliceProvider(provider) {
|
|
27039
|
+
return {
|
|
27040
|
+
status: () => provider.request({ method: "status" }),
|
|
27041
|
+
connect: () => provider.request({ method: "connect" }),
|
|
27042
|
+
disconnect: () => provider.request({ method: "disconnect" }),
|
|
27043
|
+
isConnected: () => provider.request({ method: "isConnected" }),
|
|
27044
|
+
getActiveNetwork: () => provider.request({ method: "getActiveNetwork" }),
|
|
27045
|
+
listAccounts: () => provider.request({ method: "listAccounts" }),
|
|
27046
|
+
getPrimaryAccount: () => provider.request({ method: "getPrimaryAccount" }),
|
|
27047
|
+
prepareExecute: (params) => provider.request({ method: "prepareExecute", params }),
|
|
27048
|
+
prepareExecuteAndWait: (params) => provider.request({ method: "prepareExecuteAndWait", params }),
|
|
27049
|
+
signMessage: (params) => provider.request({ method: "signMessage", params }),
|
|
27050
|
+
ledgerApi: (params) => provider.request({ method: "ledgerApi", params }),
|
|
27051
|
+
};
|
|
27052
|
+
}
|
|
27053
|
+
/**
|
|
27054
|
+
* Detect installed injected Canton wallets by walking each registered
|
|
27055
|
+
* `windowPath`, mirroring the `definedInWindow` install check used for other
|
|
27056
|
+
* non-autodiscovered wallets.
|
|
27057
|
+
*/
|
|
27058
|
+
function discoverInjectedCantonWallets(win) {
|
|
27059
|
+
const source = (typeof window !== "undefined" ? window : undefined);
|
|
27060
|
+
if (!source)
|
|
27061
|
+
return [];
|
|
27062
|
+
return INJECTED_CANTON_WALLETS.flatMap((config) => {
|
|
27063
|
+
const provider = getProperty(source, config.windowPath);
|
|
27064
|
+
if (!provider || typeof provider.request !== "function")
|
|
27065
|
+
return [];
|
|
27066
|
+
return [{ config, provider }];
|
|
27067
|
+
});
|
|
27068
|
+
}
|
|
27069
|
+
|
|
27070
|
+
/**
|
|
27071
|
+
* Discovers Canton browser-extension wallets and maps each to a
|
|
27072
|
+
* {@link CantonWallet}: CIP-103 announce-protocol wallets (on mount and on
|
|
27073
|
+
* window focus), plus injected wallets that ship the CIP-103 RPC surface as a
|
|
27074
|
+
* `window` global instead of announcing (see `INJECTED_CANTON_WALLETS`).
|
|
26984
27075
|
*/
|
|
26985
27076
|
function useCantonWallets() {
|
|
26986
27077
|
const [wallets, setWallets] = React.useState([]);
|
|
26987
|
-
const
|
|
26988
|
-
const
|
|
26989
|
-
|
|
27078
|
+
const announcedCache = React.useRef(new Map());
|
|
27079
|
+
const injectedCache = React.useRef(new Map());
|
|
27080
|
+
const toAnnouncedWallet = React.useCallback((provider) => {
|
|
27081
|
+
let connector = announcedCache.current.get(provider.id);
|
|
26990
27082
|
if (!connector) {
|
|
26991
27083
|
connector = new CantonBrowserConnector(provider);
|
|
26992
|
-
|
|
27084
|
+
announcedCache.current.set(provider.id, connector);
|
|
26993
27085
|
}
|
|
26994
|
-
return {
|
|
26995
|
-
name: provider.name,
|
|
27086
|
+
return formatCantonWallet({
|
|
26996
27087
|
connectorId: provider.id,
|
|
26997
|
-
|
|
27088
|
+
name: provider.name,
|
|
26998
27089
|
icon: provider.icon,
|
|
26999
|
-
windowFlag: provider.id,
|
|
27000
|
-
skipInstallCheck: true,
|
|
27001
|
-
isInstalled: () => true,
|
|
27002
|
-
isMultiChain: false,
|
|
27003
|
-
type: squidTypes.ChainType.CANTON,
|
|
27004
27090
|
connector,
|
|
27005
|
-
};
|
|
27091
|
+
});
|
|
27092
|
+
}, []);
|
|
27093
|
+
const toInjectedWallet = React.useCallback(({ config, provider }) => {
|
|
27094
|
+
// Rebuild if the wallet re-injects a new provider object (e.g. extension
|
|
27095
|
+
// reload): the cached connector closes over the previous provider.
|
|
27096
|
+
let entry = injectedCache.current.get(config.connectorId);
|
|
27097
|
+
if (!entry || entry.provider !== provider) {
|
|
27098
|
+
entry = {
|
|
27099
|
+
connector: new CantonBrowserConnector({ id: config.connectorId, name: config.name, icon: config.icon }, window, cantonClientFromSpliceProvider(provider)),
|
|
27100
|
+
provider,
|
|
27101
|
+
};
|
|
27102
|
+
injectedCache.current.set(config.connectorId, entry);
|
|
27103
|
+
}
|
|
27104
|
+
return formatCantonWallet({
|
|
27105
|
+
connectorId: config.connectorId,
|
|
27106
|
+
name: config.name,
|
|
27107
|
+
icon: config.icon,
|
|
27108
|
+
connector: entry.connector,
|
|
27109
|
+
});
|
|
27006
27110
|
}, []);
|
|
27007
27111
|
const refresh = React.useCallback(async () => {
|
|
27008
27112
|
if (typeof window === "undefined")
|
|
27009
27113
|
return;
|
|
27010
|
-
const
|
|
27011
|
-
|
|
27012
|
-
|
|
27114
|
+
const announced = (await discoverCantonProviders()).map(toAnnouncedWallet);
|
|
27115
|
+
const injected = discoverInjectedCantonWallets().map(toInjectedWallet);
|
|
27116
|
+
setWallets(mergeInjectedCantonWallets(announced, injected));
|
|
27117
|
+
}, [toAnnouncedWallet, toInjectedWallet]);
|
|
27013
27118
|
React.useEffect(() => {
|
|
27014
27119
|
refresh();
|
|
27015
27120
|
if (typeof window === "undefined")
|
|
27016
|
-
return;
|
|
27121
|
+
return undefined;
|
|
27017
27122
|
const onFocus = () => refresh();
|
|
27018
27123
|
window.addEventListener("focus", onFocus);
|
|
27019
|
-
|
|
27124
|
+
// Extensions may inject their global shortly after mount; re-check a couple
|
|
27125
|
+
// of times so late injection surfaces without a focus change.
|
|
27126
|
+
const retries = [500, 1500].map((ms) => window.setTimeout(refresh, ms));
|
|
27127
|
+
return () => {
|
|
27128
|
+
window.removeEventListener("focus", onFocus);
|
|
27129
|
+
retries.forEach((id) => window.clearTimeout(id));
|
|
27130
|
+
};
|
|
27020
27131
|
}, [refresh]);
|
|
27021
27132
|
return { wallets };
|
|
27022
27133
|
}
|
|
@@ -27313,7 +27424,7 @@ function useStellarWallets() {
|
|
|
27313
27424
|
try {
|
|
27314
27425
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
27315
27426
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
|
|
27316
|
-
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-
|
|
27427
|
+
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-DhwF4F1c.js'); });
|
|
27317
27428
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
27318
27429
|
const promises = modules.map(async (module) => {
|
|
27319
27430
|
const isAvailable = await module.isAvailable();
|
|
@@ -30772,7 +30883,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30772
30883
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30773
30884
|
if (!optionalChains.length)
|
|
30774
30885
|
return;
|
|
30775
|
-
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-
|
|
30886
|
+
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-DaKI7v5_.js'); });
|
|
30776
30887
|
const rawProvider = await EthereumProvider.init({
|
|
30777
30888
|
...restParameters,
|
|
30778
30889
|
disableProviderPing: true,
|
|
@@ -37499,10 +37610,6 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
37499
37610
|
}
|
|
37500
37611
|
});
|
|
37501
37612
|
const swapMutationBitcoin = reactQuery.useMutation(async ({ id, route }) => {
|
|
37502
|
-
console.log("Validating route", {
|
|
37503
|
-
bitcoinSigner,
|
|
37504
|
-
route,
|
|
37505
|
-
});
|
|
37506
37613
|
if (!bitcoinSigner || !route?.transactionRequest) {
|
|
37507
37614
|
throw new Error("Need all parameters");
|
|
37508
37615
|
}
|
|
@@ -37545,17 +37652,13 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
37545
37652
|
break;
|
|
37546
37653
|
}
|
|
37547
37654
|
case squidTypes.SquidDataType.DepositAddressCalldata: {
|
|
37548
|
-
console.log(`Route type: ${route.transactionRequest?.type}`);
|
|
37549
37655
|
if (!isOnChainTxData(route.transactionRequest)) {
|
|
37550
|
-
console.log("Invalid route data", route.transactionRequest);
|
|
37551
37656
|
throw new Error("Invalid route data");
|
|
37552
37657
|
}
|
|
37553
37658
|
const { data: transactionHex } = route.transactionRequest;
|
|
37554
37659
|
await changeNetworkIfNeeded.mutateAsync();
|
|
37555
37660
|
dispatchSignatureRequestEvent(route);
|
|
37556
|
-
console.log("Signing psbt", { transactionHex });
|
|
37557
37661
|
const { txHash } = await bitcoinSigner.signPsbt(transactionHex);
|
|
37558
|
-
console.log("Signed psbt", { txHash });
|
|
37559
37662
|
if (txHash) {
|
|
37560
37663
|
resetQueriesAfterTxSigned();
|
|
37561
37664
|
}
|
|
@@ -38889,6 +38992,7 @@ exports.isXionSmartContractAddress = isXionSmartContractAddress;
|
|
|
38889
38992
|
exports.isXrplAddressValid = isXrplAddressValid;
|
|
38890
38993
|
exports.mergeWallets = mergeWallets;
|
|
38891
38994
|
exports.nativeBitcoinTokenAddress = nativeBitcoinTokenAddress;
|
|
38995
|
+
exports.nativeCantonTokenAddress = nativeCantonTokenAddress;
|
|
38892
38996
|
exports.nativeCosmosTokenAddress = nativeCosmosTokenAddress;
|
|
38893
38997
|
exports.nativeEvmTokenAddress = nativeEvmTokenAddress;
|
|
38894
38998
|
exports.nativeSolanaTokenAddress = nativeSolanaTokenAddress;
|
|
@@ -39010,4 +39114,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
|
|
|
39010
39114
|
exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
|
|
39011
39115
|
exports.walletIconBaseUrl = walletIconBaseUrl;
|
|
39012
39116
|
exports.walletSupportsChainType = walletSupportsChainType;
|
|
39013
|
-
//# sourceMappingURL=index-
|
|
39117
|
+
//# sourceMappingURL=index-BzTFES6t.js.map
|