@sodax/sdk 2.1.0-rc.4 → 2.1.0-rc.6
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/index.cjs +678 -375
- package/dist/index.d.cts +200 -14
- package/dist/index.d.ts +200 -14
- package/dist/index.mjs +674 -376
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getAbiItem, parseAbi, isAddress, toHex, hexToBytes, encodeAbiParameters, parseAbiParameters, defineChain, encodeFunctionData, erc20Abi as erc20Abi$1, createPublicClient, http, bytesToHex, keccak256, stringToBytes, fromHex, encodePacked, decodeAbiParameters, parseEventLogs, maxUint160, maxUint48, fallback } from 'viem';
|
|
1
|
+
import { getAbiItem, parseAbi, isAddress, toHex, hexToBytes, encodeAbiParameters, parseAbiParameters, defineChain, encodeFunctionData, erc20Abi as erc20Abi$1, createPublicClient, http, bytesToHex, keccak256, stringToBytes, fromHex, encodePacked, decodeAbiParameters, parseEventLogs, isHex, maxUint160, maxUint48, fallback } from 'viem';
|
|
2
2
|
import { bcs } from '@mysten/sui/bcs';
|
|
3
3
|
import { PublicKey, Connection, VersionedTransaction, SystemProgram, ComputeBudgetProgram, TransactionMessage, TransactionInstruction } from '@solana/web3.js';
|
|
4
4
|
import { rpc, Address, xdr, Account, Horizon, Contract, TransactionBuilder, nativeToScVal, TimeoutInfinite, scValToBigInt, Operation, Asset, FeeBumpTransaction, NotFoundError, Networks, Keypair } from '@stellar/stellar-sdk';
|
|
@@ -17,7 +17,7 @@ import * as IconSdkRaw from 'icon-sdk-js';
|
|
|
17
17
|
import { ChainGrpcWasmApi, TxGrpcApi, toBase64, fromBase64, MsgExecuteContract, ChainRestAuthApi, BaseAccount, createTransaction } from '@injectivelabs/sdk-ts';
|
|
18
18
|
import { TxRaw } from 'cosmjs-types/cosmos/tx/v1beta1/tx.js';
|
|
19
19
|
import { getNetworkEndpoints, Network } from '@injectivelabs/networks';
|
|
20
|
-
import * as
|
|
20
|
+
import * as v from 'valibot';
|
|
21
21
|
import { SwapsApi, SwapsApiError } from '@sodax/swaps-api';
|
|
22
22
|
export { SwapsApiError } from '@sodax/swaps-api';
|
|
23
23
|
import BigNumber5, { BigNumber } from 'bignumber.js';
|
|
@@ -94,8 +94,8 @@ function serializeCause(cause, depth) {
|
|
|
94
94
|
}
|
|
95
95
|
function sanitizeContext(value, depth) {
|
|
96
96
|
const out = {};
|
|
97
|
-
for (const [key,
|
|
98
|
-
out[key] = sanitizeValue(
|
|
97
|
+
for (const [key, v10] of Object.entries(value)) {
|
|
98
|
+
out[key] = sanitizeValue(v10, depth + 1);
|
|
99
99
|
}
|
|
100
100
|
return out;
|
|
101
101
|
}
|
|
@@ -106,13 +106,13 @@ function sanitizeValue(value, depth) {
|
|
|
106
106
|
if (t === "bigint") return value.toString();
|
|
107
107
|
if (t === "string" || t === "number" || t === "boolean") return value;
|
|
108
108
|
if (t === "function" || t === "symbol") return safeString(value);
|
|
109
|
-
if (Array.isArray(value)) return value.map((
|
|
109
|
+
if (Array.isArray(value)) return value.map((v10) => sanitizeValue(v10, depth + 1));
|
|
110
110
|
if (value instanceof Date) return value.toISOString();
|
|
111
111
|
if (value instanceof Map) {
|
|
112
|
-
return Array.from(value.entries()).map(([k,
|
|
112
|
+
return Array.from(value.entries()).map(([k, v10]) => [sanitizeValue(k, depth + 1), sanitizeValue(v10, depth + 1)]);
|
|
113
113
|
}
|
|
114
114
|
if (value instanceof Set) {
|
|
115
|
-
return Array.from(value.values()).map((
|
|
115
|
+
return Array.from(value.values()).map((v10) => sanitizeValue(v10, depth + 1));
|
|
116
116
|
}
|
|
117
117
|
if (value instanceof Error) return { name: value.name, message: value.message };
|
|
118
118
|
if (t === "object") {
|
|
@@ -124,9 +124,9 @@ function sanitizeValue(value, depth) {
|
|
|
124
124
|
}
|
|
125
125
|
return safeString(value);
|
|
126
126
|
}
|
|
127
|
-
function safeString(
|
|
127
|
+
function safeString(v10) {
|
|
128
128
|
try {
|
|
129
|
-
return String(
|
|
129
|
+
return String(v10);
|
|
130
130
|
} catch {
|
|
131
131
|
return "[unserializable]";
|
|
132
132
|
}
|
|
@@ -3489,6 +3489,7 @@ var ICON_TX_RESULT_WAIT_MAX_RETRY = 10;
|
|
|
3489
3489
|
var MAX_UINT256 = (1n << 256n) - 1n;
|
|
3490
3490
|
var FEE_PERCENTAGE_SCALE = 10000n;
|
|
3491
3491
|
var DEFAULT_DEADLINE_OFFSET = 300n;
|
|
3492
|
+
var DEFAULT_API_BASE_URL = "https://api.sodax.com/v1";
|
|
3492
3493
|
var DEFAULT_BACKEND_API_ENDPOINT = "https://api.sodax.com/v1/be";
|
|
3493
3494
|
var DEFAULT_BACKEND_API_TIMEOUT = 3e4;
|
|
3494
3495
|
var DEFAULT_BACKEND_API_HEADERS = {
|
|
@@ -3499,8 +3500,9 @@ var DEFAULT_RELAYER_API_ENDPOINT = "https://xcall-relay.nw.iconblockchain.xyz";
|
|
|
3499
3500
|
var VAULT_TOKEN_DECIMALS = 18;
|
|
3500
3501
|
var DEFAULT_SPONSORING_API_ENDPOINT = "https://api.sodax.com/v1";
|
|
3501
3502
|
var SPONSORING_API_STELLAR_BASE_PATH = "/sponsorships/stellar";
|
|
3503
|
+
var BACKEND_API_BASE_PATH = "/be";
|
|
3502
3504
|
var apiConfig = {
|
|
3503
|
-
baseURL:
|
|
3505
|
+
baseURL: DEFAULT_API_BASE_URL,
|
|
3504
3506
|
timeout: DEFAULT_BACKEND_API_TIMEOUT,
|
|
3505
3507
|
headers: DEFAULT_BACKEND_API_HEADERS
|
|
3506
3508
|
};
|
|
@@ -4428,7 +4430,7 @@ function isValidWalletProviderForChainKey(chainKey, walletProvider) {
|
|
|
4428
4430
|
}
|
|
4429
4431
|
|
|
4430
4432
|
// ../types/dist/index.js
|
|
4431
|
-
var CONFIG_VERSION =
|
|
4433
|
+
var CONFIG_VERSION = 226;
|
|
4432
4434
|
|
|
4433
4435
|
// src/shared/utils/resolveTimeoutMs.ts
|
|
4434
4436
|
function resolveTimeoutMs(timeout, fallbackMs) {
|
|
@@ -4815,10 +4817,11 @@ async function submitTransaction(payload, apiUrl) {
|
|
|
4815
4817
|
return { ok: false, error };
|
|
4816
4818
|
}
|
|
4817
4819
|
}
|
|
4818
|
-
async function getTransactionPackets(payload, apiUrl) {
|
|
4820
|
+
async function getTransactionPackets(payload, apiUrl, timeoutMs) {
|
|
4819
4821
|
invariant(payload.params.chain_id.length > 0, "Invalid input parameters. source_chain_id empty");
|
|
4820
4822
|
invariant(payload.params.tx_hash.length > 0, "Invalid input parameters. tx_hash empty");
|
|
4821
|
-
return postRequest(payload, apiUrl);
|
|
4823
|
+
if (timeoutMs === void 0) return postRequest(payload, apiUrl);
|
|
4824
|
+
return pollTransactionPackets(payload, apiUrl, Date.now() + resolveTimeoutMs(timeoutMs, RELAY_REQUEST_TIMEOUT_MS));
|
|
4822
4825
|
}
|
|
4823
4826
|
async function getPacket(payload, apiUrl) {
|
|
4824
4827
|
invariant(payload.params.chain_id.length > 0, "Invalid input parameters. source_chain_id empty");
|
|
@@ -14365,7 +14368,7 @@ function mergeSodaxConfig(base2, override) {
|
|
|
14365
14368
|
}
|
|
14366
14369
|
function encodeContractCalls(calls) {
|
|
14367
14370
|
return encodeAbiParameters(parseAbiParameters("(address,uint256,bytes)[]"), [
|
|
14368
|
-
calls.map((
|
|
14371
|
+
calls.map((v10) => [v10.address, v10.value, v10.data])
|
|
14369
14372
|
]);
|
|
14370
14373
|
}
|
|
14371
14374
|
async function waitForTransactionReceipt(hash, provider) {
|
|
@@ -15778,12 +15781,12 @@ function encodeBtcPayloadToBytes(payload) {
|
|
|
15778
15781
|
});
|
|
15779
15782
|
}
|
|
15780
15783
|
function normalizePsbtToBase64(signedPsbt) {
|
|
15781
|
-
const
|
|
15782
|
-
return
|
|
15784
|
+
const isHex2 = /^[0-9a-fA-F]+$/.test(signedPsbt);
|
|
15785
|
+
return isHex2 ? Buffer.from(signedPsbt, "hex").toString("base64") : signedPsbt;
|
|
15783
15786
|
}
|
|
15784
15787
|
function normalizeSignatureToBase64(signature) {
|
|
15785
|
-
const
|
|
15786
|
-
return
|
|
15788
|
+
const isHex2 = /^[0-9a-fA-F]+$/.test(signature);
|
|
15789
|
+
return isHex2 ? Buffer.from(signature, "hex").toString("base64") : signature;
|
|
15787
15790
|
}
|
|
15788
15791
|
|
|
15789
15792
|
// src/shared/services/spoke/BitcoinSpokeService.ts
|
|
@@ -17057,22 +17060,22 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
17057
17060
|
const byte0 = Uint8Array.of(0);
|
|
17058
17061
|
const byte1 = Uint8Array.of(1);
|
|
17059
17062
|
const _maxDrbgIters = 1e3;
|
|
17060
|
-
let
|
|
17063
|
+
let v10 = u8n(hashLen);
|
|
17061
17064
|
let k = u8n(hashLen);
|
|
17062
17065
|
let i = 0;
|
|
17063
17066
|
const reset = () => {
|
|
17064
|
-
|
|
17067
|
+
v10.fill(1);
|
|
17065
17068
|
k.fill(0);
|
|
17066
17069
|
i = 0;
|
|
17067
17070
|
};
|
|
17068
|
-
const h = (...msgs) => hmacFn(k, concatBytes(
|
|
17071
|
+
const h = (...msgs) => hmacFn(k, concatBytes(v10, ...msgs));
|
|
17069
17072
|
const reseed = (seed = NULL) => {
|
|
17070
17073
|
k = h(byte0, seed);
|
|
17071
|
-
|
|
17074
|
+
v10 = h();
|
|
17072
17075
|
if (seed.length === 0)
|
|
17073
17076
|
return;
|
|
17074
17077
|
k = h(byte1, seed);
|
|
17075
|
-
|
|
17078
|
+
v10 = h();
|
|
17076
17079
|
};
|
|
17077
17080
|
const gen = () => {
|
|
17078
17081
|
if (i++ >= _maxDrbgIters)
|
|
@@ -17080,10 +17083,10 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
17080
17083
|
let len = 0;
|
|
17081
17084
|
const out = [];
|
|
17082
17085
|
while (len < qByteLen) {
|
|
17083
|
-
|
|
17084
|
-
const sl =
|
|
17086
|
+
v10 = h();
|
|
17087
|
+
const sl = v10.slice();
|
|
17085
17088
|
out.push(sl);
|
|
17086
|
-
len +=
|
|
17089
|
+
len += v10.length;
|
|
17087
17090
|
}
|
|
17088
17091
|
return concatBytes(...out);
|
|
17089
17092
|
};
|
|
@@ -17109,7 +17112,7 @@ function validateObject(object5, fields = {}, optFields = {}) {
|
|
|
17109
17112
|
if (current !== expectedType || val === null)
|
|
17110
17113
|
throw new Error(`param "${fieldName}" is invalid: expected ${expectedType}, got ${current}`);
|
|
17111
17114
|
}
|
|
17112
|
-
const iter = (f, isOpt) => Object.entries(f).forEach(([k,
|
|
17115
|
+
const iter = (f, isOpt) => Object.entries(f).forEach(([k, v10]) => checkField(k, v10, isOpt));
|
|
17113
17116
|
iter(fields, false);
|
|
17114
17117
|
iter(optFields, true);
|
|
17115
17118
|
}
|
|
@@ -17180,9 +17183,9 @@ function sqrt3mod4(Fp, n) {
|
|
|
17180
17183
|
function sqrt5mod8(Fp, n) {
|
|
17181
17184
|
const p5div8 = (Fp.ORDER - _5n) / _8n;
|
|
17182
17185
|
const n2 = Fp.mul(n, _2n);
|
|
17183
|
-
const
|
|
17184
|
-
const nv = Fp.mul(n,
|
|
17185
|
-
const i = Fp.mul(Fp.mul(nv, _2n),
|
|
17186
|
+
const v10 = Fp.pow(n2, p5div8);
|
|
17187
|
+
const nv = Fp.mul(n, v10);
|
|
17188
|
+
const i = Fp.mul(Fp.mul(nv, _2n), v10);
|
|
17186
17189
|
const root = Fp.mul(nv, Fp.sub(i, Fp.ONE));
|
|
17187
17190
|
assertIsSquare(Fp, root, n);
|
|
17188
17191
|
return root;
|
|
@@ -17764,9 +17767,9 @@ function edwards(params, extraOpts = {}) {
|
|
|
17764
17767
|
validateObject(extraOpts, {}, { uvRatio: "function" });
|
|
17765
17768
|
const MASK = _2n2 << BigInt(Fn.BYTES * 8) - _1n4;
|
|
17766
17769
|
const modP = (n) => Fp.create(n);
|
|
17767
|
-
const uvRatio2 = extraOpts.uvRatio || ((u,
|
|
17770
|
+
const uvRatio2 = extraOpts.uvRatio || ((u, v10) => {
|
|
17768
17771
|
try {
|
|
17769
|
-
return { isValid: true, value: Fp.sqrt(Fp.div(u,
|
|
17772
|
+
return { isValid: true, value: Fp.sqrt(Fp.div(u, v10)) };
|
|
17770
17773
|
} catch (e) {
|
|
17771
17774
|
return { isValid: false, value: _0n4 };
|
|
17772
17775
|
}
|
|
@@ -17862,8 +17865,8 @@ function edwards(params, extraOpts = {}) {
|
|
|
17862
17865
|
aInRange("point.y", y, _0n4, max);
|
|
17863
17866
|
const y2 = modP(y * y);
|
|
17864
17867
|
const u = modP(y2 - _1n4);
|
|
17865
|
-
const
|
|
17866
|
-
let { isValid, value: x } = uvRatio2(u,
|
|
17868
|
+
const v10 = modP(d * y2 - a);
|
|
17869
|
+
let { isValid, value: x } = uvRatio2(u, v10);
|
|
17867
17870
|
if (!isValid)
|
|
17868
17871
|
throw new Error("bad point: invalid y coordinate");
|
|
17869
17872
|
const isXOdd = (x & _1n4) === _1n4;
|
|
@@ -18203,13 +18206,13 @@ function adjustScalarBytes(bytes) {
|
|
|
18203
18206
|
return bytes;
|
|
18204
18207
|
}
|
|
18205
18208
|
var ED25519_SQRT_M1 = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
|
|
18206
|
-
function uvRatio(u,
|
|
18209
|
+
function uvRatio(u, v10) {
|
|
18207
18210
|
const P = ed25519_CURVE_p;
|
|
18208
|
-
const v32 = mod(
|
|
18209
|
-
const v72 = mod(v32 * v32 *
|
|
18211
|
+
const v32 = mod(v10 * v10 * v10, P);
|
|
18212
|
+
const v72 = mod(v32 * v32 * v10, P);
|
|
18210
18213
|
const pow = ed25519_pow_2_252_3(u * v72).pow_p_5_8;
|
|
18211
18214
|
let x = mod(u * v32 * pow, P);
|
|
18212
|
-
const vx2 = mod(
|
|
18215
|
+
const vx2 = mod(v10 * x * x, P);
|
|
18213
18216
|
const root1 = x;
|
|
18214
18217
|
const root2 = mod(x * ED25519_SQRT_M1, P);
|
|
18215
18218
|
const useRoot1 = vx2 === u;
|
|
@@ -18540,7 +18543,7 @@ function findSeatPrice(validators, maxNumberOfSeats, minimumStakeRatio, protocol
|
|
|
18540
18543
|
return findSeatPriceForProtocolAfter49(validators, maxNumberOfSeats, minimumStakeRatio);
|
|
18541
18544
|
}
|
|
18542
18545
|
function findSeatPriceForProtocolBefore49(validators, numSeats) {
|
|
18543
|
-
const stakes = validators.map((
|
|
18546
|
+
const stakes = validators.map((v10) => BigInt(v10.stake)).sort(sortBigIntAsc);
|
|
18544
18547
|
const num = BigInt(numSeats);
|
|
18545
18548
|
const stakesSum = stakes.reduce((a, b) => a + b);
|
|
18546
18549
|
if (stakesSum < num) {
|
|
@@ -18569,7 +18572,7 @@ function findSeatPriceForProtocolAfter49(validators, maxNumberOfSeats, minimumSt
|
|
|
18569
18572
|
if (minimumStakeRatio.length != 2) {
|
|
18570
18573
|
throw Error("minimumStakeRatio should have 2 elements");
|
|
18571
18574
|
}
|
|
18572
|
-
const stakes = validators.map((
|
|
18575
|
+
const stakes = validators.map((v10) => BigInt(v10.stake)).sort(sortBigIntAsc);
|
|
18573
18576
|
const stakesSum = stakes.reduce((a, b) => a + b);
|
|
18574
18577
|
if (validators.length < maxNumberOfSeats) {
|
|
18575
18578
|
return stakesSum * BigInt(minimumStakeRatio[0]) / BigInt(minimumStakeRatio[1]);
|
|
@@ -18741,10 +18744,10 @@ var DER = {
|
|
|
18741
18744
|
if (length < 128)
|
|
18742
18745
|
throw new E("tlv.decode(long): not minimal encoding");
|
|
18743
18746
|
}
|
|
18744
|
-
const
|
|
18745
|
-
if (
|
|
18747
|
+
const v10 = data.subarray(pos, pos + length);
|
|
18748
|
+
if (v10.length !== length)
|
|
18746
18749
|
throw new E("tlv.decode: wrong value length");
|
|
18747
|
-
return { v:
|
|
18750
|
+
return { v: v10, l: data.subarray(pos + length) };
|
|
18748
18751
|
}
|
|
18749
18752
|
},
|
|
18750
18753
|
// https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,
|
|
@@ -19491,14 +19494,14 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
19491
19494
|
return false;
|
|
19492
19495
|
const { r, s } = sig;
|
|
19493
19496
|
const h = bits2int_modN(message);
|
|
19494
|
-
const
|
|
19495
|
-
const u1 = Fn.create(h *
|
|
19496
|
-
const u2 = Fn.create(r *
|
|
19497
|
+
const is3 = Fn.inv(s);
|
|
19498
|
+
const u1 = Fn.create(h * is3);
|
|
19499
|
+
const u2 = Fn.create(r * is3);
|
|
19497
19500
|
const R = Point.BASE.multiplyUnsafe(u1).add(P.multiplyUnsafe(u2));
|
|
19498
19501
|
if (R.is0())
|
|
19499
19502
|
return false;
|
|
19500
|
-
const
|
|
19501
|
-
return
|
|
19503
|
+
const v10 = Fn.create(R.x);
|
|
19504
|
+
return v10 === r;
|
|
19502
19505
|
} catch (e) {
|
|
19503
19506
|
return false;
|
|
19504
19507
|
}
|
|
@@ -26893,19 +26896,32 @@ var SolverApiService = class {
|
|
|
26893
26896
|
*
|
|
26894
26897
|
* @param request - Object containing `intent_tx_hash` — the hub-chain tx hash of the intent.
|
|
26895
26898
|
* @param config - Solver endpoint configuration.
|
|
26899
|
+
* @param logger - Diagnostics sink; defaults to the silent logger.
|
|
26900
|
+
* @param timeoutMs - Optional budget for the request. Omit it and the call is unbounded, as it has
|
|
26901
|
+
* always been. Supply it when a stalled solver must not hold the caller open — a status read
|
|
26902
|
+
* polled on a short interval, say. An expiry surfaces as `UNKNOWN`, like any other failure.
|
|
26903
|
+
* A non-finite value (`NaN` out of `Number(process.env.X)`, or `Infinity`) is treated as no
|
|
26904
|
+
* budget at all rather than passed to `setTimeout`, which would coerce it to ~0 and fail every
|
|
26905
|
+
* request instantly. A non-positive one is a real budget of zero: the request aborts at once.
|
|
26906
|
+
* The relay's `getTransactionPackets` takes the same parameter but degrades a non-finite value
|
|
26907
|
+
* to its own per-request budget instead; the divergence is deliberate, and explained inline.
|
|
26896
26908
|
* @returns A `Result` containing `{ status: SolverIntentStatusCode, fill_tx_hash?: string }`.
|
|
26897
26909
|
* `fill_tx_hash` is set only when `status === SolverIntentStatusCode.SOLVED (3)`.
|
|
26898
26910
|
* @throws Invariant error if `intent_tx_hash` is empty (thrown before the async request).
|
|
26899
26911
|
*/
|
|
26900
|
-
static async getStatus(request, config, logger = silentLogger) {
|
|
26912
|
+
static async getStatus(request, config, logger = silentLogger, timeoutMs) {
|
|
26901
26913
|
invariant(request.intent_tx_hash.length > 0, "Empty intent_tx_hash");
|
|
26914
|
+
const budgetMs = timeoutMs !== void 0 && Number.isFinite(timeoutMs) ? Math.max(0, timeoutMs) : void 0;
|
|
26915
|
+
const controller = budgetMs === void 0 ? void 0 : new AbortController();
|
|
26916
|
+
const timeoutId = controller ? setTimeout(() => controller.abort(), budgetMs) : void 0;
|
|
26902
26917
|
try {
|
|
26903
26918
|
const response = await fetch(`${config.solverApiEndpoint}/status`, {
|
|
26904
26919
|
method: "POST",
|
|
26905
26920
|
headers: {
|
|
26906
26921
|
"Content-Type": "application/json"
|
|
26907
26922
|
},
|
|
26908
|
-
body: JSON.stringify(request)
|
|
26923
|
+
body: JSON.stringify(request),
|
|
26924
|
+
signal: controller?.signal
|
|
26909
26925
|
});
|
|
26910
26926
|
if (!response.ok) {
|
|
26911
26927
|
return {
|
|
@@ -26927,10 +26943,12 @@ var SolverApiService = class {
|
|
|
26927
26943
|
error: {
|
|
26928
26944
|
detail: {
|
|
26929
26945
|
code: SolverIntentErrorCode.UNKNOWN,
|
|
26930
|
-
message: e ? JSON.stringify(e, bigintReplacer) : "Unknown error"
|
|
26946
|
+
message: controller?.signal.aborted ? `solver /status timed out after ${budgetMs}ms` : e ? JSON.stringify(e, bigintReplacer) : "Unknown error"
|
|
26931
26947
|
}
|
|
26932
26948
|
}
|
|
26933
26949
|
};
|
|
26950
|
+
} finally {
|
|
26951
|
+
clearTimeout(timeoutId);
|
|
26934
26952
|
}
|
|
26935
26953
|
}
|
|
26936
26954
|
};
|
|
@@ -27024,6 +27042,152 @@ async function runBackendSubmitTx({
|
|
|
27024
27042
|
});
|
|
27025
27043
|
return polled.ok ? { ok: true, value: polled.value } : { ok: false, cause: polled.cause };
|
|
27026
27044
|
}
|
|
27045
|
+
var ChainKeySchema = v.custom((input) => typeof input === "string");
|
|
27046
|
+
var SpokeChainKeySchema = v.custom((input) => typeof input === "string");
|
|
27047
|
+
var AddressSchema = v.custom((input) => typeof input === "string");
|
|
27048
|
+
var XTokenSchema = v.object({
|
|
27049
|
+
symbol: v.string(),
|
|
27050
|
+
name: v.string(),
|
|
27051
|
+
decimals: v.number(),
|
|
27052
|
+
address: v.string(),
|
|
27053
|
+
chainKey: ChainKeySchema,
|
|
27054
|
+
hubAsset: AddressSchema,
|
|
27055
|
+
vault: AddressSchema,
|
|
27056
|
+
access: v.optional(v.picklist(["withdrawOnly", "depositOnly"]))
|
|
27057
|
+
});
|
|
27058
|
+
var IntentStructSchema = v.object({
|
|
27059
|
+
intentId: v.string(),
|
|
27060
|
+
creator: v.string(),
|
|
27061
|
+
inputToken: v.string(),
|
|
27062
|
+
outputToken: v.string(),
|
|
27063
|
+
inputAmount: v.string(),
|
|
27064
|
+
minOutputAmount: v.string(),
|
|
27065
|
+
deadline: v.string(),
|
|
27066
|
+
allowPartialFill: v.boolean(),
|
|
27067
|
+
srcChain: v.number(),
|
|
27068
|
+
dstChain: v.number(),
|
|
27069
|
+
srcAddress: v.string(),
|
|
27070
|
+
dstAddress: v.string(),
|
|
27071
|
+
solver: v.string(),
|
|
27072
|
+
data: v.string()
|
|
27073
|
+
});
|
|
27074
|
+
var FillEventSchema = v.object({
|
|
27075
|
+
eventType: v.literal("intent-filled"),
|
|
27076
|
+
// The hub-chain fill tx; an empty one is no use as `fill_tx_hash`.
|
|
27077
|
+
txHash: v.pipe(v.string(), v.nonEmpty()),
|
|
27078
|
+
// Terminality. An intent created with `allowPartialFill` emits a fill event per fill, so the
|
|
27079
|
+
// event alone does not mean the intent is done — only `remainingInput === '0'` does. Required:
|
|
27080
|
+
// without it there is no proof of completion, and claiming SOLVED on a partial fill would report
|
|
27081
|
+
// an unfinished swap as complete.
|
|
27082
|
+
intentState: v.object({
|
|
27083
|
+
remainingInput: v.string()
|
|
27084
|
+
})
|
|
27085
|
+
});
|
|
27086
|
+
var IntentResponseSchema = v.object({
|
|
27087
|
+
intentHash: v.string(),
|
|
27088
|
+
txHash: v.string(),
|
|
27089
|
+
logIndex: v.number(),
|
|
27090
|
+
chainId: v.number(),
|
|
27091
|
+
blockNumber: v.number(),
|
|
27092
|
+
open: v.boolean(),
|
|
27093
|
+
intent: IntentStructSchema,
|
|
27094
|
+
events: v.array(v.unknown())
|
|
27095
|
+
});
|
|
27096
|
+
var UserIntentsResponseSchema = v.object({
|
|
27097
|
+
total: v.number(),
|
|
27098
|
+
offset: v.number(),
|
|
27099
|
+
limit: v.number(),
|
|
27100
|
+
items: v.array(IntentResponseSchema)
|
|
27101
|
+
});
|
|
27102
|
+
var OrderbookResponseSchema = v.object({
|
|
27103
|
+
total: v.number(),
|
|
27104
|
+
data: v.array(
|
|
27105
|
+
v.object({
|
|
27106
|
+
intentState: v.object({
|
|
27107
|
+
exists: v.boolean(),
|
|
27108
|
+
remainingInput: v.string(),
|
|
27109
|
+
receivedOutput: v.string(),
|
|
27110
|
+
pendingPayment: v.boolean()
|
|
27111
|
+
}),
|
|
27112
|
+
intentData: v.object({
|
|
27113
|
+
intentId: v.string(),
|
|
27114
|
+
creator: v.string(),
|
|
27115
|
+
inputToken: v.string(),
|
|
27116
|
+
outputToken: v.string(),
|
|
27117
|
+
inputAmount: v.string(),
|
|
27118
|
+
minOutputAmount: v.string(),
|
|
27119
|
+
deadline: v.string(),
|
|
27120
|
+
allowPartialFill: v.boolean(),
|
|
27121
|
+
srcChain: v.number(),
|
|
27122
|
+
dstChain: v.number(),
|
|
27123
|
+
srcAddress: v.string(),
|
|
27124
|
+
dstAddress: v.string(),
|
|
27125
|
+
solver: v.string(),
|
|
27126
|
+
data: v.string(),
|
|
27127
|
+
intentHash: v.string(),
|
|
27128
|
+
txHash: v.string(),
|
|
27129
|
+
blockNumber: v.number()
|
|
27130
|
+
})
|
|
27131
|
+
})
|
|
27132
|
+
)
|
|
27133
|
+
});
|
|
27134
|
+
var MoneyMarketPositionSchema = v.object({
|
|
27135
|
+
userAddress: v.string(),
|
|
27136
|
+
positions: v.array(
|
|
27137
|
+
v.object({
|
|
27138
|
+
reserveAddress: v.string(),
|
|
27139
|
+
aTokenAddress: v.string(),
|
|
27140
|
+
variableDebtTokenAddress: v.string(),
|
|
27141
|
+
aTokenBalance: v.string(),
|
|
27142
|
+
variableDebtTokenBalance: v.string(),
|
|
27143
|
+
blockNumber: v.number()
|
|
27144
|
+
})
|
|
27145
|
+
)
|
|
27146
|
+
});
|
|
27147
|
+
var MoneyMarketAssetSchema = v.object({
|
|
27148
|
+
reserveAddress: v.string(),
|
|
27149
|
+
aTokenAddress: v.string(),
|
|
27150
|
+
totalATokenBalance: v.string(),
|
|
27151
|
+
variableDebtTokenAddress: v.string(),
|
|
27152
|
+
totalVariableDebtTokenBalance: v.string(),
|
|
27153
|
+
liquidityRate: v.string(),
|
|
27154
|
+
symbol: v.string(),
|
|
27155
|
+
totalSuppliers: v.number(),
|
|
27156
|
+
totalBorrowers: v.number(),
|
|
27157
|
+
variableBorrowRate: v.string(),
|
|
27158
|
+
stableBorrowRate: v.string(),
|
|
27159
|
+
liquidityIndex: v.string(),
|
|
27160
|
+
variableBorrowIndex: v.string(),
|
|
27161
|
+
blockNumber: v.number()
|
|
27162
|
+
});
|
|
27163
|
+
var MoneyMarketAssetsSchema = v.array(MoneyMarketAssetSchema);
|
|
27164
|
+
var MoneyMarketAssetBorrowersSchema = v.object({
|
|
27165
|
+
borrowers: v.array(v.string()),
|
|
27166
|
+
total: v.number(),
|
|
27167
|
+
offset: v.number(),
|
|
27168
|
+
limit: v.number()
|
|
27169
|
+
});
|
|
27170
|
+
var MoneyMarketAssetSuppliersSchema = v.object({
|
|
27171
|
+
suppliers: v.array(v.string()),
|
|
27172
|
+
total: v.number(),
|
|
27173
|
+
offset: v.number(),
|
|
27174
|
+
limit: v.number()
|
|
27175
|
+
});
|
|
27176
|
+
var MoneyMarketBorrowersSchema = v.object({
|
|
27177
|
+
borrowers: v.array(v.string()),
|
|
27178
|
+
total: v.number(),
|
|
27179
|
+
offset: v.number(),
|
|
27180
|
+
limit: v.number()
|
|
27181
|
+
});
|
|
27182
|
+
var GetChainsResponseSchema = v.array(SpokeChainKeySchema);
|
|
27183
|
+
var TokensByChainMapSchema = v.custom(
|
|
27184
|
+
(input) => typeof input === "object" && input !== null && Object.values(input).every((tokens) => Array.isArray(tokens) && tokens.every((t) => v.is(XTokenSchema, t)))
|
|
27185
|
+
);
|
|
27186
|
+
var TokensListSchema = v.array(XTokenSchema);
|
|
27187
|
+
var ReserveAssetsSchema = v.array(AddressSchema);
|
|
27188
|
+
|
|
27189
|
+
// src/backendApi/guards.ts
|
|
27190
|
+
var isFillEvent = (value) => v.is(FillEventSchema, value);
|
|
27027
27191
|
function decodePacketIntentTarget(payload) {
|
|
27028
27192
|
try {
|
|
27029
27193
|
const hex = payload.startsWith("0x") ? payload.slice(2) : payload;
|
|
@@ -27043,6 +27207,12 @@ function selectSolvedIntentPacket(packets, intentsContract) {
|
|
|
27043
27207
|
return packets.reduce((highest, packet) => packet.conn_sn > highest.conn_sn ? packet : highest);
|
|
27044
27208
|
}
|
|
27045
27209
|
|
|
27210
|
+
// src/swap/detailedStatus.ts
|
|
27211
|
+
var DETAILED_STATUS_NOT_DELIVERED = "relay_not_delivered";
|
|
27212
|
+
function isBackendSubmitTxAbandoned(data) {
|
|
27213
|
+
return data.status === "failed" || Boolean(data.abandonedAt);
|
|
27214
|
+
}
|
|
27215
|
+
|
|
27046
27216
|
// src/swap/errors.ts
|
|
27047
27217
|
var swapInvariant = createInvariant("swap");
|
|
27048
27218
|
var POST_EXECUTION_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
@@ -27067,6 +27237,8 @@ var isPostExecutionError = isCodeMember(POST_EXECUTION_ERROR_CODES);
|
|
|
27067
27237
|
var isSwapError = isCodeMember(SWAP_ERROR_CODES);
|
|
27068
27238
|
|
|
27069
27239
|
// src/swap/SwapService.ts
|
|
27240
|
+
var RECONCILE_TIMEOUT_MS = 5e3;
|
|
27241
|
+
var DETAILED_STATUS_SOLVER_TIMEOUT_MS = 5e3;
|
|
27070
27242
|
var SwapService = class {
|
|
27071
27243
|
// dependent services
|
|
27072
27244
|
hubProvider;
|
|
@@ -27167,7 +27339,8 @@ var SwapService = class {
|
|
|
27167
27339
|
return calculatePercentageFeeAmount(inputAmount, 10);
|
|
27168
27340
|
}
|
|
27169
27341
|
/**
|
|
27170
|
-
* Polls the solver API for the current execution status of an intent.
|
|
27342
|
+
* Polls the solver API for the current execution status of an intent. A `NOT_FOUND` or a failed
|
|
27343
|
+
* request is cross-checked against the backend's durable intent record.
|
|
27171
27344
|
*
|
|
27172
27345
|
* The `intent_tx_hash` in the request must be the hub-chain (Sonic) transaction hash where
|
|
27173
27346
|
* the intent was registered — this is the `dst_tx_hash` from the relay packet returned by
|
|
@@ -27178,7 +27351,145 @@ var SwapService = class {
|
|
|
27178
27351
|
* `fill_tx_hash` is populated only when `status === SolverIntentStatusCode.SOLVED (3)`.
|
|
27179
27352
|
*/
|
|
27180
27353
|
async getStatus(request) {
|
|
27181
|
-
return
|
|
27354
|
+
return this.resolveSolverStatus(request);
|
|
27355
|
+
}
|
|
27356
|
+
/**
|
|
27357
|
+
* {@link SwapService.getStatus} with an optional budget for the solver leg. Public `getStatus` is a
|
|
27358
|
+
* one-shot read a caller bounds however it likes, so it stays unbounded; `getDetailedStatus` is
|
|
27359
|
+
* polled and passes {@link DETAILED_STATUS_SOLVER_TIMEOUT_MS}. Both go through here so the
|
|
27360
|
+
* durable-intent reconcile below is written once.
|
|
27361
|
+
*
|
|
27362
|
+
* `timeoutMs` bounds the solver request alone. The reconcile that a failed or NOT_FOUND solver read
|
|
27363
|
+
* falls through to carries its own {@link RECONCILE_TIMEOUT_MS}, so a bounded call can cost both.
|
|
27364
|
+
*/
|
|
27365
|
+
async resolveSolverStatus(request, timeoutMs) {
|
|
27366
|
+
const solverResult = await SolverApiService.getStatus(request, this.solver, this.config.logger, timeoutMs);
|
|
27367
|
+
const forgotten = !solverResult.ok || solverResult.value.status === SolverIntentStatusCode.NOT_FOUND;
|
|
27368
|
+
if (!forgotten) return solverResult;
|
|
27369
|
+
const timeout = Math.min(RECONCILE_TIMEOUT_MS, this.backendApi.requestTimeoutMs);
|
|
27370
|
+
const intent = await this.backendApi.getIntentByTxHash(request.intent_tx_hash, { timeout });
|
|
27371
|
+
const settled = intent.ok ? intent.value.events.filter(isFillEvent).find((fill) => fill.intentState.remainingInput === "0") : void 0;
|
|
27372
|
+
if (settled) return { ok: true, value: { status: SolverIntentStatusCode.SOLVED, fill_tx_hash: settled.txHash } };
|
|
27373
|
+
const backendAnswered = intent.ok || isSodaxError(intent.error) && intent.error.context?.status === 404;
|
|
27374
|
+
if (solverResult.ok && !backendAnswered) {
|
|
27375
|
+
return {
|
|
27376
|
+
ok: false,
|
|
27377
|
+
error: {
|
|
27378
|
+
detail: {
|
|
27379
|
+
code: SolverIntentErrorCode.UNKNOWN,
|
|
27380
|
+
message: "solver reported NOT_FOUND and the durable intent record could not be read to verify it"
|
|
27381
|
+
}
|
|
27382
|
+
}
|
|
27383
|
+
};
|
|
27384
|
+
}
|
|
27385
|
+
return solverResult;
|
|
27386
|
+
}
|
|
27387
|
+
/**
|
|
27388
|
+
* Reads a swap's status from its source-chain transaction — the identifier a caller always holds.
|
|
27389
|
+
*
|
|
27390
|
+
* **Routes; does not translate.** Returns the backend submit-tx record while it is in play,
|
|
27391
|
+
* otherwise the solver's answer via the hub tx hash resolved from the relay packet. The result is
|
|
27392
|
+
* tagged with `source` (discriminate on it) and carries that source's payload unmodified.
|
|
27393
|
+
*
|
|
27394
|
+
* **Any** unusable backend response routes to the solver — a 404, a transport or server error, or
|
|
27395
|
+
* a record the backend gave up on. See `docs/SWAPS.md` § Get Detailed Status for why.
|
|
27396
|
+
*
|
|
27397
|
+
* A point-in-time read; poll it yourself, or use dapp-kit's `useDetailedStatus`.
|
|
27398
|
+
*
|
|
27399
|
+
* @param params - `srcChainKey` and `srcTxHash` of the source-chain swap transaction.
|
|
27400
|
+
* @returns A `Result` containing a {@link DetailedSwapStatus}. Fails with `LOOKUP_FAILED` when no
|
|
27401
|
+
* source can answer yet — usually the relay has not delivered the packet, so there is no hub tx
|
|
27402
|
+
* hash for the solver to be asked about.
|
|
27403
|
+
*/
|
|
27404
|
+
async getDetailedStatus(params) {
|
|
27405
|
+
try {
|
|
27406
|
+
const record3 = await this.backendApi.swaps.getSubmitTxStatus({
|
|
27407
|
+
txHash: params.srcTxHash,
|
|
27408
|
+
srcChainKey: params.srcChainKey
|
|
27409
|
+
});
|
|
27410
|
+
if (record3.ok && record3.value.success && !isBackendSubmitTxAbandoned(record3.value.data)) {
|
|
27411
|
+
return { ok: true, value: { source: "backend", data: record3.value.data } };
|
|
27412
|
+
}
|
|
27413
|
+
const backendAnswered = record3.ok || isSodaxError(record3.error) && record3.error.context?.status === 404;
|
|
27414
|
+
const dstTxHash = await this.resolveHubTxHash(params, backendAnswered);
|
|
27415
|
+
if (!dstTxHash.ok) return dstTxHash;
|
|
27416
|
+
const solver = await this.resolveSolverStatus(
|
|
27417
|
+
{ intent_tx_hash: dstTxHash.value },
|
|
27418
|
+
DETAILED_STATUS_SOLVER_TIMEOUT_MS
|
|
27419
|
+
);
|
|
27420
|
+
if (!solver.ok) {
|
|
27421
|
+
return { ok: false, error: this.detailedStatusLookupFailed(solver.error, params.srcChainKey) };
|
|
27422
|
+
}
|
|
27423
|
+
return { ok: true, value: { source: "solver", dstTxHash: dstTxHash.value, data: solver.value } };
|
|
27424
|
+
} catch (error) {
|
|
27425
|
+
return { ok: false, error: this.detailedStatusLookupFailed(error, params.srcChainKey) };
|
|
27426
|
+
}
|
|
27427
|
+
}
|
|
27428
|
+
/**
|
|
27429
|
+
* The hub-chain tx hash the solver is keyed on. A hub-source swap has no relay leg — the source
|
|
27430
|
+
* tx *is* the hub tx. Otherwise the delivered relay packet carries it, so an undelivered packet
|
|
27431
|
+
* is simply "no hash yet".
|
|
27432
|
+
*/
|
|
27433
|
+
async resolveHubTxHash(key, backendAnswered) {
|
|
27434
|
+
const missReason = backendAnswered ? DETAILED_STATUS_NOT_DELIVERED : void 0;
|
|
27435
|
+
let hubTxHash = key.srcTxHash;
|
|
27436
|
+
if (!isHubChainKeyType(key.srcChainKey)) {
|
|
27437
|
+
const relayChainId = getIntentRelayChainId(key.srcChainKey);
|
|
27438
|
+
const packets = await getTransactionPackets(
|
|
27439
|
+
{
|
|
27440
|
+
action: "get_transaction_packets",
|
|
27441
|
+
params: { chain_id: relayChainId.toString(), tx_hash: key.srcTxHash }
|
|
27442
|
+
},
|
|
27443
|
+
this.relayerApiEndpoint,
|
|
27444
|
+
RELAY_REQUEST_TIMEOUT_MS
|
|
27445
|
+
);
|
|
27446
|
+
if (!packets.ok) {
|
|
27447
|
+
const notIndexed = packets.error instanceof HttpRelayError && packets.error.status === 404;
|
|
27448
|
+
return {
|
|
27449
|
+
ok: false,
|
|
27450
|
+
error: this.detailedStatusLookupFailed(packets.error, key.srcChainKey, notIndexed ? missReason : void 0)
|
|
27451
|
+
};
|
|
27452
|
+
}
|
|
27453
|
+
if (!packets.value?.success || !Array.isArray(packets.value.data)) {
|
|
27454
|
+
return {
|
|
27455
|
+
ok: false,
|
|
27456
|
+
error: this.detailedStatusLookupFailed(
|
|
27457
|
+
new Error("relay returned no usable transaction packets"),
|
|
27458
|
+
key.srcChainKey
|
|
27459
|
+
)
|
|
27460
|
+
};
|
|
27461
|
+
}
|
|
27462
|
+
const delivered = packets.value.data.find(
|
|
27463
|
+
(packet) => typeof packet?.src_tx_hash === "string" && packet.src_tx_hash.toLowerCase() === key.srcTxHash.toLowerCase() && packet.src_chain_id === Number(relayChainId) && packet.status === "executed" && typeof packet.dst_tx_hash === "string" && packet.dst_tx_hash.length > 0
|
|
27464
|
+
);
|
|
27465
|
+
if (!delivered) {
|
|
27466
|
+
return {
|
|
27467
|
+
ok: false,
|
|
27468
|
+
error: this.detailedStatusLookupFailed(
|
|
27469
|
+
new Error("relay has not delivered the intent to the hub yet"),
|
|
27470
|
+
key.srcChainKey,
|
|
27471
|
+
missReason
|
|
27472
|
+
)
|
|
27473
|
+
};
|
|
27474
|
+
}
|
|
27475
|
+
hubTxHash = delivered.dst_tx_hash;
|
|
27476
|
+
}
|
|
27477
|
+
if (isHex(hubTxHash)) return { ok: true, value: hubTxHash };
|
|
27478
|
+
return {
|
|
27479
|
+
ok: false,
|
|
27480
|
+
error: this.detailedStatusLookupFailed(
|
|
27481
|
+
new Error(`hub tx hash is not a hex string: ${hubTxHash}`),
|
|
27482
|
+
key.srcChainKey
|
|
27483
|
+
)
|
|
27484
|
+
};
|
|
27485
|
+
}
|
|
27486
|
+
/**
|
|
27487
|
+
* `reason` is set only for {@link DETAILED_STATUS_NOT_DELIVERED} — the miss a caller can bound
|
|
27488
|
+
* with a retry budget. Leaving it off marks a dependency that is failing right now, which a
|
|
27489
|
+
* caller should keep retrying rather than give up on.
|
|
27490
|
+
*/
|
|
27491
|
+
detailedStatusLookupFailed(cause, srcChainKey, reason) {
|
|
27492
|
+
return lookupFailed("swap", "getDetailedStatus", cause, { srcChainKey, action: "swap", reason });
|
|
27182
27493
|
}
|
|
27183
27494
|
/**
|
|
27184
27495
|
* Notifies the solver API that an intent has been registered on the hub chain, triggering
|
|
@@ -30351,16 +30662,112 @@ function toInvalidResponseShapeError(params) {
|
|
|
30351
30662
|
context: { api, endpoint, reason: "invalid_response_shape", issues }
|
|
30352
30663
|
});
|
|
30353
30664
|
}
|
|
30665
|
+
|
|
30666
|
+
// src/backendApi/apiConfig.ts
|
|
30667
|
+
function flatLayer({ baseURL, timeout, headers }) {
|
|
30668
|
+
return { baseURL, timeout, headers };
|
|
30669
|
+
}
|
|
30670
|
+
function layerConfigs(...slices) {
|
|
30671
|
+
return slices.reduce(
|
|
30672
|
+
(acc, slice) => slice ? {
|
|
30673
|
+
// Truthy (not nullish) so a set-but-empty env var falls back, matching `makeRequest`.
|
|
30674
|
+
baseURL: slice.baseURL || acc.baseURL,
|
|
30675
|
+
timeout: slice.timeout ?? acc.timeout,
|
|
30676
|
+
headers: { ...acc.headers, ...slice.headers }
|
|
30677
|
+
} : acc,
|
|
30678
|
+
{
|
|
30679
|
+
baseURL: DEFAULT_API_BASE_URL,
|
|
30680
|
+
timeout: DEFAULT_BACKEND_API_TIMEOUT,
|
|
30681
|
+
headers: { ...DEFAULT_BACKEND_API_HEADERS }
|
|
30682
|
+
}
|
|
30683
|
+
);
|
|
30684
|
+
}
|
|
30685
|
+
function isHttpUrl(value) {
|
|
30686
|
+
return value.startsWith("http://") || value.startsWith("https://");
|
|
30687
|
+
}
|
|
30688
|
+
function normalizeBaseURL(baseURL) {
|
|
30689
|
+
const trimmed = trimTrailingSlashes(baseURL);
|
|
30690
|
+
return isHttpUrl(trimmed) ? trimmed : baseURL;
|
|
30691
|
+
}
|
|
30692
|
+
function stripBackendMount(baseURL) {
|
|
30693
|
+
const trimmed = trimTrailingSlashes(baseURL);
|
|
30694
|
+
if (!trimmed.endsWith(BACKEND_API_BASE_PATH)) return void 0;
|
|
30695
|
+
const root = trimmed.slice(0, -BACKEND_API_BASE_PATH.length);
|
|
30696
|
+
return isHttpUrl(root) ? root : void 0;
|
|
30697
|
+
}
|
|
30698
|
+
function stripLegacyBackendMount(baseURL) {
|
|
30699
|
+
return stripBackendMount(baseURL) ?? baseURL;
|
|
30700
|
+
}
|
|
30701
|
+
function normalizeOverrideBaseURL(override) {
|
|
30702
|
+
if (!override?.baseURL) return override;
|
|
30703
|
+
return { ...override, baseURL: stripLegacyBackendMount(override.baseURL) };
|
|
30704
|
+
}
|
|
30705
|
+
function toGatewayRoot(baseURL) {
|
|
30706
|
+
return stripBackendMount(baseURL) ?? normalizeBaseURL(baseURL);
|
|
30707
|
+
}
|
|
30708
|
+
function configuredBasePath(layers) {
|
|
30709
|
+
return layers.baseApiConfig?.basePath ?? layers.basePath;
|
|
30710
|
+
}
|
|
30711
|
+
function hasExplicitBasePath(layers) {
|
|
30712
|
+
return configuredBasePath(layers) !== void 0;
|
|
30713
|
+
}
|
|
30714
|
+
function hasLegacyBackendBaseURL(layers) {
|
|
30715
|
+
if (configuredBasePath(layers) !== void 0) return false;
|
|
30716
|
+
return stripBackendMount(layerConfigs(flatLayer(layers), layers.baseApiConfig).baseURL) !== void 0;
|
|
30717
|
+
}
|
|
30718
|
+
var PACKAGED_API_ORIGIN = new URL(DEFAULT_API_BASE_URL).origin;
|
|
30719
|
+
function isOnPackagedOrigin(baseURL) {
|
|
30720
|
+
return baseURL === PACKAGED_API_ORIGIN || baseURL.startsWith(`${PACKAGED_API_ORIGIN}/`);
|
|
30721
|
+
}
|
|
30722
|
+
function isMissingVersionPrefix(baseURL) {
|
|
30723
|
+
const normalized = trimTrailingSlashes(baseURL);
|
|
30724
|
+
if (!isOnPackagedOrigin(normalized)) return false;
|
|
30725
|
+
return normalized !== DEFAULT_API_BASE_URL && !normalized.startsWith(`${DEFAULT_API_BASE_URL}/`);
|
|
30726
|
+
}
|
|
30727
|
+
function normalizeBasePath(basePath) {
|
|
30728
|
+
const trimmed = trimTrailingSlashes(basePath.trim());
|
|
30729
|
+
const withoutLeadingSlashes = trimmed.replace(/^\/+/, "");
|
|
30730
|
+
return withoutLeadingSlashes.length === 0 ? "" : `/${withoutLeadingSlashes}`;
|
|
30731
|
+
}
|
|
30732
|
+
function resolveSharedApiConfig(layers, slice) {
|
|
30733
|
+
const layered = layerConfigs(flatLayer(layers), layers.baseApiConfig, slice);
|
|
30734
|
+
const baseURL = configuredBasePath(layers) === void 0 ? toGatewayRoot(layered.baseURL) : normalizeBaseURL(layered.baseURL);
|
|
30735
|
+
return { ...layered, baseURL };
|
|
30736
|
+
}
|
|
30737
|
+
function resolveBaseApiConfig(layers) {
|
|
30738
|
+
return {
|
|
30739
|
+
...resolveSharedApiConfig(layers),
|
|
30740
|
+
basePath: normalizeBasePath(configuredBasePath(layers) ?? BACKEND_API_BASE_PATH)
|
|
30741
|
+
};
|
|
30742
|
+
}
|
|
30743
|
+
function resolveSwapsApiConfig(layers) {
|
|
30744
|
+
return resolveSharedApiConfig(layers, layers.swapsApiConfig);
|
|
30745
|
+
}
|
|
30746
|
+
function resolveSponsoringApiConfig(layers) {
|
|
30747
|
+
const slice = layers.sponsoringApiConfig;
|
|
30748
|
+
return {
|
|
30749
|
+
baseURL: normalizeBaseURL(slice?.baseURL ?? DEFAULT_SPONSORING_API_ENDPOINT),
|
|
30750
|
+
timeout: slice?.timeout ?? resolveSharedApiConfig(layers).timeout,
|
|
30751
|
+
headers: { ...DEFAULT_BACKEND_API_HEADERS, ...slice?.headers },
|
|
30752
|
+
...slice?.apiKey === void 0 ? {} : { apiKey: slice.apiKey }
|
|
30753
|
+
};
|
|
30754
|
+
}
|
|
30755
|
+
function resolveBridgeApiConfig(layers) {
|
|
30756
|
+
return resolveSharedApiConfig(layers);
|
|
30757
|
+
}
|
|
30354
30758
|
var SwapsApiService = class _SwapsApiService {
|
|
30355
30759
|
// Fully-resolved swaps-API config supplied by the caller (BackendApiService resolves the
|
|
30356
30760
|
// `ApiConfig` union via `resolveSwapsApiConfig`); this service does not resolve the union.
|
|
30357
30761
|
config;
|
|
30358
30762
|
headers;
|
|
30359
30763
|
logger;
|
|
30360
|
-
|
|
30764
|
+
/** See {@link SwapsApiServiceOptions.trimLegacyOverrides}. */
|
|
30765
|
+
trimsLegacyOverrides;
|
|
30766
|
+
constructor(config, logger = consoleLogger, options = {}) {
|
|
30361
30767
|
this.config = config;
|
|
30362
30768
|
this.headers = { ...config.headers };
|
|
30363
30769
|
this.logger = logger;
|
|
30770
|
+
this.trimsLegacyOverrides = options.trimLegacyOverrides ?? true;
|
|
30364
30771
|
}
|
|
30365
30772
|
/**
|
|
30366
30773
|
* Build a `@sodax/swaps-api` client for a single call. Maps the SDK's `SwapsApiConfig`
|
|
@@ -30371,7 +30778,8 @@ var SwapsApiService = class _SwapsApiService {
|
|
|
30371
30778
|
* overrides both take effect without caching stale state.
|
|
30372
30779
|
*/
|
|
30373
30780
|
buildClient(overrideConfig) {
|
|
30374
|
-
const
|
|
30781
|
+
const override = overrideConfig?.baseURL;
|
|
30782
|
+
const baseUrl = override ? this.trimsLegacyOverrides ? stripLegacyBackendMount(override) : override : this.config.baseURL;
|
|
30375
30783
|
const timeout = overrideConfig?.timeout ?? this.config.timeout ?? DEFAULT_BACKEND_API_TIMEOUT;
|
|
30376
30784
|
const headers = { ...this.headers, ...overrideConfig?.headers };
|
|
30377
30785
|
return new SwapsApi({ baseUrl, headers, timeout });
|
|
@@ -30396,7 +30804,7 @@ var SwapsApiService = class _SwapsApiService {
|
|
|
30396
30804
|
if (error.code === "VALIDATION_ERROR" && error.context.issues !== void 0) {
|
|
30397
30805
|
context.reason = "invalid_response_shape";
|
|
30398
30806
|
const issues = error.context.issues;
|
|
30399
|
-
context.issues = issues instanceof
|
|
30807
|
+
context.issues = issues instanceof v.ValiError ? v.flatten(issues.issues) : issues;
|
|
30400
30808
|
}
|
|
30401
30809
|
if (error.context.status !== void 0) context.status = error.context.status;
|
|
30402
30810
|
}
|
|
@@ -30571,21 +30979,21 @@ var SwapsApiService = class _SwapsApiService {
|
|
|
30571
30979
|
return this.config.timeout ?? DEFAULT_BACKEND_API_TIMEOUT;
|
|
30572
30980
|
}
|
|
30573
30981
|
};
|
|
30574
|
-
var StellarSponsorConfigSchema =
|
|
30575
|
-
sponsorAccount:
|
|
30576
|
-
networkPassphrase:
|
|
30577
|
-
minTotalFeeStroops:
|
|
30578
|
-
maxTotalFeeStroops:
|
|
30579
|
-
operationCount:
|
|
30580
|
-
minPerOperationFeeStroops:
|
|
30581
|
-
maxPerOperationFeeStroops:
|
|
30582
|
-
recommendedPerOperationFeeStroops:
|
|
30583
|
-
maxTimeboundSeconds:
|
|
30584
|
-
requiredStartingBalance:
|
|
30982
|
+
var StellarSponsorConfigSchema = v.object({
|
|
30983
|
+
sponsorAccount: v.string(),
|
|
30984
|
+
networkPassphrase: v.string(),
|
|
30985
|
+
minTotalFeeStroops: v.string(),
|
|
30986
|
+
maxTotalFeeStroops: v.string(),
|
|
30987
|
+
operationCount: v.number(),
|
|
30988
|
+
minPerOperationFeeStroops: v.string(),
|
|
30989
|
+
maxPerOperationFeeStroops: v.string(),
|
|
30990
|
+
recommendedPerOperationFeeStroops: v.string(),
|
|
30991
|
+
maxTimeboundSeconds: v.number(),
|
|
30992
|
+
requiredStartingBalance: v.string()
|
|
30585
30993
|
});
|
|
30586
|
-
var StellarSponsoredAccountResponseSchema =
|
|
30587
|
-
|
|
30588
|
-
|
|
30994
|
+
var StellarSponsoredAccountResponseSchema = v.variant("alreadyActive", [
|
|
30995
|
+
v.object({ hash: v.string(), alreadyActive: v.literal(false) }),
|
|
30996
|
+
v.object({ hash: v.null(), alreadyActive: v.literal(true) })
|
|
30589
30997
|
]);
|
|
30590
30998
|
|
|
30591
30999
|
// src/backendApi/SponsoringApiService.ts
|
|
@@ -30613,7 +31021,7 @@ var SponsoringApiService = class {
|
|
|
30613
31021
|
logger: this.logger,
|
|
30614
31022
|
serviceLabel: "SponsoringApiService"
|
|
30615
31023
|
});
|
|
30616
|
-
const parsed =
|
|
31024
|
+
const parsed = v.safeParse(schema, raw);
|
|
30617
31025
|
if (!parsed.success) {
|
|
30618
31026
|
return {
|
|
30619
31027
|
ok: false,
|
|
@@ -30621,7 +31029,7 @@ var SponsoringApiService = class {
|
|
|
30621
31029
|
api: "sponsoring",
|
|
30622
31030
|
feature: "backend",
|
|
30623
31031
|
endpoint,
|
|
30624
|
-
issues:
|
|
31032
|
+
issues: v.flatten(parsed.issues)
|
|
30625
31033
|
})
|
|
30626
31034
|
};
|
|
30627
31035
|
}
|
|
@@ -30659,141 +31067,141 @@ var SponsoringApiService = class {
|
|
|
30659
31067
|
return this.config.baseURL;
|
|
30660
31068
|
}
|
|
30661
31069
|
};
|
|
30662
|
-
var RelayExtraDataResponseSchema =
|
|
30663
|
-
address:
|
|
30664
|
-
payload:
|
|
31070
|
+
var RelayExtraDataResponseSchema = v.object({
|
|
31071
|
+
address: v.string(),
|
|
31072
|
+
payload: v.string()
|
|
30665
31073
|
});
|
|
30666
|
-
var BridgeTokenSchema =
|
|
30667
|
-
symbol:
|
|
30668
|
-
name:
|
|
30669
|
-
decimals:
|
|
30670
|
-
address:
|
|
30671
|
-
chainKey:
|
|
30672
|
-
hubAsset:
|
|
30673
|
-
vault:
|
|
31074
|
+
var BridgeTokenSchema = v.object({
|
|
31075
|
+
symbol: v.string(),
|
|
31076
|
+
name: v.string(),
|
|
31077
|
+
decimals: v.number(),
|
|
31078
|
+
address: v.string(),
|
|
31079
|
+
chainKey: v.string(),
|
|
31080
|
+
hubAsset: v.string(),
|
|
31081
|
+
vault: v.string()
|
|
30674
31082
|
});
|
|
30675
|
-
var BridgeTokensResponseSchema =
|
|
30676
|
-
var BridgeTokensByChainResponseSchema =
|
|
30677
|
-
var BridgeAllowanceCheckResponseSchema =
|
|
30678
|
-
valid:
|
|
31083
|
+
var BridgeTokensResponseSchema = v.record(v.string(), v.array(BridgeTokenSchema));
|
|
31084
|
+
var BridgeTokensByChainResponseSchema = v.array(BridgeTokenSchema);
|
|
31085
|
+
var BridgeAllowanceCheckResponseSchema = v.object({
|
|
31086
|
+
valid: v.boolean()
|
|
30679
31087
|
});
|
|
30680
|
-
var makeBridgeApproveResponseSchema = (txSchema) =>
|
|
30681
|
-
var makeCreateBridgeIntentResponseSchema = (txSchema) =>
|
|
31088
|
+
var makeBridgeApproveResponseSchema = (txSchema) => v.object({ tx: txSchema });
|
|
31089
|
+
var makeCreateBridgeIntentResponseSchema = (txSchema) => v.object({
|
|
30682
31090
|
tx: txSchema,
|
|
30683
31091
|
relayData: RelayExtraDataResponseSchema
|
|
30684
31092
|
});
|
|
30685
|
-
var BridgeSubmitTxResponseSchema =
|
|
30686
|
-
success:
|
|
30687
|
-
data:
|
|
30688
|
-
status:
|
|
30689
|
-
message:
|
|
31093
|
+
var BridgeSubmitTxResponseSchema = v.object({
|
|
31094
|
+
success: v.boolean(),
|
|
31095
|
+
data: v.object({
|
|
31096
|
+
status: v.picklist(["inserted", "duplicate"]),
|
|
31097
|
+
message: v.string()
|
|
30690
31098
|
})
|
|
30691
31099
|
});
|
|
30692
|
-
var BridgePacketDataSchema =
|
|
30693
|
-
src_chain_id:
|
|
30694
|
-
src_tx_hash:
|
|
30695
|
-
src_address:
|
|
30696
|
-
status:
|
|
30697
|
-
dst_chain_id:
|
|
30698
|
-
conn_sn:
|
|
30699
|
-
dst_address:
|
|
30700
|
-
dst_tx_hash:
|
|
30701
|
-
signatures:
|
|
30702
|
-
payload:
|
|
31100
|
+
var BridgePacketDataSchema = v.object({
|
|
31101
|
+
src_chain_id: v.number(),
|
|
31102
|
+
src_tx_hash: v.string(),
|
|
31103
|
+
src_address: v.string(),
|
|
31104
|
+
status: v.picklist(["pending", "validating", "executing", "executed"]),
|
|
31105
|
+
dst_chain_id: v.number(),
|
|
31106
|
+
conn_sn: v.number(),
|
|
31107
|
+
dst_address: v.string(),
|
|
31108
|
+
dst_tx_hash: v.string(),
|
|
31109
|
+
signatures: v.array(v.string()),
|
|
31110
|
+
payload: v.string()
|
|
30703
31111
|
});
|
|
30704
|
-
var BridgeSubmitTxStatusResultSchema =
|
|
30705
|
-
dstIntentTxHash:
|
|
30706
|
-
packetData:
|
|
31112
|
+
var BridgeSubmitTxStatusResultSchema = v.object({
|
|
31113
|
+
dstIntentTxHash: v.string(),
|
|
31114
|
+
packetData: v.optional(BridgePacketDataSchema)
|
|
30707
31115
|
});
|
|
30708
|
-
var BridgeSubmitTxStatusDataSchema =
|
|
30709
|
-
txHash:
|
|
30710
|
-
srcChainKey:
|
|
30711
|
-
status:
|
|
30712
|
-
failedAtStep:
|
|
30713
|
-
failureReason:
|
|
30714
|
-
processingAttempts:
|
|
30715
|
-
abandonedAt:
|
|
30716
|
-
result:
|
|
30717
|
-
userMessage:
|
|
31116
|
+
var BridgeSubmitTxStatusDataSchema = v.object({
|
|
31117
|
+
txHash: v.string(),
|
|
31118
|
+
srcChainKey: v.string(),
|
|
31119
|
+
status: v.string(),
|
|
31120
|
+
failedAtStep: v.optional(v.string()),
|
|
31121
|
+
failureReason: v.optional(v.string()),
|
|
31122
|
+
processingAttempts: v.number(),
|
|
31123
|
+
abandonedAt: v.optional(v.string()),
|
|
31124
|
+
result: v.optional(BridgeSubmitTxStatusResultSchema),
|
|
31125
|
+
userMessage: v.optional(v.string())
|
|
30718
31126
|
});
|
|
30719
|
-
var BridgeSubmitTxStatusResponseSchema =
|
|
30720
|
-
success:
|
|
31127
|
+
var BridgeSubmitTxStatusResponseSchema = v.object({
|
|
31128
|
+
success: v.boolean(),
|
|
30721
31129
|
data: BridgeSubmitTxStatusDataSchema
|
|
30722
31130
|
});
|
|
30723
|
-
var BridgeFeeResponseSchema =
|
|
30724
|
-
var BridgeLimitSchema =
|
|
30725
|
-
amount:
|
|
30726
|
-
decimals:
|
|
30727
|
-
type:
|
|
31131
|
+
var BridgeFeeResponseSchema = v.object({ fee: v.string() });
|
|
31132
|
+
var BridgeLimitSchema = v.object({
|
|
31133
|
+
amount: v.string(),
|
|
31134
|
+
decimals: v.number(),
|
|
31135
|
+
type: v.picklist(["DEPOSIT_LIMIT", "WITHDRAWAL_LIMIT"])
|
|
30728
31136
|
});
|
|
30729
|
-
var BridgeableAmountResponseSchema =
|
|
30730
|
-
var BridgeableCheckResponseSchema =
|
|
30731
|
-
var
|
|
30732
|
-
var HexSchema =
|
|
30733
|
-
var BigintFromString =
|
|
30734
|
-
var BytesFromIndexRecord =
|
|
30735
|
-
|
|
30736
|
-
|
|
31137
|
+
var BridgeableAmountResponseSchema = v.object({ limit: BridgeLimitSchema });
|
|
31138
|
+
var BridgeableCheckResponseSchema = v.object({ bridgeable: v.boolean() });
|
|
31139
|
+
var AddressSchema2 = v.custom((input) => typeof input === "string");
|
|
31140
|
+
var HexSchema = v.custom((input) => typeof input === "string");
|
|
31141
|
+
var BigintFromString = v.pipe(v.string(), v.toBigint());
|
|
31142
|
+
var BytesFromIndexRecord = v.pipe(
|
|
31143
|
+
v.record(v.string(), v.number()),
|
|
31144
|
+
v.transform((indexed) => Uint8Array.from(Object.values(indexed)))
|
|
30737
31145
|
);
|
|
30738
|
-
var EvmRawTxSchema =
|
|
30739
|
-
from:
|
|
30740
|
-
to:
|
|
31146
|
+
var EvmRawTxSchema = v.object({
|
|
31147
|
+
from: AddressSchema2,
|
|
31148
|
+
to: AddressSchema2,
|
|
30741
31149
|
value: BigintFromString,
|
|
30742
31150
|
data: HexSchema
|
|
30743
31151
|
});
|
|
30744
|
-
var SolanaRawTxSchema =
|
|
30745
|
-
from:
|
|
30746
|
-
to:
|
|
31152
|
+
var SolanaRawTxSchema = v.object({
|
|
31153
|
+
from: v.string(),
|
|
31154
|
+
to: v.string(),
|
|
30747
31155
|
value: BigintFromString,
|
|
30748
|
-
data:
|
|
31156
|
+
data: v.string()
|
|
30749
31157
|
});
|
|
30750
|
-
var SuiRawTxSchema =
|
|
31158
|
+
var SuiRawTxSchema = v.object({
|
|
30751
31159
|
from: HexSchema,
|
|
30752
|
-
to:
|
|
31160
|
+
to: v.string(),
|
|
30753
31161
|
value: BigintFromString,
|
|
30754
|
-
data:
|
|
31162
|
+
data: v.string()
|
|
30755
31163
|
});
|
|
30756
|
-
var StellarRawTxSchema =
|
|
30757
|
-
from:
|
|
30758
|
-
to:
|
|
31164
|
+
var StellarRawTxSchema = v.object({
|
|
31165
|
+
from: v.string(),
|
|
31166
|
+
to: v.string(),
|
|
30759
31167
|
value: BigintFromString,
|
|
30760
|
-
data:
|
|
31168
|
+
data: v.string()
|
|
30761
31169
|
});
|
|
30762
|
-
var BitcoinRawTxSchema =
|
|
30763
|
-
from:
|
|
30764
|
-
to:
|
|
31170
|
+
var BitcoinRawTxSchema = v.object({
|
|
31171
|
+
from: v.string(),
|
|
31172
|
+
to: v.string(),
|
|
30765
31173
|
value: BigintFromString,
|
|
30766
|
-
data:
|
|
31174
|
+
data: v.string()
|
|
30767
31175
|
});
|
|
30768
|
-
var InjectiveRawTxSchema =
|
|
31176
|
+
var InjectiveRawTxSchema = v.object({
|
|
30769
31177
|
from: HexSchema,
|
|
30770
31178
|
to: HexSchema,
|
|
30771
|
-
signedDoc:
|
|
31179
|
+
signedDoc: v.object({
|
|
30772
31180
|
bodyBytes: BytesFromIndexRecord,
|
|
30773
31181
|
authInfoBytes: BytesFromIndexRecord,
|
|
30774
|
-
chainId:
|
|
31182
|
+
chainId: v.string(),
|
|
30775
31183
|
accountNumber: BigintFromString
|
|
30776
31184
|
})
|
|
30777
31185
|
});
|
|
30778
|
-
var NearRawTxSchema =
|
|
30779
|
-
signerId:
|
|
30780
|
-
params:
|
|
30781
|
-
contractId:
|
|
30782
|
-
method:
|
|
30783
|
-
args:
|
|
30784
|
-
gas:
|
|
30785
|
-
deposit:
|
|
31186
|
+
var NearRawTxSchema = v.object({
|
|
31187
|
+
signerId: v.string(),
|
|
31188
|
+
params: v.object({
|
|
31189
|
+
contractId: v.string(),
|
|
31190
|
+
method: v.string(),
|
|
31191
|
+
args: v.custom((input) => typeof input === "object" && input !== null),
|
|
31192
|
+
gas: v.optional(BigintFromString),
|
|
31193
|
+
deposit: v.optional(BigintFromString)
|
|
30786
31194
|
})
|
|
30787
31195
|
});
|
|
30788
|
-
var IconRawTxSchema =
|
|
30789
|
-
|
|
30790
|
-
|
|
31196
|
+
var IconRawTxSchema = v.record(
|
|
31197
|
+
v.string(),
|
|
31198
|
+
v.union([v.string(), v.custom((input) => typeof input === "object" && input !== null)])
|
|
30791
31199
|
);
|
|
30792
|
-
var StacksRawTxSchema =
|
|
30793
|
-
payload:
|
|
30794
|
-
estimatedLength:
|
|
31200
|
+
var StacksRawTxSchema = v.object({
|
|
31201
|
+
payload: v.string(),
|
|
31202
|
+
estimatedLength: v.optional(v.number())
|
|
30795
31203
|
});
|
|
30796
|
-
var AnyRawTxSchema =
|
|
31204
|
+
var AnyRawTxSchema = v.custom((input) => typeof input === "object" && input !== null);
|
|
30797
31205
|
function rawTxSchemaForChainKey(chainKey) {
|
|
30798
31206
|
let chainType;
|
|
30799
31207
|
try {
|
|
@@ -30846,10 +31254,13 @@ var BridgeApiService = class {
|
|
|
30846
31254
|
config;
|
|
30847
31255
|
headers;
|
|
30848
31256
|
logger;
|
|
30849
|
-
|
|
31257
|
+
/** See {@link BridgeApiServiceOptions.trimLegacyOverrides}. */
|
|
31258
|
+
trimsLegacyOverrides;
|
|
31259
|
+
constructor(config, logger = consoleLogger, options = {}) {
|
|
30850
31260
|
this.config = config;
|
|
30851
31261
|
this.headers = { ...config.headers };
|
|
30852
31262
|
this.logger = logger;
|
|
31263
|
+
this.trimsLegacyOverrides = options.trimLegacyOverrides ?? true;
|
|
30853
31264
|
}
|
|
30854
31265
|
/**
|
|
30855
31266
|
* Issues a single HTTP request, validates the JSON body against `schema`, and
|
|
@@ -30862,17 +31273,20 @@ var BridgeApiService = class {
|
|
|
30862
31273
|
const raw = await makeRequest({
|
|
30863
31274
|
endpoint,
|
|
30864
31275
|
config: { baseURL: this.config.baseURL, timeout: this.config.timeout, headers: this.headers, ...config },
|
|
30865
|
-
|
|
31276
|
+
// Normalized like a configured base URL: the override is the gateway root, so a legacy
|
|
31277
|
+
// `/be`-suffixed value must not nest `/bridge/*` under the data API's mount — unless the config
|
|
31278
|
+
// opted out of the legacy trim, in which case the per-call value is left exactly as given.
|
|
31279
|
+
overrideConfig: this.trimsLegacyOverrides ? normalizeOverrideBaseURL(overrideConfig) : overrideConfig,
|
|
30866
31280
|
logger: this.logger,
|
|
30867
31281
|
serviceLabel: "BridgeApiService"
|
|
30868
31282
|
});
|
|
30869
|
-
const parsed =
|
|
31283
|
+
const parsed = v.safeParse(schema, raw);
|
|
30870
31284
|
if (!parsed.success) {
|
|
30871
31285
|
return {
|
|
30872
31286
|
ok: false,
|
|
30873
31287
|
error: new SodaxError("EXTERNAL_API_ERROR", `Invalid response shape from bridge API for ${endpoint}`, {
|
|
30874
31288
|
feature: "backend",
|
|
30875
|
-
context: { api: "bridge", endpoint, reason: "invalid_response_shape", issues:
|
|
31289
|
+
context: { api: "bridge", endpoint, reason: "invalid_response_shape", issues: v.flatten(parsed.issues) }
|
|
30876
31290
|
})
|
|
30877
31291
|
};
|
|
30878
31292
|
}
|
|
@@ -31068,201 +31482,85 @@ var BridgeApiService = class {
|
|
|
31068
31482
|
}
|
|
31069
31483
|
};
|
|
31070
31484
|
|
|
31071
|
-
// src/backendApi/apiConfig.ts
|
|
31072
|
-
function flatLayer({ baseURL, timeout, headers }) {
|
|
31073
|
-
return { baseURL, timeout, headers };
|
|
31074
|
-
}
|
|
31075
|
-
function layerConfigs(...slices) {
|
|
31076
|
-
return slices.reduce(
|
|
31077
|
-
(acc, slice) => slice ? {
|
|
31078
|
-
baseURL: slice.baseURL ?? acc.baseURL,
|
|
31079
|
-
timeout: slice.timeout ?? acc.timeout,
|
|
31080
|
-
headers: { ...acc.headers, ...slice.headers }
|
|
31081
|
-
} : acc,
|
|
31082
|
-
{
|
|
31083
|
-
baseURL: DEFAULT_BACKEND_API_ENDPOINT,
|
|
31084
|
-
timeout: DEFAULT_BACKEND_API_TIMEOUT,
|
|
31085
|
-
headers: { ...DEFAULT_BACKEND_API_HEADERS }
|
|
31086
|
-
}
|
|
31087
|
-
);
|
|
31088
|
-
}
|
|
31089
|
-
function resolveBaseApiConfig(config) {
|
|
31090
|
-
const layers = config;
|
|
31091
|
-
return layerConfigs(flatLayer(layers), layers.baseApiConfig);
|
|
31092
|
-
}
|
|
31093
|
-
function resolveSwapsApiConfig(config) {
|
|
31094
|
-
const layers = config;
|
|
31095
|
-
return layerConfigs(flatLayer(layers), layers.baseApiConfig, layers.swapsApiConfig);
|
|
31096
|
-
}
|
|
31097
|
-
function isHttpUrl(value) {
|
|
31098
|
-
return value.startsWith("http://") || value.startsWith("https://");
|
|
31099
|
-
}
|
|
31100
|
-
function normalizeBaseURL(baseURL) {
|
|
31101
|
-
const trimmed = trimTrailingSlashes(baseURL);
|
|
31102
|
-
return isHttpUrl(trimmed) ? trimmed : baseURL;
|
|
31103
|
-
}
|
|
31104
|
-
function resolveSponsoringApiConfig(config) {
|
|
31105
|
-
const layers = config;
|
|
31106
|
-
const slice = layers.sponsoringApiConfig;
|
|
31107
|
-
return {
|
|
31108
|
-
baseURL: normalizeBaseURL(slice?.baseURL ?? DEFAULT_SPONSORING_API_ENDPOINT),
|
|
31109
|
-
timeout: slice?.timeout ?? resolveBaseApiConfig(config).timeout,
|
|
31110
|
-
headers: { ...DEFAULT_BACKEND_API_HEADERS, ...slice?.headers },
|
|
31111
|
-
...slice?.apiKey === void 0 ? {} : { apiKey: slice.apiKey }
|
|
31112
|
-
};
|
|
31113
|
-
}
|
|
31114
|
-
function resolveBridgeApiConfig(config) {
|
|
31115
|
-
return resolveBaseApiConfig(config);
|
|
31116
|
-
}
|
|
31117
|
-
var ChainKeySchema = v7.custom((input) => typeof input === "string");
|
|
31118
|
-
var SpokeChainKeySchema = v7.custom((input) => typeof input === "string");
|
|
31119
|
-
var AddressSchema2 = v7.custom((input) => typeof input === "string");
|
|
31120
|
-
var XTokenSchema = v7.object({
|
|
31121
|
-
symbol: v7.string(),
|
|
31122
|
-
name: v7.string(),
|
|
31123
|
-
decimals: v7.number(),
|
|
31124
|
-
address: v7.string(),
|
|
31125
|
-
chainKey: ChainKeySchema,
|
|
31126
|
-
hubAsset: AddressSchema2,
|
|
31127
|
-
vault: AddressSchema2,
|
|
31128
|
-
access: v7.optional(v7.picklist(["withdrawOnly", "depositOnly"]))
|
|
31129
|
-
});
|
|
31130
|
-
var IntentStructSchema = v7.object({
|
|
31131
|
-
intentId: v7.string(),
|
|
31132
|
-
creator: v7.string(),
|
|
31133
|
-
inputToken: v7.string(),
|
|
31134
|
-
outputToken: v7.string(),
|
|
31135
|
-
inputAmount: v7.string(),
|
|
31136
|
-
minOutputAmount: v7.string(),
|
|
31137
|
-
deadline: v7.string(),
|
|
31138
|
-
allowPartialFill: v7.boolean(),
|
|
31139
|
-
srcChain: v7.number(),
|
|
31140
|
-
dstChain: v7.number(),
|
|
31141
|
-
srcAddress: v7.string(),
|
|
31142
|
-
dstAddress: v7.string(),
|
|
31143
|
-
solver: v7.string(),
|
|
31144
|
-
data: v7.string()
|
|
31145
|
-
});
|
|
31146
|
-
var IntentResponseSchema = v7.object({
|
|
31147
|
-
intentHash: v7.string(),
|
|
31148
|
-
txHash: v7.string(),
|
|
31149
|
-
logIndex: v7.number(),
|
|
31150
|
-
chainId: v7.number(),
|
|
31151
|
-
blockNumber: v7.number(),
|
|
31152
|
-
open: v7.boolean(),
|
|
31153
|
-
intent: IntentStructSchema,
|
|
31154
|
-
events: v7.array(v7.unknown())
|
|
31155
|
-
});
|
|
31156
|
-
var UserIntentsResponseSchema = v7.object({
|
|
31157
|
-
total: v7.number(),
|
|
31158
|
-
offset: v7.number(),
|
|
31159
|
-
limit: v7.number(),
|
|
31160
|
-
items: v7.array(IntentResponseSchema)
|
|
31161
|
-
});
|
|
31162
|
-
var OrderbookResponseSchema = v7.object({
|
|
31163
|
-
total: v7.number(),
|
|
31164
|
-
data: v7.array(
|
|
31165
|
-
v7.object({
|
|
31166
|
-
intentState: v7.object({
|
|
31167
|
-
exists: v7.boolean(),
|
|
31168
|
-
remainingInput: v7.string(),
|
|
31169
|
-
receivedOutput: v7.string(),
|
|
31170
|
-
pendingPayment: v7.boolean()
|
|
31171
|
-
}),
|
|
31172
|
-
intentData: v7.object({
|
|
31173
|
-
intentId: v7.string(),
|
|
31174
|
-
creator: v7.string(),
|
|
31175
|
-
inputToken: v7.string(),
|
|
31176
|
-
outputToken: v7.string(),
|
|
31177
|
-
inputAmount: v7.string(),
|
|
31178
|
-
minOutputAmount: v7.string(),
|
|
31179
|
-
deadline: v7.string(),
|
|
31180
|
-
allowPartialFill: v7.boolean(),
|
|
31181
|
-
srcChain: v7.number(),
|
|
31182
|
-
dstChain: v7.number(),
|
|
31183
|
-
srcAddress: v7.string(),
|
|
31184
|
-
dstAddress: v7.string(),
|
|
31185
|
-
solver: v7.string(),
|
|
31186
|
-
data: v7.string(),
|
|
31187
|
-
intentHash: v7.string(),
|
|
31188
|
-
txHash: v7.string(),
|
|
31189
|
-
blockNumber: v7.number()
|
|
31190
|
-
})
|
|
31191
|
-
})
|
|
31192
|
-
)
|
|
31193
|
-
});
|
|
31194
|
-
var MoneyMarketPositionSchema = v7.object({
|
|
31195
|
-
userAddress: v7.string(),
|
|
31196
|
-
positions: v7.array(
|
|
31197
|
-
v7.object({
|
|
31198
|
-
reserveAddress: v7.string(),
|
|
31199
|
-
aTokenAddress: v7.string(),
|
|
31200
|
-
variableDebtTokenAddress: v7.string(),
|
|
31201
|
-
aTokenBalance: v7.string(),
|
|
31202
|
-
variableDebtTokenBalance: v7.string(),
|
|
31203
|
-
blockNumber: v7.number()
|
|
31204
|
-
})
|
|
31205
|
-
)
|
|
31206
|
-
});
|
|
31207
|
-
var MoneyMarketAssetSchema = v7.object({
|
|
31208
|
-
reserveAddress: v7.string(),
|
|
31209
|
-
aTokenAddress: v7.string(),
|
|
31210
|
-
totalATokenBalance: v7.string(),
|
|
31211
|
-
variableDebtTokenAddress: v7.string(),
|
|
31212
|
-
totalVariableDebtTokenBalance: v7.string(),
|
|
31213
|
-
liquidityRate: v7.string(),
|
|
31214
|
-
symbol: v7.string(),
|
|
31215
|
-
totalSuppliers: v7.number(),
|
|
31216
|
-
totalBorrowers: v7.number(),
|
|
31217
|
-
variableBorrowRate: v7.string(),
|
|
31218
|
-
stableBorrowRate: v7.string(),
|
|
31219
|
-
liquidityIndex: v7.string(),
|
|
31220
|
-
variableBorrowIndex: v7.string(),
|
|
31221
|
-
blockNumber: v7.number()
|
|
31222
|
-
});
|
|
31223
|
-
var MoneyMarketAssetsSchema = v7.array(MoneyMarketAssetSchema);
|
|
31224
|
-
var MoneyMarketAssetBorrowersSchema = v7.object({
|
|
31225
|
-
borrowers: v7.array(v7.string()),
|
|
31226
|
-
total: v7.number(),
|
|
31227
|
-
offset: v7.number(),
|
|
31228
|
-
limit: v7.number()
|
|
31229
|
-
});
|
|
31230
|
-
var MoneyMarketAssetSuppliersSchema = v7.object({
|
|
31231
|
-
suppliers: v7.array(v7.string()),
|
|
31232
|
-
total: v7.number(),
|
|
31233
|
-
offset: v7.number(),
|
|
31234
|
-
limit: v7.number()
|
|
31235
|
-
});
|
|
31236
|
-
var MoneyMarketBorrowersSchema = v7.object({
|
|
31237
|
-
borrowers: v7.array(v7.string()),
|
|
31238
|
-
total: v7.number(),
|
|
31239
|
-
offset: v7.number(),
|
|
31240
|
-
limit: v7.number()
|
|
31241
|
-
});
|
|
31242
|
-
var GetChainsResponseSchema = v7.array(SpokeChainKeySchema);
|
|
31243
|
-
var TokensByChainMapSchema = v7.custom(
|
|
31244
|
-
(input) => typeof input === "object" && input !== null && Object.values(input).every((tokens) => Array.isArray(tokens) && tokens.every((t) => v7.is(XTokenSchema, t)))
|
|
31245
|
-
);
|
|
31246
|
-
var TokensListSchema = v7.array(XTokenSchema);
|
|
31247
|
-
var ReserveAssetsSchema = v7.array(AddressSchema2);
|
|
31248
|
-
|
|
31249
31485
|
// src/backendApi/BackendApiService.ts
|
|
31250
31486
|
var BackendApiService = class {
|
|
31251
31487
|
// sub-services exposing domain-specific APIs
|
|
31252
31488
|
swaps;
|
|
31253
31489
|
sponsoring;
|
|
31254
31490
|
bridge;
|
|
31255
|
-
// resolved base-API config: the flat fields of the ApiConfig union with any `baseApiConfig` layered on
|
|
31491
|
+
// resolved base-API config: the flat fields of the ApiConfig union with any `baseApiConfig` layered on
|
|
31492
|
+
// top. `baseURL` is the gateway root; `basePath` is this service's own mount below it.
|
|
31256
31493
|
config;
|
|
31257
31494
|
headers;
|
|
31258
31495
|
logger;
|
|
31496
|
+
/**
|
|
31497
|
+
* The resolved request timeout. Exposed so a caller wanting a *shorter* per-call budget can clamp
|
|
31498
|
+
* to it: a `RequestOverrideConfig.timeout` replaces the configured value rather than capping it,
|
|
31499
|
+
* so passing a fixed override would silently lengthen requests for a consumer who configured a
|
|
31500
|
+
* stricter timeout.
|
|
31501
|
+
*/
|
|
31502
|
+
get requestTimeoutMs() {
|
|
31503
|
+
return this.config.timeout;
|
|
31504
|
+
}
|
|
31505
|
+
/**
|
|
31506
|
+
* Whether a legacy `/be` suffix is trimmed off a per-call `baseURL` override. Mirrors the config-level
|
|
31507
|
+
* decision: an explicit `basePath` means the consumer writes complete roots, so their per-call value is
|
|
31508
|
+
* left exactly as given rather than having a real path segment eaten.
|
|
31509
|
+
*/
|
|
31510
|
+
trimsLegacyOverrides;
|
|
31259
31511
|
constructor(config, logger = consoleLogger) {
|
|
31260
31512
|
this.config = resolveBaseApiConfig(config);
|
|
31261
31513
|
this.headers = { ...this.config.headers };
|
|
31262
31514
|
this.logger = logger;
|
|
31263
|
-
this.
|
|
31264
|
-
|
|
31265
|
-
|
|
31515
|
+
this.trimsLegacyOverrides = !hasExplicitBasePath(config);
|
|
31516
|
+
const swapsConfig2 = resolveSwapsApiConfig(config);
|
|
31517
|
+
const sponsoringConfig = resolveSponsoringApiConfig(config);
|
|
31518
|
+
const bridgeConfig2 = resolveBridgeApiConfig(config);
|
|
31519
|
+
const shortRoots = [
|
|
31520
|
+
["backendApi", this.config.baseURL],
|
|
31521
|
+
["api.swaps", swapsConfig2.baseURL],
|
|
31522
|
+
["api.bridge", bridgeConfig2.baseURL],
|
|
31523
|
+
["api.sponsoring", sponsoringConfig.baseURL]
|
|
31524
|
+
].filter(([, baseURL]) => isMissingVersionPrefix(baseURL));
|
|
31525
|
+
if (shortRoots.length > 0) {
|
|
31526
|
+
const named = shortRoots.map(([service, baseURL]) => `${service} ("${baseURL}")`).join(", ");
|
|
31527
|
+
this.logger.warn(
|
|
31528
|
+
`[BackendApiService] api.baseURL is missing the gateway's version prefix for ${named}: every route resolves one segment short. Use "${DEFAULT_API_BASE_URL}" \u2014 the prefix is deployment-owned, so it belongs in baseURL, and only the data API has a basePath to compensate.`
|
|
31529
|
+
);
|
|
31530
|
+
}
|
|
31531
|
+
if (hasLegacyBackendBaseURL(config)) {
|
|
31532
|
+
this.logger.warn(
|
|
31533
|
+
`[BackendApiService] api.baseURL should be the gateway root, not the backend data API's mount: trimmed "${BACKEND_API_BASE_PATH}" to "${this.config.baseURL}". Drop the suffix \u2014 the SDK appends it, and sibling services (/swaps, /bridge) must not sit under it.`
|
|
31534
|
+
);
|
|
31535
|
+
}
|
|
31536
|
+
const overrideOptions = { trimLegacyOverrides: this.trimsLegacyOverrides };
|
|
31537
|
+
this.swaps = new SwapsApiService(swapsConfig2, this.logger, overrideOptions);
|
|
31538
|
+
this.sponsoring = new SponsoringApiService(sponsoringConfig, this.logger);
|
|
31539
|
+
this.bridge = new BridgeApiService(bridgeConfig2, this.logger, overrideOptions);
|
|
31540
|
+
}
|
|
31541
|
+
/**
|
|
31542
|
+
* Issue the HTTP call for a route.
|
|
31543
|
+
*
|
|
31544
|
+
* The mount is applied here rather than at each route literal, so `error.context.endpoint` stays
|
|
31545
|
+
* route-relative and the mount survives a per-call `baseURL` override — that retargets the gateway
|
|
31546
|
+
* root, not which service the route belongs to. For the same reason an override is put through the
|
|
31547
|
+
* legacy-mount trim: without it, passing the old `…/v1/be` value per call would yield `/be/be/…`.
|
|
31548
|
+
*
|
|
31549
|
+
* Defaults are listed field by field so `basePath` cannot cross into `RequestConfig`, where it has no
|
|
31550
|
+
* meaning — a spread would pass it silently, since TypeScript skips excess-property checks on spreads.
|
|
31551
|
+
*/
|
|
31552
|
+
async send(endpoint, config) {
|
|
31553
|
+
const { baseURL, ...rest } = config;
|
|
31554
|
+
const overrideBaseURL = baseURL !== void 0 && this.trimsLegacyOverrides ? stripLegacyBackendMount(baseURL) : baseURL;
|
|
31555
|
+
return makeRequest({
|
|
31556
|
+
endpoint: `${this.config.basePath}${endpoint}`,
|
|
31557
|
+
config: resolveRequestConfig(
|
|
31558
|
+
{ ...rest, ...overrideBaseURL === void 0 ? {} : { baseURL: overrideBaseURL } },
|
|
31559
|
+
{ baseURL: this.config.baseURL, timeout: this.config.timeout, headers: this.headers }
|
|
31560
|
+
),
|
|
31561
|
+
logger: this.logger,
|
|
31562
|
+
serviceLabel: "BackendApiService"
|
|
31563
|
+
});
|
|
31266
31564
|
}
|
|
31267
31565
|
/**
|
|
31268
31566
|
* Issue a request and validate the JSON body against `schema`, wrapping the result in `Result<T>`.
|
|
@@ -31273,13 +31571,8 @@ var BackendApiService = class {
|
|
|
31273
31571
|
*/
|
|
31274
31572
|
async request(endpoint, config, schema) {
|
|
31275
31573
|
try {
|
|
31276
|
-
const raw = await
|
|
31277
|
-
|
|
31278
|
-
config: resolveRequestConfig(config, { ...this.config, headers: this.headers }),
|
|
31279
|
-
logger: this.logger,
|
|
31280
|
-
serviceLabel: "BackendApiService"
|
|
31281
|
-
});
|
|
31282
|
-
const parsed = v7.safeParse(schema, raw);
|
|
31574
|
+
const raw = await this.send(endpoint, config);
|
|
31575
|
+
const parsed = v.safeParse(schema, raw);
|
|
31283
31576
|
if (!parsed.success) {
|
|
31284
31577
|
return {
|
|
31285
31578
|
ok: false,
|
|
@@ -31287,7 +31580,7 @@ var BackendApiService = class {
|
|
|
31287
31580
|
api: "backend",
|
|
31288
31581
|
feature: "backend",
|
|
31289
31582
|
endpoint,
|
|
31290
|
-
issues:
|
|
31583
|
+
issues: v.flatten(parsed.issues)
|
|
31291
31584
|
})
|
|
31292
31585
|
};
|
|
31293
31586
|
}
|
|
@@ -31305,12 +31598,7 @@ var BackendApiService = class {
|
|
|
31305
31598
|
*/
|
|
31306
31599
|
async requestUnvalidated(endpoint, config) {
|
|
31307
31600
|
try {
|
|
31308
|
-
const value = await
|
|
31309
|
-
endpoint,
|
|
31310
|
-
config: resolveRequestConfig(config, { ...this.config, headers: this.headers }),
|
|
31311
|
-
logger: this.logger,
|
|
31312
|
-
serviceLabel: "BackendApiService"
|
|
31313
|
-
});
|
|
31601
|
+
const value = await this.send(endpoint, config);
|
|
31314
31602
|
return { ok: true, value };
|
|
31315
31603
|
} catch (error) {
|
|
31316
31604
|
return { ok: false, error: toExternalApiError({ api: "backend", feature: "backend", endpoint, error }) };
|
|
@@ -31612,8 +31900,9 @@ var BackendApiService = class {
|
|
|
31612
31900
|
* without constructing a new service instance. Existing header keys are
|
|
31613
31901
|
* overwritten; keys absent from `headers` are preserved.
|
|
31614
31902
|
*
|
|
31615
|
-
* Headers also reach `swaps
|
|
31616
|
-
*
|
|
31903
|
+
* Headers also reach `swaps` and `bridge`, but never `sponsoring`: it is configured independently, so
|
|
31904
|
+
* base-API credentials must not be forwarded to whatever origin it points at. Note `swaps` can also be
|
|
31905
|
+
* retargeted to another origin via `swapsApiConfig`, in which case a header set here follows it.
|
|
31617
31906
|
*
|
|
31618
31907
|
* @param headers - Key-value pairs to add or overwrite in the default headers.
|
|
31619
31908
|
*/
|
|
@@ -31625,13 +31914,22 @@ var BackendApiService = class {
|
|
|
31625
31914
|
this.bridge.setHeaders(headers);
|
|
31626
31915
|
}
|
|
31627
31916
|
/**
|
|
31628
|
-
* Return the
|
|
31917
|
+
* Return the gateway root the service is currently pointing at — WITHOUT this service's own mount.
|
|
31918
|
+
* Requests go to `getBaseURL() + getBasePath() + <route>`.
|
|
31629
31919
|
*
|
|
31630
|
-
* @returns The `baseURL` from the `ApiConfig` this instance was
|
|
31920
|
+
* @returns The resolved gateway root, i.e. the `baseURL` from the `ApiConfig` this instance was
|
|
31921
|
+
* constructed with, minus a legacy `/be` suffix if one was supplied.
|
|
31631
31922
|
*/
|
|
31632
31923
|
getBaseURL() {
|
|
31633
31924
|
return this.config.baseURL;
|
|
31634
31925
|
}
|
|
31926
|
+
/**
|
|
31927
|
+
* Return the backend data API's mount below {@link getBaseURL} — `/be` by default, or whatever
|
|
31928
|
+
* `basePath` the `ApiConfig` supplied (`''` for a service addressed directly at its origin).
|
|
31929
|
+
*/
|
|
31930
|
+
getBasePath() {
|
|
31931
|
+
return this.config.basePath;
|
|
31932
|
+
}
|
|
31635
31933
|
};
|
|
31636
31934
|
|
|
31637
31935
|
// src/bridge/errors.ts
|
|
@@ -40504,7 +40802,7 @@ var LeverageYieldService = class {
|
|
|
40504
40802
|
}
|
|
40505
40803
|
/** Looks up a vault by its `name` field. Returns `undefined` when not registered. */
|
|
40506
40804
|
getVault(name) {
|
|
40507
|
-
return this.listVaults().find((
|
|
40805
|
+
return this.listVaults().find((v10) => v10.name === name);
|
|
40508
40806
|
}
|
|
40509
40807
|
/**
|
|
40510
40808
|
* Looks up a registered vault by its on-chain proxy address (case-insensitive).
|
|
@@ -40512,7 +40810,7 @@ var LeverageYieldService = class {
|
|
|
40512
40810
|
*/
|
|
40513
40811
|
getVaultByAddress(address) {
|
|
40514
40812
|
const normalized = address.toLowerCase();
|
|
40515
|
-
return this.listVaults().find((
|
|
40813
|
+
return this.listVaults().find((v10) => v10.vault.toLowerCase() === normalized);
|
|
40516
40814
|
}
|
|
40517
40815
|
/**
|
|
40518
40816
|
* Resolves the intent `deadline`: returns the caller-supplied value verbatim, otherwise
|
|
@@ -42069,4 +42367,4 @@ var isPartnerError = isCodeMember(PARTNER_CODES);
|
|
|
42069
42367
|
(*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
42070
42368
|
*/
|
|
42071
42369
|
|
|
42072
|
-
export { ALLOWANCE_CHECK_CODES, APPROVE_CODES, AssetService, BITCOIN_CHAIN_KEYS, BITCOIN_CHAIN_KEYS_SET, BITCOIN_DUST_SATS, BTC_WALLET_ADDRESS_TYPES, BackendApiService, BackendHttpError, BalnSwapService, BigIntToHex, BigNumberZeroDecimal, BitcoinSpokeService, BnUSDMigrationService, BridgeApiService, BridgeService, CHAIN_KEYS, CHAIN_LOGO_BASE_URL, CONFIG_VERSION, CREATE_INTENT_CODES, ChainKeys, ChainTypeArr, ClService, ConfigService, CustomSorobanServer, CustomStellarAccount, DEFAULT_BACKEND_API_ENDPOINT, DEFAULT_BACKEND_API_HEADERS, DEFAULT_BACKEND_API_TIMEOUT, DEFAULT_DEADLINE_OFFSET, DEFAULT_MAX_RETRY, DEFAULT_RELAYER_API_ENDPOINT, DEFAULT_RELAY_TX_TIMEOUT, DEFAULT_RETRY_DELAY_MS, DEFAULT_SPONSORING_API_ENDPOINT, DexService, EVM_CHAIN_ID_TO_KEY, EVM_CHAIN_KEYS, EVM_CHAIN_KEYS_SET, EVM_SPOKE_ONLY_CHAIN_KEYS, EVM_SPOKE_ONLY_CHAIN_KEYS_SET, Erc20Service, Erc4626Service, EvmAssetManagerService, EvmHubProvider, EvmSolverService, EvmSpokeService, EvmVaultTokenService, FEE_PERCENTAGE_SCALE, GAS_ESTIMATION_CODES, HALF_RAY, HALF_WAD, HUB_CHAIN_KEY, HookKind, HookService, HttpRelayError, HubVaultSymbols, ICON_CHAIN_KEYS, ICON_CHAIN_KEYS_SET, ICON_TX_RESULT_WAIT_MAX_RETRY, INJECTIVE_CHAIN_KEYS, INJECTIVE_CHAIN_KEYS_SET, INTENT_CHAIN_IDS, IconSpokeService, IcxMigrationService, Injective20Token, InjectiveSpokeService, IntentCreatedEventAbi, IntentDataService, IntentDataType, IntentFilledEventAbi, IntentRelayChainIdToChainKey, IntentsAbi, LOOKUP_CODES, LTV_PRECISION, LendingPoolService, LeverageYieldService, LockupMultiplier, LockupPeriod, LsodaSymbols, LsodaTokens, MAX_UINT256, MigrationService, MintPositionEventAbi, MoneyMarketDataService, MoneyMarketService, NEAR_CHAIN_KEYS, NEAR_CHAIN_KEYS_SET, NEAR_DEFAULT_GAS, NEAR_STORAGE_DEPOSIT, NearSpokeService, PartnerFeeClaimService, PartnerService, Permit2Service, ProtocolIntentsAbi, RAY, RAY_DECIMALS, RELAY_ERROR_CODES, RELAY_FALLBACK_FLOOR_MS, RadfiApiError, RadfiProvider, RecoveryService, RelayChainIdMap, SECONDS_PER_YEAR, SODAX_ERROR_CODES, SODAX_FEATURES, SOLANA_CHAIN_KEYS, SOLANA_CHAIN_KEYS_SET, SONIC_CHAIN_KEYS, SONIC_CHAIN_KEYS_SET, SPONSORING_API_ERROR_CODES, SPONSORING_API_STELLAR_BASE_PATH, SPONSOR_CONFIG_TTL_MS, STACKS_CHAIN_KEYS, STACKS_CHAIN_KEYS_SET, STELLAR_BASE_RESERVE_TTL_MS, STELLAR_CHAIN_KEYS, STELLAR_CHAIN_KEYS_SET, STELLAR_TRUSTLINE_MIN_XLM_STROOPS, SUI_CHAIN_KEYS, SUI_CHAIN_KEYS_SET, SodaTokens, Sodax, SodaxError, SolanaSpokeService, SolverApiService, SolverIntentErrorCode, SolverIntentStatusCode, SonicSpokeService, SpokeService, SponsoringApiService, SponsoringService, StacksSpokeService, StakingLogic, StakingService, StatATokenAddresses, StellarSpokeService, SuiSpokeService, SupportedMigrationTokens, SwapService, SwapsApiService, TOKEN_LOGO_BASE_URL, USD_DECIMALS, UiPoolDataProviderService, VAULT_TOKEN_DECIMALS, WAD, WAD_RAY_RATIO, WEI_DECIMALS, adjustAmountByFee, allowanceCheckFailed, apiConfig, approveFailed, arbitrumSupportedTokens, assetManagerAbi, avalancheSupportedTokens, balnSwapAbi, baseChainInfo, baseSupportedTokens, binomialApproximatedRayPow, bitcoinSupportedTokens, bnUSDLegacySpokeChainIds, bnUSDLegacyTokens, bridgeConfig, bridgeInvariant, bscSupportedTokens, calcOpReturnOutputVbytes, calculateAllReserveIncentives, calculateAllUserIncentives, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateCompoundedRate, calculateFeeAmount, calculateHealthFactorFromBalances, calculateHealthFactorFromBalancesBigUnits, calculateLinearInterest, calculatePercentageFeeAmount, clPoolAbi, clPoolManagerAbi, clPositionManagerAbi, clQuoterAbi, clRouterAbi, clTickLensAbi, classifySponsorError, concentratedLiquidityConfig, connectionAbi, consoleLogger, convertTransactionInstructionToRaw, createInvariant, deepMerge, defaultHookAbi, detectBitcoinAddressType, dexConfig, dexInvariant, dexPools, encodeAddress, encodeBtcPayloadToBytes, encodeContractCalls, erc20Abi, erc4626Abi, estimateBitcoinTxSize, ethereumSupportedTokens, executionFailed, formatBasisPoints, formatEModeCategory, formatEModes, formatPercentage, formatReserve, formatReserveUSD, formatReserves, formatReservesAndIncentives, formatUserSummary, formatUserSummaryAndIncentives, gasEstimationFailed, getAllLegacybnUSDTokens, getAndFormatReserveEModes, getAssetManagerIdl, getAssetManagerProgram, getChainKeyFromRelayChainId, getChainType, getCompoundedBalance, getConcentratedLiquidityConfig, getConnectionIdl, getConnectionProgram, getEvmChainKeyByChainId, getEvmViemChain, getIconAddressBytes, getIntentRelayChainId, getLinearBalance, getMarketReferenceCurrencyAndUsdBalance, getPacket, getProvider, getRandomBytes, getReserveNormalizedIncome, getReservesEModes, getSolanaAddressBytes, getSolverConfig, getSpokeHook, getSpokeHooks, getStagingSolverTokens, getSupportedSolverTokens, getTransactionPackets, getbnUSDToken, hederaSupportedTokens, hexToBigInt, hexToSolanaAddress, hubConfig, hyper, hyperevmSupportedTokens, iconSupportedTokens, injectiveSupportedTokens, intentCreationFailed, isBackendHttpError, isBalnMigrateParams, isBitcoinChainKey, isBitcoinChainKeyType, isBitcoinWalletProviderType, isBridgeAllowanceCheckError, isBridgeApproveError, isBridgeCreateIntentError, isBridgeError, isBridgeLookupError, isBridgeOrchestrationError, isCodeMember, isDexApproveError, isDexCreateIntentError, isDexError, isEvmChainKey, isEvmChainKeyType, isEvmSpokeChainConfig, isEvmSpokeOnlyChainKey, isEvmSpokeOnlyChainKeyType, isEvmWalletProviderType, isFeatureError, isHookSupportedToken, isHubChainKey, isHubChainKeyType, isIconAddress, isIconChainKey, isIconChainKeyType, isIcxCreateRevertMigrationParams, isIcxMigrateParams, isInjectiveChainKey, isInjectiveChainKeyType, isJsonRpcPayloadResponse, isLegacybnUSDChainId, isLegacybnUSDToken, isLeverageYieldAllowanceCheckError, isLeverageYieldApproveError, isLeverageYieldCreateIntentError, isLeverageYieldError, isLeverageYieldLookupError, isLeverageYieldPostExecutionError, isLeverageYieldSwapError, isMigrateOrchestrationError, isMigrationAllowanceCheckError, isMigrationApproveError, isMigrationCreateIntentError, isMigrationError, isMigrationLookupError, isMoneyMarketAllowanceCheckError, isMoneyMarketApproveError, isMoneyMarketCreateIntentError, isMoneyMarketError, isMoneyMarketGasEstimationError, isMoneyMarketOrchestrationError, isNativeBitcoinToken, isNativeBitcoinTransfer, isNativeToken, isNearChainKey, isNearChainKeyType, isNewbnUSDChainId, isNewbnUSDToken, isOptionalBitcoinWalletProviderType, isOptionalEvmWalletProviderType, isOptionalStellarWalletProviderType, isPartnerError, isPartnerFeeAmount, isPartnerFeePercentage, isPostExecutionError, isRawDestinationParams, isRecoveryError, isResponseAddressType, isResponseSigningType, isRevertMigrationOrchestrationError, isSodaxError, isSolanaChainKey, isSolanaChainKeyType, isSolanaNativeToken, isSonicChainKey, isSonicChainKeyType, isSpokeApproveParamsEvmSpoke, isSpokeApproveParamsHub, isSpokeApproveParamsStellar, isSpokeChainKey, isSpokeIsAllowanceValidParamsEvmSpoke, isSpokeIsAllowanceValidParamsHub, isSpokeIsAllowanceValidParamsStellar, isSponsoringConfigError, isSponsoringLookupError, isSponsoringOrchestrationError, isStacksChainKey, isStacksChainKeyType, isStakeOrchestrationError, isStakingAllowanceCheckError, isStakingApproveError, isStakingCreateIntentError, isStakingError, isStakingInfoFetchError, isStakingOrchestrationError, isStellarChainKey, isStellarChainKeyType, isStellarWalletProviderType, isSuiChainKey, isSuiChainKeyType, isSupportedBitcoinAddressType, isSwapCreateIntentError, isSwapError, isSwapSupportedToken, isUndefinedOrValidWalletProviderForChainKey, isUnifiedBnUSDMigrateParams, isValidWalletProviderForChainKey, kaiaSupportedTokens, leverageYieldConfig, leverageYieldInvariant, leverageYieldVaults, lightlinkSupportedTokens, lookupFailed, mapRelayFailure, mergeSodaxConfig, messageOf, migrationInvariant, mintPositionParamsAbi, mmInvariant, modifyLiquidityParamsAbi, moneyMarketConfig, moneyMarketReserveAssets, moneyMarketSupportedTokens, nativeToUSD, nearSupportedTokens, newbnUSDSpokeChainIds, noopAnalytics, normalize, normalizeBN, normalizePsbtToBase64, normalizeSignatureToBase64, normalizedToUsd, optimismSupportedTokens, pancakeSwapInfinityDefaultHookAbi, pancakeSwapInfinityPoolManagerAbi, pancakeSwapInfinityPositionManagerAbi, parseToStroops, parseTokenArrayFromJson, partnerInvariant, permit2Abi, polygonSupportedTokens, poolAbi, poolKeyAbi, randomUint256, rayDiv, rayMul, rayPow, rayToWad, recoveryInvariant, redbellySupportedTokens, relayConfig, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, resolveAnalytics, resolveLogger, retry, reverseEncodeAddress, serializeAddressData, silentLogger, sleep, sodaxConfig, sodaxInvariant, solanaSupportedTokens, solverConfig, sonicSupportedTokens, sonicWalletFactoryAbi, spokeAssetManagerAbi, spokeChainConfig, spokeChainKeysSet, spokeHooks, sponsoringInvariant, stacksSupportedTokens, stagingSwapSupportedTokens, stakedSodaAbi, stakingInvariant, stakingRouterAbi, stataTokenFactoryAbi, stellarSupportedTokens, submitTransaction, suiSupportedTokens, supportedSpokeChains, supportedTokensByChain, swapExactInSingleParamsAbi, swapInvariant, swapSupportedTokens, swapsConfig, toCreateBridgeIntentParamsV2, tokenLogo, tokenLogoSlug, uiPoolDataAbi, universalRouterAbi, unknownFailed, usesBip322MessageSigning, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, verifyFailed, wadToRay, waitForStacksTransaction, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
|
|
42370
|
+
export { ALLOWANCE_CHECK_CODES, APPROVE_CODES, AssetService, BACKEND_API_BASE_PATH, BITCOIN_CHAIN_KEYS, BITCOIN_CHAIN_KEYS_SET, BITCOIN_DUST_SATS, BTC_WALLET_ADDRESS_TYPES, BackendApiService, BackendHttpError, BalnSwapService, BigIntToHex, BigNumberZeroDecimal, BitcoinSpokeService, BnUSDMigrationService, BridgeApiService, BridgeService, CHAIN_KEYS, CHAIN_LOGO_BASE_URL, CONFIG_VERSION, CREATE_INTENT_CODES, ChainKeys, ChainTypeArr, ClService, ConfigService, CustomSorobanServer, CustomStellarAccount, DEFAULT_API_BASE_URL, DEFAULT_BACKEND_API_ENDPOINT, DEFAULT_BACKEND_API_HEADERS, DEFAULT_BACKEND_API_TIMEOUT, DEFAULT_DEADLINE_OFFSET, DEFAULT_MAX_RETRY, DEFAULT_RELAYER_API_ENDPOINT, DEFAULT_RELAY_TX_TIMEOUT, DEFAULT_RETRY_DELAY_MS, DEFAULT_SPONSORING_API_ENDPOINT, DETAILED_STATUS_NOT_DELIVERED, DexService, EVM_CHAIN_ID_TO_KEY, EVM_CHAIN_KEYS, EVM_CHAIN_KEYS_SET, EVM_SPOKE_ONLY_CHAIN_KEYS, EVM_SPOKE_ONLY_CHAIN_KEYS_SET, Erc20Service, Erc4626Service, EvmAssetManagerService, EvmHubProvider, EvmSolverService, EvmSpokeService, EvmVaultTokenService, FEE_PERCENTAGE_SCALE, GAS_ESTIMATION_CODES, HALF_RAY, HALF_WAD, HUB_CHAIN_KEY, HookKind, HookService, HttpRelayError, HubVaultSymbols, ICON_CHAIN_KEYS, ICON_CHAIN_KEYS_SET, ICON_TX_RESULT_WAIT_MAX_RETRY, INJECTIVE_CHAIN_KEYS, INJECTIVE_CHAIN_KEYS_SET, INTENT_CHAIN_IDS, IconSpokeService, IcxMigrationService, Injective20Token, InjectiveSpokeService, IntentCreatedEventAbi, IntentDataService, IntentDataType, IntentFilledEventAbi, IntentRelayChainIdToChainKey, IntentsAbi, LOOKUP_CODES, LTV_PRECISION, LendingPoolService, LeverageYieldService, LockupMultiplier, LockupPeriod, LsodaSymbols, LsodaTokens, MAX_UINT256, MigrationService, MintPositionEventAbi, MoneyMarketDataService, MoneyMarketService, NEAR_CHAIN_KEYS, NEAR_CHAIN_KEYS_SET, NEAR_DEFAULT_GAS, NEAR_STORAGE_DEPOSIT, NearSpokeService, PartnerFeeClaimService, PartnerService, Permit2Service, ProtocolIntentsAbi, RAY, RAY_DECIMALS, RELAY_ERROR_CODES, RELAY_FALLBACK_FLOOR_MS, RELAY_REQUEST_TIMEOUT_MS, RadfiApiError, RadfiProvider, RecoveryService, RelayChainIdMap, SECONDS_PER_YEAR, SODAX_ERROR_CODES, SODAX_FEATURES, SOLANA_CHAIN_KEYS, SOLANA_CHAIN_KEYS_SET, SONIC_CHAIN_KEYS, SONIC_CHAIN_KEYS_SET, SPONSORING_API_ERROR_CODES, SPONSORING_API_STELLAR_BASE_PATH, SPONSOR_CONFIG_TTL_MS, STACKS_CHAIN_KEYS, STACKS_CHAIN_KEYS_SET, STELLAR_BASE_RESERVE_TTL_MS, STELLAR_CHAIN_KEYS, STELLAR_CHAIN_KEYS_SET, STELLAR_TRUSTLINE_MIN_XLM_STROOPS, SUI_CHAIN_KEYS, SUI_CHAIN_KEYS_SET, SodaTokens, Sodax, SodaxError, SolanaSpokeService, SolverApiService, SolverIntentErrorCode, SolverIntentStatusCode, SonicSpokeService, SpokeService, SponsoringApiService, SponsoringService, StacksSpokeService, StakingLogic, StakingService, StatATokenAddresses, StellarSpokeService, SuiSpokeService, SupportedMigrationTokens, SwapService, SwapsApiService, TOKEN_LOGO_BASE_URL, USD_DECIMALS, UiPoolDataProviderService, VAULT_TOKEN_DECIMALS, WAD, WAD_RAY_RATIO, WEI_DECIMALS, adjustAmountByFee, allowanceCheckFailed, apiConfig, approveFailed, arbitrumSupportedTokens, assetManagerAbi, avalancheSupportedTokens, balnSwapAbi, baseChainInfo, baseSupportedTokens, binomialApproximatedRayPow, bitcoinSupportedTokens, bnUSDLegacySpokeChainIds, bnUSDLegacyTokens, bridgeConfig, bridgeInvariant, bscSupportedTokens, calcOpReturnOutputVbytes, calculateAllReserveIncentives, calculateAllUserIncentives, calculateAvailableBorrowsMarketReferenceCurrency, calculateCompoundedInterest, calculateCompoundedRate, calculateFeeAmount, calculateHealthFactorFromBalances, calculateHealthFactorFromBalancesBigUnits, calculateLinearInterest, calculatePercentageFeeAmount, clPoolAbi, clPoolManagerAbi, clPositionManagerAbi, clQuoterAbi, clRouterAbi, clTickLensAbi, classifySponsorError, concentratedLiquidityConfig, connectionAbi, consoleLogger, convertTransactionInstructionToRaw, createInvariant, deepMerge, defaultHookAbi, detectBitcoinAddressType, dexConfig, dexInvariant, dexPools, encodeAddress, encodeBtcPayloadToBytes, encodeContractCalls, erc20Abi, erc4626Abi, estimateBitcoinTxSize, ethereumSupportedTokens, executionFailed, formatBasisPoints, formatEModeCategory, formatEModes, formatPercentage, formatReserve, formatReserveUSD, formatReserves, formatReservesAndIncentives, formatUserSummary, formatUserSummaryAndIncentives, gasEstimationFailed, getAllLegacybnUSDTokens, getAndFormatReserveEModes, getAssetManagerIdl, getAssetManagerProgram, getChainKeyFromRelayChainId, getChainType, getCompoundedBalance, getConcentratedLiquidityConfig, getConnectionIdl, getConnectionProgram, getEvmChainKeyByChainId, getEvmViemChain, getIconAddressBytes, getIntentRelayChainId, getLinearBalance, getMarketReferenceCurrencyAndUsdBalance, getPacket, getProvider, getRandomBytes, getReserveNormalizedIncome, getReservesEModes, getSolanaAddressBytes, getSolverConfig, getSpokeHook, getSpokeHooks, getStagingSolverTokens, getSupportedSolverTokens, getTransactionPackets, getbnUSDToken, hederaSupportedTokens, hexToBigInt, hexToSolanaAddress, hubConfig, hyper, hyperevmSupportedTokens, iconSupportedTokens, injectiveSupportedTokens, intentCreationFailed, isBackendHttpError, isBalnMigrateParams, isBitcoinChainKey, isBitcoinChainKeyType, isBitcoinWalletProviderType, isBridgeAllowanceCheckError, isBridgeApproveError, isBridgeCreateIntentError, isBridgeError, isBridgeLookupError, isBridgeOrchestrationError, isCodeMember, isDexApproveError, isDexCreateIntentError, isDexError, isEvmChainKey, isEvmChainKeyType, isEvmSpokeChainConfig, isEvmSpokeOnlyChainKey, isEvmSpokeOnlyChainKeyType, isEvmWalletProviderType, isFeatureError, isFillEvent, isHookSupportedToken, isHubChainKey, isHubChainKeyType, isIconAddress, isIconChainKey, isIconChainKeyType, isIcxCreateRevertMigrationParams, isIcxMigrateParams, isInjectiveChainKey, isInjectiveChainKeyType, isJsonRpcPayloadResponse, isLegacybnUSDChainId, isLegacybnUSDToken, isLeverageYieldAllowanceCheckError, isLeverageYieldApproveError, isLeverageYieldCreateIntentError, isLeverageYieldError, isLeverageYieldLookupError, isLeverageYieldPostExecutionError, isLeverageYieldSwapError, isMigrateOrchestrationError, isMigrationAllowanceCheckError, isMigrationApproveError, isMigrationCreateIntentError, isMigrationError, isMigrationLookupError, isMoneyMarketAllowanceCheckError, isMoneyMarketApproveError, isMoneyMarketCreateIntentError, isMoneyMarketError, isMoneyMarketGasEstimationError, isMoneyMarketOrchestrationError, isNativeBitcoinToken, isNativeBitcoinTransfer, isNativeToken, isNearChainKey, isNearChainKeyType, isNewbnUSDChainId, isNewbnUSDToken, isOptionalBitcoinWalletProviderType, isOptionalEvmWalletProviderType, isOptionalStellarWalletProviderType, isPartnerError, isPartnerFeeAmount, isPartnerFeePercentage, isPostExecutionError, isRawDestinationParams, isRecoveryError, isResponseAddressType, isResponseSigningType, isRevertMigrationOrchestrationError, isSodaxError, isSolanaChainKey, isSolanaChainKeyType, isSolanaNativeToken, isSonicChainKey, isSonicChainKeyType, isSpokeApproveParamsEvmSpoke, isSpokeApproveParamsHub, isSpokeApproveParamsStellar, isSpokeChainKey, isSpokeIsAllowanceValidParamsEvmSpoke, isSpokeIsAllowanceValidParamsHub, isSpokeIsAllowanceValidParamsStellar, isSponsoringConfigError, isSponsoringLookupError, isSponsoringOrchestrationError, isStacksChainKey, isStacksChainKeyType, isStakeOrchestrationError, isStakingAllowanceCheckError, isStakingApproveError, isStakingCreateIntentError, isStakingError, isStakingInfoFetchError, isStakingOrchestrationError, isStellarChainKey, isStellarChainKeyType, isStellarWalletProviderType, isSuiChainKey, isSuiChainKeyType, isSupportedBitcoinAddressType, isSwapCreateIntentError, isSwapError, isSwapSupportedToken, isUndefinedOrValidWalletProviderForChainKey, isUnifiedBnUSDMigrateParams, isValidWalletProviderForChainKey, kaiaSupportedTokens, leverageYieldConfig, leverageYieldInvariant, leverageYieldVaults, lightlinkSupportedTokens, lookupFailed, mapRelayFailure, mergeSodaxConfig, messageOf, migrationInvariant, mintPositionParamsAbi, mmInvariant, modifyLiquidityParamsAbi, moneyMarketConfig, moneyMarketReserveAssets, moneyMarketSupportedTokens, nativeToUSD, nearSupportedTokens, newbnUSDSpokeChainIds, noopAnalytics, normalize, normalizeBN, normalizePsbtToBase64, normalizeSignatureToBase64, normalizedToUsd, optimismSupportedTokens, pancakeSwapInfinityDefaultHookAbi, pancakeSwapInfinityPoolManagerAbi, pancakeSwapInfinityPositionManagerAbi, parseToStroops, parseTokenArrayFromJson, partnerInvariant, permit2Abi, polygonSupportedTokens, poolAbi, poolKeyAbi, randomUint256, rayDiv, rayMul, rayPow, rayToWad, recoveryInvariant, redbellySupportedTokens, relayConfig, relayTxAndWaitPacket, requestAddress, requestJsonRpc, requestSigning, resolveAnalytics, resolveLogger, retry, reverseEncodeAddress, serializeAddressData, silentLogger, sleep, sodaxConfig, sodaxInvariant, solanaSupportedTokens, solverConfig, sonicSupportedTokens, sonicWalletFactoryAbi, spokeAssetManagerAbi, spokeChainConfig, spokeChainKeysSet, spokeHooks, sponsoringInvariant, stacksSupportedTokens, stagingSwapSupportedTokens, stakedSodaAbi, stakingInvariant, stakingRouterAbi, stataTokenFactoryAbi, stellarSupportedTokens, submitTransaction, suiSupportedTokens, supportedSpokeChains, supportedTokensByChain, swapExactInSingleParamsAbi, swapInvariant, swapSupportedTokens, swapsConfig, toCreateBridgeIntentParamsV2, tokenLogo, tokenLogoSlug, uiPoolDataAbi, universalRouterAbi, unknownFailed, usesBip322MessageSigning, valueToBigNumber, valueToZDBigNumber, variableDebtTokenAbi, vaultTokenAbi, verifyFailed, wadToRay, waitForStacksTransaction, waitForTransactionReceipt, waitUntilIntentExecuted, walletFactoryAbi, wrappedSonicAbi };
|