@0xsquid/react-hooks 8.8.1-beta-canton.4 → 8.8.1-beta-wallet-verification.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/client/index.d.ts +0 -1
- package/dist/core/connectors/bitcoin/wallets/keplr.d.ts +2 -1
- package/dist/core/connectors/bitcoin/wallets/unisat.d.ts +3 -0
- package/dist/core/connectors/xrpl/CrossMark.d.ts +12 -0
- package/dist/core/connectors/xrpl/Xaman.d.ts +14 -0
- package/dist/core/connectors/xrpl/XamanQr.d.ts +20 -0
- package/dist/core/connectors/xrpl/XrplMetamaskSnap.d.ts +12 -0
- package/dist/core/connectors/xrpl/walletVerification.d.ts +2 -0
- package/dist/core/constants.d.ts +0 -2
- package/dist/core/types/bitcoin.d.ts +1 -0
- package/dist/core/types/config.d.ts +1 -0
- package/dist/core/types/event.d.ts +4 -1
- package/dist/core/types/index.d.ts +3 -2
- package/dist/core/types/solana.d.ts +11 -1
- package/dist/core/types/sui.d.ts +2 -1
- package/dist/core/types/wallet.d.ts +6 -9
- package/dist/core/types/walletVerificationSignature/bitcoin.d.ts +10 -0
- package/dist/core/types/walletVerificationSignature/chainTypes.d.ts +19 -0
- package/dist/core/types/walletVerificationSignature/cosmos.d.ts +10 -0
- package/dist/core/types/walletVerificationSignature/evm.d.ts +10 -0
- package/dist/core/types/walletVerificationSignature/index.d.ts +18 -0
- package/dist/core/types/walletVerificationSignature/request.d.ts +3 -0
- package/dist/core/types/walletVerificationSignature/sharedResult.d.ts +20 -0
- package/dist/core/types/walletVerificationSignature/solana.d.ts +10 -0
- package/dist/core/types/walletVerificationSignature/stellar.d.ts +10 -0
- package/dist/core/types/walletVerificationSignature/sui.d.ts +10 -0
- package/dist/core/types/walletVerificationSignature/types.d.ts +69 -0
- package/dist/core/types/walletVerificationSignature/xrpl.d.ts +12 -0
- package/dist/core/types/walletVerificationSignature.d.ts +1 -0
- package/dist/core/types/xrpl.d.ts +14 -0
- package/dist/hooks/chains/useSquidChains.d.ts +0 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/store/useDepositAddressStore.d.ts +5 -23
- package/dist/hooks/store/useWalletStore.d.ts +1 -0
- package/dist/hooks/swap/useDepositAddress.d.ts +7 -6
- package/dist/hooks/tokens/useSquidTokens.d.ts +0 -1
- package/dist/hooks/wallet/useMultiChainWallet.d.ts +18 -44
- package/dist/hooks/wallet/useSigner.d.ts +1 -1
- package/dist/hooks/wallet/useWallet.d.ts +18 -48
- package/dist/hooks/wallet/useWalletVerificationSignature.d.ts +22 -0
- package/dist/hooks/wallet/useWalletVerificationSignature.test.d.ts +1 -0
- package/dist/hooks/wallet/walletVerification/signers/bitcoin.d.ts +2 -0
- package/dist/hooks/wallet/walletVerification/signers/cosmos.d.ts +2 -0
- package/dist/hooks/wallet/walletVerification/signers/evm.d.ts +2 -0
- package/dist/hooks/wallet/walletVerification/signers/index.d.ts +3 -0
- package/dist/hooks/wallet/walletVerification/signers/solana.d.ts +2 -0
- package/dist/hooks/wallet/walletVerification/signers/stellar.d.ts +2 -0
- package/dist/hooks/wallet/walletVerification/signers/sui.d.ts +2 -0
- package/dist/hooks/wallet/walletVerification/signers/types.d.ts +33 -0
- package/dist/hooks/wallet/walletVerification/signers/xrpl.d.ts +2 -0
- package/dist/{index-D5QOR7JT.js → index-CtXS5uny.js} +1424 -560
- package/dist/index-CtXS5uny.js.map +1 -0
- package/dist/{index-mgE1SeE-.js → index-z1nGQX9p.js} +1440 -560
- package/dist/index-z1nGQX9p.js.map +1 -0
- package/dist/{index.es-Cq4mUT_n.js → index.es-CBWh71yD.js} +2 -2
- package/dist/{index.es-Cq4mUT_n.js.map → index.es-CBWh71yD.js.map} +1 -1
- package/dist/{index.es-3JPbTFKq.js → index.es-D8CAnRf1.js} +2 -2
- package/dist/{index.es-3JPbTFKq.js.map → index.es-D8CAnRf1.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +30 -6
- package/dist/index.js.map +1 -1
- package/dist/{secretService-DOOg6zVn.js → secretService-B2i6U8uo.js} +2 -2
- package/dist/{secretService-DOOg6zVn.js.map → secretService-B2i6U8uo.js.map} +1 -1
- package/dist/{secretService-DWq78rM5.js → secretService-BFehLMb_.js} +2 -2
- package/dist/{secretService-DWq78rM5.js.map → secretService-BFehLMb_.js.map} +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.esm.js +1 -8
- package/dist/server.esm.js.map +1 -1
- package/dist/server.js +0 -8
- package/dist/server.js.map +1 -1
- package/dist/services/external/index.d.ts +1 -1
- package/dist/services/external/xaman.d.ts +31 -11
- package/dist/services/external/xaman.test.d.ts +1 -0
- package/dist/services/index.d.ts +2 -0
- package/dist/services/internal/assetsService.d.ts +1 -10
- package/dist/services/internal/encodingService.d.ts +8 -0
- package/dist/services/internal/encodingService.test.d.ts +1 -0
- package/dist/services/internal/eventService.d.ts +3 -3
- package/dist/services/internal/evmService.d.ts +1 -0
- package/dist/services/internal/transactionService.d.ts +1 -5
- package/dist/{stellarService.client-C-pOt34O.js → stellarService.client-D20h9JPG.js} +2 -2
- package/dist/{stellarService.client-C-pOt34O.js.map → stellarService.client-D20h9JPG.js.map} +1 -1
- package/dist/{stellarService.client-DBROJ4yf.js → stellarService.client-yWCDuq6S.js} +2 -2
- package/dist/{stellarService.client-DBROJ4yf.js.map → stellarService.client-yWCDuq6S.js.map} +1 -1
- package/package.json +2 -2
- package/dist/core/types/canton.d.ts +0 -2
- package/dist/core/types/cosmos.d.ts +0 -5
- package/dist/hooks/transaction/useDepositTransactionStatus.d.ts +0 -25
- package/dist/hooks/transaction/useSwapStatusQuery.d.ts +0 -26
- package/dist/index-D5QOR7JT.js.map +0 -1
- package/dist/index-mgE1SeE-.js.map +0 -1
- package/dist/services/internal/cantonService.d.ts +0 -2
|
@@ -5,7 +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 bitcoin = require('bitcoinjs-lib');
|
|
8
|
+
var bitcoin$1 = require('bitcoinjs-lib');
|
|
9
9
|
var ecc = require('@bitcoinerlab/secp256k1');
|
|
10
10
|
var axios = require('axios');
|
|
11
11
|
var modal = require('@walletconnect/modal');
|
|
@@ -54,7 +54,7 @@ function _interopNamespaceDefault(e) {
|
|
|
54
54
|
return Object.freeze(n);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
var bitcoin__namespace = /*#__PURE__*/_interopNamespaceDefault(bitcoin);
|
|
57
|
+
var bitcoin__namespace = /*#__PURE__*/_interopNamespaceDefault(bitcoin$1);
|
|
58
58
|
var ecc__namespace = /*#__PURE__*/_interopNamespaceDefault(ecc);
|
|
59
59
|
|
|
60
60
|
const squidApiBaseUrl = "https://v2.api.squidrouter.com";
|
|
@@ -78,8 +78,6 @@ const solanaZeroAddress = "11111111111111111111111111111111";
|
|
|
78
78
|
const suiZeroAddress = "0x0000000000000000000000000000000000000000";
|
|
79
79
|
const xrplZeroAddress = "rrrrrrrrrrrrrrrrrrrrrhoLvTp";
|
|
80
80
|
const stellarZeroAddress = "GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF";
|
|
81
|
-
// TODO: check
|
|
82
|
-
const cantonZeroAddress = "none::12200000000000000000000000000000000000000000000000000000000000000000";
|
|
83
81
|
const chainTypeToZeroAddressMap = {
|
|
84
82
|
[squidTypes.ChainType.EVM]: viem.zeroAddress,
|
|
85
83
|
[squidTypes.ChainType.COSMOS]: cosmosZeroAddress,
|
|
@@ -88,7 +86,6 @@ const chainTypeToZeroAddressMap = {
|
|
|
88
86
|
[squidTypes.ChainType.SUI]: suiZeroAddress,
|
|
89
87
|
[squidTypes.ChainType.XRPL]: xrplZeroAddress,
|
|
90
88
|
[squidTypes.ChainType.STELLAR]: stellarZeroAddress,
|
|
91
|
-
[squidTypes.ChainType.CANTON]: cantonZeroAddress,
|
|
92
89
|
};
|
|
93
90
|
const nativeEvmTokenAddress = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
94
91
|
const nativeCosmosTokenAddress = "uosmo";
|
|
@@ -97,7 +94,6 @@ const nativeBitcoinTokenAddress = "satoshi";
|
|
|
97
94
|
const nativeSuiTokenAddress = "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI";
|
|
98
95
|
const nativeXrplTokenAddress = "xrp";
|
|
99
96
|
const nativeStellarTokenAddress = "CAS3J7GYLGXMF6TDJBBYYSE3HQ6BBSMLNUQ34T6TZMYMW2EVH34XOWMA";
|
|
100
|
-
const nativeCantonTokenAddress = "DSO::1220b1431ef217342db44d516bb9befde802be7d8899637d290895fa58880f19accc";
|
|
101
97
|
// by setting slippage to undefined, it's set to "auto"
|
|
102
98
|
const defaultSlippage = undefined;
|
|
103
99
|
const destinationAddressResetValue = "null";
|
|
@@ -161,7 +157,6 @@ const CHAIN_IDS = {
|
|
|
161
157
|
XRPL_TESTNET: "xrpl-testnet",
|
|
162
158
|
STELLAR: "stellar-mainnet",
|
|
163
159
|
STELLAR_TESTNET: "stellar-testnet",
|
|
164
|
-
CANTON: "canton",
|
|
165
160
|
};
|
|
166
161
|
const chainTypeToDefaultChainIdMap = {
|
|
167
162
|
[squidTypes.ChainType.EVM]: CHAIN_IDS.ETHEREUM,
|
|
@@ -171,7 +166,6 @@ const chainTypeToDefaultChainIdMap = {
|
|
|
171
166
|
[squidTypes.ChainType.SUI]: CHAIN_IDS.SUI,
|
|
172
167
|
[squidTypes.ChainType.XRPL]: CHAIN_IDS.XRPL,
|
|
173
168
|
[squidTypes.ChainType.STELLAR]: CHAIN_IDS.STELLAR,
|
|
174
|
-
[squidTypes.ChainType.CANTON]: CHAIN_IDS.CANTON,
|
|
175
169
|
};
|
|
176
170
|
const chainTypeToNativeTokenAddressMap = {
|
|
177
171
|
[squidTypes.ChainType.EVM]: nativeEvmTokenAddress,
|
|
@@ -181,12 +175,12 @@ const chainTypeToNativeTokenAddressMap = {
|
|
|
181
175
|
[squidTypes.ChainType.SUI]: nativeSuiTokenAddress,
|
|
182
176
|
[squidTypes.ChainType.XRPL]: nativeXrplTokenAddress,
|
|
183
177
|
[squidTypes.ChainType.STELLAR]: nativeStellarTokenAddress,
|
|
184
|
-
[squidTypes.ChainType.CANTON]: nativeCantonTokenAddress,
|
|
185
178
|
};
|
|
186
179
|
const defaultConfigValues = {
|
|
187
180
|
integratorId: INTEGRATOR_ID,
|
|
188
181
|
slippage: defaultSlippage,
|
|
189
182
|
apiUrl: squidApiBaseUrl,
|
|
183
|
+
xamanApiUrl: XAMAN_API_URL,
|
|
190
184
|
priceImpactWarnings: {
|
|
191
185
|
warning: 3,
|
|
192
186
|
critical: 5,
|
|
@@ -4214,11 +4208,11 @@ class WidgetEvents extends EventTarget {
|
|
|
4214
4208
|
this.dispatch("qrCodeGenerationFailedForSign", data);
|
|
4215
4209
|
}
|
|
4216
4210
|
/**
|
|
4217
|
-
* Dispatches event after
|
|
4218
|
-
*
|
|
4211
|
+
* Dispatches event after a QR code is scanned and we're waiting for the user
|
|
4212
|
+
* to approve or reject it.
|
|
4219
4213
|
*/
|
|
4220
|
-
|
|
4221
|
-
this.dispatch("
|
|
4214
|
+
dispatchQrScannedAwaitingApproval(data) {
|
|
4215
|
+
this.dispatch("qrScannedAwaitingUserApproval", data);
|
|
4222
4216
|
}
|
|
4223
4217
|
}
|
|
4224
4218
|
|
|
@@ -4716,6 +4710,193 @@ function extractRpcUrls(parameters) {
|
|
|
4716
4710
|
return transports.map(({ value }) => value?.url || fallbackUrl);
|
|
4717
4711
|
}
|
|
4718
4712
|
|
|
4713
|
+
var build = {};
|
|
4714
|
+
|
|
4715
|
+
var currency = {};
|
|
4716
|
+
|
|
4717
|
+
Object.defineProperty(currency, "__esModule", { value: true });
|
|
4718
|
+
|
|
4719
|
+
var bech32 = {};
|
|
4720
|
+
|
|
4721
|
+
Object.defineProperty(bech32, "__esModule", { value: true });
|
|
4722
|
+
|
|
4723
|
+
var bip44 = {};
|
|
4724
|
+
|
|
4725
|
+
Object.defineProperty(bip44, "__esModule", { value: true });
|
|
4726
|
+
|
|
4727
|
+
var chainInfo = {};
|
|
4728
|
+
|
|
4729
|
+
Object.defineProperty(chainInfo, "__esModule", { value: true });
|
|
4730
|
+
|
|
4731
|
+
var wallet = {};
|
|
4732
|
+
|
|
4733
|
+
var keplr = {};
|
|
4734
|
+
|
|
4735
|
+
Object.defineProperty(keplr, "__esModule", { value: true });
|
|
4736
|
+
|
|
4737
|
+
var eip6963 = {};
|
|
4738
|
+
|
|
4739
|
+
(function (exports) {
|
|
4740
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4741
|
+
exports.EIP6963EventNames = void 0;
|
|
4742
|
+
(function (EIP6963EventNames) {
|
|
4743
|
+
EIP6963EventNames["Announce"] = "eip6963:announceProvider";
|
|
4744
|
+
EIP6963EventNames["Request"] = "eip6963:requestProvider";
|
|
4745
|
+
})(exports.EIP6963EventNames || (exports.EIP6963EventNames = {}));
|
|
4746
|
+
|
|
4747
|
+
} (eip6963));
|
|
4748
|
+
|
|
4749
|
+
var ethereum$1 = {};
|
|
4750
|
+
|
|
4751
|
+
Object.defineProperty(ethereum$1, "__esModule", { value: true });
|
|
4752
|
+
|
|
4753
|
+
var starknet = {};
|
|
4754
|
+
|
|
4755
|
+
Object.defineProperty(starknet, "__esModule", { value: true });
|
|
4756
|
+
|
|
4757
|
+
var bitcoin = {};
|
|
4758
|
+
|
|
4759
|
+
(function (exports) {
|
|
4760
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4761
|
+
exports.CHAIN_TYPE_TO_GENESIS_HASH = exports.GENESIS_HASH_TO_CHAIN_TYPE = exports.NETWORK_TO_GENESIS_HASH = exports.GENESIS_HASH_TO_NETWORK = exports.ChainType = exports.Network = exports.GenesisHash = exports.BitcoinSignMessageType = void 0;
|
|
4762
|
+
(function (BitcoinSignMessageType) {
|
|
4763
|
+
BitcoinSignMessageType["ECDSA"] = "ecdsa";
|
|
4764
|
+
BitcoinSignMessageType["BIP322_SIMPLE"] = "bip322-simple";
|
|
4765
|
+
})(exports.BitcoinSignMessageType || (exports.BitcoinSignMessageType = {}));
|
|
4766
|
+
var GenesisHash;
|
|
4767
|
+
(function (GenesisHash) {
|
|
4768
|
+
GenesisHash["MAINNET"] = "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f";
|
|
4769
|
+
GenesisHash["TESTNET"] = "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943";
|
|
4770
|
+
GenesisHash["SIGNET"] = "00000008819873e925422c1ff0f99f7cc9bbb232af63a077a480a3633bee1ef6";
|
|
4771
|
+
})(GenesisHash = exports.GenesisHash || (exports.GenesisHash = {}));
|
|
4772
|
+
var Network;
|
|
4773
|
+
(function (Network) {
|
|
4774
|
+
Network["MAINNET"] = "mainnet";
|
|
4775
|
+
Network["LIVENET"] = "livenet";
|
|
4776
|
+
Network["TESTNET"] = "testnet";
|
|
4777
|
+
Network["SIGNET"] = "signet";
|
|
4778
|
+
})(Network = exports.Network || (exports.Network = {}));
|
|
4779
|
+
var ChainType;
|
|
4780
|
+
(function (ChainType) {
|
|
4781
|
+
ChainType["BITCOIN_MAINNET"] = "BITCOIN_MAINNET";
|
|
4782
|
+
ChainType["BITCOIN_TESTNET"] = "BITCOIN_TESTNET";
|
|
4783
|
+
ChainType["BITCOIN_SIGNET"] = "BITCOIN_SIGNET";
|
|
4784
|
+
})(ChainType = exports.ChainType || (exports.ChainType = {}));
|
|
4785
|
+
exports.GENESIS_HASH_TO_NETWORK = {
|
|
4786
|
+
[GenesisHash.MAINNET]: Network.MAINNET,
|
|
4787
|
+
[GenesisHash.TESTNET]: Network.TESTNET,
|
|
4788
|
+
[GenesisHash.SIGNET]: Network.SIGNET,
|
|
4789
|
+
};
|
|
4790
|
+
exports.NETWORK_TO_GENESIS_HASH = {
|
|
4791
|
+
[Network.MAINNET]: GenesisHash.MAINNET,
|
|
4792
|
+
[Network.LIVENET]: GenesisHash.MAINNET,
|
|
4793
|
+
[Network.TESTNET]: GenesisHash.TESTNET,
|
|
4794
|
+
[Network.SIGNET]: GenesisHash.SIGNET,
|
|
4795
|
+
};
|
|
4796
|
+
exports.GENESIS_HASH_TO_CHAIN_TYPE = {
|
|
4797
|
+
[GenesisHash.MAINNET]: ChainType.BITCOIN_MAINNET,
|
|
4798
|
+
[GenesisHash.TESTNET]: ChainType.BITCOIN_TESTNET,
|
|
4799
|
+
[GenesisHash.SIGNET]: ChainType.BITCOIN_SIGNET,
|
|
4800
|
+
};
|
|
4801
|
+
exports.CHAIN_TYPE_TO_GENESIS_HASH = {
|
|
4802
|
+
[ChainType.BITCOIN_MAINNET]: GenesisHash.MAINNET,
|
|
4803
|
+
[ChainType.BITCOIN_TESTNET]: GenesisHash.TESTNET,
|
|
4804
|
+
[ChainType.BITCOIN_SIGNET]: GenesisHash.SIGNET,
|
|
4805
|
+
};
|
|
4806
|
+
|
|
4807
|
+
} (bitcoin));
|
|
4808
|
+
|
|
4809
|
+
(function (exports) {
|
|
4810
|
+
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4811
|
+
if (k2 === undefined) k2 = k;
|
|
4812
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4813
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
4814
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
4815
|
+
}
|
|
4816
|
+
Object.defineProperty(o, k2, desc);
|
|
4817
|
+
}) : (function(o, m, k, k2) {
|
|
4818
|
+
if (k2 === undefined) k2 = k;
|
|
4819
|
+
o[k2] = m[k];
|
|
4820
|
+
}));
|
|
4821
|
+
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
4822
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
4823
|
+
};
|
|
4824
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4825
|
+
__exportStar(keplr, exports);
|
|
4826
|
+
__exportStar(eip6963, exports);
|
|
4827
|
+
__exportStar(ethereum$1, exports);
|
|
4828
|
+
__exportStar(starknet, exports);
|
|
4829
|
+
__exportStar(bitcoin, exports);
|
|
4830
|
+
|
|
4831
|
+
} (wallet));
|
|
4832
|
+
|
|
4833
|
+
var window$1 = {};
|
|
4834
|
+
|
|
4835
|
+
Object.defineProperty(window$1, "__esModule", { value: true });
|
|
4836
|
+
|
|
4837
|
+
var ethereum = {};
|
|
4838
|
+
|
|
4839
|
+
(function (exports) {
|
|
4840
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4841
|
+
exports.EthTxStatus = exports.EthSignType = void 0;
|
|
4842
|
+
(function (EthSignType) {
|
|
4843
|
+
EthSignType["MESSAGE"] = "message";
|
|
4844
|
+
EthSignType["TRANSACTION"] = "transaction";
|
|
4845
|
+
EthSignType["EIP712"] = "eip-712";
|
|
4846
|
+
})(exports.EthSignType || (exports.EthSignType = {}));
|
|
4847
|
+
(function (EthTxStatus) {
|
|
4848
|
+
EthTxStatus["Success"] = "0x1";
|
|
4849
|
+
EthTxStatus["Failure"] = "0x0";
|
|
4850
|
+
})(exports.EthTxStatus || (exports.EthTxStatus = {}));
|
|
4851
|
+
|
|
4852
|
+
} (ethereum));
|
|
4853
|
+
|
|
4854
|
+
var cosmjs = {};
|
|
4855
|
+
|
|
4856
|
+
Object.defineProperty(cosmjs, "__esModule", { value: true });
|
|
4857
|
+
|
|
4858
|
+
var cosmjsAlt = {};
|
|
4859
|
+
|
|
4860
|
+
Object.defineProperty(cosmjsAlt, "__esModule", { value: true });
|
|
4861
|
+
|
|
4862
|
+
var secretjs = {};
|
|
4863
|
+
|
|
4864
|
+
Object.defineProperty(secretjs, "__esModule", { value: true });
|
|
4865
|
+
|
|
4866
|
+
var settled = {};
|
|
4867
|
+
|
|
4868
|
+
Object.defineProperty(settled, "__esModule", { value: true });
|
|
4869
|
+
|
|
4870
|
+
(function (exports) {
|
|
4871
|
+
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
4872
|
+
if (k2 === undefined) k2 = k;
|
|
4873
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
4874
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
4875
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
4876
|
+
}
|
|
4877
|
+
Object.defineProperty(o, k2, desc);
|
|
4878
|
+
}) : (function(o, m, k, k2) {
|
|
4879
|
+
if (k2 === undefined) k2 = k;
|
|
4880
|
+
o[k2] = m[k];
|
|
4881
|
+
}));
|
|
4882
|
+
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
4883
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
4884
|
+
};
|
|
4885
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4886
|
+
__exportStar(currency, exports);
|
|
4887
|
+
__exportStar(bech32, exports);
|
|
4888
|
+
__exportStar(bip44, exports);
|
|
4889
|
+
__exportStar(chainInfo, exports);
|
|
4890
|
+
__exportStar(wallet, exports);
|
|
4891
|
+
__exportStar(window$1, exports);
|
|
4892
|
+
__exportStar(ethereum, exports);
|
|
4893
|
+
__exportStar(cosmjs, exports);
|
|
4894
|
+
__exportStar(cosmjsAlt, exports);
|
|
4895
|
+
__exportStar(secretjs, exports);
|
|
4896
|
+
__exportStar(settled, exports);
|
|
4897
|
+
|
|
4898
|
+
} (build));
|
|
4899
|
+
|
|
4719
4900
|
class BitcoinConnectorError extends Error {
|
|
4720
4901
|
constructor(message) {
|
|
4721
4902
|
super(message);
|
|
@@ -4763,6 +4944,9 @@ class KeplrConnector {
|
|
|
4763
4944
|
address: account,
|
|
4764
4945
|
};
|
|
4765
4946
|
}
|
|
4947
|
+
async signMessage(message) {
|
|
4948
|
+
return this.getProvider.signMessage(message, build.BitcoinSignMessageType.BIP322_SIMPLE);
|
|
4949
|
+
}
|
|
4766
4950
|
}
|
|
4767
4951
|
|
|
4768
4952
|
bitcoin__namespace.initEccLib(ecc__namespace);
|
|
@@ -4906,6 +5090,7 @@ class PhantomConnector {
|
|
|
4906
5090
|
}
|
|
4907
5091
|
}
|
|
4908
5092
|
|
|
5093
|
+
const UNISAT_BIP322_SIMPLE_SIGNATURE_TYPE = "bip322-simple";
|
|
4909
5094
|
class UnisatConnector {
|
|
4910
5095
|
get getProvider() {
|
|
4911
5096
|
const provider = window?.unisat;
|
|
@@ -4931,8 +5116,220 @@ class UnisatConnector {
|
|
|
4931
5116
|
address: account,
|
|
4932
5117
|
};
|
|
4933
5118
|
}
|
|
5119
|
+
async signMessage(message) {
|
|
5120
|
+
const signMessage = this.getProvider.signMessage;
|
|
5121
|
+
if (typeof signMessage !== "function") {
|
|
5122
|
+
throw new Error("Unisat does not expose Bitcoin message signing.");
|
|
5123
|
+
}
|
|
5124
|
+
return signMessage(message, UNISAT_BIP322_SIMPLE_SIGNATURE_TYPE);
|
|
5125
|
+
}
|
|
4934
5126
|
}
|
|
4935
5127
|
|
|
5128
|
+
function encodeUtf8(value) {
|
|
5129
|
+
return new TextEncoder().encode(value);
|
|
5130
|
+
}
|
|
5131
|
+
function bytesToBase64(bytes) {
|
|
5132
|
+
if (typeof Buffer !== "undefined") {
|
|
5133
|
+
return Buffer.from(Uint8Array.from(bytes)).toString("base64");
|
|
5134
|
+
}
|
|
5135
|
+
let binary = "";
|
|
5136
|
+
for (let index = 0; index < bytes.length; index += 1) {
|
|
5137
|
+
binary += String.fromCharCode(bytes[index]);
|
|
5138
|
+
}
|
|
5139
|
+
return btoa(binary);
|
|
5140
|
+
}
|
|
5141
|
+
function isBase64(value) {
|
|
5142
|
+
const trimmedValue = value.trim();
|
|
5143
|
+
if (!trimmedValue) {
|
|
5144
|
+
return false;
|
|
5145
|
+
}
|
|
5146
|
+
try {
|
|
5147
|
+
if (typeof Buffer !== "undefined") {
|
|
5148
|
+
return (Buffer.from(trimmedValue, "base64")
|
|
5149
|
+
.toString("base64")
|
|
5150
|
+
.replace(/=+$/, "") === trimmedValue.replace(/=+$/, ""));
|
|
5151
|
+
}
|
|
5152
|
+
return (btoa(atob(trimmedValue)).replace(/=+$/, "") ===
|
|
5153
|
+
trimmedValue.replace(/=+$/, ""));
|
|
5154
|
+
}
|
|
5155
|
+
catch {
|
|
5156
|
+
return false;
|
|
5157
|
+
}
|
|
5158
|
+
}
|
|
5159
|
+
function base64StringOrBytes(value) {
|
|
5160
|
+
if (typeof value === "string") {
|
|
5161
|
+
return isBase64(value) ? value : bytesToBase64(encodeUtf8(value));
|
|
5162
|
+
}
|
|
5163
|
+
return bytesToBase64(value);
|
|
5164
|
+
}
|
|
5165
|
+
function normalizeBase64Ed25519Signature(signature) {
|
|
5166
|
+
if (!isBase64(signature) || typeof Buffer === "undefined") {
|
|
5167
|
+
return signature;
|
|
5168
|
+
}
|
|
5169
|
+
const decoded = Buffer.from(signature, "base64");
|
|
5170
|
+
if (decoded.length === 64) {
|
|
5171
|
+
return signature;
|
|
5172
|
+
}
|
|
5173
|
+
const nestedSignature = decoded.toString("utf8");
|
|
5174
|
+
return isBase64(nestedSignature) &&
|
|
5175
|
+
Buffer.from(nestedSignature, "base64").length === 64
|
|
5176
|
+
? nestedSignature
|
|
5177
|
+
: signature;
|
|
5178
|
+
}
|
|
5179
|
+
function stringToUtf8Hex(value, { uppercase = false } = {}) {
|
|
5180
|
+
const hex = Array.from(encodeUtf8(value), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
5181
|
+
return uppercase ? hex.toUpperCase() : hex;
|
|
5182
|
+
}
|
|
5183
|
+
|
|
5184
|
+
exports.WalletVerificationSignatureType = void 0;
|
|
5185
|
+
(function (WalletVerificationSignatureType) {
|
|
5186
|
+
WalletVerificationSignatureType["EVM"] = "eip191";
|
|
5187
|
+
WalletVerificationSignatureType["COSMOS"] = "cosmos-adr36";
|
|
5188
|
+
WalletVerificationSignatureType["BITCOIN"] = "bitcoin-bip322-simple";
|
|
5189
|
+
WalletVerificationSignatureType["SOLANA"] = "solana-ed25519";
|
|
5190
|
+
WalletVerificationSignatureType["SUI"] = "sui-personal-message";
|
|
5191
|
+
WalletVerificationSignatureType["XRPL"] = "xrpl-signin";
|
|
5192
|
+
WalletVerificationSignatureType["XAMAN"] = "xaman-signin";
|
|
5193
|
+
WalletVerificationSignatureType["STELLAR"] = "stellar-sep53";
|
|
5194
|
+
})(exports.WalletVerificationSignatureType || (exports.WalletVerificationSignatureType = {}));
|
|
5195
|
+
const WALLET_VERIFICATION_SIGNATURE_TYPE_BY_CHAIN_TYPE = {
|
|
5196
|
+
[squidTypes.ChainType.EVM]: exports.WalletVerificationSignatureType.EVM,
|
|
5197
|
+
[squidTypes.ChainType.COSMOS]: exports.WalletVerificationSignatureType.COSMOS,
|
|
5198
|
+
[squidTypes.ChainType.BTC]: exports.WalletVerificationSignatureType.BITCOIN,
|
|
5199
|
+
[squidTypes.ChainType.SOLANA]: exports.WalletVerificationSignatureType.SOLANA,
|
|
5200
|
+
[squidTypes.ChainType.SUI]: exports.WalletVerificationSignatureType.SUI,
|
|
5201
|
+
[squidTypes.ChainType.XRPL]: exports.WalletVerificationSignatureType.XRPL,
|
|
5202
|
+
[squidTypes.ChainType.STELLAR]: exports.WalletVerificationSignatureType.STELLAR,
|
|
5203
|
+
};
|
|
5204
|
+
|
|
5205
|
+
function buildSignatureOnlyWalletVerificationSignatureResult({ chainType, signatureType, address, message, signature, }) {
|
|
5206
|
+
return {
|
|
5207
|
+
chainType,
|
|
5208
|
+
address,
|
|
5209
|
+
message,
|
|
5210
|
+
signedPayload: message,
|
|
5211
|
+
signature,
|
|
5212
|
+
signatureType,
|
|
5213
|
+
metadata: {},
|
|
5214
|
+
};
|
|
5215
|
+
}
|
|
5216
|
+
function buildSignedPayloadWalletVerificationSignatureResult({ chainType, signatureType, address, message, signedPayload, signature, publicKey, publicKeyEncoding, signedPayloadEncoding, signerAddress, }) {
|
|
5217
|
+
return {
|
|
5218
|
+
chainType,
|
|
5219
|
+
address,
|
|
5220
|
+
message,
|
|
5221
|
+
signedPayload,
|
|
5222
|
+
signature,
|
|
5223
|
+
signatureType,
|
|
5224
|
+
metadata: {
|
|
5225
|
+
signedPayloadEncoding,
|
|
5226
|
+
...(publicKey ? { publicKey } : {}),
|
|
5227
|
+
...(publicKeyEncoding ? { publicKeyEncoding } : {}),
|
|
5228
|
+
...(signerAddress ? { signerAddress } : {}),
|
|
5229
|
+
},
|
|
5230
|
+
};
|
|
5231
|
+
}
|
|
5232
|
+
|
|
5233
|
+
const buildBitcoinWalletVerificationSignatureResult = (params) => buildSignedPayloadWalletVerificationSignatureResult({
|
|
5234
|
+
...params,
|
|
5235
|
+
chainType: squidTypes.ChainType.BTC,
|
|
5236
|
+
signatureType: exports.WalletVerificationSignatureType.BITCOIN,
|
|
5237
|
+
});
|
|
5238
|
+
|
|
5239
|
+
const buildCosmosWalletVerificationSignatureResult = (params) => buildSignedPayloadWalletVerificationSignatureResult({
|
|
5240
|
+
...params,
|
|
5241
|
+
chainType: squidTypes.ChainType.COSMOS,
|
|
5242
|
+
signatureType: exports.WalletVerificationSignatureType.COSMOS,
|
|
5243
|
+
});
|
|
5244
|
+
|
|
5245
|
+
const buildWalletVerificationSignatureResult = ({ address, message, signature, }) => buildSignatureOnlyWalletVerificationSignatureResult({
|
|
5246
|
+
chainType: squidTypes.ChainType.EVM,
|
|
5247
|
+
signatureType: exports.WalletVerificationSignatureType.EVM,
|
|
5248
|
+
address,
|
|
5249
|
+
message,
|
|
5250
|
+
signature,
|
|
5251
|
+
});
|
|
5252
|
+
|
|
5253
|
+
exports.WalletVerificationSignatureErrorCode = void 0;
|
|
5254
|
+
(function (WalletVerificationSignatureErrorCode) {
|
|
5255
|
+
WalletVerificationSignatureErrorCode["INVALID_MESSAGE"] = "INVALID_MESSAGE";
|
|
5256
|
+
WalletVerificationSignatureErrorCode["UNSUPPORTED_CHAIN_TYPE"] = "UNSUPPORTED_CHAIN_TYPE";
|
|
5257
|
+
WalletVerificationSignatureErrorCode["WALLET_NOT_CONNECTED"] = "WALLET_NOT_CONNECTED";
|
|
5258
|
+
WalletVerificationSignatureErrorCode["SIGNER_UNAVAILABLE"] = "SIGNER_UNAVAILABLE";
|
|
5259
|
+
WalletVerificationSignatureErrorCode["ACTIVE_ACCOUNT_MISMATCH"] = "ACTIVE_ACCOUNT_MISMATCH";
|
|
5260
|
+
WalletVerificationSignatureErrorCode["SIGNATURE_REJECTED"] = "SIGNATURE_REJECTED";
|
|
5261
|
+
})(exports.WalletVerificationSignatureErrorCode || (exports.WalletVerificationSignatureErrorCode = {}));
|
|
5262
|
+
class WalletVerificationSignatureError extends Error {
|
|
5263
|
+
code;
|
|
5264
|
+
chainType;
|
|
5265
|
+
cause;
|
|
5266
|
+
constructor({ code, message, chainType, cause, }) {
|
|
5267
|
+
super(message);
|
|
5268
|
+
this.name = "WalletVerificationSignatureError";
|
|
5269
|
+
this.code = code;
|
|
5270
|
+
this.chainType = chainType;
|
|
5271
|
+
this.cause = cause;
|
|
5272
|
+
}
|
|
5273
|
+
}
|
|
5274
|
+
|
|
5275
|
+
const assertWalletVerificationSigningRequest = ({ message, chainType, }) => {
|
|
5276
|
+
if (message.trim().length === 0) {
|
|
5277
|
+
throw new WalletVerificationSignatureError({
|
|
5278
|
+
code: exports.WalletVerificationSignatureErrorCode.INVALID_MESSAGE,
|
|
5279
|
+
chainType,
|
|
5280
|
+
message: "Invalid wallet verification message.",
|
|
5281
|
+
});
|
|
5282
|
+
}
|
|
5283
|
+
};
|
|
5284
|
+
const assertEvmVerificationSigningRequest = ({ message, chainType, }) => {
|
|
5285
|
+
if (chainType !== squidTypes.ChainType.EVM) {
|
|
5286
|
+
throw new WalletVerificationSignatureError({
|
|
5287
|
+
code: exports.WalletVerificationSignatureErrorCode.UNSUPPORTED_CHAIN_TYPE,
|
|
5288
|
+
chainType,
|
|
5289
|
+
message: "Unsupported EVM wallet verification chain type.",
|
|
5290
|
+
});
|
|
5291
|
+
}
|
|
5292
|
+
assertWalletVerificationSigningRequest({ message, chainType });
|
|
5293
|
+
};
|
|
5294
|
+
|
|
5295
|
+
const buildSolanaWalletVerificationSignatureResult = ({ address, message, signedPayload, signature, publicKey, publicKeyEncoding, signedPayloadEncoding, }) => buildSignedPayloadWalletVerificationSignatureResult({
|
|
5296
|
+
chainType: squidTypes.ChainType.SOLANA,
|
|
5297
|
+
signatureType: exports.WalletVerificationSignatureType.SOLANA,
|
|
5298
|
+
address,
|
|
5299
|
+
message,
|
|
5300
|
+
signedPayload,
|
|
5301
|
+
signature,
|
|
5302
|
+
publicKey,
|
|
5303
|
+
publicKeyEncoding,
|
|
5304
|
+
signedPayloadEncoding,
|
|
5305
|
+
});
|
|
5306
|
+
|
|
5307
|
+
const buildStellarWalletVerificationSignatureResult = (params) => buildSignedPayloadWalletVerificationSignatureResult({
|
|
5308
|
+
...params,
|
|
5309
|
+
chainType: squidTypes.ChainType.STELLAR,
|
|
5310
|
+
signatureType: exports.WalletVerificationSignatureType.STELLAR,
|
|
5311
|
+
});
|
|
5312
|
+
|
|
5313
|
+
const buildSuiWalletVerificationSignatureResult = ({ address, message, signedPayload, signature, publicKey, publicKeyEncoding, signedPayloadEncoding, }) => buildSignedPayloadWalletVerificationSignatureResult({
|
|
5314
|
+
chainType: squidTypes.ChainType.SUI,
|
|
5315
|
+
signatureType: exports.WalletVerificationSignatureType.SUI,
|
|
5316
|
+
address,
|
|
5317
|
+
message,
|
|
5318
|
+
signedPayload,
|
|
5319
|
+
signature,
|
|
5320
|
+
publicKey,
|
|
5321
|
+
publicKeyEncoding,
|
|
5322
|
+
signedPayloadEncoding,
|
|
5323
|
+
});
|
|
5324
|
+
|
|
5325
|
+
const buildXrplWalletVerificationSignatureResult = (params) => {
|
|
5326
|
+
return buildSignedPayloadWalletVerificationSignatureResult({
|
|
5327
|
+
...params,
|
|
5328
|
+
chainType: squidTypes.ChainType.XRPL,
|
|
5329
|
+
signatureType: params.signatureType,
|
|
5330
|
+
});
|
|
5331
|
+
};
|
|
5332
|
+
|
|
4936
5333
|
var XrplTransactionType;
|
|
4937
5334
|
(function (XrplTransactionType) {
|
|
4938
5335
|
XrplTransactionType["PAYMENT"] = "Payment";
|
|
@@ -4979,6 +5376,14 @@ var XRPL_METHOD;
|
|
|
4979
5376
|
XRPL_METHOD["SIGN_TRANSACTION"] = "xrpl_signTransaction";
|
|
4980
5377
|
})(XRPL_METHOD || (XRPL_METHOD = {}));
|
|
4981
5378
|
|
|
5379
|
+
function createXrplActiveAccountMismatchError(walletName) {
|
|
5380
|
+
return new WalletVerificationSignatureError({
|
|
5381
|
+
code: exports.WalletVerificationSignatureErrorCode.ACTIVE_ACCOUNT_MISMATCH,
|
|
5382
|
+
chainType: squidTypes.ChainType.XRPL,
|
|
5383
|
+
message: `${walletName} signed with a different active account. Reconnect the XRPL wallet and try again.`,
|
|
5384
|
+
});
|
|
5385
|
+
}
|
|
5386
|
+
|
|
4982
5387
|
var NetworkLabel;
|
|
4983
5388
|
(function (NetworkLabel) {
|
|
4984
5389
|
NetworkLabel["XAHAU"] = "xahau";
|
|
@@ -5031,6 +5436,38 @@ class CrossmarkConnector {
|
|
|
5031
5436
|
status: data.resp.result.meta.TransactionResult,
|
|
5032
5437
|
};
|
|
5033
5438
|
}
|
|
5439
|
+
async signOwnershipMessage({ address, message, }) {
|
|
5440
|
+
const provider = this.getProvider();
|
|
5441
|
+
if (!provider) {
|
|
5442
|
+
throw new Error("Crossmark provider not found");
|
|
5443
|
+
}
|
|
5444
|
+
const signedPayload = stringToUtf8Hex(message);
|
|
5445
|
+
const result = await provider.async.signInAndWait(signedPayload);
|
|
5446
|
+
const proof = result?.response.data;
|
|
5447
|
+
if (!proof) {
|
|
5448
|
+
throw new Error("Invalid Crossmark sign-in response");
|
|
5449
|
+
}
|
|
5450
|
+
if (proof.meta?.isRejected) {
|
|
5451
|
+
throw new Error("User rejected the request.");
|
|
5452
|
+
}
|
|
5453
|
+
if (proof.meta?.isError) {
|
|
5454
|
+
throw new Error(proof.errorMessage || "Error signing message");
|
|
5455
|
+
}
|
|
5456
|
+
if (proof.address.trim() !== address) {
|
|
5457
|
+
throw createXrplActiveAccountMismatchError("Crossmark");
|
|
5458
|
+
}
|
|
5459
|
+
if (!proof.publicKey || !proof.signature) {
|
|
5460
|
+
throw new Error("Invalid Crossmark sign-in response");
|
|
5461
|
+
}
|
|
5462
|
+
return {
|
|
5463
|
+
signedPayload,
|
|
5464
|
+
signedPayloadEncoding: "utf8-hex",
|
|
5465
|
+
signature: proof.signature,
|
|
5466
|
+
publicKey: proof.publicKey,
|
|
5467
|
+
publicKeyEncoding: "hex",
|
|
5468
|
+
signatureType: exports.WalletVerificationSignatureType.XRPL,
|
|
5469
|
+
};
|
|
5470
|
+
}
|
|
5034
5471
|
getActiveNetwork() {
|
|
5035
5472
|
const provider = this.getProvider();
|
|
5036
5473
|
if (!provider) {
|
|
@@ -20409,6 +20846,34 @@ class XrplMetamaskSnapConnector {
|
|
|
20409
20846
|
status: txStatus,
|
|
20410
20847
|
};
|
|
20411
20848
|
}
|
|
20849
|
+
async signOwnershipMessage({ address, message, }) {
|
|
20850
|
+
await this.initialize();
|
|
20851
|
+
if (!this.provider)
|
|
20852
|
+
throw new Error("Provider not initialized");
|
|
20853
|
+
await this.requestSnap(snapId);
|
|
20854
|
+
const account = await this.getAccount();
|
|
20855
|
+
if (account.account !== address) {
|
|
20856
|
+
throw createXrplActiveAccountMismatchError("XRPL Snap");
|
|
20857
|
+
}
|
|
20858
|
+
const signedPayload = stringToUtf8Hex(message);
|
|
20859
|
+
const response = await this.invokeSnap({
|
|
20860
|
+
method: "xrpl_signMessage",
|
|
20861
|
+
params: {
|
|
20862
|
+
message: signedPayload,
|
|
20863
|
+
},
|
|
20864
|
+
});
|
|
20865
|
+
if (!account.publicKey || !response.signature) {
|
|
20866
|
+
throw new Error("Invalid XRPL Snap sign-message response");
|
|
20867
|
+
}
|
|
20868
|
+
return {
|
|
20869
|
+
signedPayload,
|
|
20870
|
+
signedPayloadEncoding: "utf8-hex",
|
|
20871
|
+
signature: response.signature,
|
|
20872
|
+
publicKey: account.publicKey,
|
|
20873
|
+
publicKeyEncoding: "hex",
|
|
20874
|
+
signatureType: exports.WalletVerificationSignatureType.XRPL,
|
|
20875
|
+
};
|
|
20876
|
+
}
|
|
20412
20877
|
// Cannot use constructor because of the async initialization
|
|
20413
20878
|
async initialize() {
|
|
20414
20879
|
this.provider = await this.getProvider();
|
|
@@ -20866,11 +21331,11 @@ const isBitcoinAddressValid = (address) => {
|
|
|
20866
21331
|
if (address.startsWith("bc1p")) {
|
|
20867
21332
|
// this is a bitcoin taproot address type, it has different encoding than other 3 address types
|
|
20868
21333
|
// and requires different validation logic
|
|
20869
|
-
const decoded = bitcoin.address.fromBech32(address);
|
|
21334
|
+
const decoded = bitcoin$1.address.fromBech32(address);
|
|
20870
21335
|
return decoded.prefix === "bc" && decoded.version === 1;
|
|
20871
21336
|
}
|
|
20872
21337
|
else {
|
|
20873
|
-
bitcoin.address.toOutputScript(address);
|
|
21338
|
+
bitcoin$1.address.toOutputScript(address);
|
|
20874
21339
|
return true;
|
|
20875
21340
|
}
|
|
20876
21341
|
}
|
|
@@ -20879,18 +21344,6 @@ const isBitcoinAddressValid = (address) => {
|
|
|
20879
21344
|
}
|
|
20880
21345
|
};
|
|
20881
21346
|
|
|
20882
|
-
// Canton PartyID = address
|
|
20883
|
-
const CANTON_PARTY_ID_SEPARATOR = "::";
|
|
20884
|
-
function isCantonAddressValid(address) {
|
|
20885
|
-
// Canton address format: `name::fingerprint`, where name is an arbitrary string
|
|
20886
|
-
// and fingerprint is a 64-character hex string with a 1220 prefix (SHA-256 hash of the public key)
|
|
20887
|
-
const parts = address.split(CANTON_PARTY_ID_SEPARATOR);
|
|
20888
|
-
if (parts.length !== 2)
|
|
20889
|
-
return false;
|
|
20890
|
-
const [name, fingerprint] = parts;
|
|
20891
|
-
return name.length > 0 && /^1220[0-9a-f]{64}$/.test(fingerprint);
|
|
20892
|
-
}
|
|
20893
|
-
|
|
20894
21347
|
exports.HistoryTxType = void 0;
|
|
20895
21348
|
(function (HistoryTxType) {
|
|
20896
21349
|
HistoryTxType[HistoryTxType["SWAP"] = 0] = "SWAP";
|
|
@@ -21004,7 +21457,6 @@ const getSourceExplorerTxUrl = (chain, txID) => {
|
|
|
21004
21457
|
case CHAIN_IDS.AGORIC:
|
|
21005
21458
|
case CHAIN_IDS.XRPL:
|
|
21006
21459
|
case CHAIN_IDS.XRPL_TESTNET:
|
|
21007
|
-
case CHAIN_IDS.CANTON:
|
|
21008
21460
|
txSuffix = "/transactions/";
|
|
21009
21461
|
break;
|
|
21010
21462
|
case CHAIN_IDS.HEDERA:
|
|
@@ -21114,16 +21566,10 @@ const simplifyRouteAction = (action) => {
|
|
|
21114
21566
|
};
|
|
21115
21567
|
const fetchSwapTransactionStatus = async ({ transaction, integratorId, apiUrl, }) => {
|
|
21116
21568
|
const statusEndpoint = `${apiUrl}/v2/status`;
|
|
21117
|
-
const isCanton = transaction?.fromChain === CHAIN_IDS.CANTON;
|
|
21118
|
-
// For Canton, the backend handles all tx detection/submission from the quoteId
|
|
21119
|
-
// alone, so no transactionId is sent — only the quoteId param below.
|
|
21120
|
-
const transactionId = isCanton
|
|
21121
|
-
? undefined
|
|
21122
|
-
: transaction?.transactionIdForStatus ?? transaction?.transactionId;
|
|
21123
21569
|
try {
|
|
21124
21570
|
const response = await axios.get(statusEndpoint, {
|
|
21125
21571
|
params: {
|
|
21126
|
-
transactionId,
|
|
21572
|
+
transactionId: transaction?.transactionIdForStatus ?? transaction?.transactionId,
|
|
21127
21573
|
fromChainId: transaction?.fromChain,
|
|
21128
21574
|
toChainId: transaction?.toChain,
|
|
21129
21575
|
bridgeType: transaction?.bridgeType,
|
|
@@ -21170,7 +21616,7 @@ function isActionCompletedOnSourceTx(action, fromChainId) {
|
|
|
21170
21616
|
function sleep(ms) {
|
|
21171
21617
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
21172
21618
|
}
|
|
21173
|
-
const
|
|
21619
|
+
const isDepositRoute = (route) => {
|
|
21174
21620
|
return (!!route &&
|
|
21175
21621
|
route.transactionRequest?.type === squidTypes.SquidDataType.ChainflipDepositAddress);
|
|
21176
21622
|
};
|
|
@@ -21195,12 +21641,6 @@ function isOnChainTxData(squidData) {
|
|
|
21195
21641
|
squidTypes.SquidDataType.DepositAddressWithMemo,
|
|
21196
21642
|
].includes(squidData.type);
|
|
21197
21643
|
}
|
|
21198
|
-
/**
|
|
21199
|
-
* Checks if a route is of type DepositAddressDirectTransfer
|
|
21200
|
-
*/
|
|
21201
|
-
function isDepositAddressDirectTransferRoute(squidData) {
|
|
21202
|
-
return (squidData.type === squidTypes.SquidDataType.DepositAddressDirectTransfer);
|
|
21203
|
-
}
|
|
21204
21644
|
function getHistoryTransactionId(tx) {
|
|
21205
21645
|
switch (tx.txType) {
|
|
21206
21646
|
case exports.HistoryTxType.SWAP:
|
|
@@ -21339,6 +21779,93 @@ const standardWalletOverrides = {
|
|
|
21339
21779
|
}),
|
|
21340
21780
|
};
|
|
21341
21781
|
|
|
21782
|
+
const EvmNetworkNotSupportedErrorCode = 4902;
|
|
21783
|
+
async function addEthereumChain({ chain, provider, }) {
|
|
21784
|
+
const chainName = chain.rpc.includes("tenderly")
|
|
21785
|
+
? `${chain.networkName} Tenderly fork`
|
|
21786
|
+
: chain.networkName;
|
|
21787
|
+
const chainParameters = {
|
|
21788
|
+
chainId: `0x${parseInt(chain.chainId, 10).toString(16)}`,
|
|
21789
|
+
chainName,
|
|
21790
|
+
nativeCurrency: chain.nativeCurrency,
|
|
21791
|
+
rpcUrls: [chain.rpc],
|
|
21792
|
+
blockExplorerUrls: chain.blockExplorerUrls,
|
|
21793
|
+
iconUrls: [chain.chainIconURI],
|
|
21794
|
+
};
|
|
21795
|
+
try {
|
|
21796
|
+
return provider.request({
|
|
21797
|
+
method: "wallet_addEthereumChain",
|
|
21798
|
+
params: [chainParameters],
|
|
21799
|
+
});
|
|
21800
|
+
}
|
|
21801
|
+
catch (error) {
|
|
21802
|
+
console.debug("Error adding chain:", error);
|
|
21803
|
+
}
|
|
21804
|
+
}
|
|
21805
|
+
const parseEvmAddress = (address) => {
|
|
21806
|
+
if (address && isEvmAddressValid(address)) {
|
|
21807
|
+
return address;
|
|
21808
|
+
}
|
|
21809
|
+
};
|
|
21810
|
+
function isEvmAddressValid(address) {
|
|
21811
|
+
return viem.isAddress(address);
|
|
21812
|
+
}
|
|
21813
|
+
/**
|
|
21814
|
+
* Formats a Wagmi connector into a Squid Wallet
|
|
21815
|
+
*/
|
|
21816
|
+
function formatEvmWallet(connector) {
|
|
21817
|
+
const { icon, name: defaultName, id: wagmiConnectorId } = connector;
|
|
21818
|
+
const walletOverrides = standardWalletOverrides[wagmiConnectorId];
|
|
21819
|
+
const walletIcon = walletOverrides?.icon || icon;
|
|
21820
|
+
const name = walletOverrides?.name || defaultName;
|
|
21821
|
+
const connectorId = walletOverrides?.connectorId || wagmiConnectorId;
|
|
21822
|
+
const isNonInstallableWallet = [
|
|
21823
|
+
"injected",
|
|
21824
|
+
"walletConnect",
|
|
21825
|
+
"metaMaskSDK",
|
|
21826
|
+
"coinbaseWalletSDK",
|
|
21827
|
+
].includes(wagmiConnectorId);
|
|
21828
|
+
return {
|
|
21829
|
+
connectorId,
|
|
21830
|
+
name,
|
|
21831
|
+
connectorName: name,
|
|
21832
|
+
type: squidTypes.ChainType.EVM,
|
|
21833
|
+
icon: walletIcon,
|
|
21834
|
+
rdns: wagmiConnectorId,
|
|
21835
|
+
windowFlag: name,
|
|
21836
|
+
// For non-installable wallets, we don't want to show the "Installed" label
|
|
21837
|
+
// but still want to allow the user to connect
|
|
21838
|
+
skipInstallCheck: isNonInstallableWallet,
|
|
21839
|
+
isInstalled: isNonInstallableWallet ? undefined : () => true,
|
|
21840
|
+
connector,
|
|
21841
|
+
isMobile: true,
|
|
21842
|
+
};
|
|
21843
|
+
}
|
|
21844
|
+
function filterWagmiConnector(connector) {
|
|
21845
|
+
// Safe is auto-connected when available, should not be listed as an available wallet
|
|
21846
|
+
return connector.id !== "safe";
|
|
21847
|
+
}
|
|
21848
|
+
/**
|
|
21849
|
+
* Waits for a transaction receipt, handling retries if indexing is in progress
|
|
21850
|
+
*/
|
|
21851
|
+
async function waitForReceiptWithRetry(txResponse, retries = 5, delayMs = 2000) {
|
|
21852
|
+
let lastError;
|
|
21853
|
+
for (let i = 0; i < retries; i++) {
|
|
21854
|
+
try {
|
|
21855
|
+
return await txResponse.wait();
|
|
21856
|
+
}
|
|
21857
|
+
catch (error) {
|
|
21858
|
+
lastError = error;
|
|
21859
|
+
if (error?.message?.match(/transaction indexing is in progress/i)) {
|
|
21860
|
+
await sleep(delayMs);
|
|
21861
|
+
continue;
|
|
21862
|
+
}
|
|
21863
|
+
throw error;
|
|
21864
|
+
}
|
|
21865
|
+
}
|
|
21866
|
+
throw lastError;
|
|
21867
|
+
}
|
|
21868
|
+
|
|
21342
21869
|
const SOLANA_FEATURES = ["solana:signTransaction"];
|
|
21343
21870
|
/**
|
|
21344
21871
|
* Validates that a given standard wallet has all the required features for a Solana wallet
|
|
@@ -21640,6 +22167,7 @@ function formatSuiWallet(wallet) {
|
|
|
21640
22167
|
skipInstallCheck: isSlushWebWallet,
|
|
21641
22168
|
connector: {
|
|
21642
22169
|
signTransaction: features["sui:signTransaction"].signTransaction,
|
|
22170
|
+
signPersonalMessage: features["sui:signPersonalMessage"]?.signPersonalMessage,
|
|
21643
22171
|
connect: async (params) => {
|
|
21644
22172
|
const { accounts } = await features["standard:connect"].connect(params);
|
|
21645
22173
|
if (!accounts.length) {
|
|
@@ -21703,17 +22231,7 @@ const chainTypeToTrimLength = {
|
|
|
21703
22231
|
start: 4,
|
|
21704
22232
|
end: 4,
|
|
21705
22233
|
},
|
|
21706
|
-
// abc...123::abc...123
|
|
21707
|
-
[squidTypes.ChainType.CANTON]: {
|
|
21708
|
-
start: 3,
|
|
21709
|
-
end: 3,
|
|
21710
|
-
},
|
|
21711
22234
|
};
|
|
21712
|
-
const truncateWithEllipsis = (value, startLength, endLength) => value.length <= startLength + endLength
|
|
21713
|
-
? value
|
|
21714
|
-
: value.slice(0, startLength) +
|
|
21715
|
-
"..." +
|
|
21716
|
-
value.slice(value.length - endLength);
|
|
21717
22235
|
const formatHash = ({ chainType, hash }) => {
|
|
21718
22236
|
if (!hash)
|
|
21719
22237
|
return "";
|
|
@@ -21726,22 +22244,21 @@ const formatHash = ({ chainType, hash }) => {
|
|
|
21726
22244
|
chainTypeFormat = squidTypes.ChainType.COSMOS;
|
|
21727
22245
|
}
|
|
21728
22246
|
}
|
|
21729
|
-
const
|
|
21730
|
-
|
|
21731
|
-
|
|
21732
|
-
|
|
21733
|
-
return
|
|
21734
|
-
|
|
21735
|
-
|
|
21736
|
-
|
|
21737
|
-
return truncateWithEllipsis(hash, start, end);
|
|
22247
|
+
const trimLengthStart = chainTypeToTrimLength[chainTypeFormat].start;
|
|
22248
|
+
const trimLengthEnd = chainTypeToTrimLength[chainTypeFormat].end;
|
|
22249
|
+
// return the same hash if its length is less than the trim length
|
|
22250
|
+
if (hash.length <= trimLengthStart + trimLengthEnd)
|
|
22251
|
+
return hash;
|
|
22252
|
+
return (hash.slice(0, trimLengthStart) +
|
|
22253
|
+
"..." +
|
|
22254
|
+
hash.slice(hash.length - trimLengthEnd, hash.length));
|
|
21738
22255
|
};
|
|
21739
22256
|
const isWalletAddressValid = (chainData, address) => {
|
|
21740
22257
|
if (!address || !chainData?.chainType)
|
|
21741
22258
|
return false;
|
|
21742
22259
|
switch (chainData.chainType) {
|
|
21743
22260
|
case squidTypes.ChainType.EVM:
|
|
21744
|
-
return
|
|
22261
|
+
return isEvmAddressValid(address);
|
|
21745
22262
|
case squidTypes.ChainType.COSMOS:
|
|
21746
22263
|
return isCosmosAddressValid(chainData.bech32Config.bech32PrefixAccAddr, address);
|
|
21747
22264
|
case squidTypes.ChainType.BTC:
|
|
@@ -21754,8 +22271,6 @@ const isWalletAddressValid = (chainData, address) => {
|
|
|
21754
22271
|
return isXrplAddressValid(address);
|
|
21755
22272
|
case squidTypes.ChainType.STELLAR:
|
|
21756
22273
|
return isStellarAddressValid(address);
|
|
21757
|
-
case squidTypes.ChainType.CANTON:
|
|
21758
|
-
return isCantonAddressValid(address);
|
|
21759
22274
|
}
|
|
21760
22275
|
};
|
|
21761
22276
|
const redirectToExtensionsStore = (wallet) => {
|
|
@@ -22017,8 +22532,6 @@ const connectByChainType = async (chainType, wallet, defaultChain, params) => {
|
|
|
22017
22532
|
connector,
|
|
22018
22533
|
},
|
|
22019
22534
|
});
|
|
22020
|
-
case squidTypes.ChainType.CANTON:
|
|
22021
|
-
return null;
|
|
22022
22535
|
}
|
|
22023
22536
|
};
|
|
22024
22537
|
const getChainTypesToConnect = (selectedChainTypes, defaultChain, supportedChains) => {
|
|
@@ -22296,6 +22809,17 @@ class EnsService {
|
|
|
22296
22809
|
}
|
|
22297
22810
|
}
|
|
22298
22811
|
|
|
22812
|
+
const XAMAN_OWNERSHIP_CHALLENGE_MEMO_TYPE = "squid-history-challenge";
|
|
22813
|
+
function getXamanNetwork(network) {
|
|
22814
|
+
switch (network) {
|
|
22815
|
+
case XrplNetwork.MAINNET:
|
|
22816
|
+
return exports.XamanXrplNetwork.MAINNET;
|
|
22817
|
+
case XrplNetwork.TESTNET:
|
|
22818
|
+
return exports.XamanXrplNetwork.TESTNET;
|
|
22819
|
+
default:
|
|
22820
|
+
throw new Error(`Network ${network} is not supported`);
|
|
22821
|
+
}
|
|
22822
|
+
}
|
|
22299
22823
|
/**
|
|
22300
22824
|
* Client to interact with the Xaman backend through a Squid proxy.
|
|
22301
22825
|
* Retrieves the QR code data for the following methods:
|
|
@@ -22304,38 +22828,54 @@ class EnsService {
|
|
|
22304
22828
|
* - send tx
|
|
22305
22829
|
*/
|
|
22306
22830
|
class XamanClient {
|
|
22307
|
-
static
|
|
22308
|
-
|
|
22831
|
+
static defaultBaseUrl = XAMAN_API_URL;
|
|
22832
|
+
baseUrl;
|
|
22833
|
+
constructor({ baseUrl = XAMAN_API_URL } = {}) {
|
|
22834
|
+
this.baseUrl = baseUrl;
|
|
22835
|
+
}
|
|
22836
|
+
async signIn(signal) {
|
|
22309
22837
|
return this.fetch("sign-in", undefined, signal);
|
|
22310
22838
|
}
|
|
22311
|
-
|
|
22839
|
+
async userSession(payload, signal) {
|
|
22312
22840
|
return this.fetch("user-session", { payload }, signal);
|
|
22313
22841
|
}
|
|
22314
|
-
|
|
22315
|
-
|
|
22842
|
+
/**
|
|
22843
|
+
* Requests a Xaman SignIn payload for wallet ownership verification.
|
|
22844
|
+
*
|
|
22845
|
+
* Expected proxy endpoint: POST /xaman/sign-ownership-message with
|
|
22846
|
+
* `{ message }`, returning the same QR/deeplink/websocket shape as sign-in.
|
|
22847
|
+
* The backend should create a SignIn payload whose signed Memo contains:
|
|
22848
|
+
* - MemoType: UTF-8 hex for the Xaman ownership challenge memo
|
|
22849
|
+
* - MemoData: UTF-8 hex for the challenge message
|
|
22850
|
+
*/
|
|
22851
|
+
async signOwnershipMessage(message, signal) {
|
|
22852
|
+
return this.fetch("sign-ownership-message", { message }, signal);
|
|
22853
|
+
}
|
|
22854
|
+
async sendTx({ tx, signal, network, }) {
|
|
22855
|
+
const xamanNetwork = getXamanNetwork(network);
|
|
22316
22856
|
return this.fetch("send-tx", { tx, network: xamanNetwork }, signal);
|
|
22317
22857
|
}
|
|
22318
|
-
|
|
22319
|
-
const url =
|
|
22858
|
+
async fetch(endpoint, body, signal) {
|
|
22859
|
+
const url = this.createUrl(endpoint);
|
|
22320
22860
|
const res = await fetch(url.toString(), {
|
|
22321
22861
|
method: "POST",
|
|
22862
|
+
headers: {
|
|
22863
|
+
"Content-Type": "application/json",
|
|
22864
|
+
},
|
|
22322
22865
|
body: body != null ? JSON.stringify(body) : undefined,
|
|
22323
22866
|
signal,
|
|
22324
22867
|
});
|
|
22325
22868
|
if (!res.ok) {
|
|
22326
|
-
|
|
22869
|
+
const errorBody = await res.text().catch(() => "");
|
|
22870
|
+
throw new Error(`Request failed with status ${res.status}${errorBody ? `: ${errorBody}` : ""}`);
|
|
22327
22871
|
}
|
|
22328
22872
|
return res.json();
|
|
22329
22873
|
}
|
|
22330
|
-
|
|
22331
|
-
|
|
22332
|
-
|
|
22333
|
-
|
|
22334
|
-
|
|
22335
|
-
return exports.XamanXrplNetwork.TESTNET;
|
|
22336
|
-
default:
|
|
22337
|
-
throw new Error(`Network ${network} is not supported`);
|
|
22338
|
-
}
|
|
22874
|
+
createUrl(endpoint) {
|
|
22875
|
+
const baseUrl = this.baseUrl.startsWith("/") && typeof window !== "undefined"
|
|
22876
|
+
? new URL(this.baseUrl, window.location.origin).toString()
|
|
22877
|
+
: this.baseUrl;
|
|
22878
|
+
return new URL(endpoint, baseUrl);
|
|
22339
22879
|
}
|
|
22340
22880
|
}
|
|
22341
22881
|
function isXamanXAppContext() {
|
|
@@ -22668,6 +23208,7 @@ const getConfigWithDefaults = (config) => {
|
|
|
22668
23208
|
slippage: get$2(config, "slippage", defaultConfigValues.slippage),
|
|
22669
23209
|
collectFees: get$2(config, "collectFees", defaultConfigValues.collectFees),
|
|
22670
23210
|
apiUrl: get$2(config, "apiUrl", defaultConfigValues.apiUrl),
|
|
23211
|
+
xamanApiUrl: get$2(config, "xamanApiUrl", defaultConfigValues.xamanApiUrl),
|
|
22671
23212
|
priceImpactWarnings: get$2(config, "priceImpactWarnings", defaultConfigValues.priceImpactWarnings),
|
|
22672
23213
|
initialAssets: get$2(config, "initialAssets", defaultConfigValues.initialAssets),
|
|
22673
23214
|
defaultTokensPerChain: get$2(config, "defaultTokensPerChain", defaultConfigValues.defaultTokensPerChain),
|
|
@@ -23093,10 +23634,7 @@ const getNewSwapParamsFromInput = ({ inputParams, initialSwapRoute, tokens, chai
|
|
|
23093
23634
|
else {
|
|
23094
23635
|
newFallbackAddress = fallbackAddress ?? initialSwapRoute?.fallbackAddress;
|
|
23095
23636
|
}
|
|
23096
|
-
const
|
|
23097
|
-
const newDepositRefundAddress = sourceChainChanged
|
|
23098
|
-
? undefined
|
|
23099
|
-
: depositRefundAddress || initialSwapRoute?.depositRefundAddress;
|
|
23637
|
+
const newDepositRefundAddress = depositRefundAddress || initialSwapRoute?.depositRefundAddress;
|
|
23100
23638
|
return {
|
|
23101
23639
|
fromChainId: srcChainId,
|
|
23102
23640
|
fromTokenAddress: sourceTokenAddress,
|
|
@@ -23375,7 +23913,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23375
23913
|
};
|
|
23376
23914
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23377
23915
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23378
|
-
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-
|
|
23916
|
+
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-BFehLMb_.js'); });
|
|
23379
23917
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23380
23918
|
};
|
|
23381
23919
|
function getTokenAssetsKey(token) {
|
|
@@ -23402,29 +23940,9 @@ async function fetchAssetsColors() {
|
|
|
23402
23940
|
};
|
|
23403
23941
|
}
|
|
23404
23942
|
}
|
|
23405
|
-
|
|
23406
|
-
|
|
23407
|
-
|
|
23408
|
-
}
|
|
23409
|
-
/**
|
|
23410
|
-
* Normalizes SDK data after each init/refetch before the rest of hooks consumes it.
|
|
23411
|
-
*
|
|
23412
|
-
* - Removes chains whose chainType is not supported by the local package.
|
|
23413
|
-
* - Drops tokens for those removed chains.
|
|
23414
|
-
* - Converts Evmos chains/tokens to EVM.
|
|
23415
|
-
* - Applies optional asset colors.
|
|
23416
|
-
*/
|
|
23417
|
-
function initializeSquidData(squid, assetsColors = {
|
|
23418
|
-
chains: {},
|
|
23419
|
-
tokens: {},
|
|
23420
|
-
}) {
|
|
23421
|
-
const supportedChains = squid.chains.filter((chain) => isSupportedChainType(chain.chainType));
|
|
23422
|
-
const supportedChainIds = new Set(supportedChains.map((chain) => chain.chainId));
|
|
23423
|
-
const evmosChainIds = supportedChains
|
|
23424
|
-
.filter(isEvmosChain)
|
|
23425
|
-
.map((c) => c.chainId);
|
|
23426
|
-
const supportedTokens = squid.tokens.filter((token) => supportedChainIds.has(token.chainId));
|
|
23427
|
-
squid.tokens = supportedTokens.map((token) => {
|
|
23943
|
+
function initializeSquidWithAssetsColors(squid, assetsColors) {
|
|
23944
|
+
const evmosChainIds = squid.chains.filter(isEvmosChain).map((c) => c.chainId);
|
|
23945
|
+
squid.tokens = squid.tokens.map((token) => {
|
|
23428
23946
|
const isEvmosToken = evmosChainIds.includes(token.chainId);
|
|
23429
23947
|
return {
|
|
23430
23948
|
...token,
|
|
@@ -23433,7 +23951,7 @@ function initializeSquidData(squid, assetsColors = {
|
|
|
23433
23951
|
textColor: assetsColors.tokens[getTokenAssetsKey(token)]?.textColor,
|
|
23434
23952
|
};
|
|
23435
23953
|
});
|
|
23436
|
-
squid.chains =
|
|
23954
|
+
squid.chains = squid.chains.map((chain) => {
|
|
23437
23955
|
const bgColor = assetsColors.chains[chain.chainId]?.bgColor;
|
|
23438
23956
|
// convert evmos cosmos chains to evm chains
|
|
23439
23957
|
// TODO: this will be fixed in the backend
|
|
@@ -23503,90 +24021,6 @@ function convertEvmosToEvmChain(cosmosChain) {
|
|
|
23503
24021
|
};
|
|
23504
24022
|
}
|
|
23505
24023
|
|
|
23506
|
-
const EvmNetworkNotSupportedErrorCode = 4902;
|
|
23507
|
-
async function addEthereumChain({ chain, provider, }) {
|
|
23508
|
-
const chainName = chain.rpc.includes("tenderly")
|
|
23509
|
-
? `${chain.networkName} Tenderly fork`
|
|
23510
|
-
: chain.networkName;
|
|
23511
|
-
const chainParameters = {
|
|
23512
|
-
chainId: `0x${parseInt(chain.chainId, 10).toString(16)}`,
|
|
23513
|
-
chainName,
|
|
23514
|
-
nativeCurrency: chain.nativeCurrency,
|
|
23515
|
-
rpcUrls: [chain.rpc],
|
|
23516
|
-
blockExplorerUrls: chain.blockExplorerUrls,
|
|
23517
|
-
iconUrls: [chain.chainIconURI],
|
|
23518
|
-
};
|
|
23519
|
-
try {
|
|
23520
|
-
return provider.request({
|
|
23521
|
-
method: "wallet_addEthereumChain",
|
|
23522
|
-
params: [chainParameters],
|
|
23523
|
-
});
|
|
23524
|
-
}
|
|
23525
|
-
catch (error) {
|
|
23526
|
-
console.debug("Error adding chain:", error);
|
|
23527
|
-
}
|
|
23528
|
-
}
|
|
23529
|
-
const parseEvmAddress = (address) => {
|
|
23530
|
-
if (address && viem.isAddress(address)) {
|
|
23531
|
-
return address;
|
|
23532
|
-
}
|
|
23533
|
-
};
|
|
23534
|
-
/**
|
|
23535
|
-
* Formats a Wagmi connector into a Squid Wallet
|
|
23536
|
-
*/
|
|
23537
|
-
function formatEvmWallet(connector) {
|
|
23538
|
-
const { icon, name: defaultName, id: wagmiConnectorId } = connector;
|
|
23539
|
-
const walletOverrides = standardWalletOverrides[wagmiConnectorId];
|
|
23540
|
-
const walletIcon = walletOverrides?.icon || icon;
|
|
23541
|
-
const name = walletOverrides?.name || defaultName;
|
|
23542
|
-
const connectorId = walletOverrides?.connectorId || wagmiConnectorId;
|
|
23543
|
-
const isNonInstallableWallet = [
|
|
23544
|
-
"injected",
|
|
23545
|
-
"walletConnect",
|
|
23546
|
-
"metaMaskSDK",
|
|
23547
|
-
"coinbaseWalletSDK",
|
|
23548
|
-
].includes(wagmiConnectorId);
|
|
23549
|
-
return {
|
|
23550
|
-
connectorId,
|
|
23551
|
-
name,
|
|
23552
|
-
connectorName: name,
|
|
23553
|
-
type: squidTypes.ChainType.EVM,
|
|
23554
|
-
icon: walletIcon,
|
|
23555
|
-
rdns: wagmiConnectorId,
|
|
23556
|
-
windowFlag: name,
|
|
23557
|
-
// For non-installable wallets, we don't want to show the "Installed" label
|
|
23558
|
-
// but still want to allow the user to connect
|
|
23559
|
-
skipInstallCheck: isNonInstallableWallet,
|
|
23560
|
-
isInstalled: isNonInstallableWallet ? undefined : () => true,
|
|
23561
|
-
connector,
|
|
23562
|
-
isMobile: true,
|
|
23563
|
-
};
|
|
23564
|
-
}
|
|
23565
|
-
function filterWagmiConnector(connector) {
|
|
23566
|
-
// Safe is auto-connected when available, should not be listed as an available wallet
|
|
23567
|
-
return connector.id !== "safe";
|
|
23568
|
-
}
|
|
23569
|
-
/**
|
|
23570
|
-
* Waits for a transaction receipt, handling retries if indexing is in progress
|
|
23571
|
-
*/
|
|
23572
|
-
async function waitForReceiptWithRetry(txResponse, retries = 5, delayMs = 2000) {
|
|
23573
|
-
let lastError;
|
|
23574
|
-
for (let i = 0; i < retries; i++) {
|
|
23575
|
-
try {
|
|
23576
|
-
return await txResponse.wait();
|
|
23577
|
-
}
|
|
23578
|
-
catch (error) {
|
|
23579
|
-
lastError = error;
|
|
23580
|
-
if (error?.message?.match(/transaction indexing is in progress/i)) {
|
|
23581
|
-
await sleep(delayMs);
|
|
23582
|
-
continue;
|
|
23583
|
-
}
|
|
23584
|
-
throw error;
|
|
23585
|
-
}
|
|
23586
|
-
}
|
|
23587
|
-
throw lastError;
|
|
23588
|
-
}
|
|
23589
|
-
|
|
23590
24024
|
const countryCurrencyMap = [
|
|
23591
24025
|
{
|
|
23592
24026
|
currencyCode: "AED",
|
|
@@ -25310,7 +25744,7 @@ const useSquid = () => {
|
|
|
25310
25744
|
queryFn: async () => {
|
|
25311
25745
|
if (squid) {
|
|
25312
25746
|
await squid?.init();
|
|
25313
|
-
|
|
25747
|
+
initializeSquidWithAssetsColors(squid, assetsColors);
|
|
25314
25748
|
return squid;
|
|
25315
25749
|
}
|
|
25316
25750
|
return null;
|
|
@@ -25369,7 +25803,7 @@ const useSquidTokens = (direction) => {
|
|
|
25369
25803
|
config.availableChains,
|
|
25370
25804
|
direction,
|
|
25371
25805
|
]);
|
|
25372
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens,
|
|
25806
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = React.useMemo(() => {
|
|
25373
25807
|
return tokens?.reduce((acc, token) => {
|
|
25374
25808
|
switch (token.type) {
|
|
25375
25809
|
case squidTypes.ChainType.EVM:
|
|
@@ -25393,9 +25827,6 @@ const useSquidTokens = (direction) => {
|
|
|
25393
25827
|
case squidTypes.ChainType.STELLAR:
|
|
25394
25828
|
acc.stellarTokens.push(token);
|
|
25395
25829
|
break;
|
|
25396
|
-
case squidTypes.ChainType.CANTON:
|
|
25397
|
-
acc.cantonTokens.push(token);
|
|
25398
|
-
break;
|
|
25399
25830
|
}
|
|
25400
25831
|
return acc;
|
|
25401
25832
|
}, {
|
|
@@ -25406,7 +25837,6 @@ const useSquidTokens = (direction) => {
|
|
|
25406
25837
|
suiTokens: [],
|
|
25407
25838
|
xrplTokens: [],
|
|
25408
25839
|
stellarTokens: [],
|
|
25409
|
-
cantonTokens: [],
|
|
25410
25840
|
});
|
|
25411
25841
|
}, [tokens]);
|
|
25412
25842
|
const findToken = React.useCallback((address, chainId) => {
|
|
@@ -25424,7 +25854,6 @@ const useSquidTokens = (direction) => {
|
|
|
25424
25854
|
suiTokens,
|
|
25425
25855
|
xrplTokens,
|
|
25426
25856
|
stellarTokens,
|
|
25427
|
-
cantonTokens,
|
|
25428
25857
|
};
|
|
25429
25858
|
};
|
|
25430
25859
|
|
|
@@ -25962,7 +26391,6 @@ const chainTypeToRefetchInterval = {
|
|
|
25962
26391
|
[squidTypes.ChainType.SUI]: 1_000,
|
|
25963
26392
|
[squidTypes.ChainType.XRPL]: 1_000,
|
|
25964
26393
|
[squidTypes.ChainType.STELLAR]: 1_000,
|
|
25965
|
-
[squidTypes.ChainType.CANTON]: 1_000,
|
|
25966
26394
|
};
|
|
25967
26395
|
/**
|
|
25968
26396
|
* Returns the status refetch interval of a Send transaction
|
|
@@ -26229,7 +26657,7 @@ const useSquidChains = (direction) => {
|
|
|
26229
26657
|
const chain = findChain(chainId);
|
|
26230
26658
|
return chain?.chainType;
|
|
26231
26659
|
}, [findChain]);
|
|
26232
|
-
const { evmChains, cosmosChains, suiChains, stellarChains, xrplChains
|
|
26660
|
+
const { evmChains, cosmosChains, suiChains, stellarChains, xrplChains } = React.useMemo(() => {
|
|
26233
26661
|
return chains.reduce((acc, chain) => {
|
|
26234
26662
|
switch (chain.chainType) {
|
|
26235
26663
|
case squidTypes.ChainType.EVM:
|
|
@@ -26247,9 +26675,6 @@ const useSquidChains = (direction) => {
|
|
|
26247
26675
|
case squidTypes.ChainType.STELLAR:
|
|
26248
26676
|
acc.stellarChains.push(chain);
|
|
26249
26677
|
break;
|
|
26250
|
-
case squidTypes.ChainType.CANTON:
|
|
26251
|
-
acc.cantonChains.push(chain);
|
|
26252
|
-
break;
|
|
26253
26678
|
}
|
|
26254
26679
|
return acc;
|
|
26255
26680
|
}, {
|
|
@@ -26258,7 +26683,6 @@ const useSquidChains = (direction) => {
|
|
|
26258
26683
|
suiChains: [],
|
|
26259
26684
|
xrplChains: [],
|
|
26260
26685
|
stellarChains: [],
|
|
26261
|
-
cantonChains: [],
|
|
26262
26686
|
});
|
|
26263
26687
|
}, [chains]);
|
|
26264
26688
|
const { supportedSourceChains, supportedDestinationChains } = React.useMemo(() => {
|
|
@@ -26279,7 +26703,6 @@ const useSquidChains = (direction) => {
|
|
|
26279
26703
|
suiChains,
|
|
26280
26704
|
xrplChains,
|
|
26281
26705
|
stellarChains,
|
|
26282
|
-
cantonChains,
|
|
26283
26706
|
getChainType,
|
|
26284
26707
|
findChain,
|
|
26285
26708
|
};
|
|
@@ -26804,7 +27227,7 @@ function useStellarWallets() {
|
|
|
26804
27227
|
try {
|
|
26805
27228
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
26806
27229
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
|
|
26807
|
-
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-
|
|
27230
|
+
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-yWCDuq6S.js'); });
|
|
26808
27231
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
26809
27232
|
const promises = modules.map(async (module) => {
|
|
26810
27233
|
const isAvailable = await module.isAvailable();
|
|
@@ -26984,6 +27407,56 @@ class XamanConnector {
|
|
|
26984
27407
|
this.xumm = await getXummClient();
|
|
26985
27408
|
}
|
|
26986
27409
|
}
|
|
27410
|
+
async runPayloadFlow({ txPayload, onSigned, }) {
|
|
27411
|
+
this.validateXummInitialized();
|
|
27412
|
+
if (!this.xumm.xapp) {
|
|
27413
|
+
throw new Error("Not in xApp context");
|
|
27414
|
+
}
|
|
27415
|
+
if (!this.xumm.payload) {
|
|
27416
|
+
throw new Error("Payload not available");
|
|
27417
|
+
}
|
|
27418
|
+
await this.xumm.xapp.openSignRequest(txPayload);
|
|
27419
|
+
return new Promise((resolve, reject) => {
|
|
27420
|
+
this.validateXummInitialized();
|
|
27421
|
+
const unsubscribe = () => {
|
|
27422
|
+
this.xumm?.off("payload", handlePayload);
|
|
27423
|
+
};
|
|
27424
|
+
const rejectAndUnsubscribe = (error) => {
|
|
27425
|
+
unsubscribe();
|
|
27426
|
+
reject(error);
|
|
27427
|
+
};
|
|
27428
|
+
const handlePayload = async (data) => {
|
|
27429
|
+
this.validateXummInitialized();
|
|
27430
|
+
if (!data) {
|
|
27431
|
+
return;
|
|
27432
|
+
}
|
|
27433
|
+
if (data.reason === "DECLINED") {
|
|
27434
|
+
rejectAndUnsubscribe(new Error("User rejected the request."));
|
|
27435
|
+
return;
|
|
27436
|
+
}
|
|
27437
|
+
if (data.reason !== "SIGNED") {
|
|
27438
|
+
return;
|
|
27439
|
+
}
|
|
27440
|
+
if (!this.xumm.payload) {
|
|
27441
|
+
rejectAndUnsubscribe(new Error("Payload not available"));
|
|
27442
|
+
return;
|
|
27443
|
+
}
|
|
27444
|
+
try {
|
|
27445
|
+
const fullPayload = await this.xumm.payload.get(data.uuid);
|
|
27446
|
+
if (!fullPayload) {
|
|
27447
|
+
throw new Error("Invalid Xaman payload response");
|
|
27448
|
+
}
|
|
27449
|
+
unsubscribe();
|
|
27450
|
+
const response = await onSigned(fullPayload);
|
|
27451
|
+
resolve(response);
|
|
27452
|
+
}
|
|
27453
|
+
catch (error) {
|
|
27454
|
+
rejectAndUnsubscribe(error);
|
|
27455
|
+
}
|
|
27456
|
+
};
|
|
27457
|
+
this.xumm.on("payload", handlePayload);
|
|
27458
|
+
});
|
|
27459
|
+
}
|
|
26987
27460
|
async connect() {
|
|
26988
27461
|
await this.initializeXumm();
|
|
26989
27462
|
this.validateXummInitialized();
|
|
@@ -27001,7 +27474,7 @@ class XamanConnector {
|
|
|
27001
27474
|
if (!this.xumm.payload) {
|
|
27002
27475
|
throw new Error("Payload not available");
|
|
27003
27476
|
}
|
|
27004
|
-
const xamanNetwork =
|
|
27477
|
+
const xamanNetwork = getXamanNetwork(network);
|
|
27005
27478
|
const txPayload = await this.xumm.payload.create({
|
|
27006
27479
|
TransactionType: XrplTransactionType.PAYMENT,
|
|
27007
27480
|
options: {
|
|
@@ -27009,33 +27482,65 @@ class XamanConnector {
|
|
|
27009
27482
|
},
|
|
27010
27483
|
txjson: tx,
|
|
27011
27484
|
});
|
|
27012
|
-
await this.
|
|
27013
|
-
|
|
27014
|
-
|
|
27015
|
-
|
|
27016
|
-
|
|
27017
|
-
}
|
|
27018
|
-
this.xumm.on("payload", async (data) => {
|
|
27019
|
-
this.validateXummInitialized();
|
|
27020
|
-
if (data && data.reason === "DECLINED") {
|
|
27021
|
-
reject(new Error("User rejected the request."));
|
|
27485
|
+
const response = await this.runPayloadFlow({
|
|
27486
|
+
txPayload,
|
|
27487
|
+
onSigned: (fullPayload) => {
|
|
27488
|
+
if (!fullPayload.response.txid) {
|
|
27489
|
+
throw new Error("Transaction hash not found");
|
|
27022
27490
|
}
|
|
27023
|
-
|
|
27024
|
-
|
|
27025
|
-
|
|
27026
|
-
|
|
27027
|
-
|
|
27028
|
-
|
|
27029
|
-
|
|
27030
|
-
|
|
27031
|
-
|
|
27032
|
-
|
|
27033
|
-
|
|
27034
|
-
|
|
27035
|
-
|
|
27036
|
-
|
|
27491
|
+
return {
|
|
27492
|
+
hash: fullPayload.response.txid,
|
|
27493
|
+
status: XrplTxStatus.SUCCESS,
|
|
27494
|
+
};
|
|
27495
|
+
},
|
|
27496
|
+
});
|
|
27497
|
+
return response;
|
|
27498
|
+
}
|
|
27499
|
+
async signOwnershipMessage({ address, message, }) {
|
|
27500
|
+
await this.initializeXumm();
|
|
27501
|
+
this.validateXummInitialized();
|
|
27502
|
+
if (!this.xumm.xapp) {
|
|
27503
|
+
throw new Error("Not in xApp context");
|
|
27504
|
+
}
|
|
27505
|
+
if (!this.xumm.payload) {
|
|
27506
|
+
throw new Error("Payload not available");
|
|
27507
|
+
}
|
|
27508
|
+
const txPayload = await this.xumm.payload.create({
|
|
27509
|
+
txjson: {
|
|
27510
|
+
TransactionType: "SignIn",
|
|
27511
|
+
Memos: [
|
|
27512
|
+
{
|
|
27513
|
+
Memo: {
|
|
27514
|
+
MemoType: stringToUtf8Hex(XAMAN_OWNERSHIP_CHALLENGE_MEMO_TYPE, {
|
|
27515
|
+
uppercase: true,
|
|
27516
|
+
}),
|
|
27517
|
+
MemoData: stringToUtf8Hex(message, { uppercase: true }),
|
|
27518
|
+
},
|
|
27519
|
+
},
|
|
27520
|
+
],
|
|
27521
|
+
},
|
|
27522
|
+
});
|
|
27523
|
+
if (!txPayload) {
|
|
27524
|
+
throw new Error("Failed to create Xaman sign-in payload");
|
|
27525
|
+
}
|
|
27526
|
+
const response = await this.runPayloadFlow({
|
|
27527
|
+
txPayload,
|
|
27528
|
+
onSigned: (fullPayload) => {
|
|
27529
|
+
const signedAddress = fullPayload.response.account;
|
|
27530
|
+
const signedPayload = fullPayload.response.hex;
|
|
27531
|
+
if (signedAddress !== address) {
|
|
27532
|
+
throw createXrplActiveAccountMismatchError("Xaman");
|
|
27037
27533
|
}
|
|
27038
|
-
|
|
27534
|
+
if (!signedPayload) {
|
|
27535
|
+
throw new Error("Invalid Xaman sign-in response");
|
|
27536
|
+
}
|
|
27537
|
+
return {
|
|
27538
|
+
signedPayload,
|
|
27539
|
+
signedPayloadEncoding: "xrpl-tx-hex",
|
|
27540
|
+
signatureType: exports.WalletVerificationSignatureType.XAMAN,
|
|
27541
|
+
signerAddress: fullPayload.response.signer ?? undefined,
|
|
27542
|
+
};
|
|
27543
|
+
},
|
|
27039
27544
|
});
|
|
27040
27545
|
return response;
|
|
27041
27546
|
}
|
|
@@ -27077,96 +27582,157 @@ function websocket(url, onMessage) {
|
|
|
27077
27582
|
|
|
27078
27583
|
const genericXamanQrErrorMessage = "Failed to generate Xaman QR code";
|
|
27079
27584
|
class XamanQrConnector {
|
|
27585
|
+
xamanClient;
|
|
27080
27586
|
cancelConnectQr = null;
|
|
27081
27587
|
cancelSignAndSubmitQr = null;
|
|
27588
|
+
cancelSignOwnershipQr = null;
|
|
27589
|
+
constructor(xamanClient = new XamanClient()) {
|
|
27590
|
+
this.xamanClient = xamanClient;
|
|
27591
|
+
}
|
|
27082
27592
|
cancelConnect() {
|
|
27083
27593
|
this.cancelConnectQr?.();
|
|
27084
27594
|
}
|
|
27085
27595
|
cancelSignAndSubmit() {
|
|
27086
27596
|
this.cancelSignAndSubmitQr?.();
|
|
27087
27597
|
}
|
|
27088
|
-
|
|
27598
|
+
cancelSignOwnershipMessage() {
|
|
27599
|
+
this.cancelSignOwnershipQr?.();
|
|
27600
|
+
}
|
|
27601
|
+
getPayloadId(message) {
|
|
27602
|
+
if (!message.payload_uuidv4) {
|
|
27603
|
+
throw new Error("Invalid Xaman websocket response");
|
|
27604
|
+
}
|
|
27605
|
+
return message.payload_uuidv4;
|
|
27606
|
+
}
|
|
27607
|
+
async runQrFlow({ flow, cancelMessage, setCancel, createPayload, onSigned, }) {
|
|
27089
27608
|
const controller = new AbortController();
|
|
27090
|
-
|
|
27091
|
-
controller.abort(
|
|
27092
|
-
};
|
|
27609
|
+
setCancel(() => {
|
|
27610
|
+
controller.abort(cancelMessage);
|
|
27611
|
+
});
|
|
27093
27612
|
let response;
|
|
27094
27613
|
try {
|
|
27095
|
-
response = await
|
|
27614
|
+
response = await createPayload(controller.signal);
|
|
27096
27615
|
}
|
|
27097
|
-
catch
|
|
27616
|
+
catch {
|
|
27617
|
+
if (flow === "sign") {
|
|
27618
|
+
WidgetEvents.getInstance().dispatchQrCodeGenerationFailedForSign(undefined);
|
|
27619
|
+
}
|
|
27098
27620
|
throw new QrCodeGenerationError(genericXamanQrErrorMessage);
|
|
27099
27621
|
}
|
|
27100
|
-
|
|
27101
|
-
|
|
27102
|
-
|
|
27103
|
-
|
|
27622
|
+
if (flow === "connect") {
|
|
27623
|
+
WidgetEvents.getInstance().dispatchQrCodeGeneratedForConnect({
|
|
27624
|
+
matrix: response.qrMatrix,
|
|
27625
|
+
deepLinkUrl: response.deepLinkUrl,
|
|
27626
|
+
});
|
|
27627
|
+
}
|
|
27628
|
+
else {
|
|
27629
|
+
WidgetEvents.getInstance().dispatchQrCodeGeneratedForSign({
|
|
27630
|
+
matrix: response.qrMatrix,
|
|
27631
|
+
deepLinkUrl: response.deepLinkUrl,
|
|
27632
|
+
});
|
|
27633
|
+
}
|
|
27104
27634
|
const { promise, close } = websocket(response.wsStatusUrl, (event, resolve, reject) => {
|
|
27105
|
-
|
|
27106
|
-
|
|
27107
|
-
|
|
27108
|
-
|
|
27635
|
+
let message;
|
|
27636
|
+
try {
|
|
27637
|
+
message = JSON.parse(event.data);
|
|
27638
|
+
}
|
|
27639
|
+
catch (error) {
|
|
27640
|
+
reject(error);
|
|
27641
|
+
return;
|
|
27642
|
+
}
|
|
27643
|
+
if (message.opened === true) {
|
|
27644
|
+
WidgetEvents.getInstance().dispatchQrScannedAwaitingApproval({
|
|
27645
|
+
flow,
|
|
27109
27646
|
});
|
|
27647
|
+
return;
|
|
27648
|
+
}
|
|
27649
|
+
if (message.signed === true) {
|
|
27650
|
+
Promise.resolve(onSigned(message)).then(resolve).catch(reject);
|
|
27651
|
+
return;
|
|
27110
27652
|
}
|
|
27111
|
-
|
|
27653
|
+
if (message.signed === false) {
|
|
27112
27654
|
reject(new Error("User rejected the request."));
|
|
27113
27655
|
}
|
|
27114
27656
|
});
|
|
27115
|
-
|
|
27657
|
+
setCancel(() => {
|
|
27116
27658
|
close();
|
|
27117
|
-
};
|
|
27118
|
-
|
|
27119
|
-
|
|
27659
|
+
});
|
|
27660
|
+
return promise.finally(() => {
|
|
27661
|
+
setCancel(null);
|
|
27662
|
+
});
|
|
27663
|
+
}
|
|
27664
|
+
async connect() {
|
|
27665
|
+
return this.runQrFlow({
|
|
27666
|
+
flow: "connect",
|
|
27667
|
+
cancelMessage: "User canceled the connection process",
|
|
27668
|
+
setCancel: (cancel) => {
|
|
27669
|
+
this.cancelConnectQr = cancel;
|
|
27670
|
+
},
|
|
27671
|
+
createPayload: (signal) => this.xamanClient.signIn(signal),
|
|
27672
|
+
onSigned: async (message) => {
|
|
27673
|
+
const data = await this.xamanClient.userSession(this.getPayloadId(message));
|
|
27674
|
+
if (!data.response.account) {
|
|
27675
|
+
throw new Error("Invalid Xaman sign-in response");
|
|
27676
|
+
}
|
|
27677
|
+
return data.response.account;
|
|
27678
|
+
},
|
|
27679
|
+
});
|
|
27120
27680
|
}
|
|
27121
27681
|
async signAndSubmit({ tx, network, }) {
|
|
27122
|
-
|
|
27123
|
-
|
|
27124
|
-
|
|
27125
|
-
|
|
27126
|
-
|
|
27127
|
-
|
|
27128
|
-
|
|
27682
|
+
return this.runQrFlow({
|
|
27683
|
+
flow: "sign",
|
|
27684
|
+
cancelMessage: "User canceled the transaction",
|
|
27685
|
+
setCancel: (cancel) => {
|
|
27686
|
+
this.cancelSignAndSubmitQr = cancel;
|
|
27687
|
+
},
|
|
27688
|
+
createPayload: (signal) => this.xamanClient.sendTx({
|
|
27129
27689
|
tx,
|
|
27130
27690
|
network,
|
|
27131
|
-
signal
|
|
27132
|
-
})
|
|
27133
|
-
|
|
27134
|
-
|
|
27135
|
-
|
|
27136
|
-
|
|
27137
|
-
|
|
27138
|
-
|
|
27139
|
-
matrix: response.qrMatrix,
|
|
27140
|
-
deepLinkUrl: response.deepLinkUrl,
|
|
27141
|
-
});
|
|
27142
|
-
const { promise, close } = websocket(response.wsStatusUrl, (event, resolve, reject) => {
|
|
27143
|
-
const msg = JSON.parse(event.data);
|
|
27144
|
-
if (msg.opened === true) {
|
|
27145
|
-
// User has scanned the QR code
|
|
27146
|
-
WidgetEvents.getInstance().dispatchQrTxScannedAwaitingApproval(undefined);
|
|
27147
|
-
}
|
|
27148
|
-
else if (msg.signed === true) {
|
|
27149
|
-
// Tx has been signed
|
|
27150
|
-
resolve({
|
|
27151
|
-
hash: msg.txid,
|
|
27691
|
+
signal,
|
|
27692
|
+
}),
|
|
27693
|
+
onSigned: (message) => {
|
|
27694
|
+
if (!message.txid) {
|
|
27695
|
+
throw new Error("Invalid Xaman transaction response");
|
|
27696
|
+
}
|
|
27697
|
+
return {
|
|
27698
|
+
hash: message.txid,
|
|
27152
27699
|
status: XrplTxStatus.SUCCESS,
|
|
27153
|
-
}
|
|
27154
|
-
}
|
|
27155
|
-
|
|
27156
|
-
|
|
27157
|
-
|
|
27158
|
-
|
|
27700
|
+
};
|
|
27701
|
+
},
|
|
27702
|
+
});
|
|
27703
|
+
}
|
|
27704
|
+
async signOwnershipMessage({ address, message, }) {
|
|
27705
|
+
return this.runQrFlow({
|
|
27706
|
+
flow: "sign",
|
|
27707
|
+
cancelMessage: "User canceled the signing process",
|
|
27708
|
+
setCancel: (cancel) => {
|
|
27709
|
+
this.cancelSignOwnershipQr = cancel;
|
|
27710
|
+
},
|
|
27711
|
+
createPayload: (signal) => this.xamanClient.signOwnershipMessage(message, signal),
|
|
27712
|
+
onSigned: async (statusMessage) => {
|
|
27713
|
+
const data = await this.xamanClient.userSession(this.getPayloadId(statusMessage));
|
|
27714
|
+
const signedAddress = data.response.account;
|
|
27715
|
+
const signedPayload = data.response.hex;
|
|
27716
|
+
if (signedAddress !== address) {
|
|
27717
|
+
throw createXrplActiveAccountMismatchError("Xaman");
|
|
27718
|
+
}
|
|
27719
|
+
if (!signedPayload) {
|
|
27720
|
+
throw new Error("Invalid Xaman sign-in response");
|
|
27721
|
+
}
|
|
27722
|
+
return {
|
|
27723
|
+
signedPayload,
|
|
27724
|
+
signedPayloadEncoding: "xrpl-tx-hex",
|
|
27725
|
+
signatureType: exports.WalletVerificationSignatureType.XAMAN,
|
|
27726
|
+
signerAddress: data.response.signer ?? undefined,
|
|
27727
|
+
};
|
|
27728
|
+
},
|
|
27159
27729
|
});
|
|
27160
|
-
this.cancelSignAndSubmitQr = () => {
|
|
27161
|
-
close();
|
|
27162
|
-
};
|
|
27163
|
-
const result = await promise;
|
|
27164
|
-
return result;
|
|
27165
27730
|
}
|
|
27166
27731
|
}
|
|
27167
27732
|
|
|
27168
27733
|
function useXrplWallets() {
|
|
27169
27734
|
const { clientWindow } = useClient();
|
|
27735
|
+
const xamanApiUrl = useConfigStore((state) => state.config.xamanApiUrl);
|
|
27170
27736
|
const wallets = React.useMemo(() => {
|
|
27171
27737
|
const isXAppContext = isXamanXAppContext();
|
|
27172
27738
|
const xamanWalletIcon = `${walletIconBaseUrl}/xaman.webp`;
|
|
@@ -27187,7 +27753,7 @@ function useXrplWallets() {
|
|
|
27187
27753
|
type: squidTypes.ChainType.XRPL,
|
|
27188
27754
|
name: "Xaman",
|
|
27189
27755
|
windowFlag: exports.WindowWalletFlag.XamanQr,
|
|
27190
|
-
connector: new XamanQrConnector(),
|
|
27756
|
+
connector: new XamanQrConnector(new XamanClient({ baseUrl: xamanApiUrl })),
|
|
27191
27757
|
skipInstallCheck: true,
|
|
27192
27758
|
isMobile: true,
|
|
27193
27759
|
connectorId: "xaman-qr",
|
|
@@ -27201,7 +27767,7 @@ function useXrplWallets() {
|
|
|
27201
27767
|
isXAppContext ? xamanXAppWallet : xamanQrWallet,
|
|
27202
27768
|
...populateWallets(clientWindow, xrplWallets),
|
|
27203
27769
|
];
|
|
27204
|
-
}, [clientWindow]);
|
|
27770
|
+
}, [clientWindow, xamanApiUrl]);
|
|
27205
27771
|
return {
|
|
27206
27772
|
wallets,
|
|
27207
27773
|
};
|
|
@@ -27336,6 +27902,7 @@ const useWallet = () => {
|
|
|
27336
27902
|
setConnectingWallet({
|
|
27337
27903
|
wallet,
|
|
27338
27904
|
status: exports.ConnectingWalletStatus.CONNECTING,
|
|
27905
|
+
qrScanned: false,
|
|
27339
27906
|
});
|
|
27340
27907
|
try {
|
|
27341
27908
|
const result = await connectWallet({
|
|
@@ -27470,11 +28037,29 @@ const useWallet = () => {
|
|
|
27470
28037
|
matrix: event.detail.matrix,
|
|
27471
28038
|
deepLinkUrl: event.detail.deepLinkUrl,
|
|
27472
28039
|
},
|
|
28040
|
+
qrScanned: false,
|
|
28041
|
+
});
|
|
28042
|
+
};
|
|
28043
|
+
const onQrWalletScannedAwaitingApproval = () => {
|
|
28044
|
+
const currentState = useWalletStore.getState().connectingWalletState;
|
|
28045
|
+
if (currentState.qrData == null) {
|
|
28046
|
+
return;
|
|
28047
|
+
}
|
|
28048
|
+
setConnectingWallet({
|
|
28049
|
+
...currentState,
|
|
28050
|
+
qrScanned: true,
|
|
27473
28051
|
});
|
|
27474
28052
|
};
|
|
28053
|
+
const onQrScannedAwaitingApproval = (event) => {
|
|
28054
|
+
if (event.detail.flow === "connect") {
|
|
28055
|
+
onQrWalletScannedAwaitingApproval();
|
|
28056
|
+
}
|
|
28057
|
+
};
|
|
27475
28058
|
WidgetEvents.getInstance().listenToWidget("qrCodeGeneratedForConnect", onQrWalletConnectData);
|
|
28059
|
+
WidgetEvents.getInstance().listenToWidget("qrScannedAwaitingUserApproval", onQrScannedAwaitingApproval);
|
|
27476
28060
|
return () => {
|
|
27477
28061
|
WidgetEvents.getInstance().removeWidgetListener("qrCodeGeneratedForConnect", onQrWalletConnectData);
|
|
28062
|
+
WidgetEvents.getInstance().removeWidgetListener("qrScannedAwaitingUserApproval", onQrScannedAwaitingApproval);
|
|
27478
28063
|
};
|
|
27479
28064
|
}, [setConnectingWallet]);
|
|
27480
28065
|
return {
|
|
@@ -27503,7 +28088,6 @@ const useMultiChainWallet = (chain) => {
|
|
|
27503
28088
|
const suiAddress = connectedAddresses[squidTypes.ChainType.SUI];
|
|
27504
28089
|
const xrplAddress = connectedAddresses[squidTypes.ChainType.XRPL];
|
|
27505
28090
|
const stellarAddress = connectedAddresses[squidTypes.ChainType.STELLAR];
|
|
27506
|
-
const cantonAddress = connectedAddresses[squidTypes.ChainType.CANTON];
|
|
27507
28091
|
// Cosmos is a special case because the address changes on every chain
|
|
27508
28092
|
// so we can't use the default cosmos connected address
|
|
27509
28093
|
const { data: cosmosAddress } = useCosmosForChain(chain);
|
|
@@ -27591,16 +28175,6 @@ const useMultiChainWallet = (chain) => {
|
|
|
27591
28175
|
chainType: chain.chainType,
|
|
27592
28176
|
}),
|
|
27593
28177
|
};
|
|
27594
|
-
case squidTypes.ChainType.CANTON:
|
|
27595
|
-
if (!cantonAddress)
|
|
27596
|
-
return {};
|
|
27597
|
-
return {
|
|
27598
|
-
address: cantonAddress,
|
|
27599
|
-
formatted: formatHash({
|
|
27600
|
-
hash: cantonAddress,
|
|
27601
|
-
chainType: chain.chainType,
|
|
27602
|
-
}),
|
|
27603
|
-
};
|
|
27604
28178
|
}
|
|
27605
28179
|
}, [
|
|
27606
28180
|
chain?.chainType,
|
|
@@ -27612,7 +28186,6 @@ const useMultiChainWallet = (chain) => {
|
|
|
27612
28186
|
suiAddress,
|
|
27613
28187
|
xrplAddress,
|
|
27614
28188
|
stellarAddress,
|
|
27615
|
-
cantonAddress,
|
|
27616
28189
|
]);
|
|
27617
28190
|
/**
|
|
27618
28191
|
* Change current network for desired chain
|
|
@@ -28437,8 +29010,6 @@ async function createClient(chain) {
|
|
|
28437
29010
|
return new XrplRpcClient(chain.rpc);
|
|
28438
29011
|
case squidTypes.ChainType.STELLAR:
|
|
28439
29012
|
return new StellarRpcClient(chain.rpc);
|
|
28440
|
-
case squidTypes.ChainType.CANTON:
|
|
28441
|
-
return null;
|
|
28442
29013
|
}
|
|
28443
29014
|
}
|
|
28444
29015
|
|
|
@@ -29631,7 +30202,7 @@ const useStellarBalance = ({ userAddress, chain, enabled, token, refreshInterval
|
|
|
29631
30202
|
};
|
|
29632
30203
|
|
|
29633
30204
|
function useNativeTokenForChain(chain) {
|
|
29634
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens,
|
|
30205
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = useSquidTokens();
|
|
29635
30206
|
const getTokensForChainType = () => {
|
|
29636
30207
|
if (!chain?.chainType)
|
|
29637
30208
|
return [];
|
|
@@ -29650,8 +30221,6 @@ function useNativeTokenForChain(chain) {
|
|
|
29650
30221
|
return xrplTokens;
|
|
29651
30222
|
case squidTypes.ChainType.STELLAR:
|
|
29652
30223
|
return stellarTokens;
|
|
29653
|
-
case squidTypes.ChainType.CANTON:
|
|
29654
|
-
return cantonTokens;
|
|
29655
30224
|
}
|
|
29656
30225
|
};
|
|
29657
30226
|
const nativeTokenForChainType = React.useMemo(() => {
|
|
@@ -29886,11 +30455,6 @@ const useNativeBalance = (chain) => {
|
|
|
29886
30455
|
break;
|
|
29887
30456
|
case squidTypes.ChainType.STELLAR:
|
|
29888
30457
|
balance = nativeStellarBalance;
|
|
29889
|
-
break;
|
|
29890
|
-
case squidTypes.ChainType.CANTON:
|
|
29891
|
-
// TODO: implement canton balance fetching
|
|
29892
|
-
balance = undefined;
|
|
29893
|
-
break;
|
|
29894
30458
|
}
|
|
29895
30459
|
const balanceFormatted = !!balance
|
|
29896
30460
|
? formatBNToReadable(balance.value, balance.decimals)
|
|
@@ -29927,9 +30491,6 @@ const useNativeBalance = (chain) => {
|
|
|
29927
30491
|
return isXrpLoading;
|
|
29928
30492
|
case squidTypes.ChainType.STELLAR:
|
|
29929
30493
|
return isStellarLoading;
|
|
29930
|
-
case squidTypes.ChainType.CANTON:
|
|
29931
|
-
// TODO: implement canton balance fetching
|
|
29932
|
-
return false;
|
|
29933
30494
|
}
|
|
29934
30495
|
}, [
|
|
29935
30496
|
chain?.chainType,
|
|
@@ -30154,7 +30715,7 @@ function hederaWalletConnect(parameters) {
|
|
|
30154
30715
|
const optionalChains = config.chains.map((x) => x.id);
|
|
30155
30716
|
if (!optionalChains.length)
|
|
30156
30717
|
return;
|
|
30157
|
-
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-
|
|
30718
|
+
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-D8CAnRf1.js'); });
|
|
30158
30719
|
const rawProvider = await EthereumProvider.init({
|
|
30159
30720
|
...restParameters,
|
|
30160
30721
|
disableProviderPing: true,
|
|
@@ -30384,8 +30945,6 @@ const useSigner = ({ chain }) => {
|
|
|
30384
30945
|
return isXrplSignerReady;
|
|
30385
30946
|
case squidTypes.ChainType.STELLAR:
|
|
30386
30947
|
return isStellarSignerReady;
|
|
30387
|
-
case squidTypes.ChainType.CANTON:
|
|
30388
|
-
return false;
|
|
30389
30948
|
}
|
|
30390
30949
|
}, [
|
|
30391
30950
|
chain?.chainType,
|
|
@@ -30835,21 +31394,21 @@ const useSendTransactionStore = zustand.create((set, get) => ({
|
|
|
30835
31394
|
|
|
30836
31395
|
const useDepositAddressStore = zustand.create((set) => ({
|
|
30837
31396
|
deposit: null,
|
|
30838
|
-
|
|
31397
|
+
isEnabled: false,
|
|
30839
31398
|
setDeposit: (data) => {
|
|
30840
31399
|
set({ deposit: data });
|
|
30841
31400
|
},
|
|
30842
|
-
|
|
30843
|
-
set({
|
|
31401
|
+
toggleDepositFlow: (enabled) => {
|
|
31402
|
+
set({ isEnabled: enabled });
|
|
30844
31403
|
},
|
|
30845
31404
|
}));
|
|
30846
31405
|
|
|
30847
31406
|
function useDepositAddress(squidRoute) {
|
|
30848
|
-
const {
|
|
30849
|
-
|
|
31407
|
+
const { isEnabled, depositAddress } = useDepositAddressStore((state) => ({
|
|
31408
|
+
isEnabled: state.isEnabled,
|
|
30850
31409
|
depositAddress: state.deposit?.depositAddress,
|
|
30851
31410
|
}));
|
|
30852
|
-
const { setDeposit,
|
|
31411
|
+
const { setDeposit, toggleDepositFlow, deposit } = useDepositAddressStore();
|
|
30853
31412
|
const { squid } = useSquidStore();
|
|
30854
31413
|
const { fromChain } = useSwap();
|
|
30855
31414
|
const isAvailableAsPaymentMethod = React.useMemo(() => {
|
|
@@ -30858,7 +31417,6 @@ function useDepositAddress(squidRoute) {
|
|
|
30858
31417
|
const chainsSupportingDepositAddress = [
|
|
30859
31418
|
CHAIN_IDS.BITCOIN,
|
|
30860
31419
|
CHAIN_IDS.SOLANA,
|
|
30861
|
-
CHAIN_IDS.CANTON,
|
|
30862
31420
|
];
|
|
30863
31421
|
return chainsSupportingDepositAddress.includes(fromChain.chainId);
|
|
30864
31422
|
}, [fromChain?.chainId]);
|
|
@@ -30866,50 +31424,34 @@ function useDepositAddress(squidRoute) {
|
|
|
30866
31424
|
return (squidRoute?.transactionRequest?.type ===
|
|
30867
31425
|
squidTypes.SquidDataType.ChainflipDepositAddress);
|
|
30868
31426
|
}, [squidRoute?.transactionRequest?.type]);
|
|
30869
|
-
|
|
30870
|
-
|
|
30871
|
-
|
|
30872
|
-
|
|
30873
|
-
|
|
30874
|
-
|
|
30875
|
-
: "connectedWallet";
|
|
30876
|
-
const isDepositAddressActive = paymentMethod === "depositAddress";
|
|
31427
|
+
const enable = React.useCallback(() => {
|
|
31428
|
+
toggleDepositFlow(true);
|
|
31429
|
+
}, [toggleDepositFlow]);
|
|
31430
|
+
const disable = React.useCallback(() => {
|
|
31431
|
+
toggleDepositFlow(false);
|
|
31432
|
+
}, [toggleDepositFlow]);
|
|
30877
31433
|
const closeDepositChannel = React.useCallback(() => {
|
|
31434
|
+
toggleDepositFlow(false);
|
|
30878
31435
|
setDeposit(null);
|
|
30879
|
-
}, [setDeposit]);
|
|
31436
|
+
}, [toggleDepositFlow, setDeposit]);
|
|
30880
31437
|
const getRouteWithDeposit = reactQuery.useMutation(async ({ route }) => {
|
|
30881
|
-
if (!squid
|
|
30882
|
-
throw new Error("
|
|
30883
|
-
|
|
30884
|
-
|
|
30885
|
-
|
|
30886
|
-
|
|
30887
|
-
|
|
30888
|
-
|
|
30889
|
-
|
|
30890
|
-
|
|
30891
|
-
statusTrackingId: depositAddressResponse.chainflipStatusTrackingId,
|
|
30892
|
-
});
|
|
30893
|
-
return;
|
|
30894
|
-
}
|
|
30895
|
-
else if (isDepositAddressDirectTransferRoute(route.transactionRequest)) {
|
|
30896
|
-
const orderHash = route.transactionRequest.data;
|
|
30897
|
-
setDeposit({
|
|
30898
|
-
amount: route.params.fromAmount ?? "",
|
|
30899
|
-
depositAddress: route.transactionRequest.target,
|
|
30900
|
-
// Squid Scan indexes the Canton tx by the orderHash
|
|
30901
|
-
statusTrackingId: orderHash,
|
|
30902
|
-
memo: orderHash,
|
|
30903
|
-
});
|
|
30904
|
-
return;
|
|
30905
|
-
}
|
|
31438
|
+
if (!squid)
|
|
31439
|
+
throw new Error("Squid SDK not initialized");
|
|
31440
|
+
const depositAddressResponse = (await squid.executeRoute({
|
|
31441
|
+
signer: {},
|
|
31442
|
+
route,
|
|
31443
|
+
}));
|
|
31444
|
+
setDeposit(depositAddressResponse);
|
|
31445
|
+
return {
|
|
31446
|
+
depositAddress: depositAddressResponse,
|
|
31447
|
+
};
|
|
30906
31448
|
});
|
|
30907
31449
|
return {
|
|
30908
|
-
|
|
30909
|
-
isDepositAddressActive,
|
|
31450
|
+
isEnabled,
|
|
30910
31451
|
isAvailableAsPaymentMethod,
|
|
30911
31452
|
swapWillGenerateDepositAddress,
|
|
30912
|
-
|
|
31453
|
+
enable,
|
|
31454
|
+
disable,
|
|
30913
31455
|
getRouteWithDeposit,
|
|
30914
31456
|
depositAddress,
|
|
30915
31457
|
closeDepositChannel,
|
|
@@ -30941,7 +31483,7 @@ const useUrlSwapParams = () => {
|
|
|
30941
31483
|
|
|
30942
31484
|
const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, queryOptions, }) => {
|
|
30943
31485
|
const { evmChains, cosmosChains, suiChains, xrplChains, stellarChains } = useSquidChains(direction);
|
|
30944
|
-
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens,
|
|
31486
|
+
const { evmTokens, cosmosTokens, solanaTokens, bitcoinTokens, suiTokens, xrplTokens, stellarTokens, } = useSquidTokens(direction);
|
|
30945
31487
|
const { keplrTypeWallet } = useCosmosContext();
|
|
30946
31488
|
const placeholderData = React.useMemo(() => {
|
|
30947
31489
|
const tokens = {
|
|
@@ -30952,7 +31494,6 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30952
31494
|
[squidTypes.ChainType.SUI]: suiTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30953
31495
|
[squidTypes.ChainType.XRPL]: xrplTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30954
31496
|
[squidTypes.ChainType.STELLAR]: stellarTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30955
|
-
[squidTypes.ChainType.CANTON]: cantonTokens.map((t) => ({ ...t, balance: "0" })),
|
|
30956
31497
|
};
|
|
30957
31498
|
if (!chainType) {
|
|
30958
31499
|
// Return all tokens with zero balance
|
|
@@ -30974,7 +31515,6 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30974
31515
|
suiTokens,
|
|
30975
31516
|
xrplTokens,
|
|
30976
31517
|
stellarTokens,
|
|
30977
|
-
cantonTokens,
|
|
30978
31518
|
]);
|
|
30979
31519
|
const isQueryEnabled = React.useMemo(() => {
|
|
30980
31520
|
// Respect the queryOptions.enabled override if provided
|
|
@@ -30997,8 +31537,6 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
30997
31537
|
return xrplTokens.length > 0;
|
|
30998
31538
|
case squidTypes.ChainType.STELLAR:
|
|
30999
31539
|
return stellarTokens.length > 0;
|
|
31000
|
-
case squidTypes.ChainType.CANTON:
|
|
31001
|
-
return cantonTokens.length > 0;
|
|
31002
31540
|
}
|
|
31003
31541
|
}, [
|
|
31004
31542
|
chainType,
|
|
@@ -31011,7 +31549,6 @@ const useAllTokensWithBalanceForChainType = ({ chainType, address, direction, qu
|
|
|
31011
31549
|
suiTokens.length,
|
|
31012
31550
|
xrplTokens.length,
|
|
31013
31551
|
stellarTokens.length,
|
|
31014
|
-
cantonTokens.length,
|
|
31015
31552
|
]);
|
|
31016
31553
|
const query = reactQuery.useQuery(keys().allTokensBalance(address, chainType, direction), async () => {
|
|
31017
31554
|
// Return zero balances if no address
|
|
@@ -31121,12 +31658,6 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
31121
31658
|
direction,
|
|
31122
31659
|
queryOptions,
|
|
31123
31660
|
});
|
|
31124
|
-
const cantonBalancesQuery = useAllTokensWithBalanceForChainType({
|
|
31125
|
-
chainType: squidTypes.ChainType.CANTON,
|
|
31126
|
-
address: connectedAddresses?.[squidTypes.ChainType.CANTON],
|
|
31127
|
-
direction,
|
|
31128
|
-
queryOptions,
|
|
31129
|
-
});
|
|
31130
31661
|
// Create a map of chain type to balance query results
|
|
31131
31662
|
const balanceQueries = React.useMemo(() => ({
|
|
31132
31663
|
[squidTypes.ChainType.EVM]: evmBalancesQuery,
|
|
@@ -31136,7 +31667,6 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
31136
31667
|
[squidTypes.ChainType.SUI]: suiBalancesQuery,
|
|
31137
31668
|
[squidTypes.ChainType.XRPL]: xrplBalancesQuery,
|
|
31138
31669
|
[squidTypes.ChainType.STELLAR]: stellarBalancesQuery,
|
|
31139
|
-
[squidTypes.ChainType.CANTON]: cantonBalancesQuery,
|
|
31140
31670
|
}), [
|
|
31141
31671
|
evmBalancesQuery,
|
|
31142
31672
|
cosmosBalancesQuery,
|
|
@@ -31145,7 +31675,6 @@ const useAllConnectedWalletBalances = ({ direction, queryOptions = {
|
|
|
31145
31675
|
suiBalancesQuery,
|
|
31146
31676
|
xrplBalancesQuery,
|
|
31147
31677
|
stellarBalancesQuery,
|
|
31148
|
-
cantonBalancesQuery,
|
|
31149
31678
|
]);
|
|
31150
31679
|
// Combine all tokens from different chains
|
|
31151
31680
|
const allTokens = React.useMemo(() => Object.values(balanceQueries).flatMap((query) => query.data?.tokens ?? []), [balanceQueries]);
|
|
@@ -31245,9 +31774,6 @@ const useMultiChainBalance = ({ chain, token, userAddress, enabled = true, }) =>
|
|
|
31245
31774
|
return xrplBalance;
|
|
31246
31775
|
case squidTypes.ChainType.STELLAR:
|
|
31247
31776
|
return stellarBalance;
|
|
31248
|
-
case squidTypes.ChainType.CANTON:
|
|
31249
|
-
// TODO: implement canton balance fetching
|
|
31250
|
-
return "0";
|
|
31251
31777
|
}
|
|
31252
31778
|
}, [
|
|
31253
31779
|
chain?.chainType,
|
|
@@ -32356,9 +32882,6 @@ function useSendTransaction({ to, amount, token, chain, }) {
|
|
|
32356
32882
|
chain,
|
|
32357
32883
|
});
|
|
32358
32884
|
break;
|
|
32359
|
-
case squidTypes.ChainType.CANTON: {
|
|
32360
|
-
throw new Error("Not implemented");
|
|
32361
|
-
}
|
|
32362
32885
|
}
|
|
32363
32886
|
return {
|
|
32364
32887
|
amount,
|
|
@@ -32562,8 +33085,6 @@ async function getSendTransactionStatus({ chain, txHash, }) {
|
|
|
32562
33085
|
txHash,
|
|
32563
33086
|
chain,
|
|
32564
33087
|
});
|
|
32565
|
-
case squidTypes.ChainType.CANTON:
|
|
32566
|
-
throw new Error("Not implemented");
|
|
32567
33088
|
}
|
|
32568
33089
|
}
|
|
32569
33090
|
|
|
@@ -32587,7 +33108,7 @@ const useHistory = (txType) => {
|
|
|
32587
33108
|
fromChain: tx.params.fromChain,
|
|
32588
33109
|
fromToken: tx.params.fromToken,
|
|
32589
33110
|
fromAddress: tx.params.fromAddress,
|
|
32590
|
-
fromAmount: tx.params.fromAmount
|
|
33111
|
+
fromAmount: tx.params.fromAmount,
|
|
32591
33112
|
toChain: tx.params.toChain,
|
|
32592
33113
|
toToken: tx.params.toToken,
|
|
32593
33114
|
toAddress: tx.params.toAddress,
|
|
@@ -33015,129 +33536,6 @@ const useApproval = ({ squidRoute, }) => {
|
|
|
33015
33536
|
};
|
|
33016
33537
|
};
|
|
33017
33538
|
|
|
33018
|
-
const useSwapStatusQuery = ({ transaction, retry = 25, refetchOnWindowFocus = "always", enabled = true, onStatus, onEndStatus, onNotFound, onError, }) => {
|
|
33019
|
-
const config = useConfigStore((state) => state.config);
|
|
33020
|
-
const isInitialized = useConfigStore((state) => state.isInitialized);
|
|
33021
|
-
const [isTransactionComplete, setIsTransactionComplete] = React.useState(false);
|
|
33022
|
-
const [refetchInterval, setRefetchInterval] = React.useState(getSwapTxStatusRefetchInterval(transaction));
|
|
33023
|
-
const { getChainType } = useSquidChains();
|
|
33024
|
-
const fetchTransactionStatusWithLatestConfig = React.useCallback(async () => {
|
|
33025
|
-
const latestConfig = useConfigStore.getState().config;
|
|
33026
|
-
return fetchSwapTransactionStatus({
|
|
33027
|
-
transaction,
|
|
33028
|
-
integratorId: latestConfig.integratorId,
|
|
33029
|
-
apiUrl: latestConfig.apiUrl,
|
|
33030
|
-
});
|
|
33031
|
-
}, [transaction]);
|
|
33032
|
-
const transactionStatusQuery = reactQuery.useQuery(keys().swapTransactionStatus(transaction?.transactionId), fetchTransactionStatusWithLatestConfig, {
|
|
33033
|
-
enabled: enabled &&
|
|
33034
|
-
transaction?.transactionId !== "0" &&
|
|
33035
|
-
!!transaction?.transactionId &&
|
|
33036
|
-
!!transaction.fromAddress &&
|
|
33037
|
-
!!config.apiUrl &&
|
|
33038
|
-
transaction !== undefined &&
|
|
33039
|
-
!isTransactionComplete &&
|
|
33040
|
-
isInitialized,
|
|
33041
|
-
refetchInterval(statusResponse) {
|
|
33042
|
-
if (statusResponse &&
|
|
33043
|
-
transactionEndStatuses.includes(getTransactionStatus(statusResponse) ?? "")) {
|
|
33044
|
-
return false;
|
|
33045
|
-
}
|
|
33046
|
-
return refetchInterval;
|
|
33047
|
-
},
|
|
33048
|
-
retryDelay: getChainType(transaction?.fromChain) === squidTypes.ChainType.COSMOS ? 5000 : 3000,
|
|
33049
|
-
retry: getChainType(transaction?.fromChain) === squidTypes.ChainType.COSMOS ? 6 : retry,
|
|
33050
|
-
refetchOnWindowFocus,
|
|
33051
|
-
onSuccess: (statusResponse) => {
|
|
33052
|
-
WidgetEvents.getInstance().dispatchSwapStatus(statusResponse.squidTransactionStatus ?? "");
|
|
33053
|
-
onStatus?.({
|
|
33054
|
-
status: getTransactionStatus(statusResponse) ?? "",
|
|
33055
|
-
statusResponse,
|
|
33056
|
-
});
|
|
33057
|
-
const endStatus = getTransactionEndStatus({ statusResponse });
|
|
33058
|
-
if (endStatus) {
|
|
33059
|
-
setIsTransactionComplete(true);
|
|
33060
|
-
onEndStatus?.({ status: endStatus, statusResponse });
|
|
33061
|
-
}
|
|
33062
|
-
},
|
|
33063
|
-
onError: (error) => {
|
|
33064
|
-
if (is404Error(error.cause)) {
|
|
33065
|
-
onNotFound?.();
|
|
33066
|
-
return;
|
|
33067
|
-
}
|
|
33068
|
-
setRefetchInterval(-1);
|
|
33069
|
-
setIsTransactionComplete(true);
|
|
33070
|
-
onError?.();
|
|
33071
|
-
},
|
|
33072
|
-
});
|
|
33073
|
-
return {
|
|
33074
|
-
transactionStatusQuery,
|
|
33075
|
-
};
|
|
33076
|
-
};
|
|
33077
|
-
|
|
33078
|
-
// Statuses that indicate the source deposit has been received and the swap is
|
|
33079
|
-
// now progressing — the point at which it becomes a history-backed transaction.
|
|
33080
|
-
const sourceReceivedStatuses = [
|
|
33081
|
-
// Chainflip
|
|
33082
|
-
"DEPOSIT_RECEIVED",
|
|
33083
|
-
"BROADCAST_REQUESTED",
|
|
33084
|
-
"COMPLETE",
|
|
33085
|
-
// Canton (Squid Intents)
|
|
33086
|
-
"awaiting",
|
|
33087
|
-
"success",
|
|
33088
|
-
];
|
|
33089
|
-
/**
|
|
33090
|
-
* Tracks a generated deposit address before it becomes a persisted swap history item.
|
|
33091
|
-
*
|
|
33092
|
-
* Mirrors the hooks-first pattern of `useExecuteTransaction`: once the source deposit
|
|
33093
|
-
* is received, it registers the transaction in the transaction + history stores, then
|
|
33094
|
-
* signals the view (via `onReceived`) to navigate. The view never writes to the stores.
|
|
33095
|
-
*/
|
|
33096
|
-
const useDepositTransactionStatus = ({ transaction, route, retry = 25, refetchOnWindowFocus = "always", enabled = true, onReceived, }) => {
|
|
33097
|
-
const { fromChain, toChain } = useSwap();
|
|
33098
|
-
const { addSwapTransaction } = useHistory();
|
|
33099
|
-
const getTransaction = useTransactionStore((state) => state.getTransaction);
|
|
33100
|
-
const setTransactionStoreState = useTransactionStore((state) => state.setTransactionState);
|
|
33101
|
-
return useSwapStatusQuery({
|
|
33102
|
-
transaction,
|
|
33103
|
-
retry,
|
|
33104
|
-
refetchOnWindowFocus,
|
|
33105
|
-
enabled,
|
|
33106
|
-
onStatus: ({ status }) => {
|
|
33107
|
-
if (!sourceReceivedStatuses.includes(status))
|
|
33108
|
-
return;
|
|
33109
|
-
if (!transaction?.transactionId || !route?.transactionRequest)
|
|
33110
|
-
return;
|
|
33111
|
-
const txLocalId = transaction.transactionId;
|
|
33112
|
-
if (getTransaction(txLocalId))
|
|
33113
|
-
return;
|
|
33114
|
-
useTransactionStore.setState({
|
|
33115
|
-
txLocalId,
|
|
33116
|
-
currentTransaction: undefined,
|
|
33117
|
-
});
|
|
33118
|
-
const tx = {
|
|
33119
|
-
routeType: route.transactionRequest.type,
|
|
33120
|
-
fromChain,
|
|
33121
|
-
toChain,
|
|
33122
|
-
fromAddress: transaction.fromAddress,
|
|
33123
|
-
transactionId: txLocalId,
|
|
33124
|
-
transactionIdForStatus: transaction.transactionIdForStatus,
|
|
33125
|
-
quoteId: transaction.quoteId ?? "",
|
|
33126
|
-
status: exports.TransactionStatus.ONGOING,
|
|
33127
|
-
sourceStatus: exports.TransactionStatus.SUCCESS,
|
|
33128
|
-
timestamp: Date.now(),
|
|
33129
|
-
};
|
|
33130
|
-
setTransactionStoreState(txLocalId, tx);
|
|
33131
|
-
addSwapTransaction({
|
|
33132
|
-
...tx,
|
|
33133
|
-
params: route.params,
|
|
33134
|
-
estimate: route.estimate,
|
|
33135
|
-
});
|
|
33136
|
-
onReceived?.();
|
|
33137
|
-
},
|
|
33138
|
-
});
|
|
33139
|
-
};
|
|
33140
|
-
|
|
33141
33539
|
const DEFAULT_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/assets/main/images/webp128/providers/squid.webp";
|
|
33142
33540
|
const AXELAR_PROVIDER_IMAGE_URL = "https://raw.githubusercontent.com/0xsquid/assets/main/images/webp128/providers/axelar.webp";
|
|
33143
33541
|
const useEstimate = (squidRoute) => {
|
|
@@ -34197,13 +34595,13 @@ function bytesFromBase64(b64) {
|
|
|
34197
34595
|
return arr;
|
|
34198
34596
|
}
|
|
34199
34597
|
helpers.bytesFromBase64 = bytesFromBase64;
|
|
34200
|
-
const btoa = globalThis$1.btoa || ((bin) => globalThis$1.Buffer.from(bin, "binary").toString("base64"));
|
|
34598
|
+
const btoa$1 = globalThis$1.btoa || ((bin) => globalThis$1.Buffer.from(bin, "binary").toString("base64"));
|
|
34201
34599
|
function base64FromBytes(arr) {
|
|
34202
34600
|
const bin = [];
|
|
34203
34601
|
arr.forEach((byte) => {
|
|
34204
34602
|
bin.push(String.fromCharCode(byte));
|
|
34205
34603
|
});
|
|
34206
|
-
return btoa(bin.join(""));
|
|
34604
|
+
return btoa$1(bin.join(""));
|
|
34207
34605
|
}
|
|
34208
34606
|
helpers.base64FromBytes = base64FromBytes;
|
|
34209
34607
|
function omitDefault(input) {
|
|
@@ -36456,7 +36854,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36456
36854
|
if (!route.params.fromAddress || !route.params.toAddress) {
|
|
36457
36855
|
throw new Error("From or to address is required");
|
|
36458
36856
|
}
|
|
36459
|
-
const isDirectTransfer =
|
|
36857
|
+
const isDirectTransfer = isDepositRoute(route);
|
|
36460
36858
|
// Means it's a transfer to a deposit address
|
|
36461
36859
|
// Instead of a Swap/Contract call using a DEX like Jupiter
|
|
36462
36860
|
if (isDirectTransfer) {
|
|
@@ -36467,7 +36865,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36467
36865
|
throw new Error("Deposit address is required");
|
|
36468
36866
|
}
|
|
36469
36867
|
const signature = await executeSolanaTransfer({
|
|
36470
|
-
amount: BigInt(route.params.fromAmount
|
|
36868
|
+
amount: BigInt(route.params.fromAmount),
|
|
36471
36869
|
target: depositData.depositAddress,
|
|
36472
36870
|
signer: solanaSigner,
|
|
36473
36871
|
connection: solanaConnection,
|
|
@@ -36477,7 +36875,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36477
36875
|
const txParams = setTransactionState({
|
|
36478
36876
|
route,
|
|
36479
36877
|
txHash,
|
|
36480
|
-
transactionIdForStatus: depositData.
|
|
36878
|
+
transactionIdForStatus: depositData.chainflipStatusTrackingId,
|
|
36481
36879
|
userAddress: sourceUserAddress,
|
|
36482
36880
|
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
36483
36881
|
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
@@ -36528,7 +36926,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36528
36926
|
}
|
|
36529
36927
|
});
|
|
36530
36928
|
const swapMutationBitcoin = reactQuery.useMutation(async ({ id, route }) => {
|
|
36531
|
-
const { depositAddress, amount: sendAmount,
|
|
36929
|
+
const { depositAddress, amount: sendAmount, chainflipStatusTrackingId, } = useDepositAddressStore.getState().deposit ?? {};
|
|
36532
36930
|
if (!depositAddress) {
|
|
36533
36931
|
throw new Error(`Invalid deposit address: ${depositAddress}`);
|
|
36534
36932
|
}
|
|
@@ -36551,7 +36949,7 @@ const useExecuteTransaction = (squidRoute) => {
|
|
|
36551
36949
|
txHash,
|
|
36552
36950
|
// When bridging from Bitcoin we need to send the chainflipId to the status endpoint
|
|
36553
36951
|
// instead of the Bitcoin transaction hash
|
|
36554
|
-
transactionIdForStatus:
|
|
36952
|
+
transactionIdForStatus: chainflipStatusTrackingId,
|
|
36555
36953
|
userAddress: sourceUserAddress,
|
|
36556
36954
|
status: exports.TransactionStatus.INITIAL_LOADING,
|
|
36557
36955
|
sourceStatus: exports.TransactionStatus.ONGOING,
|
|
@@ -36999,7 +37397,7 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
36999
37397
|
const squid = useSquidStore((state) => state.squid);
|
|
37000
37398
|
const fallbackAddress = useSwapRoutePersistStore((store) => store.swapRoute?.fallbackAddress);
|
|
37001
37399
|
const depositRefundAddress = useSwapRoutePersistStore((store) => store.swapRoute?.depositRefundAddress);
|
|
37002
|
-
const {
|
|
37400
|
+
const { isAvailableAsPaymentMethod, isEnabled: isDepositAddressEnabled } = useDepositAddress();
|
|
37003
37401
|
const getRouteMutation = useGetRoute();
|
|
37004
37402
|
const { fromChain, toChain, fromPrice, destinationAddress: { address: destinationAddress } = {}, fromToken, toToken, } = useSwap();
|
|
37005
37403
|
const { connectedAddress: { address: sourceConnectedAddress }, } = useMultiChainWallet(fromChain);
|
|
@@ -37007,7 +37405,7 @@ refetchIntervalInBackground = false, refetchInterval = 30000, quoteOnly = true,
|
|
|
37007
37405
|
// Tokens will be sent to this address in case of swap failure
|
|
37008
37406
|
//
|
|
37009
37407
|
// If deposit address is not selected, we use the connected address as the source address instead
|
|
37010
|
-
const sourceUserAddress =
|
|
37408
|
+
const sourceUserAddress = isDepositAddressEnabled && isAvailableAsPaymentMethod
|
|
37011
37409
|
? depositRefundAddress ?? sourceConnectedAddress
|
|
37012
37410
|
: sourceConnectedAddress;
|
|
37013
37411
|
const squidRouteQueryKeys = React.useMemo(() => keys().transaction(fromChain?.chainId, toChain?.chainId, toToken?.address, fromToken?.address, fromPrice, config.slippage, sourceUserAddress, config.degenMode, destinationAddress, fallbackAddress, quoteOnly, fromChain?.chainType, config.preHook, config.postHook, config.overrideGasRefundAddress), [
|
|
@@ -37152,50 +37550,94 @@ function useSendTransactionStatus({ chain, txHash, }) {
|
|
|
37152
37550
|
* Fetch status of a Swap transaction
|
|
37153
37551
|
*/
|
|
37154
37552
|
const useSwapTransactionStatus = ({ transaction, retry = 25, refetchOnWindowFocus = "always", enabled = true, }) => {
|
|
37553
|
+
const config = useConfigStore((state) => state.config);
|
|
37554
|
+
const isInitialized = useConfigStore((state) => state.isInitialized);
|
|
37155
37555
|
const { replaceSwapTransactionStatus } = useHistory();
|
|
37156
37556
|
const findTransaction = useHistoryStore((state) => state.findTransaction);
|
|
37557
|
+
const [isTransactionComplete, setIsTransactionComplete] = React.useState(false);
|
|
37558
|
+
const [refetchInterval, setRefetchInterval] = React.useState(getSwapTxStatusRefetchInterval(transaction));
|
|
37559
|
+
const { getChainType } = useSquidChains();
|
|
37157
37560
|
const currentHistoryItem = React.useMemo(() => findTransaction({
|
|
37158
37561
|
transactionId: transaction?.transactionId,
|
|
37159
37562
|
txType: exports.HistoryTxType.SWAP,
|
|
37160
37563
|
}), [findTransaction, transaction?.transactionId]);
|
|
37161
|
-
|
|
37162
|
-
|
|
37163
|
-
|
|
37164
|
-
|
|
37564
|
+
/**
|
|
37565
|
+
* Transaction status endpoint
|
|
37566
|
+
* Squid api is using axelar endpoint and parsing the response
|
|
37567
|
+
* @returns {StatusResponse} Status response
|
|
37568
|
+
*/
|
|
37569
|
+
const fetchTransactionStatusWithLatestConfig = React.useCallback(async () => {
|
|
37570
|
+
const latestConfig = useConfigStore.getState().config;
|
|
37571
|
+
return fetchSwapTransactionStatus({
|
|
37572
|
+
transaction,
|
|
37573
|
+
integratorId: latestConfig.integratorId,
|
|
37574
|
+
apiUrl: latestConfig.apiUrl,
|
|
37575
|
+
});
|
|
37576
|
+
}, [transaction]);
|
|
37577
|
+
const transactionStatusQuery = reactQuery.useQuery(keys().swapTransactionStatus(transaction?.transactionId), fetchTransactionStatusWithLatestConfig, {
|
|
37165
37578
|
enabled: enabled &&
|
|
37579
|
+
transaction?.transactionId !== "0" &&
|
|
37580
|
+
!!transaction?.transactionId &&
|
|
37581
|
+
!!transaction.fromAddress &&
|
|
37582
|
+
!!config.apiUrl &&
|
|
37583
|
+
transaction !== undefined &&
|
|
37584
|
+
!isTransactionComplete &&
|
|
37585
|
+
isInitialized &&
|
|
37166
37586
|
!!currentHistoryItem &&
|
|
37167
37587
|
!isHistoryTransactionEnded({
|
|
37168
37588
|
data: currentHistoryItem?.data,
|
|
37169
37589
|
txType: exports.HistoryTxType.SWAP,
|
|
37170
37590
|
}),
|
|
37171
|
-
|
|
37172
|
-
|
|
37173
|
-
|
|
37174
|
-
|
|
37175
|
-
|
|
37176
|
-
statusResponse
|
|
37177
|
-
|
|
37178
|
-
}
|
|
37591
|
+
refetchInterval(statusResponse) {
|
|
37592
|
+
// If the status response is something telling that the transaction
|
|
37593
|
+
// is finished, then store transaction history state if success
|
|
37594
|
+
// And return false to indicate refetcher to stop
|
|
37595
|
+
if (statusResponse &&
|
|
37596
|
+
transactionEndStatuses.includes(getTransactionStatus(statusResponse) ?? "")) {
|
|
37597
|
+
return false;
|
|
37598
|
+
}
|
|
37599
|
+
return refetchInterval; // Had to handle a variable here because after onError, we want the interval to stop
|
|
37179
37600
|
},
|
|
37180
|
-
|
|
37181
|
-
|
|
37182
|
-
|
|
37183
|
-
|
|
37184
|
-
|
|
37185
|
-
|
|
37186
|
-
|
|
37187
|
-
});
|
|
37601
|
+
// At the moment Cosmos indexing takes more time, so need more time between retries
|
|
37602
|
+
retryDelay: getChainType(transaction?.fromChain) === squidTypes.ChainType.COSMOS ? 5000 : 3000,
|
|
37603
|
+
retry: getChainType(transaction?.fromChain) === squidTypes.ChainType.COSMOS ? 6 : retry,
|
|
37604
|
+
refetchOnWindowFocus,
|
|
37605
|
+
onSuccess: (statusResponse) => {
|
|
37606
|
+
// Dispatch event
|
|
37607
|
+
WidgetEvents.getInstance().dispatchSwapStatus(statusResponse.squidTransactionStatus ?? "");
|
|
37608
|
+
const endStatus = getTransactionEndStatus({ statusResponse });
|
|
37609
|
+
if (endStatus && transaction?.transactionId) {
|
|
37610
|
+
setIsTransactionComplete(true);
|
|
37611
|
+
replaceSwapTransactionStatus({
|
|
37612
|
+
transactionId: transaction.transactionId,
|
|
37613
|
+
statusResponse,
|
|
37614
|
+
status: endStatus,
|
|
37615
|
+
});
|
|
37616
|
+
}
|
|
37188
37617
|
},
|
|
37189
|
-
onError: () => {
|
|
37618
|
+
onError: (error) => {
|
|
37619
|
+
// `fetchTransactionStatus` throws an error with a cause being an AxiosError
|
|
37620
|
+
const is404 = is404Error(error.cause);
|
|
37190
37621
|
if (!transaction?.transactionId)
|
|
37191
37622
|
return;
|
|
37192
|
-
|
|
37193
|
-
|
|
37194
|
-
|
|
37195
|
-
|
|
37196
|
-
|
|
37623
|
+
if (is404) {
|
|
37624
|
+
replaceSwapTransactionStatus({
|
|
37625
|
+
transactionId: transaction.transactionId,
|
|
37626
|
+
statusResponse: undefined,
|
|
37627
|
+
status: exports.TransactionStatus.NOT_FOUND,
|
|
37628
|
+
});
|
|
37629
|
+
}
|
|
37630
|
+
else {
|
|
37631
|
+
setRefetchInterval(-1);
|
|
37632
|
+
setIsTransactionComplete(true);
|
|
37633
|
+
replaceSwapTransactionStatus({
|
|
37634
|
+
transactionId: transaction.transactionId,
|
|
37635
|
+
statusResponse: undefined,
|
|
37636
|
+
status: exports.TransactionStatus.ERROR,
|
|
37637
|
+
});
|
|
37638
|
+
}
|
|
37197
37639
|
},
|
|
37198
|
-
})
|
|
37640
|
+
});
|
|
37199
37641
|
return {
|
|
37200
37642
|
transactionStatusQuery,
|
|
37201
37643
|
latestStatus: transactionStatusQuery.data
|
|
@@ -37406,6 +37848,430 @@ const useIntegratorContext = () => {
|
|
|
37406
37848
|
return { walletHandledExternally, isEmbed, widgetInIframe };
|
|
37407
37849
|
};
|
|
37408
37850
|
|
|
37851
|
+
function wrapSignatureError({ chainType, message, error, }) {
|
|
37852
|
+
if (error instanceof WalletVerificationSignatureError) {
|
|
37853
|
+
throw error;
|
|
37854
|
+
}
|
|
37855
|
+
throw new WalletVerificationSignatureError({
|
|
37856
|
+
code: exports.WalletVerificationSignatureErrorCode.SIGNATURE_REJECTED,
|
|
37857
|
+
chainType,
|
|
37858
|
+
message,
|
|
37859
|
+
cause: error,
|
|
37860
|
+
});
|
|
37861
|
+
}
|
|
37862
|
+
function getEvmAddress({ connectedWallets, walletClient, wagmiAddress, }) {
|
|
37863
|
+
return (connectedWallets[squidTypes.ChainType.EVM].address ??
|
|
37864
|
+
walletClient?.account?.address ??
|
|
37865
|
+
wagmiAddress);
|
|
37866
|
+
}
|
|
37867
|
+
|
|
37868
|
+
function createBitcoinWalletVerificationSigner({ connectedWallets, }) {
|
|
37869
|
+
const bitcoinWallet = connectedWallets[squidTypes.ChainType.BTC].wallet;
|
|
37870
|
+
return {
|
|
37871
|
+
sign: async ({ message }) => {
|
|
37872
|
+
const bitcoinAddress = connectedWallets[squidTypes.ChainType.BTC].address;
|
|
37873
|
+
const bitcoinConnector = bitcoinWallet?.connector;
|
|
37874
|
+
const signMessage = bitcoinConnector?.signMessage;
|
|
37875
|
+
if (!bitcoinAddress) {
|
|
37876
|
+
throw new WalletVerificationSignatureError({
|
|
37877
|
+
code: exports.WalletVerificationSignatureErrorCode.WALLET_NOT_CONNECTED,
|
|
37878
|
+
chainType: squidTypes.ChainType.BTC,
|
|
37879
|
+
message: "Connect a Bitcoin wallet before signing verification messages.",
|
|
37880
|
+
});
|
|
37881
|
+
}
|
|
37882
|
+
if (typeof signMessage !== "function") {
|
|
37883
|
+
throw new WalletVerificationSignatureError({
|
|
37884
|
+
code: exports.WalletVerificationSignatureErrorCode.SIGNER_UNAVAILABLE,
|
|
37885
|
+
chainType: squidTypes.ChainType.BTC,
|
|
37886
|
+
message: "The connected Bitcoin wallet does not expose BIP-322 message signing.",
|
|
37887
|
+
});
|
|
37888
|
+
}
|
|
37889
|
+
try {
|
|
37890
|
+
const signature = await signMessage.call(bitcoinConnector, message);
|
|
37891
|
+
return buildBitcoinWalletVerificationSignatureResult({
|
|
37892
|
+
address: bitcoinAddress,
|
|
37893
|
+
message,
|
|
37894
|
+
signedPayload: bytesToBase64(encodeUtf8(message)),
|
|
37895
|
+
signature,
|
|
37896
|
+
signedPayloadEncoding: "base64",
|
|
37897
|
+
});
|
|
37898
|
+
}
|
|
37899
|
+
catch (error) {
|
|
37900
|
+
wrapSignatureError({
|
|
37901
|
+
chainType: squidTypes.ChainType.BTC,
|
|
37902
|
+
message: "Failed to sign Bitcoin wallet verification message.",
|
|
37903
|
+
error,
|
|
37904
|
+
});
|
|
37905
|
+
}
|
|
37906
|
+
},
|
|
37907
|
+
};
|
|
37908
|
+
}
|
|
37909
|
+
|
|
37910
|
+
function createCosmosWalletVerificationSigner({ connectedWallets, }) {
|
|
37911
|
+
const cosmosWallet = connectedWallets[squidTypes.ChainType.COSMOS].wallet;
|
|
37912
|
+
return {
|
|
37913
|
+
sign: async ({ message, chainId }) => {
|
|
37914
|
+
const cosmosAddress = connectedWallets[squidTypes.ChainType.COSMOS].address;
|
|
37915
|
+
const provider = cosmosWallet?.connector?.().provider;
|
|
37916
|
+
const signArbitrary = provider?.signArbitrary;
|
|
37917
|
+
const getKey = provider?.getKey;
|
|
37918
|
+
if (!cosmosAddress) {
|
|
37919
|
+
throw new WalletVerificationSignatureError({
|
|
37920
|
+
code: exports.WalletVerificationSignatureErrorCode.WALLET_NOT_CONNECTED,
|
|
37921
|
+
chainType: squidTypes.ChainType.COSMOS,
|
|
37922
|
+
message: "Connect a Cosmos wallet before signing verification messages.",
|
|
37923
|
+
});
|
|
37924
|
+
}
|
|
37925
|
+
if (typeof signArbitrary !== "function" || typeof getKey !== "function") {
|
|
37926
|
+
throw new WalletVerificationSignatureError({
|
|
37927
|
+
code: exports.WalletVerificationSignatureErrorCode.SIGNER_UNAVAILABLE,
|
|
37928
|
+
chainType: squidTypes.ChainType.COSMOS,
|
|
37929
|
+
message: "The connected Cosmos wallet does not expose ADR-36 message signing.",
|
|
37930
|
+
});
|
|
37931
|
+
}
|
|
37932
|
+
try {
|
|
37933
|
+
const [signed, key] = await Promise.all([
|
|
37934
|
+
signArbitrary.call(provider, chainId, cosmosAddress, message),
|
|
37935
|
+
getKey.call(provider, chainId),
|
|
37936
|
+
]);
|
|
37937
|
+
return buildCosmosWalletVerificationSignatureResult({
|
|
37938
|
+
address: cosmosAddress,
|
|
37939
|
+
message,
|
|
37940
|
+
signedPayload: bytesToBase64(encodeUtf8(message)),
|
|
37941
|
+
signature: signed.signature,
|
|
37942
|
+
publicKey: base64StringOrBytes(signed.pub_key?.value ?? key.pubKey),
|
|
37943
|
+
publicKeyEncoding: "base64",
|
|
37944
|
+
signedPayloadEncoding: "base64",
|
|
37945
|
+
});
|
|
37946
|
+
}
|
|
37947
|
+
catch (error) {
|
|
37948
|
+
wrapSignatureError({
|
|
37949
|
+
chainType: squidTypes.ChainType.COSMOS,
|
|
37950
|
+
message: "Failed to sign Cosmos wallet verification message.",
|
|
37951
|
+
error,
|
|
37952
|
+
});
|
|
37953
|
+
}
|
|
37954
|
+
},
|
|
37955
|
+
};
|
|
37956
|
+
}
|
|
37957
|
+
|
|
37958
|
+
function createEvmWalletVerificationSigner(params) {
|
|
37959
|
+
const { connectedWallets, walletClient, wagmiAddress } = params;
|
|
37960
|
+
return {
|
|
37961
|
+
sign: async ({ message }) => {
|
|
37962
|
+
const resolvedAddress = getEvmAddress({
|
|
37963
|
+
connectedWallets,
|
|
37964
|
+
walletClient,
|
|
37965
|
+
wagmiAddress,
|
|
37966
|
+
});
|
|
37967
|
+
if (!resolvedAddress) {
|
|
37968
|
+
throw new WalletVerificationSignatureError({
|
|
37969
|
+
code: exports.WalletVerificationSignatureErrorCode.WALLET_NOT_CONNECTED,
|
|
37970
|
+
chainType: squidTypes.ChainType.EVM,
|
|
37971
|
+
message: "Connect an EVM wallet before signing verification messages.",
|
|
37972
|
+
});
|
|
37973
|
+
}
|
|
37974
|
+
if (typeof walletClient?.signMessage !== "function") {
|
|
37975
|
+
throw new WalletVerificationSignatureError({
|
|
37976
|
+
code: exports.WalletVerificationSignatureErrorCode.SIGNER_UNAVAILABLE,
|
|
37977
|
+
chainType: squidTypes.ChainType.EVM,
|
|
37978
|
+
message: "The connected EVM wallet does not expose message signing.",
|
|
37979
|
+
});
|
|
37980
|
+
}
|
|
37981
|
+
try {
|
|
37982
|
+
const signature = await walletClient.signMessage({
|
|
37983
|
+
account: resolvedAddress,
|
|
37984
|
+
message,
|
|
37985
|
+
});
|
|
37986
|
+
return buildWalletVerificationSignatureResult({
|
|
37987
|
+
address: resolvedAddress,
|
|
37988
|
+
message,
|
|
37989
|
+
signature,
|
|
37990
|
+
});
|
|
37991
|
+
}
|
|
37992
|
+
catch (error) {
|
|
37993
|
+
wrapSignatureError({
|
|
37994
|
+
chainType: squidTypes.ChainType.EVM,
|
|
37995
|
+
message: "Failed to sign EVM wallet verification message.",
|
|
37996
|
+
error,
|
|
37997
|
+
});
|
|
37998
|
+
}
|
|
37999
|
+
},
|
|
38000
|
+
};
|
|
38001
|
+
}
|
|
38002
|
+
|
|
38003
|
+
function createSolanaWalletVerificationSigner({ connectedWallets, }) {
|
|
38004
|
+
const solanaWallet = connectedWallets[squidTypes.ChainType.SOLANA].wallet;
|
|
38005
|
+
return {
|
|
38006
|
+
sign: async ({ message }) => {
|
|
38007
|
+
const solanaAddress = connectedWallets[squidTypes.ChainType.SOLANA].address;
|
|
38008
|
+
const solanaConnector = solanaWallet?.connector;
|
|
38009
|
+
const [account] = solanaConnector?.wallet.accounts ?? [];
|
|
38010
|
+
const signMessage = solanaConnector?.wallet.features["solana:signMessage"]?.signMessage;
|
|
38011
|
+
if (!solanaAddress || !account) {
|
|
38012
|
+
throw new WalletVerificationSignatureError({
|
|
38013
|
+
code: exports.WalletVerificationSignatureErrorCode.WALLET_NOT_CONNECTED,
|
|
38014
|
+
chainType: squidTypes.ChainType.SOLANA,
|
|
38015
|
+
message: "Connect a Solana wallet before signing verification messages.",
|
|
38016
|
+
});
|
|
38017
|
+
}
|
|
38018
|
+
if (typeof signMessage !== "function") {
|
|
38019
|
+
throw new WalletVerificationSignatureError({
|
|
38020
|
+
code: exports.WalletVerificationSignatureErrorCode.SIGNER_UNAVAILABLE,
|
|
38021
|
+
chainType: squidTypes.ChainType.SOLANA,
|
|
38022
|
+
message: "The connected Solana wallet does not expose message signing.",
|
|
38023
|
+
});
|
|
38024
|
+
}
|
|
38025
|
+
try {
|
|
38026
|
+
const [signed] = await signMessage({
|
|
38027
|
+
account,
|
|
38028
|
+
message: encodeUtf8(message),
|
|
38029
|
+
});
|
|
38030
|
+
if (!signed) {
|
|
38031
|
+
throw new Error("Solana wallet did not return a signature.");
|
|
38032
|
+
}
|
|
38033
|
+
return buildSolanaWalletVerificationSignatureResult({
|
|
38034
|
+
address: solanaAddress,
|
|
38035
|
+
message,
|
|
38036
|
+
signedPayload: bytesToBase64(signed.signedMessage),
|
|
38037
|
+
signature: bytesToBase64(signed.signature),
|
|
38038
|
+
publicKey: account.address,
|
|
38039
|
+
publicKeyEncoding: "base58",
|
|
38040
|
+
signedPayloadEncoding: "base64",
|
|
38041
|
+
});
|
|
38042
|
+
}
|
|
38043
|
+
catch (error) {
|
|
38044
|
+
wrapSignatureError({
|
|
38045
|
+
chainType: squidTypes.ChainType.SOLANA,
|
|
38046
|
+
message: "Failed to sign Solana wallet verification message.",
|
|
38047
|
+
error,
|
|
38048
|
+
});
|
|
38049
|
+
}
|
|
38050
|
+
},
|
|
38051
|
+
};
|
|
38052
|
+
}
|
|
38053
|
+
|
|
38054
|
+
function createStellarWalletVerificationSigner({ connectedWallets, }) {
|
|
38055
|
+
const stellarWallet = connectedWallets[squidTypes.ChainType.STELLAR].wallet;
|
|
38056
|
+
return {
|
|
38057
|
+
sign: async ({ message, networkPassphrase }) => {
|
|
38058
|
+
const stellarAddress = connectedWallets[squidTypes.ChainType.STELLAR].address;
|
|
38059
|
+
const stellarConnector = stellarWallet?.connector;
|
|
38060
|
+
const signMessage = stellarConnector?.signMessage;
|
|
38061
|
+
if (!stellarAddress) {
|
|
38062
|
+
throw new WalletVerificationSignatureError({
|
|
38063
|
+
code: exports.WalletVerificationSignatureErrorCode.WALLET_NOT_CONNECTED,
|
|
38064
|
+
chainType: squidTypes.ChainType.STELLAR,
|
|
38065
|
+
message: "Connect a Stellar wallet before signing verification messages.",
|
|
38066
|
+
});
|
|
38067
|
+
}
|
|
38068
|
+
if (typeof signMessage !== "function") {
|
|
38069
|
+
throw new WalletVerificationSignatureError({
|
|
38070
|
+
code: exports.WalletVerificationSignatureErrorCode.SIGNER_UNAVAILABLE,
|
|
38071
|
+
chainType: squidTypes.ChainType.STELLAR,
|
|
38072
|
+
message: "The connected Stellar wallet does not expose message signing.",
|
|
38073
|
+
});
|
|
38074
|
+
}
|
|
38075
|
+
try {
|
|
38076
|
+
const network = networkPassphrase == null && stellarConnector?.getNetwork
|
|
38077
|
+
? await stellarConnector.getNetwork().catch(() => undefined)
|
|
38078
|
+
: undefined;
|
|
38079
|
+
const resolvedNetworkPassphrase = networkPassphrase ?? network?.networkPassphrase;
|
|
38080
|
+
const signedPayload = bytesToBase64(encodeUtf8(message));
|
|
38081
|
+
const signed = await signMessage.call(stellarConnector, signedPayload, {
|
|
38082
|
+
address: stellarAddress,
|
|
38083
|
+
networkPassphrase: resolvedNetworkPassphrase,
|
|
38084
|
+
});
|
|
38085
|
+
const resolvedSignerAddress = signed.signerAddress ??
|
|
38086
|
+
(await stellarConnector
|
|
38087
|
+
?.getAddress?.()
|
|
38088
|
+
.then(({ address }) => address)
|
|
38089
|
+
.catch(() => undefined));
|
|
38090
|
+
if (resolvedSignerAddress && resolvedSignerAddress !== stellarAddress) {
|
|
38091
|
+
throw new WalletVerificationSignatureError({
|
|
38092
|
+
code: exports.WalletVerificationSignatureErrorCode.ACTIVE_ACCOUNT_MISMATCH,
|
|
38093
|
+
chainType: squidTypes.ChainType.STELLAR,
|
|
38094
|
+
message: "The Stellar wallet signed with a different active account. Reconnect the Stellar wallet and try again.",
|
|
38095
|
+
});
|
|
38096
|
+
}
|
|
38097
|
+
return buildStellarWalletVerificationSignatureResult({
|
|
38098
|
+
address: stellarAddress,
|
|
38099
|
+
message,
|
|
38100
|
+
signedPayload,
|
|
38101
|
+
signature: normalizeBase64Ed25519Signature(signed.signedMessage),
|
|
38102
|
+
publicKey: resolvedSignerAddress ?? stellarAddress,
|
|
38103
|
+
publicKeyEncoding: "base32",
|
|
38104
|
+
signedPayloadEncoding: "base64",
|
|
38105
|
+
signerAddress: resolvedSignerAddress,
|
|
38106
|
+
});
|
|
38107
|
+
}
|
|
38108
|
+
catch (error) {
|
|
38109
|
+
wrapSignatureError({
|
|
38110
|
+
chainType: squidTypes.ChainType.STELLAR,
|
|
38111
|
+
message: "Failed to sign Stellar wallet verification message.",
|
|
38112
|
+
error,
|
|
38113
|
+
});
|
|
38114
|
+
}
|
|
38115
|
+
},
|
|
38116
|
+
};
|
|
38117
|
+
}
|
|
38118
|
+
|
|
38119
|
+
function createSuiWalletVerificationSigner({ connectedWallets, }) {
|
|
38120
|
+
const suiWallet = connectedWallets[squidTypes.ChainType.SUI].wallet;
|
|
38121
|
+
return {
|
|
38122
|
+
sign: async ({ message }) => {
|
|
38123
|
+
const suiAddress = connectedWallets[squidTypes.ChainType.SUI].address;
|
|
38124
|
+
const suiAccount = connectedWallets[squidTypes.ChainType.SUI].account;
|
|
38125
|
+
const signPersonalMessage = suiWallet?.connector.signPersonalMessage;
|
|
38126
|
+
if (!suiAddress || !suiAccount) {
|
|
38127
|
+
throw new WalletVerificationSignatureError({
|
|
38128
|
+
code: exports.WalletVerificationSignatureErrorCode.WALLET_NOT_CONNECTED,
|
|
38129
|
+
chainType: squidTypes.ChainType.SUI,
|
|
38130
|
+
message: "Connect a Sui wallet before signing verification messages.",
|
|
38131
|
+
});
|
|
38132
|
+
}
|
|
38133
|
+
if (typeof signPersonalMessage !== "function") {
|
|
38134
|
+
throw new WalletVerificationSignatureError({
|
|
38135
|
+
code: exports.WalletVerificationSignatureErrorCode.SIGNER_UNAVAILABLE,
|
|
38136
|
+
chainType: squidTypes.ChainType.SUI,
|
|
38137
|
+
message: "The connected Sui wallet does not expose personal message signing.",
|
|
38138
|
+
});
|
|
38139
|
+
}
|
|
38140
|
+
try {
|
|
38141
|
+
const signed = await signPersonalMessage({
|
|
38142
|
+
account: suiAccount,
|
|
38143
|
+
message: encodeUtf8(message),
|
|
38144
|
+
});
|
|
38145
|
+
return buildSuiWalletVerificationSignatureResult({
|
|
38146
|
+
address: suiAddress,
|
|
38147
|
+
message,
|
|
38148
|
+
signedPayload: signed.bytes,
|
|
38149
|
+
signature: signed.signature,
|
|
38150
|
+
publicKey: suiAccount.publicKey
|
|
38151
|
+
? bytesToBase64(suiAccount.publicKey)
|
|
38152
|
+
: undefined,
|
|
38153
|
+
publicKeyEncoding: "base64",
|
|
38154
|
+
signedPayloadEncoding: "base64",
|
|
38155
|
+
});
|
|
38156
|
+
}
|
|
38157
|
+
catch (error) {
|
|
38158
|
+
wrapSignatureError({
|
|
38159
|
+
chainType: squidTypes.ChainType.SUI,
|
|
38160
|
+
message: "Failed to sign Sui wallet verification message.",
|
|
38161
|
+
error,
|
|
38162
|
+
});
|
|
38163
|
+
}
|
|
38164
|
+
},
|
|
38165
|
+
};
|
|
38166
|
+
}
|
|
38167
|
+
|
|
38168
|
+
function createXrplWalletVerificationSigner({ connectedWallets, }) {
|
|
38169
|
+
const xrplWallet = connectedWallets[squidTypes.ChainType.XRPL].wallet;
|
|
38170
|
+
return {
|
|
38171
|
+
sign: async ({ message }) => {
|
|
38172
|
+
const xrplAddress = connectedWallets[squidTypes.ChainType.XRPL].address;
|
|
38173
|
+
const xrplConnector = xrplWallet?.connector;
|
|
38174
|
+
const signOwnershipMessage = xrplConnector?.signOwnershipMessage;
|
|
38175
|
+
if (!xrplAddress) {
|
|
38176
|
+
throw new WalletVerificationSignatureError({
|
|
38177
|
+
code: exports.WalletVerificationSignatureErrorCode.WALLET_NOT_CONNECTED,
|
|
38178
|
+
chainType: squidTypes.ChainType.XRPL,
|
|
38179
|
+
message: "Connect an XRPL wallet before signing verification messages.",
|
|
38180
|
+
});
|
|
38181
|
+
}
|
|
38182
|
+
if (typeof signOwnershipMessage !== "function") {
|
|
38183
|
+
throw new WalletVerificationSignatureError({
|
|
38184
|
+
code: exports.WalletVerificationSignatureErrorCode.SIGNER_UNAVAILABLE,
|
|
38185
|
+
chainType: squidTypes.ChainType.XRPL,
|
|
38186
|
+
message: "The connected XRPL wallet does not expose ownership message signing.",
|
|
38187
|
+
});
|
|
38188
|
+
}
|
|
38189
|
+
try {
|
|
38190
|
+
const signed = await signOwnershipMessage.call(xrplConnector, {
|
|
38191
|
+
address: xrplAddress,
|
|
38192
|
+
message,
|
|
38193
|
+
});
|
|
38194
|
+
return buildXrplWalletVerificationSignatureResult({
|
|
38195
|
+
address: xrplAddress,
|
|
38196
|
+
message,
|
|
38197
|
+
signedPayload: signed.signedPayload,
|
|
38198
|
+
signature: signed.signature,
|
|
38199
|
+
publicKey: signed.publicKey,
|
|
38200
|
+
publicKeyEncoding: signed.publicKeyEncoding,
|
|
38201
|
+
signedPayloadEncoding: signed.signedPayloadEncoding,
|
|
38202
|
+
signatureType: signed.signatureType,
|
|
38203
|
+
signerAddress: signed.signerAddress,
|
|
38204
|
+
});
|
|
38205
|
+
}
|
|
38206
|
+
catch (error) {
|
|
38207
|
+
wrapSignatureError({
|
|
38208
|
+
chainType: squidTypes.ChainType.XRPL,
|
|
38209
|
+
message: "Failed to sign XRPL wallet verification message.",
|
|
38210
|
+
error,
|
|
38211
|
+
});
|
|
38212
|
+
}
|
|
38213
|
+
},
|
|
38214
|
+
cancel: () => {
|
|
38215
|
+
xrplWallet?.connector.cancelSignOwnershipMessage?.();
|
|
38216
|
+
},
|
|
38217
|
+
};
|
|
38218
|
+
}
|
|
38219
|
+
|
|
38220
|
+
function createWalletVerificationSigners(params) {
|
|
38221
|
+
return {
|
|
38222
|
+
[squidTypes.ChainType.EVM]: createEvmWalletVerificationSigner(params),
|
|
38223
|
+
[squidTypes.ChainType.COSMOS]: createCosmosWalletVerificationSigner(params),
|
|
38224
|
+
[squidTypes.ChainType.BTC]: createBitcoinWalletVerificationSigner(params),
|
|
38225
|
+
[squidTypes.ChainType.SOLANA]: createSolanaWalletVerificationSigner(params),
|
|
38226
|
+
[squidTypes.ChainType.SUI]: createSuiWalletVerificationSigner(params),
|
|
38227
|
+
[squidTypes.ChainType.XRPL]: createXrplWalletVerificationSigner(params),
|
|
38228
|
+
[squidTypes.ChainType.STELLAR]: createStellarWalletVerificationSigner(params),
|
|
38229
|
+
};
|
|
38230
|
+
}
|
|
38231
|
+
|
|
38232
|
+
const useWalletVerificationSignature = () => {
|
|
38233
|
+
const connectedWallets = useWalletStore((store) => store.connectedWalletsByChainType);
|
|
38234
|
+
const { address: wagmiAddress, connector: activeConnector } = wagmi.useAccount();
|
|
38235
|
+
const evmWallet = connectedWallets[squidTypes.ChainType.EVM].wallet;
|
|
38236
|
+
const evmConnector = evmWallet?.connector ?? activeConnector;
|
|
38237
|
+
const { data: walletClient } = wagmi.useWalletClient({ connector: evmConnector });
|
|
38238
|
+
const signers = React.useMemo(() => createWalletVerificationSigners({
|
|
38239
|
+
connectedWallets,
|
|
38240
|
+
walletClient,
|
|
38241
|
+
wagmiAddress,
|
|
38242
|
+
}), [connectedWallets, wagmiAddress, walletClient]);
|
|
38243
|
+
const signVerificationMessage = React.useCallback(async (request) => {
|
|
38244
|
+
assertWalletVerificationSigningRequest(request);
|
|
38245
|
+
const signer = signers[request.chainType];
|
|
38246
|
+
if (!signer) {
|
|
38247
|
+
throw new WalletVerificationSignatureError({
|
|
38248
|
+
code: exports.WalletVerificationSignatureErrorCode.UNSUPPORTED_CHAIN_TYPE,
|
|
38249
|
+
chainType: request.chainType,
|
|
38250
|
+
message: "Unsupported wallet verification chain type.",
|
|
38251
|
+
});
|
|
38252
|
+
}
|
|
38253
|
+
return signer.sign(request);
|
|
38254
|
+
}, [signers]);
|
|
38255
|
+
const cancelSignVerificationMessage = React.useCallback(({ chainType } = {}) => {
|
|
38256
|
+
if (!chainType) {
|
|
38257
|
+
return;
|
|
38258
|
+
}
|
|
38259
|
+
signers[chainType]?.cancel?.();
|
|
38260
|
+
}, [signers]);
|
|
38261
|
+
const signVerificationMessageMutation = reactQuery.useMutation({
|
|
38262
|
+
mutationFn: signVerificationMessage,
|
|
38263
|
+
});
|
|
38264
|
+
return {
|
|
38265
|
+
signatureTypes: WALLET_VERIFICATION_SIGNATURE_TYPE_BY_CHAIN_TYPE,
|
|
38266
|
+
supportedChainTypes: Object.values(squidTypes.ChainType),
|
|
38267
|
+
signVerificationMessage: signVerificationMessageMutation.mutateAsync,
|
|
38268
|
+
cancelSignVerificationMessage,
|
|
38269
|
+
isSigning: signVerificationMessageMutation.isLoading,
|
|
38270
|
+
error: signVerificationMessageMutation.error,
|
|
38271
|
+
reset: signVerificationMessageMutation.reset,
|
|
38272
|
+
};
|
|
38273
|
+
};
|
|
38274
|
+
|
|
37409
38275
|
/**
|
|
37410
38276
|
* Maximum IOU amount on XRPL
|
|
37411
38277
|
* @see https://xrpl.org/docs/references/protocol/data-types/currency-formats#comparison
|
|
@@ -37594,10 +38460,8 @@ const SquidProvider = ({ children, config, placeholder, }) => {
|
|
|
37594
38460
|
}
|
|
37595
38461
|
if (assetsColorsResponse.status === "fulfilled") {
|
|
37596
38462
|
useAssetsColorsStore.setState(assetsColorsResponse.value);
|
|
38463
|
+
initializeSquidWithAssetsColors(squid, assetsColorsResponse.value);
|
|
37597
38464
|
}
|
|
37598
|
-
initializeSquidData(squid, assetsColorsResponse.status === "fulfilled"
|
|
37599
|
-
? assetsColorsResponse.value
|
|
37600
|
-
: undefined);
|
|
37601
38465
|
const shouldResetSwapRouteStore =
|
|
37602
38466
|
// reset swap route if specified in config
|
|
37603
38467
|
!config?.loadPreviousStateFromLocalStorage ||
|
|
@@ -37685,17 +38549,29 @@ exports.HederaExtensionHelper = HederaExtensionHelper;
|
|
|
37685
38549
|
exports.Nr = Nr;
|
|
37686
38550
|
exports.SquidProvider = SquidProvider;
|
|
37687
38551
|
exports.TX_STATUS_CONSTANTS = TX_STATUS_CONSTANTS;
|
|
38552
|
+
exports.WALLET_VERIFICATION_SIGNATURE_TYPE_BY_CHAIN_TYPE = WALLET_VERIFICATION_SIGNATURE_TYPE_BY_CHAIN_TYPE;
|
|
38553
|
+
exports.WalletVerificationSignatureError = WalletVerificationSignatureError;
|
|
37688
38554
|
exports.WidgetEvents = WidgetEvents;
|
|
37689
38555
|
exports.Wo = Wo;
|
|
38556
|
+
exports.XAMAN_OWNERSHIP_CHALLENGE_MEMO_TYPE = XAMAN_OWNERSHIP_CHALLENGE_MEMO_TYPE;
|
|
37690
38557
|
exports.accessProperty = accessProperty;
|
|
37691
38558
|
exports.adaptiveRound = adaptiveRound;
|
|
37692
38559
|
exports.addEthereumChain = addEthereumChain;
|
|
37693
38560
|
exports.addTokenToWallet = addTokenToWallet;
|
|
37694
38561
|
exports.areSameAddress = areSameAddress;
|
|
37695
38562
|
exports.areTokenSymbolsCompatible = areTokenSymbolsCompatible;
|
|
38563
|
+
exports.assertEvmVerificationSigningRequest = assertEvmVerificationSigningRequest;
|
|
38564
|
+
exports.assertWalletVerificationSigningRequest = assertWalletVerificationSigningRequest;
|
|
37696
38565
|
exports.assetsBaseUrl = assetsBaseUrl;
|
|
38566
|
+
exports.buildBitcoinWalletVerificationSignatureResult = buildBitcoinWalletVerificationSignatureResult;
|
|
38567
|
+
exports.buildCosmosWalletVerificationSignatureResult = buildCosmosWalletVerificationSignatureResult;
|
|
38568
|
+
exports.buildSolanaWalletVerificationSignatureResult = buildSolanaWalletVerificationSignatureResult;
|
|
38569
|
+
exports.buildStellarWalletVerificationSignatureResult = buildStellarWalletVerificationSignatureResult;
|
|
38570
|
+
exports.buildSuiWalletVerificationSignatureResult = buildSuiWalletVerificationSignatureResult;
|
|
37697
38571
|
exports.buildUrlSearchParamsFromSwapEvent = buildUrlSearchParamsFromSwapEvent;
|
|
38572
|
+
exports.buildWalletVerificationSignatureResult = buildWalletVerificationSignatureResult;
|
|
37698
38573
|
exports.buildXrplTrustSetTx = buildXrplTrustSetTx;
|
|
38574
|
+
exports.buildXrplWalletVerificationSignatureResult = buildXrplWalletVerificationSignatureResult;
|
|
37699
38575
|
exports.calculateTotal24hChange = calculateTotal24hChange;
|
|
37700
38576
|
exports.calculateTotalUsdBalanceUSD = calculateTotalUsdBalanceUSD;
|
|
37701
38577
|
exports.cancelConnectWallet = cancelConnectWallet;
|
|
@@ -37722,6 +38598,7 @@ exports.fetchHighestBalanceToken = fetchHighestBalanceToken;
|
|
|
37722
38598
|
exports.fetchSwapTransactionStatus = fetchSwapTransactionStatus;
|
|
37723
38599
|
exports.filterChains = filterChains;
|
|
37724
38600
|
exports.filterSolanaWallets = filterSolanaWallets;
|
|
38601
|
+
exports.filterSuiWallets = filterSuiWallets;
|
|
37725
38602
|
exports.filterTokens = filterTokens;
|
|
37726
38603
|
exports.filterTokensForDestination = filterTokensForDestination;
|
|
37727
38604
|
exports.filterViewableTokens = filterViewableTokens;
|
|
@@ -37771,6 +38648,7 @@ exports.getStellarTrustLineAsset = getStellarTrustLineAsset;
|
|
|
37771
38648
|
exports.getStepStatuses = getStepStatuses;
|
|
37772
38649
|
exports.getStepsInfos = getStepsInfos;
|
|
37773
38650
|
exports.getSuggestedAmountsForCurrency = getSuggestedAmountsForCurrency;
|
|
38651
|
+
exports.getSuiChain = getSuiChain;
|
|
37774
38652
|
exports.getSupportedChainIdsForDirection = getSupportedChainIdsForDirection;
|
|
37775
38653
|
exports.getSwapTxStatusRefetchInterval = getSwapTxStatusRefetchInterval;
|
|
37776
38654
|
exports.getTokenAssetsKey = getTokenAssetsKey;
|
|
@@ -37786,15 +38664,16 @@ exports.getXummClient = getXummClient;
|
|
|
37786
38664
|
exports.groupTokensByChainId = groupTokensByChainId;
|
|
37787
38665
|
exports.groupTokensBySymbol = groupTokensBySymbol;
|
|
37788
38666
|
exports.handleTransactionErrorEvents = handleTransactionErrorEvents;
|
|
37789
|
-
exports.
|
|
38667
|
+
exports.initializeSquidWithAssetsColors = initializeSquidWithAssetsColors;
|
|
37790
38668
|
exports.is404Error = is404Error;
|
|
37791
38669
|
exports.isActionCompletedOnSourceTx = isActionCompletedOnSourceTx;
|
|
38670
|
+
exports.isBitcoinAddressValid = isBitcoinAddressValid;
|
|
37792
38671
|
exports.isChainflipBridgeTransaction = isChainflipBridgeTransaction;
|
|
37793
|
-
exports.isChainflipDepositRoute = isChainflipDepositRoute;
|
|
37794
38672
|
exports.isCoralBridgeAction = isCoralBridgeAction;
|
|
37795
38673
|
exports.isCosmosAddressValid = isCosmosAddressValid;
|
|
37796
|
-
exports.
|
|
38674
|
+
exports.isDepositRoute = isDepositRoute;
|
|
37797
38675
|
exports.isEmptyObject = isEmptyObject;
|
|
38676
|
+
exports.isEvmAddressValid = isEvmAddressValid;
|
|
37798
38677
|
exports.isEvmChainNotSupportedError = isEvmChainNotSupportedError;
|
|
37799
38678
|
exports.isEvmosChain = isEvmosChain;
|
|
37800
38679
|
exports.isFallbackAddressNeeded = isFallbackAddressNeeded;
|
|
@@ -37809,7 +38688,7 @@ exports.isStatusError = isStatusError;
|
|
|
37809
38688
|
exports.isStellarAddressValid = isStellarAddressValid;
|
|
37810
38689
|
exports.isStellarIssuedToken = isStellarIssuedToken;
|
|
37811
38690
|
exports.isStellarToken = isStellarToken;
|
|
37812
|
-
exports.
|
|
38691
|
+
exports.isSuiAddressValid = isSuiAddressValid;
|
|
37813
38692
|
exports.isSwapRouteError = isSwapRouteError;
|
|
37814
38693
|
exports.isUserRejectionError = isUserRejectionError;
|
|
37815
38694
|
exports.isValidHorizonAsset = isValidHorizonAsset;
|
|
@@ -37845,6 +38724,7 @@ exports.searchTokens = searchTokens;
|
|
|
37845
38724
|
exports.shareSubgraphId = shareSubgraphId;
|
|
37846
38725
|
exports.simplifyRouteAction = simplifyRouteAction;
|
|
37847
38726
|
exports.sleep = sleep;
|
|
38727
|
+
exports.slushWebWalletData = slushWebWalletData;
|
|
37848
38728
|
exports.sortAddressBook = sortAddressBook;
|
|
37849
38729
|
exports.sortAllTokens = sortAllTokens;
|
|
37850
38730
|
exports.sortTokensBySharedSubgraphIds = sortTokensBySharedSubgraphIds;
|
|
@@ -37874,7 +38754,6 @@ exports.useCountryDetails = useCountryDetails;
|
|
|
37874
38754
|
exports.useCurrencyDetails = useCurrencyDetails;
|
|
37875
38755
|
exports.useDebouncedValue = useDebouncedValue;
|
|
37876
38756
|
exports.useDepositAddress = useDepositAddress;
|
|
37877
|
-
exports.useDepositTransactionStatus = useDepositTransactionStatus;
|
|
37878
38757
|
exports.useEnsDataForAddress = useEnsDataForAddress;
|
|
37879
38758
|
exports.useEnsSearch = useEnsSearch;
|
|
37880
38759
|
exports.useEstimate = useEstimate;
|
|
@@ -37935,10 +38814,11 @@ exports.useTransactionStore = useTransactionStore;
|
|
|
37935
38814
|
exports.useUrlSwapParams = useUrlSwapParams;
|
|
37936
38815
|
exports.useWallet = useWallet;
|
|
37937
38816
|
exports.useWalletStore = useWalletStore;
|
|
38817
|
+
exports.useWalletVerificationSignature = useWalletVerificationSignature;
|
|
37938
38818
|
exports.useWallets = useWallets;
|
|
37939
38819
|
exports.useXrplNativeBalance = useXrplNativeBalance;
|
|
37940
38820
|
exports.useXrplTrustLine = useXrplTrustLine;
|
|
37941
38821
|
exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
|
|
37942
38822
|
exports.walletIconBaseUrl = walletIconBaseUrl;
|
|
37943
38823
|
exports.walletSupportsChainType = walletSupportsChainType;
|
|
37944
|
-
//# sourceMappingURL=index-
|
|
38824
|
+
//# sourceMappingURL=index-z1nGQX9p.js.map
|