@0xsquid/react-hooks 8.13.0 → 8.14.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/types/solana.d.ts +8 -0
- package/dist/{index-8RIq6GyB.js → index-BjIX7utV.js} +246 -89
- package/dist/index-BjIX7utV.js.map +1 -0
- package/dist/{index-BVneqIL5.js → index-DkBrtnan.js} +246 -90
- package/dist/index-DkBrtnan.js.map +1 -0
- package/dist/{index.es-CnV3EYrQ.js → index.es-BQULJYpe.js} +2 -2
- package/dist/{index.es-CnV3EYrQ.js.map → index.es-BQULJYpe.js.map} +1 -1
- package/dist/{index.es-Bm5GQH70.js → index.es-CeXN3P4q.js} +2 -2
- package/dist/{index.es-Bm5GQH70.js.map → index.es-CeXN3P4q.js.map} +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/{secretService-D8ySaXvX.js → secretService-BBTgxmnG.js} +2 -2
- package/dist/{secretService-D8ySaXvX.js.map → secretService-BBTgxmnG.js.map} +1 -1
- package/dist/{secretService-C6GiPeC8.js → secretService-BebOsCud.js} +2 -2
- package/dist/{secretService-C6GiPeC8.js.map → secretService-BebOsCud.js.map} +1 -1
- package/dist/services/internal/errorService.d.ts +5 -2
- package/dist/services/internal/evmService.d.ts +1 -0
- package/dist/{stellarService.client-DkBWS3eX.js → stellarService.client-B6_2UV4u.js} +2 -2
- package/dist/{stellarService.client-DkBWS3eX.js.map → stellarService.client-B6_2UV4u.js.map} +1 -1
- package/dist/{stellarService.client-IiUZ6NO6.js → stellarService.client-DlQku8Rs.js} +2 -2
- package/dist/{stellarService.client-IiUZ6NO6.js.map → stellarService.client-DlQku8Rs.js.map} +1 -1
- package/dist/tests/errorService.test.d.ts +1 -0
- package/dist/tests/solanaService.test.d.ts +1 -0
- package/dist/tests/useEvmBalance.test.d.ts +1 -0
- package/dist/tests/useEvmNativeBalance.test.d.ts +1 -0
- package/package.json +5 -3
- package/dist/index-8RIq6GyB.js.map +0 -1
- package/dist/index-BVneqIL5.js.map +0 -1
|
@@ -1,2 +1,10 @@
|
|
|
1
1
|
import type { StandardWalletAdapter } from "@solana/wallet-standard-wallet-adapter-base";
|
|
2
2
|
export type SolanaConnector = StandardWalletAdapter;
|
|
3
|
+
export declare const SOLANA_ON_CHAIN_ERROR_CODE = "SOLANA_ON_CHAIN_ERROR";
|
|
4
|
+
export declare const SOLANA_BLOCKHASH_EXPIRED_CODE = "SOLANA_BLOCKHASH_EXPIRED";
|
|
5
|
+
export type SolanaTransactionErrorCode = typeof SOLANA_ON_CHAIN_ERROR_CODE | typeof SOLANA_BLOCKHASH_EXPIRED_CODE;
|
|
6
|
+
export declare class SolanaTransactionError extends Error {
|
|
7
|
+
readonly code: SolanaTransactionErrorCode;
|
|
8
|
+
readonly signature?: string;
|
|
9
|
+
constructor(code: SolanaTransactionErrorCode, message: string, signature?: string);
|
|
10
|
+
}
|
|
@@ -252,6 +252,19 @@ class QrCodeGenerationError extends Error {
|
|
|
252
252
|
}
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
+
const SOLANA_ON_CHAIN_ERROR_CODE = "SOLANA_ON_CHAIN_ERROR";
|
|
256
|
+
const SOLANA_BLOCKHASH_EXPIRED_CODE = "SOLANA_BLOCKHASH_EXPIRED";
|
|
257
|
+
class SolanaTransactionError extends Error {
|
|
258
|
+
code;
|
|
259
|
+
signature;
|
|
260
|
+
constructor(code, message, signature) {
|
|
261
|
+
super(message);
|
|
262
|
+
this.name = "SolanaTransactionError";
|
|
263
|
+
this.code = code;
|
|
264
|
+
this.signature = signature;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
255
268
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
256
269
|
|
|
257
270
|
function getDefaultExportFromCjs (x) {
|
|
@@ -1631,7 +1644,7 @@ var _setCacheAdd = setCacheAdd$1;
|
|
|
1631
1644
|
* @name has
|
|
1632
1645
|
* @memberOf SetCache
|
|
1633
1646
|
* @param {*} value The value to search for.
|
|
1634
|
-
* @returns {
|
|
1647
|
+
* @returns {boolean} Returns `true` if `value` is found, else `false`.
|
|
1635
1648
|
*/
|
|
1636
1649
|
|
|
1637
1650
|
function setCacheHas$1(value) {
|
|
@@ -4224,24 +4237,38 @@ class WidgetEvents extends EventTarget {
|
|
|
4224
4237
|
}
|
|
4225
4238
|
}
|
|
4226
4239
|
|
|
4240
|
+
const isRecord$1 = (value) => typeof value === "object" && value !== null;
|
|
4241
|
+
const isErrorCode = (value) => typeof value === "string" || typeof value === "number";
|
|
4242
|
+
const toErrorLike = (value) => {
|
|
4243
|
+
if (!isRecord$1(value))
|
|
4244
|
+
return undefined;
|
|
4245
|
+
const { code, message, reason, error, data, cause } = value;
|
|
4246
|
+
return {
|
|
4247
|
+
code: isErrorCode(code) ? code : undefined,
|
|
4248
|
+
message: typeof message === "string" ? message : undefined,
|
|
4249
|
+
reason: typeof reason === "string" ? reason : undefined,
|
|
4250
|
+
error: toErrorLike(error),
|
|
4251
|
+
data: toErrorLike(data),
|
|
4252
|
+
cause: toErrorLike(cause),
|
|
4253
|
+
};
|
|
4254
|
+
};
|
|
4227
4255
|
/**
|
|
4228
4256
|
* Normalizes different error structures into a consistent format
|
|
4229
4257
|
* This helps handle different wallet error formats uniformly
|
|
4230
4258
|
*/
|
|
4231
4259
|
const normalizeError = (error) => {
|
|
4260
|
+
const errorLike = toErrorLike(error);
|
|
4261
|
+
if (!errorLike)
|
|
4262
|
+
return {};
|
|
4232
4263
|
// Handle nested error objects (like Rainbow's error.error structure)
|
|
4233
|
-
|
|
4234
|
-
return {
|
|
4235
|
-
code: error.error.code,
|
|
4236
|
-
message: error.error.message,
|
|
4237
|
-
reason: error.error.reason,
|
|
4238
|
-
};
|
|
4239
|
-
}
|
|
4240
|
-
// Handle direct error properties
|
|
4264
|
+
const source = errorLike.error ?? errorLike;
|
|
4241
4265
|
return {
|
|
4242
|
-
code:
|
|
4243
|
-
message:
|
|
4244
|
-
reason:
|
|
4266
|
+
code: source.code,
|
|
4267
|
+
message: source.message,
|
|
4268
|
+
reason: source.reason,
|
|
4269
|
+
dataCode: source.data?.code,
|
|
4270
|
+
dataMessage: source.data?.message,
|
|
4271
|
+
causeMessage: source.cause?.message,
|
|
4245
4272
|
};
|
|
4246
4273
|
};
|
|
4247
4274
|
const transactionErrorCode = {
|
|
@@ -4275,11 +4302,6 @@ const transactionErrorCode = {
|
|
|
4275
4302
|
type: exports.TransactionErrorType.REJECTED_BY_USER,
|
|
4276
4303
|
internalLabel: "EVM: REJECTED: CODE 4001",
|
|
4277
4304
|
},
|
|
4278
|
-
// Rainbow
|
|
4279
|
-
"-32603": {
|
|
4280
|
-
type: exports.TransactionErrorType.REJECTED_BY_USER,
|
|
4281
|
-
internalLabel: "EVM: REJECTED: CODE -32603",
|
|
4282
|
-
},
|
|
4283
4305
|
// Joey (XRPL)
|
|
4284
4306
|
"User rejected.": {
|
|
4285
4307
|
type: exports.TransactionErrorType.REJECTED_BY_USER,
|
|
@@ -4339,16 +4361,60 @@ const transactionErrorCode = {
|
|
|
4339
4361
|
type: exports.TransactionErrorType.CALL_EXCEPTION,
|
|
4340
4362
|
internalLabel: "EVM: CALL_EXCEPTION",
|
|
4341
4363
|
},
|
|
4364
|
+
[SOLANA_ON_CHAIN_ERROR_CODE]: {
|
|
4365
|
+
type: exports.TransactionErrorType.CALL_EXCEPTION,
|
|
4366
|
+
internalLabel: "SOL: Transaction failed on chain",
|
|
4367
|
+
},
|
|
4368
|
+
[SOLANA_BLOCKHASH_EXPIRED_CODE]: {
|
|
4369
|
+
type: exports.TransactionErrorType.UNKNOWN,
|
|
4370
|
+
internalLabel: "SOL: Transaction blockhash expired",
|
|
4371
|
+
},
|
|
4342
4372
|
UNKNOWN: {
|
|
4343
4373
|
type: exports.TransactionErrorType.UNKNOWN,
|
|
4344
4374
|
internalLabel: "UNKNOWN ERROR: Transaction failed",
|
|
4345
4375
|
},
|
|
4346
4376
|
};
|
|
4377
|
+
// Rainbow reports a user rejection with the generic JSON-RPC internal error
|
|
4378
|
+
// code, while Phantom uses the same code for real failures.
|
|
4379
|
+
const INTERNAL_RPC_ERROR_CODE = "-32603";
|
|
4380
|
+
const userRejectionMessagePatterns = [
|
|
4381
|
+
/user rejected/i,
|
|
4382
|
+
/rejected the request/i,
|
|
4383
|
+
/rejected by the user/i,
|
|
4384
|
+
/user denied/i,
|
|
4385
|
+
];
|
|
4386
|
+
const internalRpcRejectionError = {
|
|
4387
|
+
type: exports.TransactionErrorType.REJECTED_BY_USER,
|
|
4388
|
+
internalLabel: "EVM: REJECTED: CODE -32603",
|
|
4389
|
+
};
|
|
4390
|
+
const USER_REJECTED_CODE = "4001";
|
|
4391
|
+
const isUserRejectionMessage = (message) => message !== undefined &&
|
|
4392
|
+
userRejectionMessagePatterns.some((pattern) => pattern.test(message));
|
|
4393
|
+
const isInternalRpcRejection = ({ code, message, dataCode, dataMessage, causeMessage, }) => code != undefined &&
|
|
4394
|
+
code.toString() === INTERNAL_RPC_ERROR_CODE &&
|
|
4395
|
+
(dataCode?.toString() === USER_REJECTED_CODE ||
|
|
4396
|
+
[message, dataMessage, causeMessage].some(isUserRejectionMessage));
|
|
4397
|
+
// @solana/web3.js SendTransactionError carries no code; its message starts
|
|
4398
|
+
// with the preflight failure text.
|
|
4399
|
+
const messagePatternErrors = [
|
|
4400
|
+
{
|
|
4401
|
+
pattern: /^(Simulation failed|Transaction simulation failed)/i,
|
|
4402
|
+
error: {
|
|
4403
|
+
type: exports.TransactionErrorType.CALL_EXCEPTION,
|
|
4404
|
+
internalLabel: "SOL: Transaction simulation failed",
|
|
4405
|
+
},
|
|
4406
|
+
},
|
|
4407
|
+
];
|
|
4408
|
+
const matchMessagePattern = (message) => message === undefined
|
|
4409
|
+
? undefined
|
|
4410
|
+
: messagePatternErrors.find(({ pattern }) => pattern.test(message))?.error;
|
|
4347
4411
|
/**
|
|
4348
4412
|
* Detects if an error is a user rejection based on normalized error structure
|
|
4349
4413
|
*/
|
|
4350
4414
|
const isUserRejectionError = (normalizedError) => {
|
|
4351
4415
|
const { code, message } = normalizedError;
|
|
4416
|
+
if (isInternalRpcRejection(normalizedError))
|
|
4417
|
+
return true;
|
|
4352
4418
|
// Check if the error matches any known rejection patterns from transactionErrorCode
|
|
4353
4419
|
return Object.entries(transactionErrorCode).some(([key, value]) => {
|
|
4354
4420
|
if (value.type !== exports.TransactionErrorType.REJECTED_BY_USER)
|
|
@@ -4369,6 +4435,8 @@ const isUserRejectionError = (normalizedError) => {
|
|
|
4369
4435
|
*/
|
|
4370
4436
|
const getTransactionError = (error) => {
|
|
4371
4437
|
const normalizedError = normalizeError(error);
|
|
4438
|
+
if (isInternalRpcRejection(normalizedError))
|
|
4439
|
+
return internalRpcRejectionError;
|
|
4372
4440
|
if (isUserRejectionError(normalizedError)) {
|
|
4373
4441
|
// Return the specific rejection error if we can find it
|
|
4374
4442
|
if (normalizedError.code) {
|
|
@@ -4385,10 +4453,12 @@ const getTransactionError = (error) => {
|
|
|
4385
4453
|
}
|
|
4386
4454
|
if (normalizedError.code) {
|
|
4387
4455
|
return (transactionErrorCode[normalizedError.code.toString()] ||
|
|
4456
|
+
matchMessagePattern(normalizedError.message) ||
|
|
4388
4457
|
transactionErrorCode.UNKNOWN);
|
|
4389
4458
|
}
|
|
4390
4459
|
if (normalizedError.message) {
|
|
4391
4460
|
return (transactionErrorCode[normalizedError.message] ||
|
|
4461
|
+
matchMessagePattern(normalizedError.message) ||
|
|
4392
4462
|
transactionErrorCode.UNKNOWN);
|
|
4393
4463
|
}
|
|
4394
4464
|
return transactionErrorCode.UNKNOWN;
|
|
@@ -10351,16 +10421,16 @@ bn.exports;
|
|
|
10351
10421
|
var w = this.words[i];
|
|
10352
10422
|
var word = (((w << off) | carry) & 0xffffff).toString(16);
|
|
10353
10423
|
carry = (w >>> (24 - off)) & 0xffffff;
|
|
10354
|
-
if (carry !== 0 || i !== this.length - 1) {
|
|
10355
|
-
out = zeros[6 - word.length] + word + out;
|
|
10356
|
-
} else {
|
|
10357
|
-
out = word + out;
|
|
10358
|
-
}
|
|
10359
10424
|
off += 2;
|
|
10360
10425
|
if (off >= 26) {
|
|
10361
10426
|
off -= 26;
|
|
10362
10427
|
i--;
|
|
10363
10428
|
}
|
|
10429
|
+
if (carry !== 0 || i !== this.length - 1) {
|
|
10430
|
+
out = zeros[6 - word.length] + word + out;
|
|
10431
|
+
} else {
|
|
10432
|
+
out = word + out;
|
|
10433
|
+
}
|
|
10364
10434
|
}
|
|
10365
10435
|
if (carry !== 0) {
|
|
10366
10436
|
out = carry.toString(16) + out;
|
|
@@ -10727,6 +10797,12 @@ bn.exports;
|
|
|
10727
10797
|
// Handle the residue
|
|
10728
10798
|
if (bitsLeft > 0) {
|
|
10729
10799
|
this.words[i] = ~this.words[i] & (0x3ffffff >> (26 - bitsLeft));
|
|
10800
|
+
i++;
|
|
10801
|
+
}
|
|
10802
|
+
|
|
10803
|
+
// Clear words above the requested width so the result stays below 2 ** width
|
|
10804
|
+
for (; i < this.length; i++) {
|
|
10805
|
+
this.words[i] = 0;
|
|
10730
10806
|
}
|
|
10731
10807
|
|
|
10732
10808
|
// And remove leading zeroes
|
|
@@ -11820,6 +11896,10 @@ bn.exports;
|
|
|
11820
11896
|
this.words[i] = carry;
|
|
11821
11897
|
this.length++;
|
|
11822
11898
|
}
|
|
11899
|
+
if (num === 0) {
|
|
11900
|
+
this.length = 1;
|
|
11901
|
+
this._normSign();
|
|
11902
|
+
}
|
|
11823
11903
|
|
|
11824
11904
|
return this;
|
|
11825
11905
|
};
|
|
@@ -12025,6 +12105,11 @@ bn.exports;
|
|
|
12025
12105
|
this.words[this.length - 1] &= mask;
|
|
12026
12106
|
}
|
|
12027
12107
|
|
|
12108
|
+
if (this.length === 0) {
|
|
12109
|
+
this.words[0] = 0;
|
|
12110
|
+
this.length = 1;
|
|
12111
|
+
}
|
|
12112
|
+
|
|
12028
12113
|
return this.strip();
|
|
12029
12114
|
};
|
|
12030
12115
|
|
|
@@ -12351,17 +12436,19 @@ bn.exports;
|
|
|
12351
12436
|
// Fast case - exact division
|
|
12352
12437
|
if (dm.mod.isZero()) return dm.div;
|
|
12353
12438
|
|
|
12354
|
-
var mod = dm.
|
|
12439
|
+
var mod = dm.mod.abs();
|
|
12355
12440
|
|
|
12356
|
-
var half = num.
|
|
12357
|
-
var r2 = num.
|
|
12441
|
+
var half = num.abs().iushrn(1);
|
|
12442
|
+
var r2 = num.words[0] & 1;
|
|
12358
12443
|
var cmp = mod.cmp(half);
|
|
12359
12444
|
|
|
12360
12445
|
// Round down
|
|
12361
12446
|
if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
|
|
12362
12447
|
|
|
12363
|
-
// Round up
|
|
12364
|
-
|
|
12448
|
+
// Round up, away from zero
|
|
12449
|
+
var up = new BN(1);
|
|
12450
|
+
up.negative = this.negative ^ num.negative;
|
|
12451
|
+
return dm.div.iadd(up);
|
|
12365
12452
|
};
|
|
12366
12453
|
|
|
12367
12454
|
BN.prototype.modn = function modn (num) {
|
|
@@ -21650,14 +21737,71 @@ const isSolanaAddressValid = (address) => {
|
|
|
21650
21737
|
};
|
|
21651
21738
|
const deserializeSolanaTransaction = (transactionBuffer) => {
|
|
21652
21739
|
// Squid can return legacy Solana transactions (ITS) or versioned transactions
|
|
21653
|
-
// (Jupiter/Chainflip). Deserialize once to detect the payload type.
|
|
21654
|
-
// transactions need to be converted to Transaction because their blockhash is
|
|
21655
|
-
// mutable and must be refreshed before signing.
|
|
21740
|
+
// (Jupiter/Chainflip). Deserialize once to detect the payload type.
|
|
21656
21741
|
const versionedTransaction = web3_js.VersionedTransaction.deserialize(transactionBuffer);
|
|
21657
21742
|
return versionedTransaction.version === "legacy"
|
|
21658
21743
|
? web3_js.Transaction.from(transactionBuffer)
|
|
21659
21744
|
: versionedTransaction;
|
|
21660
21745
|
};
|
|
21746
|
+
const isSignedTransaction = (transaction) => transaction instanceof web3_js.Transaction
|
|
21747
|
+
? transaction.signatures.some(({ signature }) => signature !== null)
|
|
21748
|
+
: transaction.signatures.some((signature) => signature.some((byte) => byte !== 0));
|
|
21749
|
+
const getTransactionBlockhash = (transaction) => transaction instanceof web3_js.Transaction
|
|
21750
|
+
? transaction.recentBlockhash
|
|
21751
|
+
: transaction.message.recentBlockhash;
|
|
21752
|
+
const setTransactionBlockhash = (transaction, blockhash) => {
|
|
21753
|
+
if (transaction instanceof web3_js.Transaction) {
|
|
21754
|
+
transaction.recentBlockhash = blockhash;
|
|
21755
|
+
}
|
|
21756
|
+
else {
|
|
21757
|
+
transaction.message.recentBlockhash = blockhash;
|
|
21758
|
+
}
|
|
21759
|
+
};
|
|
21760
|
+
// Squid builds the transaction server-side, so its blockhash can expire before
|
|
21761
|
+
// the wallet approves it. Pre-signed transactions keep their blockhash: a new
|
|
21762
|
+
// one would invalidate their signatures.
|
|
21763
|
+
const resolveBlockhash = async (transaction, connection) => {
|
|
21764
|
+
const latestBlockhash = await connection.getLatestBlockhash();
|
|
21765
|
+
if (!isSignedTransaction(transaction)) {
|
|
21766
|
+
setTransactionBlockhash(transaction, latestBlockhash.blockhash);
|
|
21767
|
+
return latestBlockhash;
|
|
21768
|
+
}
|
|
21769
|
+
const blockhash = getTransactionBlockhash(transaction);
|
|
21770
|
+
if (!blockhash) {
|
|
21771
|
+
throw new Error("Signed transaction has no blockhash");
|
|
21772
|
+
}
|
|
21773
|
+
const { value: isValid } = await connection.isBlockhashValid(blockhash);
|
|
21774
|
+
if (!isValid) {
|
|
21775
|
+
throw new SolanaTransactionError(SOLANA_BLOCKHASH_EXPIRED_CODE, "Transaction blockhash expired; request a new route");
|
|
21776
|
+
}
|
|
21777
|
+
// The kept blockhash is older than the latest one, so the latest expiry
|
|
21778
|
+
// height is an upper bound: confirmation never gives up too early.
|
|
21779
|
+
return {
|
|
21780
|
+
blockhash,
|
|
21781
|
+
lastValidBlockHeight: latestBlockhash.lastValidBlockHeight,
|
|
21782
|
+
};
|
|
21783
|
+
};
|
|
21784
|
+
const assertConfirmed = (signature, { err }) => {
|
|
21785
|
+
if (err) {
|
|
21786
|
+
throw new SolanaTransactionError(SOLANA_ON_CHAIN_ERROR_CODE, `Solana transaction failed on chain: ${JSON.stringify(err)}`, signature);
|
|
21787
|
+
}
|
|
21788
|
+
};
|
|
21789
|
+
const SWAP_SEND_OPTIONS = {
|
|
21790
|
+
skipPreflight: false,
|
|
21791
|
+
maxRetries: 2,
|
|
21792
|
+
preflightCommitment: "confirmed",
|
|
21793
|
+
};
|
|
21794
|
+
// Wallets that submit the transaction themselves (Phantom) run their own
|
|
21795
|
+
// preflight and hide its failure behind a generic error. Sign only and submit
|
|
21796
|
+
// through our connection so RPC errors stay visible.
|
|
21797
|
+
const sendSolanaTransaction = async (signer, connection, transaction) => {
|
|
21798
|
+
if (!signer.signTransaction) {
|
|
21799
|
+
return signer.sendTransaction(transaction, connection, SWAP_SEND_OPTIONS);
|
|
21800
|
+
}
|
|
21801
|
+
const signed = await signer.signTransaction(transaction);
|
|
21802
|
+
const raw = signed.serialize();
|
|
21803
|
+
return connection.sendRawTransaction(raw, SWAP_SEND_OPTIONS);
|
|
21804
|
+
};
|
|
21661
21805
|
/**
|
|
21662
21806
|
* Execute a Solana swap transaction
|
|
21663
21807
|
* This will be used for the swap flow - Using Jupiter Dex under the hood
|
|
@@ -21670,21 +21814,15 @@ const executeSolanaSwap = async ({ route, signer, connection, onSigned, }) => {
|
|
|
21670
21814
|
const swapTransactionBuf = Buffer.from(swapRequest, "base64");
|
|
21671
21815
|
const transaction = deserializeSolanaTransaction(swapTransactionBuf);
|
|
21672
21816
|
try {
|
|
21673
|
-
const
|
|
21674
|
-
|
|
21675
|
-
// ITS legacy transactions arrive with the placeholder blockhash
|
|
21676
|
-
// 11111111111111111111111111111111.
|
|
21677
|
-
// Refresh it right before signing so the submitted transaction
|
|
21678
|
-
// uses a valid blockhash. Versioned transactions are not mutable here.
|
|
21679
|
-
transaction.recentBlockhash = latestBlockhash.blockhash;
|
|
21680
|
-
}
|
|
21681
|
-
const signature = await signer.sendTransaction(transaction, connection);
|
|
21817
|
+
const { blockhash, lastValidBlockHeight } = await resolveBlockhash(transaction, connection);
|
|
21818
|
+
const signature = await sendSolanaTransaction(signer, connection, transaction);
|
|
21682
21819
|
onSigned?.(signature);
|
|
21683
|
-
await connection.confirmTransaction({
|
|
21820
|
+
const { value } = await connection.confirmTransaction({
|
|
21684
21821
|
signature,
|
|
21685
|
-
blockhash
|
|
21686
|
-
lastValidBlockHeight
|
|
21822
|
+
blockhash,
|
|
21823
|
+
lastValidBlockHeight,
|
|
21687
21824
|
});
|
|
21825
|
+
assertConfirmed(signature, value);
|
|
21688
21826
|
return signature;
|
|
21689
21827
|
}
|
|
21690
21828
|
catch (error) {
|
|
@@ -21749,11 +21887,12 @@ const executeSolanaTransfer = async ({ amount, target, signer, connection, sourc
|
|
|
21749
21887
|
// Trigger callback for UI purposes (show loading state)
|
|
21750
21888
|
onSigned?.(signature);
|
|
21751
21889
|
// Wait for transaction confirmation
|
|
21752
|
-
await connection.confirmTransaction({
|
|
21890
|
+
const { value } = await connection.confirmTransaction({
|
|
21753
21891
|
signature,
|
|
21754
21892
|
blockhash,
|
|
21755
21893
|
lastValidBlockHeight,
|
|
21756
21894
|
});
|
|
21895
|
+
assertConfirmed(signature, value);
|
|
21757
21896
|
return signature;
|
|
21758
21897
|
};
|
|
21759
21898
|
|
|
@@ -23682,7 +23821,7 @@ const filterViewableTokens = (tokens, config, direction) => {
|
|
|
23682
23821
|
};
|
|
23683
23822
|
const getSecretNetworkBalances = async (chainData, cosmosAddress, squidTokens, keplrTypeWallet) => {
|
|
23684
23823
|
const squidSecretTokens = squidTokens.filter((t) => t.chainId === CHAIN_IDS.SECRET);
|
|
23685
|
-
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-
|
|
23824
|
+
const { fetchAllSecretBalances } = await Promise.resolve().then(function () { return require('./secretService-BebOsCud.js'); });
|
|
23686
23825
|
return fetchAllSecretBalances(chainData, cosmosAddress, squidSecretTokens, keplrTypeWallet);
|
|
23687
23826
|
};
|
|
23688
23827
|
function getTokenAssetsKey(token) {
|
|
@@ -23833,8 +23972,9 @@ async function addEthereumChain({ chain, provider, }) {
|
|
|
23833
23972
|
console.debug("Error adding chain:", error);
|
|
23834
23973
|
}
|
|
23835
23974
|
}
|
|
23975
|
+
const isEvmAddressValid = (address) => !!address && viem.isAddress(address);
|
|
23836
23976
|
const parseEvmAddress = (address) => {
|
|
23837
|
-
if (
|
|
23977
|
+
if (isEvmAddressValid(address)) {
|
|
23838
23978
|
return address;
|
|
23839
23979
|
}
|
|
23840
23980
|
};
|
|
@@ -28083,7 +28223,7 @@ function useSolana() {
|
|
|
28083
28223
|
};
|
|
28084
28224
|
}
|
|
28085
28225
|
const useSolanaConnection = () => {
|
|
28086
|
-
const connectionRef = React.useRef(new web3_js.Connection(SOLANA_RPC_URL));
|
|
28226
|
+
const connectionRef = React.useRef(new web3_js.Connection(SOLANA_RPC_URL, "confirmed"));
|
|
28087
28227
|
return connectionRef.current;
|
|
28088
28228
|
};
|
|
28089
28229
|
|
|
@@ -28109,7 +28249,7 @@ function useStellarWallets() {
|
|
|
28109
28249
|
try {
|
|
28110
28250
|
const { allowAllModules: initializeAllModules } = await import('@creit.tech/stellar-wallets-kit');
|
|
28111
28251
|
const { LedgerModule } = await import('@creit.tech/stellar-wallets-kit/modules/ledger.module.mjs');
|
|
28112
|
-
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-
|
|
28252
|
+
const { formatStellarWallet } = await Promise.resolve().then(function () { return require('./stellarService.client-B6_2UV4u.js'); });
|
|
28113
28253
|
const modules = [...initializeAllModules(), new LedgerModule()];
|
|
28114
28254
|
const promises = modules.map(async (module) => {
|
|
28115
28255
|
const isAvailable = await module.isAvailable();
|
|
@@ -30823,18 +30963,24 @@ const DEFAULT_REFRESH_INTERVAL_MS$1 = 15000;
|
|
|
30823
30963
|
const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
30824
30964
|
const { isChainTypeConnected } = useWallet();
|
|
30825
30965
|
const isNativeToken = token?.address.toLowerCase() === nativeEvmTokenAddress.toLowerCase();
|
|
30826
|
-
const
|
|
30966
|
+
const evmAddress = parseEvmAddress(userAddress);
|
|
30967
|
+
const tokenAddress = parseEvmAddress(token?.address);
|
|
30968
|
+
const isEvmChain = chain?.chainType === squidTypes.ChainType.EVM;
|
|
30969
|
+
const chainId = isEvmChain ? Number(chain.chainId) : undefined;
|
|
30970
|
+
const isEvmConnected = isChainTypeConnected(squidTypes.ChainType.EVM);
|
|
30971
|
+
const isNativeQueryEnabled = enabled && isEvmChain && isEvmConnected && !!evmAddress && isNativeToken;
|
|
30972
|
+
const isErc20QueryEnabled = enabled &&
|
|
30973
|
+
isEvmChain &&
|
|
30974
|
+
isEvmConnected &&
|
|
30975
|
+
!!evmAddress &&
|
|
30976
|
+
!!tokenAddress &&
|
|
30977
|
+
!isNativeToken;
|
|
30827
30978
|
// Only fetch using useBalance if it's a native token
|
|
30828
30979
|
const { data: nativeBalance, isLoading: isNativeTokenLoading } = wagmi.useBalance({
|
|
30829
|
-
address:
|
|
30830
|
-
chainId
|
|
30980
|
+
address: evmAddress,
|
|
30981
|
+
chainId,
|
|
30831
30982
|
query: {
|
|
30832
|
-
enabled:
|
|
30833
|
-
!!userAddress &&
|
|
30834
|
-
isNativeToken &&
|
|
30835
|
-
!!chain &&
|
|
30836
|
-
chain.chainType === squidTypes.ChainType.EVM &&
|
|
30837
|
-
isChainTypeConnected(chain.chainType),
|
|
30983
|
+
enabled: isNativeQueryEnabled,
|
|
30838
30984
|
refetchInterval: refreshIntervalMs,
|
|
30839
30985
|
retry: 2,
|
|
30840
30986
|
},
|
|
@@ -30842,23 +30988,20 @@ const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshInter
|
|
|
30842
30988
|
// Only fetch using useReadContract if it's not a native token
|
|
30843
30989
|
// This is temporary, because of wagmi error: https://github.com/wevm/wagmi/issues/4353
|
|
30844
30990
|
const { data: erc20Balance, isLoading: isErc20Loading } = wagmi.useReadContract({
|
|
30845
|
-
address:
|
|
30991
|
+
address: tokenAddress,
|
|
30846
30992
|
abi: viem.erc20Abi,
|
|
30847
30993
|
functionName: "balanceOf",
|
|
30848
|
-
args: [
|
|
30849
|
-
chainId
|
|
30994
|
+
args: evmAddress ? [evmAddress] : undefined,
|
|
30995
|
+
chainId,
|
|
30850
30996
|
query: {
|
|
30851
|
-
enabled:
|
|
30852
|
-
enabled &&
|
|
30853
|
-
!!userAddress &&
|
|
30854
|
-
!isNativeToken,
|
|
30997
|
+
enabled: isErc20QueryEnabled,
|
|
30855
30998
|
refetchInterval: refreshIntervalMs,
|
|
30856
30999
|
retry: 2,
|
|
30857
31000
|
},
|
|
30858
31001
|
});
|
|
30859
31002
|
if (isNativeToken) {
|
|
30860
31003
|
return {
|
|
30861
|
-
isLoading: isNativeTokenLoading,
|
|
31004
|
+
isLoading: isNativeQueryEnabled && isNativeTokenLoading,
|
|
30862
31005
|
balance: nativeBalance
|
|
30863
31006
|
? formatBNToReadable(nativeBalance.value, nativeBalance.decimals)
|
|
30864
31007
|
: "0",
|
|
@@ -30868,11 +31011,16 @@ const useEvmBalance = ({ chain, token, userAddress, enabled = true, refreshInter
|
|
|
30868
31011
|
balance: erc20Balance && token
|
|
30869
31012
|
? formatBNToReadable(erc20Balance, token.decimals)
|
|
30870
31013
|
: "0",
|
|
30871
|
-
isLoading: isErc20Loading,
|
|
31014
|
+
isLoading: isErc20QueryEnabled && isErc20Loading,
|
|
30872
31015
|
};
|
|
30873
31016
|
};
|
|
30874
31017
|
const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
30875
31018
|
const { isConnected } = useCosmosContext();
|
|
31019
|
+
const isQueryEnabled = !!isConnected &&
|
|
31020
|
+
enabled &&
|
|
31021
|
+
!!token &&
|
|
31022
|
+
chain?.chainType === squidTypes.ChainType.COSMOS &&
|
|
31023
|
+
isWalletAddressValid(chain, userAddress);
|
|
30876
31024
|
const { data: balance = "0", isLoading } = reactQuery.useQuery({
|
|
30877
31025
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
30878
31026
|
queryFn: async () => {
|
|
@@ -30885,17 +31033,17 @@ const useCosmosBalance = ({ chain, token, userAddress, enabled = true, refreshIn
|
|
|
30885
31033
|
const balanceBn = await getCosmosTokenBalance(chain, userAddress, token.address);
|
|
30886
31034
|
return formatBNToReadable(balanceBn, token.decimals);
|
|
30887
31035
|
},
|
|
30888
|
-
enabled:
|
|
30889
|
-
enabled &&
|
|
30890
|
-
!!userAddress &&
|
|
30891
|
-
!!token &&
|
|
30892
|
-
chain?.chainType === squidTypes.ChainType.COSMOS,
|
|
31036
|
+
enabled: isQueryEnabled,
|
|
30893
31037
|
refetchInterval: refreshIntervalMs,
|
|
30894
31038
|
retry: 2,
|
|
30895
31039
|
});
|
|
30896
|
-
return { balance, isLoading };
|
|
31040
|
+
return { balance, isLoading: isQueryEnabled && isLoading };
|
|
30897
31041
|
};
|
|
30898
31042
|
const useSolanaBalance = ({ chain, token, userAddress, enabled = true, refreshIntervalMs = DEFAULT_REFRESH_INTERVAL_MS$1, }) => {
|
|
31043
|
+
const isQueryEnabled = enabled &&
|
|
31044
|
+
!!token &&
|
|
31045
|
+
chain?.chainType === squidTypes.ChainType.SOLANA &&
|
|
31046
|
+
isWalletAddressValid(chain, userAddress);
|
|
30899
31047
|
const { data: balance = "0", isLoading } = reactQuery.useQuery({
|
|
30900
31048
|
queryKey: keys().balance(chain?.chainId, token?.address, userAddress),
|
|
30901
31049
|
queryFn: async () => {
|
|
@@ -30904,14 +31052,11 @@ const useSolanaBalance = ({ chain, token, userAddress, enabled = true, refreshIn
|
|
|
30904
31052
|
const balanceBn = await getSolanaTokenBalance(userAddress, token.address);
|
|
30905
31053
|
return formatBNToReadable(balanceBn, token.decimals);
|
|
30906
31054
|
},
|
|
30907
|
-
enabled:
|
|
30908
|
-
!!userAddress &&
|
|
30909
|
-
!!token &&
|
|
30910
|
-
chain?.chainType === squidTypes.ChainType.SOLANA,
|
|
31055
|
+
enabled: isQueryEnabled,
|
|
30911
31056
|
refetchInterval: refreshIntervalMs,
|
|
30912
31057
|
retry: 2,
|
|
30913
31058
|
});
|
|
30914
|
-
return { balance, isLoading };
|
|
31059
|
+
return { balance, isLoading: isQueryEnabled && isLoading };
|
|
30915
31060
|
};
|
|
30916
31061
|
// TODO: implement fetching balances for all bitcoin tokens
|
|
30917
31062
|
const useBitcoinBalance = ({ userAddress, chain, }) => {
|
|
@@ -31044,11 +31189,14 @@ function useNativeTokenForChain(chain) {
|
|
|
31044
31189
|
|
|
31045
31190
|
const useEvmNativeBalance = ({ address, chain, }) => {
|
|
31046
31191
|
const { isChainTypeConnected } = useWallet();
|
|
31192
|
+
const isEvmChain = chain?.chainType === squidTypes.ChainType.EVM;
|
|
31193
|
+
const evmAddress = parseEvmAddress(address);
|
|
31194
|
+
const isQueryEnabled = isEvmChain && !!evmAddress && isChainTypeConnected(squidTypes.ChainType.EVM);
|
|
31047
31195
|
const { data: nativeEvmBalance, isLoading } = wagmi.useBalance({
|
|
31048
|
-
address:
|
|
31049
|
-
chainId: Number(chain
|
|
31196
|
+
address: evmAddress,
|
|
31197
|
+
chainId: isEvmChain ? Number(chain.chainId) : undefined,
|
|
31050
31198
|
query: {
|
|
31051
|
-
enabled:
|
|
31199
|
+
enabled: isQueryEnabled,
|
|
31052
31200
|
refetchInterval: 10000,
|
|
31053
31201
|
staleTime: 5000,
|
|
31054
31202
|
refetchOnWindowFocus: true,
|
|
@@ -31072,7 +31220,7 @@ const useEvmNativeBalance = ({ address, chain, }) => {
|
|
|
31072
31220
|
}, [nativeEvmBalance?.decimals, nativeEvmBalance?.value, chain?.chainId]);
|
|
31073
31221
|
return {
|
|
31074
31222
|
balance,
|
|
31075
|
-
isLoading,
|
|
31223
|
+
isLoading: isQueryEnabled && isLoading,
|
|
31076
31224
|
};
|
|
31077
31225
|
};
|
|
31078
31226
|
const useCosmosNativeBalance = ({ address, chain, }) => {
|
|
@@ -31126,13 +31274,14 @@ const useBitcoinNativeBalance = ({ chain, address, }) => {
|
|
|
31126
31274
|
};
|
|
31127
31275
|
const useSolanaNativeBalance = ({ chain, address, }) => {
|
|
31128
31276
|
const { nativeToken } = useNativeTokenForChain(chain);
|
|
31277
|
+
const isQueryEnabled = nativeToken?.decimals != null &&
|
|
31278
|
+
chain?.chainType === squidTypes.ChainType.SOLANA &&
|
|
31279
|
+
isWalletAddressValid(chain, address);
|
|
31129
31280
|
const { data: rawBalance, isLoading } = reactQuery.useQuery(keys().balance(chain?.chainId, nativeToken?.address, address), async () => {
|
|
31130
31281
|
const balance = await getSolanaNativeBalance(address);
|
|
31131
31282
|
return formatBNToReadable(balance, nativeToken.decimals);
|
|
31132
31283
|
}, {
|
|
31133
|
-
enabled:
|
|
31134
|
-
nativeToken?.decimals != null &&
|
|
31135
|
-
chain?.chainType === squidTypes.ChainType.SOLANA,
|
|
31284
|
+
enabled: isQueryEnabled,
|
|
31136
31285
|
refetchInterval: 40000,
|
|
31137
31286
|
staleTime: 20000,
|
|
31138
31287
|
refetchOnWindowFocus: true,
|
|
@@ -31148,7 +31297,7 @@ const useSolanaNativeBalance = ({ chain, address, }) => {
|
|
|
31148
31297
|
}, [nativeToken?.decimals, rawBalance]);
|
|
31149
31298
|
return {
|
|
31150
31299
|
balance,
|
|
31151
|
-
isLoading,
|
|
31300
|
+
isLoading: isQueryEnabled && isLoading,
|
|
31152
31301
|
};
|
|
31153
31302
|
};
|
|
31154
31303
|
const useSuiNativeBalance = ({ address, chain, }) => {
|
|
@@ -31556,7 +31705,7 @@ function hederaWalletConnect(parameters) {
|
|
|
31556
31705
|
const optionalChains = config.chains.map((x) => x.id);
|
|
31557
31706
|
if (!optionalChains.length)
|
|
31558
31707
|
return;
|
|
31559
|
-
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-
|
|
31708
|
+
const { EthereumProvider } = await Promise.resolve().then(function () { return require('./index.es-BQULJYpe.js'); });
|
|
31560
31709
|
const rawProvider = await EthereumProvider.init({
|
|
31561
31710
|
...restParameters,
|
|
31562
31711
|
disableProviderPing: true,
|
|
@@ -31900,7 +32049,10 @@ function useHederaTokenAssociations({ address, chain, token }) {
|
|
|
31900
32049
|
token,
|
|
31901
32050
|
});
|
|
31902
32051
|
},
|
|
31903
|
-
enabled:
|
|
32052
|
+
enabled: isEvmAddressValid(address) &&
|
|
32053
|
+
!!publicClient &&
|
|
32054
|
+
chain?.chainId === CHAIN_IDS.HEDERA &&
|
|
32055
|
+
token?.chainId === CHAIN_IDS.HEDERA,
|
|
31904
32056
|
});
|
|
31905
32057
|
return {
|
|
31906
32058
|
isTokenAssociated,
|
|
@@ -32013,7 +32165,9 @@ function useStellarAccountActivation({ address, chain, token, }) {
|
|
|
32013
32165
|
reserveBaseBn: accountReserveBase,
|
|
32014
32166
|
};
|
|
32015
32167
|
},
|
|
32016
|
-
enabled: !!address &&
|
|
32168
|
+
enabled: !!address &&
|
|
32169
|
+
chain?.chainType === squidTypes.ChainType.STELLAR &&
|
|
32170
|
+
isStellarAddressValid(address),
|
|
32017
32171
|
refetchInterval: DEFAULT_REFETCH_INTERVAL$2,
|
|
32018
32172
|
refetchOnWindowFocus: true,
|
|
32019
32173
|
});
|
|
@@ -39107,7 +39261,9 @@ function useXrplTrustLine({ address, chain, token, amount }) {
|
|
|
39107
39261
|
const xrplClient = await getClient(chain);
|
|
39108
39262
|
return xrplClient.accountActivatedInfo(address);
|
|
39109
39263
|
},
|
|
39110
|
-
enabled: !!address &&
|
|
39264
|
+
enabled: !!address &&
|
|
39265
|
+
chain?.chainType === squidTypes.ChainType.XRPL &&
|
|
39266
|
+
isXrplAddressValid(address),
|
|
39111
39267
|
refetchInterval: DEFAULT_REFETCH_INTERVAL,
|
|
39112
39268
|
refetchOnWindowFocus: true,
|
|
39113
39269
|
});
|
|
@@ -39369,6 +39525,7 @@ exports.isCoralBridgeAction = isCoralBridgeAction;
|
|
|
39369
39525
|
exports.isCosmosAddressValid = isCosmosAddressValid;
|
|
39370
39526
|
exports.isDepositAddressDirectTransferRoute = isDepositAddressDirectTransferRoute;
|
|
39371
39527
|
exports.isEmptyObject = isEmptyObject;
|
|
39528
|
+
exports.isEvmAddressValid = isEvmAddressValid;
|
|
39372
39529
|
exports.isEvmChainNotSupportedError = isEvmChainNotSupportedError;
|
|
39373
39530
|
exports.isEvmosChain = isEvmosChain;
|
|
39374
39531
|
exports.isFallbackAddressNeeded = isFallbackAddressNeeded;
|
|
@@ -39516,4 +39673,4 @@ exports.useXrplTrustLine = useXrplTrustLine;
|
|
|
39516
39673
|
exports.waitForReceiptWithRetry = waitForReceiptWithRetry;
|
|
39517
39674
|
exports.walletIconBaseUrl = walletIconBaseUrl;
|
|
39518
39675
|
exports.walletSupportsChainType = walletSupportsChainType;
|
|
39519
|
-
//# sourceMappingURL=index-
|
|
39676
|
+
//# sourceMappingURL=index-BjIX7utV.js.map
|