@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.cjs
CHANGED
|
@@ -19,7 +19,7 @@ var IconSdkRaw = require('icon-sdk-js');
|
|
|
19
19
|
var sdkTs = require('@injectivelabs/sdk-ts');
|
|
20
20
|
var tx_js = require('cosmjs-types/cosmos/tx/v1beta1/tx.js');
|
|
21
21
|
var networks = require('@injectivelabs/networks');
|
|
22
|
-
var
|
|
22
|
+
var v = require('valibot');
|
|
23
23
|
var swapsApi = require('@sodax/swaps-api');
|
|
24
24
|
var BigNumber5 = require('bignumber.js');
|
|
25
25
|
var swapSdkCore = require('@pancakeswap/swap-sdk-core');
|
|
@@ -49,7 +49,7 @@ var rlp__namespace = /*#__PURE__*/_interopNamespace(rlp);
|
|
|
49
49
|
var ecc__namespace = /*#__PURE__*/_interopNamespace(ecc);
|
|
50
50
|
var BN__default = /*#__PURE__*/_interopDefault(BN);
|
|
51
51
|
var IconSdkRaw__namespace = /*#__PURE__*/_interopNamespace(IconSdkRaw);
|
|
52
|
-
var
|
|
52
|
+
var v__namespace = /*#__PURE__*/_interopNamespace(v);
|
|
53
53
|
var BigNumber5__default = /*#__PURE__*/_interopDefault(BigNumber5);
|
|
54
54
|
|
|
55
55
|
// src/errors/SodaxError.ts
|
|
@@ -122,8 +122,8 @@ function serializeCause(cause, depth) {
|
|
|
122
122
|
}
|
|
123
123
|
function sanitizeContext(value, depth) {
|
|
124
124
|
const out = {};
|
|
125
|
-
for (const [key,
|
|
126
|
-
out[key] = sanitizeValue(
|
|
125
|
+
for (const [key, v10] of Object.entries(value)) {
|
|
126
|
+
out[key] = sanitizeValue(v10, depth + 1);
|
|
127
127
|
}
|
|
128
128
|
return out;
|
|
129
129
|
}
|
|
@@ -134,13 +134,13 @@ function sanitizeValue(value, depth) {
|
|
|
134
134
|
if (t === "bigint") return value.toString();
|
|
135
135
|
if (t === "string" || t === "number" || t === "boolean") return value;
|
|
136
136
|
if (t === "function" || t === "symbol") return safeString(value);
|
|
137
|
-
if (Array.isArray(value)) return value.map((
|
|
137
|
+
if (Array.isArray(value)) return value.map((v10) => sanitizeValue(v10, depth + 1));
|
|
138
138
|
if (value instanceof Date) return value.toISOString();
|
|
139
139
|
if (value instanceof Map) {
|
|
140
|
-
return Array.from(value.entries()).map(([k,
|
|
140
|
+
return Array.from(value.entries()).map(([k, v10]) => [sanitizeValue(k, depth + 1), sanitizeValue(v10, depth + 1)]);
|
|
141
141
|
}
|
|
142
142
|
if (value instanceof Set) {
|
|
143
|
-
return Array.from(value.values()).map((
|
|
143
|
+
return Array.from(value.values()).map((v10) => sanitizeValue(v10, depth + 1));
|
|
144
144
|
}
|
|
145
145
|
if (value instanceof Error) return { name: value.name, message: value.message };
|
|
146
146
|
if (t === "object") {
|
|
@@ -152,9 +152,9 @@ function sanitizeValue(value, depth) {
|
|
|
152
152
|
}
|
|
153
153
|
return safeString(value);
|
|
154
154
|
}
|
|
155
|
-
function safeString(
|
|
155
|
+
function safeString(v10) {
|
|
156
156
|
try {
|
|
157
|
-
return String(
|
|
157
|
+
return String(v10);
|
|
158
158
|
} catch {
|
|
159
159
|
return "[unserializable]";
|
|
160
160
|
}
|
|
@@ -3517,6 +3517,7 @@ var ICON_TX_RESULT_WAIT_MAX_RETRY = 10;
|
|
|
3517
3517
|
var MAX_UINT256 = (1n << 256n) - 1n;
|
|
3518
3518
|
var FEE_PERCENTAGE_SCALE = 10000n;
|
|
3519
3519
|
var DEFAULT_DEADLINE_OFFSET = 300n;
|
|
3520
|
+
var DEFAULT_API_BASE_URL = "https://api.sodax.com/v1";
|
|
3520
3521
|
var DEFAULT_BACKEND_API_ENDPOINT = "https://api.sodax.com/v1/be";
|
|
3521
3522
|
var DEFAULT_BACKEND_API_TIMEOUT = 3e4;
|
|
3522
3523
|
var DEFAULT_BACKEND_API_HEADERS = {
|
|
@@ -3527,8 +3528,9 @@ var DEFAULT_RELAYER_API_ENDPOINT = "https://xcall-relay.nw.iconblockchain.xyz";
|
|
|
3527
3528
|
var VAULT_TOKEN_DECIMALS = 18;
|
|
3528
3529
|
var DEFAULT_SPONSORING_API_ENDPOINT = "https://api.sodax.com/v1";
|
|
3529
3530
|
var SPONSORING_API_STELLAR_BASE_PATH = "/sponsorships/stellar";
|
|
3531
|
+
var BACKEND_API_BASE_PATH = "/be";
|
|
3530
3532
|
var apiConfig = {
|
|
3531
|
-
baseURL:
|
|
3533
|
+
baseURL: DEFAULT_API_BASE_URL,
|
|
3532
3534
|
timeout: DEFAULT_BACKEND_API_TIMEOUT,
|
|
3533
3535
|
headers: DEFAULT_BACKEND_API_HEADERS
|
|
3534
3536
|
};
|
|
@@ -4456,7 +4458,7 @@ function isValidWalletProviderForChainKey(chainKey, walletProvider) {
|
|
|
4456
4458
|
}
|
|
4457
4459
|
|
|
4458
4460
|
// ../types/dist/index.js
|
|
4459
|
-
var CONFIG_VERSION =
|
|
4461
|
+
var CONFIG_VERSION = 226;
|
|
4460
4462
|
|
|
4461
4463
|
// src/shared/utils/resolveTimeoutMs.ts
|
|
4462
4464
|
function resolveTimeoutMs(timeout, fallbackMs) {
|
|
@@ -4843,10 +4845,11 @@ async function submitTransaction(payload, apiUrl) {
|
|
|
4843
4845
|
return { ok: false, error };
|
|
4844
4846
|
}
|
|
4845
4847
|
}
|
|
4846
|
-
async function getTransactionPackets(payload, apiUrl) {
|
|
4848
|
+
async function getTransactionPackets(payload, apiUrl, timeoutMs) {
|
|
4847
4849
|
invariant(payload.params.chain_id.length > 0, "Invalid input parameters. source_chain_id empty");
|
|
4848
4850
|
invariant(payload.params.tx_hash.length > 0, "Invalid input parameters. tx_hash empty");
|
|
4849
|
-
return postRequest(payload, apiUrl);
|
|
4851
|
+
if (timeoutMs === void 0) return postRequest(payload, apiUrl);
|
|
4852
|
+
return pollTransactionPackets(payload, apiUrl, Date.now() + resolveTimeoutMs(timeoutMs, RELAY_REQUEST_TIMEOUT_MS));
|
|
4850
4853
|
}
|
|
4851
4854
|
async function getPacket(payload, apiUrl) {
|
|
4852
4855
|
invariant(payload.params.chain_id.length > 0, "Invalid input parameters. source_chain_id empty");
|
|
@@ -14393,7 +14396,7 @@ function mergeSodaxConfig(base2, override) {
|
|
|
14393
14396
|
}
|
|
14394
14397
|
function encodeContractCalls(calls) {
|
|
14395
14398
|
return viem.encodeAbiParameters(viem.parseAbiParameters("(address,uint256,bytes)[]"), [
|
|
14396
|
-
calls.map((
|
|
14399
|
+
calls.map((v10) => [v10.address, v10.value, v10.data])
|
|
14397
14400
|
]);
|
|
14398
14401
|
}
|
|
14399
14402
|
async function waitForTransactionReceipt(hash, provider) {
|
|
@@ -15806,12 +15809,12 @@ function encodeBtcPayloadToBytes(payload) {
|
|
|
15806
15809
|
});
|
|
15807
15810
|
}
|
|
15808
15811
|
function normalizePsbtToBase64(signedPsbt) {
|
|
15809
|
-
const
|
|
15810
|
-
return
|
|
15812
|
+
const isHex2 = /^[0-9a-fA-F]+$/.test(signedPsbt);
|
|
15813
|
+
return isHex2 ? Buffer.from(signedPsbt, "hex").toString("base64") : signedPsbt;
|
|
15811
15814
|
}
|
|
15812
15815
|
function normalizeSignatureToBase64(signature) {
|
|
15813
|
-
const
|
|
15814
|
-
return
|
|
15816
|
+
const isHex2 = /^[0-9a-fA-F]+$/.test(signature);
|
|
15817
|
+
return isHex2 ? Buffer.from(signature, "hex").toString("base64") : signature;
|
|
15815
15818
|
}
|
|
15816
15819
|
|
|
15817
15820
|
// src/shared/services/spoke/BitcoinSpokeService.ts
|
|
@@ -17085,22 +17088,22 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
17085
17088
|
const byte0 = Uint8Array.of(0);
|
|
17086
17089
|
const byte1 = Uint8Array.of(1);
|
|
17087
17090
|
const _maxDrbgIters = 1e3;
|
|
17088
|
-
let
|
|
17091
|
+
let v10 = u8n(hashLen);
|
|
17089
17092
|
let k = u8n(hashLen);
|
|
17090
17093
|
let i = 0;
|
|
17091
17094
|
const reset = () => {
|
|
17092
|
-
|
|
17095
|
+
v10.fill(1);
|
|
17093
17096
|
k.fill(0);
|
|
17094
17097
|
i = 0;
|
|
17095
17098
|
};
|
|
17096
|
-
const h = (...msgs) => hmacFn(k, concatBytes(
|
|
17099
|
+
const h = (...msgs) => hmacFn(k, concatBytes(v10, ...msgs));
|
|
17097
17100
|
const reseed = (seed = NULL) => {
|
|
17098
17101
|
k = h(byte0, seed);
|
|
17099
|
-
|
|
17102
|
+
v10 = h();
|
|
17100
17103
|
if (seed.length === 0)
|
|
17101
17104
|
return;
|
|
17102
17105
|
k = h(byte1, seed);
|
|
17103
|
-
|
|
17106
|
+
v10 = h();
|
|
17104
17107
|
};
|
|
17105
17108
|
const gen = () => {
|
|
17106
17109
|
if (i++ >= _maxDrbgIters)
|
|
@@ -17108,10 +17111,10 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
|
17108
17111
|
let len = 0;
|
|
17109
17112
|
const out = [];
|
|
17110
17113
|
while (len < qByteLen) {
|
|
17111
|
-
|
|
17112
|
-
const sl =
|
|
17114
|
+
v10 = h();
|
|
17115
|
+
const sl = v10.slice();
|
|
17113
17116
|
out.push(sl);
|
|
17114
|
-
len +=
|
|
17117
|
+
len += v10.length;
|
|
17115
17118
|
}
|
|
17116
17119
|
return concatBytes(...out);
|
|
17117
17120
|
};
|
|
@@ -17137,7 +17140,7 @@ function validateObject(object5, fields = {}, optFields = {}) {
|
|
|
17137
17140
|
if (current !== expectedType || val === null)
|
|
17138
17141
|
throw new Error(`param "${fieldName}" is invalid: expected ${expectedType}, got ${current}`);
|
|
17139
17142
|
}
|
|
17140
|
-
const iter = (f, isOpt) => Object.entries(f).forEach(([k,
|
|
17143
|
+
const iter = (f, isOpt) => Object.entries(f).forEach(([k, v10]) => checkField(k, v10, isOpt));
|
|
17141
17144
|
iter(fields, false);
|
|
17142
17145
|
iter(optFields, true);
|
|
17143
17146
|
}
|
|
@@ -17208,9 +17211,9 @@ function sqrt3mod4(Fp, n) {
|
|
|
17208
17211
|
function sqrt5mod8(Fp, n) {
|
|
17209
17212
|
const p5div8 = (Fp.ORDER - _5n) / _8n;
|
|
17210
17213
|
const n2 = Fp.mul(n, _2n);
|
|
17211
|
-
const
|
|
17212
|
-
const nv = Fp.mul(n,
|
|
17213
|
-
const i = Fp.mul(Fp.mul(nv, _2n),
|
|
17214
|
+
const v10 = Fp.pow(n2, p5div8);
|
|
17215
|
+
const nv = Fp.mul(n, v10);
|
|
17216
|
+
const i = Fp.mul(Fp.mul(nv, _2n), v10);
|
|
17214
17217
|
const root = Fp.mul(nv, Fp.sub(i, Fp.ONE));
|
|
17215
17218
|
assertIsSquare(Fp, root, n);
|
|
17216
17219
|
return root;
|
|
@@ -17792,9 +17795,9 @@ function edwards(params, extraOpts = {}) {
|
|
|
17792
17795
|
validateObject(extraOpts, {}, { uvRatio: "function" });
|
|
17793
17796
|
const MASK = _2n2 << BigInt(Fn.BYTES * 8) - _1n4;
|
|
17794
17797
|
const modP = (n) => Fp.create(n);
|
|
17795
|
-
const uvRatio2 = extraOpts.uvRatio || ((u,
|
|
17798
|
+
const uvRatio2 = extraOpts.uvRatio || ((u, v10) => {
|
|
17796
17799
|
try {
|
|
17797
|
-
return { isValid: true, value: Fp.sqrt(Fp.div(u,
|
|
17800
|
+
return { isValid: true, value: Fp.sqrt(Fp.div(u, v10)) };
|
|
17798
17801
|
} catch (e) {
|
|
17799
17802
|
return { isValid: false, value: _0n4 };
|
|
17800
17803
|
}
|
|
@@ -17890,8 +17893,8 @@ function edwards(params, extraOpts = {}) {
|
|
|
17890
17893
|
aInRange("point.y", y, _0n4, max);
|
|
17891
17894
|
const y2 = modP(y * y);
|
|
17892
17895
|
const u = modP(y2 - _1n4);
|
|
17893
|
-
const
|
|
17894
|
-
let { isValid, value: x } = uvRatio2(u,
|
|
17896
|
+
const v10 = modP(d * y2 - a);
|
|
17897
|
+
let { isValid, value: x } = uvRatio2(u, v10);
|
|
17895
17898
|
if (!isValid)
|
|
17896
17899
|
throw new Error("bad point: invalid y coordinate");
|
|
17897
17900
|
const isXOdd = (x & _1n4) === _1n4;
|
|
@@ -18231,13 +18234,13 @@ function adjustScalarBytes(bytes) {
|
|
|
18231
18234
|
return bytes;
|
|
18232
18235
|
}
|
|
18233
18236
|
var ED25519_SQRT_M1 = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
|
|
18234
|
-
function uvRatio(u,
|
|
18237
|
+
function uvRatio(u, v10) {
|
|
18235
18238
|
const P = ed25519_CURVE_p;
|
|
18236
|
-
const v32 = mod(
|
|
18237
|
-
const v72 = mod(v32 * v32 *
|
|
18239
|
+
const v32 = mod(v10 * v10 * v10, P);
|
|
18240
|
+
const v72 = mod(v32 * v32 * v10, P);
|
|
18238
18241
|
const pow = ed25519_pow_2_252_3(u * v72).pow_p_5_8;
|
|
18239
18242
|
let x = mod(u * v32 * pow, P);
|
|
18240
|
-
const vx2 = mod(
|
|
18243
|
+
const vx2 = mod(v10 * x * x, P);
|
|
18241
18244
|
const root1 = x;
|
|
18242
18245
|
const root2 = mod(x * ED25519_SQRT_M1, P);
|
|
18243
18246
|
const useRoot1 = vx2 === u;
|
|
@@ -18568,7 +18571,7 @@ function findSeatPrice(validators, maxNumberOfSeats, minimumStakeRatio, protocol
|
|
|
18568
18571
|
return findSeatPriceForProtocolAfter49(validators, maxNumberOfSeats, minimumStakeRatio);
|
|
18569
18572
|
}
|
|
18570
18573
|
function findSeatPriceForProtocolBefore49(validators, numSeats) {
|
|
18571
|
-
const stakes = validators.map((
|
|
18574
|
+
const stakes = validators.map((v10) => BigInt(v10.stake)).sort(sortBigIntAsc);
|
|
18572
18575
|
const num = BigInt(numSeats);
|
|
18573
18576
|
const stakesSum = stakes.reduce((a, b) => a + b);
|
|
18574
18577
|
if (stakesSum < num) {
|
|
@@ -18597,7 +18600,7 @@ function findSeatPriceForProtocolAfter49(validators, maxNumberOfSeats, minimumSt
|
|
|
18597
18600
|
if (minimumStakeRatio.length != 2) {
|
|
18598
18601
|
throw Error("minimumStakeRatio should have 2 elements");
|
|
18599
18602
|
}
|
|
18600
|
-
const stakes = validators.map((
|
|
18603
|
+
const stakes = validators.map((v10) => BigInt(v10.stake)).sort(sortBigIntAsc);
|
|
18601
18604
|
const stakesSum = stakes.reduce((a, b) => a + b);
|
|
18602
18605
|
if (validators.length < maxNumberOfSeats) {
|
|
18603
18606
|
return stakesSum * BigInt(minimumStakeRatio[0]) / BigInt(minimumStakeRatio[1]);
|
|
@@ -18769,10 +18772,10 @@ var DER = {
|
|
|
18769
18772
|
if (length < 128)
|
|
18770
18773
|
throw new E("tlv.decode(long): not minimal encoding");
|
|
18771
18774
|
}
|
|
18772
|
-
const
|
|
18773
|
-
if (
|
|
18775
|
+
const v10 = data.subarray(pos, pos + length);
|
|
18776
|
+
if (v10.length !== length)
|
|
18774
18777
|
throw new E("tlv.decode: wrong value length");
|
|
18775
|
-
return { v:
|
|
18778
|
+
return { v: v10, l: data.subarray(pos + length) };
|
|
18776
18779
|
}
|
|
18777
18780
|
},
|
|
18778
18781
|
// https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,
|
|
@@ -19519,14 +19522,14 @@ function ecdsa(Point, hash, ecdsaOpts = {}) {
|
|
|
19519
19522
|
return false;
|
|
19520
19523
|
const { r, s } = sig;
|
|
19521
19524
|
const h = bits2int_modN(message);
|
|
19522
|
-
const
|
|
19523
|
-
const u1 = Fn.create(h *
|
|
19524
|
-
const u2 = Fn.create(r *
|
|
19525
|
+
const is3 = Fn.inv(s);
|
|
19526
|
+
const u1 = Fn.create(h * is3);
|
|
19527
|
+
const u2 = Fn.create(r * is3);
|
|
19525
19528
|
const R = Point.BASE.multiplyUnsafe(u1).add(P.multiplyUnsafe(u2));
|
|
19526
19529
|
if (R.is0())
|
|
19527
19530
|
return false;
|
|
19528
|
-
const
|
|
19529
|
-
return
|
|
19531
|
+
const v10 = Fn.create(R.x);
|
|
19532
|
+
return v10 === r;
|
|
19530
19533
|
} catch (e) {
|
|
19531
19534
|
return false;
|
|
19532
19535
|
}
|
|
@@ -26921,19 +26924,32 @@ var SolverApiService = class {
|
|
|
26921
26924
|
*
|
|
26922
26925
|
* @param request - Object containing `intent_tx_hash` — the hub-chain tx hash of the intent.
|
|
26923
26926
|
* @param config - Solver endpoint configuration.
|
|
26927
|
+
* @param logger - Diagnostics sink; defaults to the silent logger.
|
|
26928
|
+
* @param timeoutMs - Optional budget for the request. Omit it and the call is unbounded, as it has
|
|
26929
|
+
* always been. Supply it when a stalled solver must not hold the caller open — a status read
|
|
26930
|
+
* polled on a short interval, say. An expiry surfaces as `UNKNOWN`, like any other failure.
|
|
26931
|
+
* A non-finite value (`NaN` out of `Number(process.env.X)`, or `Infinity`) is treated as no
|
|
26932
|
+
* budget at all rather than passed to `setTimeout`, which would coerce it to ~0 and fail every
|
|
26933
|
+
* request instantly. A non-positive one is a real budget of zero: the request aborts at once.
|
|
26934
|
+
* The relay's `getTransactionPackets` takes the same parameter but degrades a non-finite value
|
|
26935
|
+
* to its own per-request budget instead; the divergence is deliberate, and explained inline.
|
|
26924
26936
|
* @returns A `Result` containing `{ status: SolverIntentStatusCode, fill_tx_hash?: string }`.
|
|
26925
26937
|
* `fill_tx_hash` is set only when `status === SolverIntentStatusCode.SOLVED (3)`.
|
|
26926
26938
|
* @throws Invariant error if `intent_tx_hash` is empty (thrown before the async request).
|
|
26927
26939
|
*/
|
|
26928
|
-
static async getStatus(request, config, logger = silentLogger) {
|
|
26940
|
+
static async getStatus(request, config, logger = silentLogger, timeoutMs) {
|
|
26929
26941
|
invariant(request.intent_tx_hash.length > 0, "Empty intent_tx_hash");
|
|
26942
|
+
const budgetMs = timeoutMs !== void 0 && Number.isFinite(timeoutMs) ? Math.max(0, timeoutMs) : void 0;
|
|
26943
|
+
const controller = budgetMs === void 0 ? void 0 : new AbortController();
|
|
26944
|
+
const timeoutId = controller ? setTimeout(() => controller.abort(), budgetMs) : void 0;
|
|
26930
26945
|
try {
|
|
26931
26946
|
const response = await fetch(`${config.solverApiEndpoint}/status`, {
|
|
26932
26947
|
method: "POST",
|
|
26933
26948
|
headers: {
|
|
26934
26949
|
"Content-Type": "application/json"
|
|
26935
26950
|
},
|
|
26936
|
-
body: JSON.stringify(request)
|
|
26951
|
+
body: JSON.stringify(request),
|
|
26952
|
+
signal: controller?.signal
|
|
26937
26953
|
});
|
|
26938
26954
|
if (!response.ok) {
|
|
26939
26955
|
return {
|
|
@@ -26955,10 +26971,12 @@ var SolverApiService = class {
|
|
|
26955
26971
|
error: {
|
|
26956
26972
|
detail: {
|
|
26957
26973
|
code: exports.SolverIntentErrorCode.UNKNOWN,
|
|
26958
|
-
message: e ? JSON.stringify(e, bigintReplacer) : "Unknown error"
|
|
26974
|
+
message: controller?.signal.aborted ? `solver /status timed out after ${budgetMs}ms` : e ? JSON.stringify(e, bigintReplacer) : "Unknown error"
|
|
26959
26975
|
}
|
|
26960
26976
|
}
|
|
26961
26977
|
};
|
|
26978
|
+
} finally {
|
|
26979
|
+
clearTimeout(timeoutId);
|
|
26962
26980
|
}
|
|
26963
26981
|
}
|
|
26964
26982
|
};
|
|
@@ -27052,6 +27070,152 @@ async function runBackendSubmitTx({
|
|
|
27052
27070
|
});
|
|
27053
27071
|
return polled.ok ? { ok: true, value: polled.value } : { ok: false, cause: polled.cause };
|
|
27054
27072
|
}
|
|
27073
|
+
var ChainKeySchema = v__namespace.custom((input) => typeof input === "string");
|
|
27074
|
+
var SpokeChainKeySchema = v__namespace.custom((input) => typeof input === "string");
|
|
27075
|
+
var AddressSchema = v__namespace.custom((input) => typeof input === "string");
|
|
27076
|
+
var XTokenSchema = v__namespace.object({
|
|
27077
|
+
symbol: v__namespace.string(),
|
|
27078
|
+
name: v__namespace.string(),
|
|
27079
|
+
decimals: v__namespace.number(),
|
|
27080
|
+
address: v__namespace.string(),
|
|
27081
|
+
chainKey: ChainKeySchema,
|
|
27082
|
+
hubAsset: AddressSchema,
|
|
27083
|
+
vault: AddressSchema,
|
|
27084
|
+
access: v__namespace.optional(v__namespace.picklist(["withdrawOnly", "depositOnly"]))
|
|
27085
|
+
});
|
|
27086
|
+
var IntentStructSchema = v__namespace.object({
|
|
27087
|
+
intentId: v__namespace.string(),
|
|
27088
|
+
creator: v__namespace.string(),
|
|
27089
|
+
inputToken: v__namespace.string(),
|
|
27090
|
+
outputToken: v__namespace.string(),
|
|
27091
|
+
inputAmount: v__namespace.string(),
|
|
27092
|
+
minOutputAmount: v__namespace.string(),
|
|
27093
|
+
deadline: v__namespace.string(),
|
|
27094
|
+
allowPartialFill: v__namespace.boolean(),
|
|
27095
|
+
srcChain: v__namespace.number(),
|
|
27096
|
+
dstChain: v__namespace.number(),
|
|
27097
|
+
srcAddress: v__namespace.string(),
|
|
27098
|
+
dstAddress: v__namespace.string(),
|
|
27099
|
+
solver: v__namespace.string(),
|
|
27100
|
+
data: v__namespace.string()
|
|
27101
|
+
});
|
|
27102
|
+
var FillEventSchema = v__namespace.object({
|
|
27103
|
+
eventType: v__namespace.literal("intent-filled"),
|
|
27104
|
+
// The hub-chain fill tx; an empty one is no use as `fill_tx_hash`.
|
|
27105
|
+
txHash: v__namespace.pipe(v__namespace.string(), v__namespace.nonEmpty()),
|
|
27106
|
+
// Terminality. An intent created with `allowPartialFill` emits a fill event per fill, so the
|
|
27107
|
+
// event alone does not mean the intent is done — only `remainingInput === '0'` does. Required:
|
|
27108
|
+
// without it there is no proof of completion, and claiming SOLVED on a partial fill would report
|
|
27109
|
+
// an unfinished swap as complete.
|
|
27110
|
+
intentState: v__namespace.object({
|
|
27111
|
+
remainingInput: v__namespace.string()
|
|
27112
|
+
})
|
|
27113
|
+
});
|
|
27114
|
+
var IntentResponseSchema = v__namespace.object({
|
|
27115
|
+
intentHash: v__namespace.string(),
|
|
27116
|
+
txHash: v__namespace.string(),
|
|
27117
|
+
logIndex: v__namespace.number(),
|
|
27118
|
+
chainId: v__namespace.number(),
|
|
27119
|
+
blockNumber: v__namespace.number(),
|
|
27120
|
+
open: v__namespace.boolean(),
|
|
27121
|
+
intent: IntentStructSchema,
|
|
27122
|
+
events: v__namespace.array(v__namespace.unknown())
|
|
27123
|
+
});
|
|
27124
|
+
var UserIntentsResponseSchema = v__namespace.object({
|
|
27125
|
+
total: v__namespace.number(),
|
|
27126
|
+
offset: v__namespace.number(),
|
|
27127
|
+
limit: v__namespace.number(),
|
|
27128
|
+
items: v__namespace.array(IntentResponseSchema)
|
|
27129
|
+
});
|
|
27130
|
+
var OrderbookResponseSchema = v__namespace.object({
|
|
27131
|
+
total: v__namespace.number(),
|
|
27132
|
+
data: v__namespace.array(
|
|
27133
|
+
v__namespace.object({
|
|
27134
|
+
intentState: v__namespace.object({
|
|
27135
|
+
exists: v__namespace.boolean(),
|
|
27136
|
+
remainingInput: v__namespace.string(),
|
|
27137
|
+
receivedOutput: v__namespace.string(),
|
|
27138
|
+
pendingPayment: v__namespace.boolean()
|
|
27139
|
+
}),
|
|
27140
|
+
intentData: v__namespace.object({
|
|
27141
|
+
intentId: v__namespace.string(),
|
|
27142
|
+
creator: v__namespace.string(),
|
|
27143
|
+
inputToken: v__namespace.string(),
|
|
27144
|
+
outputToken: v__namespace.string(),
|
|
27145
|
+
inputAmount: v__namespace.string(),
|
|
27146
|
+
minOutputAmount: v__namespace.string(),
|
|
27147
|
+
deadline: v__namespace.string(),
|
|
27148
|
+
allowPartialFill: v__namespace.boolean(),
|
|
27149
|
+
srcChain: v__namespace.number(),
|
|
27150
|
+
dstChain: v__namespace.number(),
|
|
27151
|
+
srcAddress: v__namespace.string(),
|
|
27152
|
+
dstAddress: v__namespace.string(),
|
|
27153
|
+
solver: v__namespace.string(),
|
|
27154
|
+
data: v__namespace.string(),
|
|
27155
|
+
intentHash: v__namespace.string(),
|
|
27156
|
+
txHash: v__namespace.string(),
|
|
27157
|
+
blockNumber: v__namespace.number()
|
|
27158
|
+
})
|
|
27159
|
+
})
|
|
27160
|
+
)
|
|
27161
|
+
});
|
|
27162
|
+
var MoneyMarketPositionSchema = v__namespace.object({
|
|
27163
|
+
userAddress: v__namespace.string(),
|
|
27164
|
+
positions: v__namespace.array(
|
|
27165
|
+
v__namespace.object({
|
|
27166
|
+
reserveAddress: v__namespace.string(),
|
|
27167
|
+
aTokenAddress: v__namespace.string(),
|
|
27168
|
+
variableDebtTokenAddress: v__namespace.string(),
|
|
27169
|
+
aTokenBalance: v__namespace.string(),
|
|
27170
|
+
variableDebtTokenBalance: v__namespace.string(),
|
|
27171
|
+
blockNumber: v__namespace.number()
|
|
27172
|
+
})
|
|
27173
|
+
)
|
|
27174
|
+
});
|
|
27175
|
+
var MoneyMarketAssetSchema = v__namespace.object({
|
|
27176
|
+
reserveAddress: v__namespace.string(),
|
|
27177
|
+
aTokenAddress: v__namespace.string(),
|
|
27178
|
+
totalATokenBalance: v__namespace.string(),
|
|
27179
|
+
variableDebtTokenAddress: v__namespace.string(),
|
|
27180
|
+
totalVariableDebtTokenBalance: v__namespace.string(),
|
|
27181
|
+
liquidityRate: v__namespace.string(),
|
|
27182
|
+
symbol: v__namespace.string(),
|
|
27183
|
+
totalSuppliers: v__namespace.number(),
|
|
27184
|
+
totalBorrowers: v__namespace.number(),
|
|
27185
|
+
variableBorrowRate: v__namespace.string(),
|
|
27186
|
+
stableBorrowRate: v__namespace.string(),
|
|
27187
|
+
liquidityIndex: v__namespace.string(),
|
|
27188
|
+
variableBorrowIndex: v__namespace.string(),
|
|
27189
|
+
blockNumber: v__namespace.number()
|
|
27190
|
+
});
|
|
27191
|
+
var MoneyMarketAssetsSchema = v__namespace.array(MoneyMarketAssetSchema);
|
|
27192
|
+
var MoneyMarketAssetBorrowersSchema = v__namespace.object({
|
|
27193
|
+
borrowers: v__namespace.array(v__namespace.string()),
|
|
27194
|
+
total: v__namespace.number(),
|
|
27195
|
+
offset: v__namespace.number(),
|
|
27196
|
+
limit: v__namespace.number()
|
|
27197
|
+
});
|
|
27198
|
+
var MoneyMarketAssetSuppliersSchema = v__namespace.object({
|
|
27199
|
+
suppliers: v__namespace.array(v__namespace.string()),
|
|
27200
|
+
total: v__namespace.number(),
|
|
27201
|
+
offset: v__namespace.number(),
|
|
27202
|
+
limit: v__namespace.number()
|
|
27203
|
+
});
|
|
27204
|
+
var MoneyMarketBorrowersSchema = v__namespace.object({
|
|
27205
|
+
borrowers: v__namespace.array(v__namespace.string()),
|
|
27206
|
+
total: v__namespace.number(),
|
|
27207
|
+
offset: v__namespace.number(),
|
|
27208
|
+
limit: v__namespace.number()
|
|
27209
|
+
});
|
|
27210
|
+
var GetChainsResponseSchema = v__namespace.array(SpokeChainKeySchema);
|
|
27211
|
+
var TokensByChainMapSchema = v__namespace.custom(
|
|
27212
|
+
(input) => typeof input === "object" && input !== null && Object.values(input).every((tokens) => Array.isArray(tokens) && tokens.every((t) => v__namespace.is(XTokenSchema, t)))
|
|
27213
|
+
);
|
|
27214
|
+
var TokensListSchema = v__namespace.array(XTokenSchema);
|
|
27215
|
+
var ReserveAssetsSchema = v__namespace.array(AddressSchema);
|
|
27216
|
+
|
|
27217
|
+
// src/backendApi/guards.ts
|
|
27218
|
+
var isFillEvent = (value) => v__namespace.is(FillEventSchema, value);
|
|
27055
27219
|
function decodePacketIntentTarget(payload) {
|
|
27056
27220
|
try {
|
|
27057
27221
|
const hex = payload.startsWith("0x") ? payload.slice(2) : payload;
|
|
@@ -27071,6 +27235,12 @@ function selectSolvedIntentPacket(packets, intentsContract) {
|
|
|
27071
27235
|
return packets.reduce((highest, packet) => packet.conn_sn > highest.conn_sn ? packet : highest);
|
|
27072
27236
|
}
|
|
27073
27237
|
|
|
27238
|
+
// src/swap/detailedStatus.ts
|
|
27239
|
+
var DETAILED_STATUS_NOT_DELIVERED = "relay_not_delivered";
|
|
27240
|
+
function isBackendSubmitTxAbandoned(data) {
|
|
27241
|
+
return data.status === "failed" || Boolean(data.abandonedAt);
|
|
27242
|
+
}
|
|
27243
|
+
|
|
27074
27244
|
// src/swap/errors.ts
|
|
27075
27245
|
var swapInvariant = createInvariant("swap");
|
|
27076
27246
|
var POST_EXECUTION_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
@@ -27095,6 +27265,8 @@ var isPostExecutionError = isCodeMember(POST_EXECUTION_ERROR_CODES);
|
|
|
27095
27265
|
var isSwapError = isCodeMember(SWAP_ERROR_CODES);
|
|
27096
27266
|
|
|
27097
27267
|
// src/swap/SwapService.ts
|
|
27268
|
+
var RECONCILE_TIMEOUT_MS = 5e3;
|
|
27269
|
+
var DETAILED_STATUS_SOLVER_TIMEOUT_MS = 5e3;
|
|
27098
27270
|
var SwapService = class {
|
|
27099
27271
|
// dependent services
|
|
27100
27272
|
hubProvider;
|
|
@@ -27195,7 +27367,8 @@ var SwapService = class {
|
|
|
27195
27367
|
return calculatePercentageFeeAmount(inputAmount, 10);
|
|
27196
27368
|
}
|
|
27197
27369
|
/**
|
|
27198
|
-
* Polls the solver API for the current execution status of an intent.
|
|
27370
|
+
* Polls the solver API for the current execution status of an intent. A `NOT_FOUND` or a failed
|
|
27371
|
+
* request is cross-checked against the backend's durable intent record.
|
|
27199
27372
|
*
|
|
27200
27373
|
* The `intent_tx_hash` in the request must be the hub-chain (Sonic) transaction hash where
|
|
27201
27374
|
* the intent was registered — this is the `dst_tx_hash` from the relay packet returned by
|
|
@@ -27206,7 +27379,145 @@ var SwapService = class {
|
|
|
27206
27379
|
* `fill_tx_hash` is populated only when `status === SolverIntentStatusCode.SOLVED (3)`.
|
|
27207
27380
|
*/
|
|
27208
27381
|
async getStatus(request) {
|
|
27209
|
-
return
|
|
27382
|
+
return this.resolveSolverStatus(request);
|
|
27383
|
+
}
|
|
27384
|
+
/**
|
|
27385
|
+
* {@link SwapService.getStatus} with an optional budget for the solver leg. Public `getStatus` is a
|
|
27386
|
+
* one-shot read a caller bounds however it likes, so it stays unbounded; `getDetailedStatus` is
|
|
27387
|
+
* polled and passes {@link DETAILED_STATUS_SOLVER_TIMEOUT_MS}. Both go through here so the
|
|
27388
|
+
* durable-intent reconcile below is written once.
|
|
27389
|
+
*
|
|
27390
|
+
* `timeoutMs` bounds the solver request alone. The reconcile that a failed or NOT_FOUND solver read
|
|
27391
|
+
* falls through to carries its own {@link RECONCILE_TIMEOUT_MS}, so a bounded call can cost both.
|
|
27392
|
+
*/
|
|
27393
|
+
async resolveSolverStatus(request, timeoutMs) {
|
|
27394
|
+
const solverResult = await SolverApiService.getStatus(request, this.solver, this.config.logger, timeoutMs);
|
|
27395
|
+
const forgotten = !solverResult.ok || solverResult.value.status === exports.SolverIntentStatusCode.NOT_FOUND;
|
|
27396
|
+
if (!forgotten) return solverResult;
|
|
27397
|
+
const timeout = Math.min(RECONCILE_TIMEOUT_MS, this.backendApi.requestTimeoutMs);
|
|
27398
|
+
const intent = await this.backendApi.getIntentByTxHash(request.intent_tx_hash, { timeout });
|
|
27399
|
+
const settled = intent.ok ? intent.value.events.filter(isFillEvent).find((fill) => fill.intentState.remainingInput === "0") : void 0;
|
|
27400
|
+
if (settled) return { ok: true, value: { status: exports.SolverIntentStatusCode.SOLVED, fill_tx_hash: settled.txHash } };
|
|
27401
|
+
const backendAnswered = intent.ok || isSodaxError(intent.error) && intent.error.context?.status === 404;
|
|
27402
|
+
if (solverResult.ok && !backendAnswered) {
|
|
27403
|
+
return {
|
|
27404
|
+
ok: false,
|
|
27405
|
+
error: {
|
|
27406
|
+
detail: {
|
|
27407
|
+
code: exports.SolverIntentErrorCode.UNKNOWN,
|
|
27408
|
+
message: "solver reported NOT_FOUND and the durable intent record could not be read to verify it"
|
|
27409
|
+
}
|
|
27410
|
+
}
|
|
27411
|
+
};
|
|
27412
|
+
}
|
|
27413
|
+
return solverResult;
|
|
27414
|
+
}
|
|
27415
|
+
/**
|
|
27416
|
+
* Reads a swap's status from its source-chain transaction — the identifier a caller always holds.
|
|
27417
|
+
*
|
|
27418
|
+
* **Routes; does not translate.** Returns the backend submit-tx record while it is in play,
|
|
27419
|
+
* otherwise the solver's answer via the hub tx hash resolved from the relay packet. The result is
|
|
27420
|
+
* tagged with `source` (discriminate on it) and carries that source's payload unmodified.
|
|
27421
|
+
*
|
|
27422
|
+
* **Any** unusable backend response routes to the solver — a 404, a transport or server error, or
|
|
27423
|
+
* a record the backend gave up on. See `docs/SWAPS.md` § Get Detailed Status for why.
|
|
27424
|
+
*
|
|
27425
|
+
* A point-in-time read; poll it yourself, or use dapp-kit's `useDetailedStatus`.
|
|
27426
|
+
*
|
|
27427
|
+
* @param params - `srcChainKey` and `srcTxHash` of the source-chain swap transaction.
|
|
27428
|
+
* @returns A `Result` containing a {@link DetailedSwapStatus}. Fails with `LOOKUP_FAILED` when no
|
|
27429
|
+
* source can answer yet — usually the relay has not delivered the packet, so there is no hub tx
|
|
27430
|
+
* hash for the solver to be asked about.
|
|
27431
|
+
*/
|
|
27432
|
+
async getDetailedStatus(params) {
|
|
27433
|
+
try {
|
|
27434
|
+
const record3 = await this.backendApi.swaps.getSubmitTxStatus({
|
|
27435
|
+
txHash: params.srcTxHash,
|
|
27436
|
+
srcChainKey: params.srcChainKey
|
|
27437
|
+
});
|
|
27438
|
+
if (record3.ok && record3.value.success && !isBackendSubmitTxAbandoned(record3.value.data)) {
|
|
27439
|
+
return { ok: true, value: { source: "backend", data: record3.value.data } };
|
|
27440
|
+
}
|
|
27441
|
+
const backendAnswered = record3.ok || isSodaxError(record3.error) && record3.error.context?.status === 404;
|
|
27442
|
+
const dstTxHash = await this.resolveHubTxHash(params, backendAnswered);
|
|
27443
|
+
if (!dstTxHash.ok) return dstTxHash;
|
|
27444
|
+
const solver = await this.resolveSolverStatus(
|
|
27445
|
+
{ intent_tx_hash: dstTxHash.value },
|
|
27446
|
+
DETAILED_STATUS_SOLVER_TIMEOUT_MS
|
|
27447
|
+
);
|
|
27448
|
+
if (!solver.ok) {
|
|
27449
|
+
return { ok: false, error: this.detailedStatusLookupFailed(solver.error, params.srcChainKey) };
|
|
27450
|
+
}
|
|
27451
|
+
return { ok: true, value: { source: "solver", dstTxHash: dstTxHash.value, data: solver.value } };
|
|
27452
|
+
} catch (error) {
|
|
27453
|
+
return { ok: false, error: this.detailedStatusLookupFailed(error, params.srcChainKey) };
|
|
27454
|
+
}
|
|
27455
|
+
}
|
|
27456
|
+
/**
|
|
27457
|
+
* The hub-chain tx hash the solver is keyed on. A hub-source swap has no relay leg — the source
|
|
27458
|
+
* tx *is* the hub tx. Otherwise the delivered relay packet carries it, so an undelivered packet
|
|
27459
|
+
* is simply "no hash yet".
|
|
27460
|
+
*/
|
|
27461
|
+
async resolveHubTxHash(key, backendAnswered) {
|
|
27462
|
+
const missReason = backendAnswered ? DETAILED_STATUS_NOT_DELIVERED : void 0;
|
|
27463
|
+
let hubTxHash = key.srcTxHash;
|
|
27464
|
+
if (!isHubChainKeyType(key.srcChainKey)) {
|
|
27465
|
+
const relayChainId = getIntentRelayChainId(key.srcChainKey);
|
|
27466
|
+
const packets = await getTransactionPackets(
|
|
27467
|
+
{
|
|
27468
|
+
action: "get_transaction_packets",
|
|
27469
|
+
params: { chain_id: relayChainId.toString(), tx_hash: key.srcTxHash }
|
|
27470
|
+
},
|
|
27471
|
+
this.relayerApiEndpoint,
|
|
27472
|
+
RELAY_REQUEST_TIMEOUT_MS
|
|
27473
|
+
);
|
|
27474
|
+
if (!packets.ok) {
|
|
27475
|
+
const notIndexed = packets.error instanceof HttpRelayError && packets.error.status === 404;
|
|
27476
|
+
return {
|
|
27477
|
+
ok: false,
|
|
27478
|
+
error: this.detailedStatusLookupFailed(packets.error, key.srcChainKey, notIndexed ? missReason : void 0)
|
|
27479
|
+
};
|
|
27480
|
+
}
|
|
27481
|
+
if (!packets.value?.success || !Array.isArray(packets.value.data)) {
|
|
27482
|
+
return {
|
|
27483
|
+
ok: false,
|
|
27484
|
+
error: this.detailedStatusLookupFailed(
|
|
27485
|
+
new Error("relay returned no usable transaction packets"),
|
|
27486
|
+
key.srcChainKey
|
|
27487
|
+
)
|
|
27488
|
+
};
|
|
27489
|
+
}
|
|
27490
|
+
const delivered = packets.value.data.find(
|
|
27491
|
+
(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
|
|
27492
|
+
);
|
|
27493
|
+
if (!delivered) {
|
|
27494
|
+
return {
|
|
27495
|
+
ok: false,
|
|
27496
|
+
error: this.detailedStatusLookupFailed(
|
|
27497
|
+
new Error("relay has not delivered the intent to the hub yet"),
|
|
27498
|
+
key.srcChainKey,
|
|
27499
|
+
missReason
|
|
27500
|
+
)
|
|
27501
|
+
};
|
|
27502
|
+
}
|
|
27503
|
+
hubTxHash = delivered.dst_tx_hash;
|
|
27504
|
+
}
|
|
27505
|
+
if (viem.isHex(hubTxHash)) return { ok: true, value: hubTxHash };
|
|
27506
|
+
return {
|
|
27507
|
+
ok: false,
|
|
27508
|
+
error: this.detailedStatusLookupFailed(
|
|
27509
|
+
new Error(`hub tx hash is not a hex string: ${hubTxHash}`),
|
|
27510
|
+
key.srcChainKey
|
|
27511
|
+
)
|
|
27512
|
+
};
|
|
27513
|
+
}
|
|
27514
|
+
/**
|
|
27515
|
+
* `reason` is set only for {@link DETAILED_STATUS_NOT_DELIVERED} — the miss a caller can bound
|
|
27516
|
+
* with a retry budget. Leaving it off marks a dependency that is failing right now, which a
|
|
27517
|
+
* caller should keep retrying rather than give up on.
|
|
27518
|
+
*/
|
|
27519
|
+
detailedStatusLookupFailed(cause, srcChainKey, reason) {
|
|
27520
|
+
return lookupFailed("swap", "getDetailedStatus", cause, { srcChainKey, action: "swap", reason });
|
|
27210
27521
|
}
|
|
27211
27522
|
/**
|
|
27212
27523
|
* Notifies the solver API that an intent has been registered on the hub chain, triggering
|
|
@@ -30379,16 +30690,112 @@ function toInvalidResponseShapeError(params) {
|
|
|
30379
30690
|
context: { api, endpoint, reason: "invalid_response_shape", issues }
|
|
30380
30691
|
});
|
|
30381
30692
|
}
|
|
30693
|
+
|
|
30694
|
+
// src/backendApi/apiConfig.ts
|
|
30695
|
+
function flatLayer({ baseURL, timeout, headers }) {
|
|
30696
|
+
return { baseURL, timeout, headers };
|
|
30697
|
+
}
|
|
30698
|
+
function layerConfigs(...slices) {
|
|
30699
|
+
return slices.reduce(
|
|
30700
|
+
(acc, slice) => slice ? {
|
|
30701
|
+
// Truthy (not nullish) so a set-but-empty env var falls back, matching `makeRequest`.
|
|
30702
|
+
baseURL: slice.baseURL || acc.baseURL,
|
|
30703
|
+
timeout: slice.timeout ?? acc.timeout,
|
|
30704
|
+
headers: { ...acc.headers, ...slice.headers }
|
|
30705
|
+
} : acc,
|
|
30706
|
+
{
|
|
30707
|
+
baseURL: DEFAULT_API_BASE_URL,
|
|
30708
|
+
timeout: DEFAULT_BACKEND_API_TIMEOUT,
|
|
30709
|
+
headers: { ...DEFAULT_BACKEND_API_HEADERS }
|
|
30710
|
+
}
|
|
30711
|
+
);
|
|
30712
|
+
}
|
|
30713
|
+
function isHttpUrl(value) {
|
|
30714
|
+
return value.startsWith("http://") || value.startsWith("https://");
|
|
30715
|
+
}
|
|
30716
|
+
function normalizeBaseURL(baseURL) {
|
|
30717
|
+
const trimmed = trimTrailingSlashes(baseURL);
|
|
30718
|
+
return isHttpUrl(trimmed) ? trimmed : baseURL;
|
|
30719
|
+
}
|
|
30720
|
+
function stripBackendMount(baseURL) {
|
|
30721
|
+
const trimmed = trimTrailingSlashes(baseURL);
|
|
30722
|
+
if (!trimmed.endsWith(BACKEND_API_BASE_PATH)) return void 0;
|
|
30723
|
+
const root = trimmed.slice(0, -BACKEND_API_BASE_PATH.length);
|
|
30724
|
+
return isHttpUrl(root) ? root : void 0;
|
|
30725
|
+
}
|
|
30726
|
+
function stripLegacyBackendMount(baseURL) {
|
|
30727
|
+
return stripBackendMount(baseURL) ?? baseURL;
|
|
30728
|
+
}
|
|
30729
|
+
function normalizeOverrideBaseURL(override) {
|
|
30730
|
+
if (!override?.baseURL) return override;
|
|
30731
|
+
return { ...override, baseURL: stripLegacyBackendMount(override.baseURL) };
|
|
30732
|
+
}
|
|
30733
|
+
function toGatewayRoot(baseURL) {
|
|
30734
|
+
return stripBackendMount(baseURL) ?? normalizeBaseURL(baseURL);
|
|
30735
|
+
}
|
|
30736
|
+
function configuredBasePath(layers) {
|
|
30737
|
+
return layers.baseApiConfig?.basePath ?? layers.basePath;
|
|
30738
|
+
}
|
|
30739
|
+
function hasExplicitBasePath(layers) {
|
|
30740
|
+
return configuredBasePath(layers) !== void 0;
|
|
30741
|
+
}
|
|
30742
|
+
function hasLegacyBackendBaseURL(layers) {
|
|
30743
|
+
if (configuredBasePath(layers) !== void 0) return false;
|
|
30744
|
+
return stripBackendMount(layerConfigs(flatLayer(layers), layers.baseApiConfig).baseURL) !== void 0;
|
|
30745
|
+
}
|
|
30746
|
+
var PACKAGED_API_ORIGIN = new URL(DEFAULT_API_BASE_URL).origin;
|
|
30747
|
+
function isOnPackagedOrigin(baseURL) {
|
|
30748
|
+
return baseURL === PACKAGED_API_ORIGIN || baseURL.startsWith(`${PACKAGED_API_ORIGIN}/`);
|
|
30749
|
+
}
|
|
30750
|
+
function isMissingVersionPrefix(baseURL) {
|
|
30751
|
+
const normalized = trimTrailingSlashes(baseURL);
|
|
30752
|
+
if (!isOnPackagedOrigin(normalized)) return false;
|
|
30753
|
+
return normalized !== DEFAULT_API_BASE_URL && !normalized.startsWith(`${DEFAULT_API_BASE_URL}/`);
|
|
30754
|
+
}
|
|
30755
|
+
function normalizeBasePath(basePath) {
|
|
30756
|
+
const trimmed = trimTrailingSlashes(basePath.trim());
|
|
30757
|
+
const withoutLeadingSlashes = trimmed.replace(/^\/+/, "");
|
|
30758
|
+
return withoutLeadingSlashes.length === 0 ? "" : `/${withoutLeadingSlashes}`;
|
|
30759
|
+
}
|
|
30760
|
+
function resolveSharedApiConfig(layers, slice) {
|
|
30761
|
+
const layered = layerConfigs(flatLayer(layers), layers.baseApiConfig, slice);
|
|
30762
|
+
const baseURL = configuredBasePath(layers) === void 0 ? toGatewayRoot(layered.baseURL) : normalizeBaseURL(layered.baseURL);
|
|
30763
|
+
return { ...layered, baseURL };
|
|
30764
|
+
}
|
|
30765
|
+
function resolveBaseApiConfig(layers) {
|
|
30766
|
+
return {
|
|
30767
|
+
...resolveSharedApiConfig(layers),
|
|
30768
|
+
basePath: normalizeBasePath(configuredBasePath(layers) ?? BACKEND_API_BASE_PATH)
|
|
30769
|
+
};
|
|
30770
|
+
}
|
|
30771
|
+
function resolveSwapsApiConfig(layers) {
|
|
30772
|
+
return resolveSharedApiConfig(layers, layers.swapsApiConfig);
|
|
30773
|
+
}
|
|
30774
|
+
function resolveSponsoringApiConfig(layers) {
|
|
30775
|
+
const slice = layers.sponsoringApiConfig;
|
|
30776
|
+
return {
|
|
30777
|
+
baseURL: normalizeBaseURL(slice?.baseURL ?? DEFAULT_SPONSORING_API_ENDPOINT),
|
|
30778
|
+
timeout: slice?.timeout ?? resolveSharedApiConfig(layers).timeout,
|
|
30779
|
+
headers: { ...DEFAULT_BACKEND_API_HEADERS, ...slice?.headers },
|
|
30780
|
+
...slice?.apiKey === void 0 ? {} : { apiKey: slice.apiKey }
|
|
30781
|
+
};
|
|
30782
|
+
}
|
|
30783
|
+
function resolveBridgeApiConfig(layers) {
|
|
30784
|
+
return resolveSharedApiConfig(layers);
|
|
30785
|
+
}
|
|
30382
30786
|
var SwapsApiService = class _SwapsApiService {
|
|
30383
30787
|
// Fully-resolved swaps-API config supplied by the caller (BackendApiService resolves the
|
|
30384
30788
|
// `ApiConfig` union via `resolveSwapsApiConfig`); this service does not resolve the union.
|
|
30385
30789
|
config;
|
|
30386
30790
|
headers;
|
|
30387
30791
|
logger;
|
|
30388
|
-
|
|
30792
|
+
/** See {@link SwapsApiServiceOptions.trimLegacyOverrides}. */
|
|
30793
|
+
trimsLegacyOverrides;
|
|
30794
|
+
constructor(config, logger = consoleLogger, options = {}) {
|
|
30389
30795
|
this.config = config;
|
|
30390
30796
|
this.headers = { ...config.headers };
|
|
30391
30797
|
this.logger = logger;
|
|
30798
|
+
this.trimsLegacyOverrides = options.trimLegacyOverrides ?? true;
|
|
30392
30799
|
}
|
|
30393
30800
|
/**
|
|
30394
30801
|
* Build a `@sodax/swaps-api` client for a single call. Maps the SDK's `SwapsApiConfig`
|
|
@@ -30399,7 +30806,8 @@ var SwapsApiService = class _SwapsApiService {
|
|
|
30399
30806
|
* overrides both take effect without caching stale state.
|
|
30400
30807
|
*/
|
|
30401
30808
|
buildClient(overrideConfig) {
|
|
30402
|
-
const
|
|
30809
|
+
const override = overrideConfig?.baseURL;
|
|
30810
|
+
const baseUrl = override ? this.trimsLegacyOverrides ? stripLegacyBackendMount(override) : override : this.config.baseURL;
|
|
30403
30811
|
const timeout = overrideConfig?.timeout ?? this.config.timeout ?? DEFAULT_BACKEND_API_TIMEOUT;
|
|
30404
30812
|
const headers = { ...this.headers, ...overrideConfig?.headers };
|
|
30405
30813
|
return new swapsApi.SwapsApi({ baseUrl, headers, timeout });
|
|
@@ -30424,7 +30832,7 @@ var SwapsApiService = class _SwapsApiService {
|
|
|
30424
30832
|
if (error.code === "VALIDATION_ERROR" && error.context.issues !== void 0) {
|
|
30425
30833
|
context.reason = "invalid_response_shape";
|
|
30426
30834
|
const issues = error.context.issues;
|
|
30427
|
-
context.issues = issues instanceof
|
|
30835
|
+
context.issues = issues instanceof v__namespace.ValiError ? v__namespace.flatten(issues.issues) : issues;
|
|
30428
30836
|
}
|
|
30429
30837
|
if (error.context.status !== void 0) context.status = error.context.status;
|
|
30430
30838
|
}
|
|
@@ -30599,21 +31007,21 @@ var SwapsApiService = class _SwapsApiService {
|
|
|
30599
31007
|
return this.config.timeout ?? DEFAULT_BACKEND_API_TIMEOUT;
|
|
30600
31008
|
}
|
|
30601
31009
|
};
|
|
30602
|
-
var StellarSponsorConfigSchema =
|
|
30603
|
-
sponsorAccount:
|
|
30604
|
-
networkPassphrase:
|
|
30605
|
-
minTotalFeeStroops:
|
|
30606
|
-
maxTotalFeeStroops:
|
|
30607
|
-
operationCount:
|
|
30608
|
-
minPerOperationFeeStroops:
|
|
30609
|
-
maxPerOperationFeeStroops:
|
|
30610
|
-
recommendedPerOperationFeeStroops:
|
|
30611
|
-
maxTimeboundSeconds:
|
|
30612
|
-
requiredStartingBalance:
|
|
31010
|
+
var StellarSponsorConfigSchema = v__namespace.object({
|
|
31011
|
+
sponsorAccount: v__namespace.string(),
|
|
31012
|
+
networkPassphrase: v__namespace.string(),
|
|
31013
|
+
minTotalFeeStroops: v__namespace.string(),
|
|
31014
|
+
maxTotalFeeStroops: v__namespace.string(),
|
|
31015
|
+
operationCount: v__namespace.number(),
|
|
31016
|
+
minPerOperationFeeStroops: v__namespace.string(),
|
|
31017
|
+
maxPerOperationFeeStroops: v__namespace.string(),
|
|
31018
|
+
recommendedPerOperationFeeStroops: v__namespace.string(),
|
|
31019
|
+
maxTimeboundSeconds: v__namespace.number(),
|
|
31020
|
+
requiredStartingBalance: v__namespace.string()
|
|
30613
31021
|
});
|
|
30614
|
-
var StellarSponsoredAccountResponseSchema =
|
|
30615
|
-
|
|
30616
|
-
|
|
31022
|
+
var StellarSponsoredAccountResponseSchema = v__namespace.variant("alreadyActive", [
|
|
31023
|
+
v__namespace.object({ hash: v__namespace.string(), alreadyActive: v__namespace.literal(false) }),
|
|
31024
|
+
v__namespace.object({ hash: v__namespace.null(), alreadyActive: v__namespace.literal(true) })
|
|
30617
31025
|
]);
|
|
30618
31026
|
|
|
30619
31027
|
// src/backendApi/SponsoringApiService.ts
|
|
@@ -30641,7 +31049,7 @@ var SponsoringApiService = class {
|
|
|
30641
31049
|
logger: this.logger,
|
|
30642
31050
|
serviceLabel: "SponsoringApiService"
|
|
30643
31051
|
});
|
|
30644
|
-
const parsed =
|
|
31052
|
+
const parsed = v__namespace.safeParse(schema, raw);
|
|
30645
31053
|
if (!parsed.success) {
|
|
30646
31054
|
return {
|
|
30647
31055
|
ok: false,
|
|
@@ -30649,7 +31057,7 @@ var SponsoringApiService = class {
|
|
|
30649
31057
|
api: "sponsoring",
|
|
30650
31058
|
feature: "backend",
|
|
30651
31059
|
endpoint,
|
|
30652
|
-
issues:
|
|
31060
|
+
issues: v__namespace.flatten(parsed.issues)
|
|
30653
31061
|
})
|
|
30654
31062
|
};
|
|
30655
31063
|
}
|
|
@@ -30687,141 +31095,141 @@ var SponsoringApiService = class {
|
|
|
30687
31095
|
return this.config.baseURL;
|
|
30688
31096
|
}
|
|
30689
31097
|
};
|
|
30690
|
-
var RelayExtraDataResponseSchema =
|
|
30691
|
-
address:
|
|
30692
|
-
payload:
|
|
31098
|
+
var RelayExtraDataResponseSchema = v__namespace.object({
|
|
31099
|
+
address: v__namespace.string(),
|
|
31100
|
+
payload: v__namespace.string()
|
|
30693
31101
|
});
|
|
30694
|
-
var BridgeTokenSchema =
|
|
30695
|
-
symbol:
|
|
30696
|
-
name:
|
|
30697
|
-
decimals:
|
|
30698
|
-
address:
|
|
30699
|
-
chainKey:
|
|
30700
|
-
hubAsset:
|
|
30701
|
-
vault:
|
|
31102
|
+
var BridgeTokenSchema = v__namespace.object({
|
|
31103
|
+
symbol: v__namespace.string(),
|
|
31104
|
+
name: v__namespace.string(),
|
|
31105
|
+
decimals: v__namespace.number(),
|
|
31106
|
+
address: v__namespace.string(),
|
|
31107
|
+
chainKey: v__namespace.string(),
|
|
31108
|
+
hubAsset: v__namespace.string(),
|
|
31109
|
+
vault: v__namespace.string()
|
|
30702
31110
|
});
|
|
30703
|
-
var BridgeTokensResponseSchema =
|
|
30704
|
-
var BridgeTokensByChainResponseSchema =
|
|
30705
|
-
var BridgeAllowanceCheckResponseSchema =
|
|
30706
|
-
valid:
|
|
31111
|
+
var BridgeTokensResponseSchema = v__namespace.record(v__namespace.string(), v__namespace.array(BridgeTokenSchema));
|
|
31112
|
+
var BridgeTokensByChainResponseSchema = v__namespace.array(BridgeTokenSchema);
|
|
31113
|
+
var BridgeAllowanceCheckResponseSchema = v__namespace.object({
|
|
31114
|
+
valid: v__namespace.boolean()
|
|
30707
31115
|
});
|
|
30708
|
-
var makeBridgeApproveResponseSchema = (txSchema) =>
|
|
30709
|
-
var makeCreateBridgeIntentResponseSchema = (txSchema) =>
|
|
31116
|
+
var makeBridgeApproveResponseSchema = (txSchema) => v__namespace.object({ tx: txSchema });
|
|
31117
|
+
var makeCreateBridgeIntentResponseSchema = (txSchema) => v__namespace.object({
|
|
30710
31118
|
tx: txSchema,
|
|
30711
31119
|
relayData: RelayExtraDataResponseSchema
|
|
30712
31120
|
});
|
|
30713
|
-
var BridgeSubmitTxResponseSchema =
|
|
30714
|
-
success:
|
|
30715
|
-
data:
|
|
30716
|
-
status:
|
|
30717
|
-
message:
|
|
31121
|
+
var BridgeSubmitTxResponseSchema = v__namespace.object({
|
|
31122
|
+
success: v__namespace.boolean(),
|
|
31123
|
+
data: v__namespace.object({
|
|
31124
|
+
status: v__namespace.picklist(["inserted", "duplicate"]),
|
|
31125
|
+
message: v__namespace.string()
|
|
30718
31126
|
})
|
|
30719
31127
|
});
|
|
30720
|
-
var BridgePacketDataSchema =
|
|
30721
|
-
src_chain_id:
|
|
30722
|
-
src_tx_hash:
|
|
30723
|
-
src_address:
|
|
30724
|
-
status:
|
|
30725
|
-
dst_chain_id:
|
|
30726
|
-
conn_sn:
|
|
30727
|
-
dst_address:
|
|
30728
|
-
dst_tx_hash:
|
|
30729
|
-
signatures:
|
|
30730
|
-
payload:
|
|
31128
|
+
var BridgePacketDataSchema = v__namespace.object({
|
|
31129
|
+
src_chain_id: v__namespace.number(),
|
|
31130
|
+
src_tx_hash: v__namespace.string(),
|
|
31131
|
+
src_address: v__namespace.string(),
|
|
31132
|
+
status: v__namespace.picklist(["pending", "validating", "executing", "executed"]),
|
|
31133
|
+
dst_chain_id: v__namespace.number(),
|
|
31134
|
+
conn_sn: v__namespace.number(),
|
|
31135
|
+
dst_address: v__namespace.string(),
|
|
31136
|
+
dst_tx_hash: v__namespace.string(),
|
|
31137
|
+
signatures: v__namespace.array(v__namespace.string()),
|
|
31138
|
+
payload: v__namespace.string()
|
|
30731
31139
|
});
|
|
30732
|
-
var BridgeSubmitTxStatusResultSchema =
|
|
30733
|
-
dstIntentTxHash:
|
|
30734
|
-
packetData:
|
|
31140
|
+
var BridgeSubmitTxStatusResultSchema = v__namespace.object({
|
|
31141
|
+
dstIntentTxHash: v__namespace.string(),
|
|
31142
|
+
packetData: v__namespace.optional(BridgePacketDataSchema)
|
|
30735
31143
|
});
|
|
30736
|
-
var BridgeSubmitTxStatusDataSchema =
|
|
30737
|
-
txHash:
|
|
30738
|
-
srcChainKey:
|
|
30739
|
-
status:
|
|
30740
|
-
failedAtStep:
|
|
30741
|
-
failureReason:
|
|
30742
|
-
processingAttempts:
|
|
30743
|
-
abandonedAt:
|
|
30744
|
-
result:
|
|
30745
|
-
userMessage:
|
|
31144
|
+
var BridgeSubmitTxStatusDataSchema = v__namespace.object({
|
|
31145
|
+
txHash: v__namespace.string(),
|
|
31146
|
+
srcChainKey: v__namespace.string(),
|
|
31147
|
+
status: v__namespace.string(),
|
|
31148
|
+
failedAtStep: v__namespace.optional(v__namespace.string()),
|
|
31149
|
+
failureReason: v__namespace.optional(v__namespace.string()),
|
|
31150
|
+
processingAttempts: v__namespace.number(),
|
|
31151
|
+
abandonedAt: v__namespace.optional(v__namespace.string()),
|
|
31152
|
+
result: v__namespace.optional(BridgeSubmitTxStatusResultSchema),
|
|
31153
|
+
userMessage: v__namespace.optional(v__namespace.string())
|
|
30746
31154
|
});
|
|
30747
|
-
var BridgeSubmitTxStatusResponseSchema =
|
|
30748
|
-
success:
|
|
31155
|
+
var BridgeSubmitTxStatusResponseSchema = v__namespace.object({
|
|
31156
|
+
success: v__namespace.boolean(),
|
|
30749
31157
|
data: BridgeSubmitTxStatusDataSchema
|
|
30750
31158
|
});
|
|
30751
|
-
var BridgeFeeResponseSchema =
|
|
30752
|
-
var BridgeLimitSchema =
|
|
30753
|
-
amount:
|
|
30754
|
-
decimals:
|
|
30755
|
-
type:
|
|
31159
|
+
var BridgeFeeResponseSchema = v__namespace.object({ fee: v__namespace.string() });
|
|
31160
|
+
var BridgeLimitSchema = v__namespace.object({
|
|
31161
|
+
amount: v__namespace.string(),
|
|
31162
|
+
decimals: v__namespace.number(),
|
|
31163
|
+
type: v__namespace.picklist(["DEPOSIT_LIMIT", "WITHDRAWAL_LIMIT"])
|
|
30756
31164
|
});
|
|
30757
|
-
var BridgeableAmountResponseSchema =
|
|
30758
|
-
var BridgeableCheckResponseSchema =
|
|
30759
|
-
var
|
|
30760
|
-
var HexSchema =
|
|
30761
|
-
var BigintFromString =
|
|
30762
|
-
var BytesFromIndexRecord =
|
|
30763
|
-
|
|
30764
|
-
|
|
31165
|
+
var BridgeableAmountResponseSchema = v__namespace.object({ limit: BridgeLimitSchema });
|
|
31166
|
+
var BridgeableCheckResponseSchema = v__namespace.object({ bridgeable: v__namespace.boolean() });
|
|
31167
|
+
var AddressSchema2 = v__namespace.custom((input) => typeof input === "string");
|
|
31168
|
+
var HexSchema = v__namespace.custom((input) => typeof input === "string");
|
|
31169
|
+
var BigintFromString = v__namespace.pipe(v__namespace.string(), v__namespace.toBigint());
|
|
31170
|
+
var BytesFromIndexRecord = v__namespace.pipe(
|
|
31171
|
+
v__namespace.record(v__namespace.string(), v__namespace.number()),
|
|
31172
|
+
v__namespace.transform((indexed) => Uint8Array.from(Object.values(indexed)))
|
|
30765
31173
|
);
|
|
30766
|
-
var EvmRawTxSchema =
|
|
30767
|
-
from:
|
|
30768
|
-
to:
|
|
31174
|
+
var EvmRawTxSchema = v__namespace.object({
|
|
31175
|
+
from: AddressSchema2,
|
|
31176
|
+
to: AddressSchema2,
|
|
30769
31177
|
value: BigintFromString,
|
|
30770
31178
|
data: HexSchema
|
|
30771
31179
|
});
|
|
30772
|
-
var SolanaRawTxSchema =
|
|
30773
|
-
from:
|
|
30774
|
-
to:
|
|
31180
|
+
var SolanaRawTxSchema = v__namespace.object({
|
|
31181
|
+
from: v__namespace.string(),
|
|
31182
|
+
to: v__namespace.string(),
|
|
30775
31183
|
value: BigintFromString,
|
|
30776
|
-
data:
|
|
31184
|
+
data: v__namespace.string()
|
|
30777
31185
|
});
|
|
30778
|
-
var SuiRawTxSchema =
|
|
31186
|
+
var SuiRawTxSchema = v__namespace.object({
|
|
30779
31187
|
from: HexSchema,
|
|
30780
|
-
to:
|
|
31188
|
+
to: v__namespace.string(),
|
|
30781
31189
|
value: BigintFromString,
|
|
30782
|
-
data:
|
|
31190
|
+
data: v__namespace.string()
|
|
30783
31191
|
});
|
|
30784
|
-
var StellarRawTxSchema =
|
|
30785
|
-
from:
|
|
30786
|
-
to:
|
|
31192
|
+
var StellarRawTxSchema = v__namespace.object({
|
|
31193
|
+
from: v__namespace.string(),
|
|
31194
|
+
to: v__namespace.string(),
|
|
30787
31195
|
value: BigintFromString,
|
|
30788
|
-
data:
|
|
31196
|
+
data: v__namespace.string()
|
|
30789
31197
|
});
|
|
30790
|
-
var BitcoinRawTxSchema =
|
|
30791
|
-
from:
|
|
30792
|
-
to:
|
|
31198
|
+
var BitcoinRawTxSchema = v__namespace.object({
|
|
31199
|
+
from: v__namespace.string(),
|
|
31200
|
+
to: v__namespace.string(),
|
|
30793
31201
|
value: BigintFromString,
|
|
30794
|
-
data:
|
|
31202
|
+
data: v__namespace.string()
|
|
30795
31203
|
});
|
|
30796
|
-
var InjectiveRawTxSchema =
|
|
31204
|
+
var InjectiveRawTxSchema = v__namespace.object({
|
|
30797
31205
|
from: HexSchema,
|
|
30798
31206
|
to: HexSchema,
|
|
30799
|
-
signedDoc:
|
|
31207
|
+
signedDoc: v__namespace.object({
|
|
30800
31208
|
bodyBytes: BytesFromIndexRecord,
|
|
30801
31209
|
authInfoBytes: BytesFromIndexRecord,
|
|
30802
|
-
chainId:
|
|
31210
|
+
chainId: v__namespace.string(),
|
|
30803
31211
|
accountNumber: BigintFromString
|
|
30804
31212
|
})
|
|
30805
31213
|
});
|
|
30806
|
-
var NearRawTxSchema =
|
|
30807
|
-
signerId:
|
|
30808
|
-
params:
|
|
30809
|
-
contractId:
|
|
30810
|
-
method:
|
|
30811
|
-
args:
|
|
30812
|
-
gas:
|
|
30813
|
-
deposit:
|
|
31214
|
+
var NearRawTxSchema = v__namespace.object({
|
|
31215
|
+
signerId: v__namespace.string(),
|
|
31216
|
+
params: v__namespace.object({
|
|
31217
|
+
contractId: v__namespace.string(),
|
|
31218
|
+
method: v__namespace.string(),
|
|
31219
|
+
args: v__namespace.custom((input) => typeof input === "object" && input !== null),
|
|
31220
|
+
gas: v__namespace.optional(BigintFromString),
|
|
31221
|
+
deposit: v__namespace.optional(BigintFromString)
|
|
30814
31222
|
})
|
|
30815
31223
|
});
|
|
30816
|
-
var IconRawTxSchema =
|
|
30817
|
-
|
|
30818
|
-
|
|
31224
|
+
var IconRawTxSchema = v__namespace.record(
|
|
31225
|
+
v__namespace.string(),
|
|
31226
|
+
v__namespace.union([v__namespace.string(), v__namespace.custom((input) => typeof input === "object" && input !== null)])
|
|
30819
31227
|
);
|
|
30820
|
-
var StacksRawTxSchema =
|
|
30821
|
-
payload:
|
|
30822
|
-
estimatedLength:
|
|
31228
|
+
var StacksRawTxSchema = v__namespace.object({
|
|
31229
|
+
payload: v__namespace.string(),
|
|
31230
|
+
estimatedLength: v__namespace.optional(v__namespace.number())
|
|
30823
31231
|
});
|
|
30824
|
-
var AnyRawTxSchema =
|
|
31232
|
+
var AnyRawTxSchema = v__namespace.custom((input) => typeof input === "object" && input !== null);
|
|
30825
31233
|
function rawTxSchemaForChainKey(chainKey) {
|
|
30826
31234
|
let chainType;
|
|
30827
31235
|
try {
|
|
@@ -30874,10 +31282,13 @@ var BridgeApiService = class {
|
|
|
30874
31282
|
config;
|
|
30875
31283
|
headers;
|
|
30876
31284
|
logger;
|
|
30877
|
-
|
|
31285
|
+
/** See {@link BridgeApiServiceOptions.trimLegacyOverrides}. */
|
|
31286
|
+
trimsLegacyOverrides;
|
|
31287
|
+
constructor(config, logger = consoleLogger, options = {}) {
|
|
30878
31288
|
this.config = config;
|
|
30879
31289
|
this.headers = { ...config.headers };
|
|
30880
31290
|
this.logger = logger;
|
|
31291
|
+
this.trimsLegacyOverrides = options.trimLegacyOverrides ?? true;
|
|
30881
31292
|
}
|
|
30882
31293
|
/**
|
|
30883
31294
|
* Issues a single HTTP request, validates the JSON body against `schema`, and
|
|
@@ -30890,17 +31301,20 @@ var BridgeApiService = class {
|
|
|
30890
31301
|
const raw = await makeRequest({
|
|
30891
31302
|
endpoint,
|
|
30892
31303
|
config: { baseURL: this.config.baseURL, timeout: this.config.timeout, headers: this.headers, ...config },
|
|
30893
|
-
|
|
31304
|
+
// Normalized like a configured base URL: the override is the gateway root, so a legacy
|
|
31305
|
+
// `/be`-suffixed value must not nest `/bridge/*` under the data API's mount — unless the config
|
|
31306
|
+
// opted out of the legacy trim, in which case the per-call value is left exactly as given.
|
|
31307
|
+
overrideConfig: this.trimsLegacyOverrides ? normalizeOverrideBaseURL(overrideConfig) : overrideConfig,
|
|
30894
31308
|
logger: this.logger,
|
|
30895
31309
|
serviceLabel: "BridgeApiService"
|
|
30896
31310
|
});
|
|
30897
|
-
const parsed =
|
|
31311
|
+
const parsed = v__namespace.safeParse(schema, raw);
|
|
30898
31312
|
if (!parsed.success) {
|
|
30899
31313
|
return {
|
|
30900
31314
|
ok: false,
|
|
30901
31315
|
error: new SodaxError("EXTERNAL_API_ERROR", `Invalid response shape from bridge API for ${endpoint}`, {
|
|
30902
31316
|
feature: "backend",
|
|
30903
|
-
context: { api: "bridge", endpoint, reason: "invalid_response_shape", issues:
|
|
31317
|
+
context: { api: "bridge", endpoint, reason: "invalid_response_shape", issues: v__namespace.flatten(parsed.issues) }
|
|
30904
31318
|
})
|
|
30905
31319
|
};
|
|
30906
31320
|
}
|
|
@@ -31096,201 +31510,85 @@ var BridgeApiService = class {
|
|
|
31096
31510
|
}
|
|
31097
31511
|
};
|
|
31098
31512
|
|
|
31099
|
-
// src/backendApi/apiConfig.ts
|
|
31100
|
-
function flatLayer({ baseURL, timeout, headers }) {
|
|
31101
|
-
return { baseURL, timeout, headers };
|
|
31102
|
-
}
|
|
31103
|
-
function layerConfigs(...slices) {
|
|
31104
|
-
return slices.reduce(
|
|
31105
|
-
(acc, slice) => slice ? {
|
|
31106
|
-
baseURL: slice.baseURL ?? acc.baseURL,
|
|
31107
|
-
timeout: slice.timeout ?? acc.timeout,
|
|
31108
|
-
headers: { ...acc.headers, ...slice.headers }
|
|
31109
|
-
} : acc,
|
|
31110
|
-
{
|
|
31111
|
-
baseURL: DEFAULT_BACKEND_API_ENDPOINT,
|
|
31112
|
-
timeout: DEFAULT_BACKEND_API_TIMEOUT,
|
|
31113
|
-
headers: { ...DEFAULT_BACKEND_API_HEADERS }
|
|
31114
|
-
}
|
|
31115
|
-
);
|
|
31116
|
-
}
|
|
31117
|
-
function resolveBaseApiConfig(config) {
|
|
31118
|
-
const layers = config;
|
|
31119
|
-
return layerConfigs(flatLayer(layers), layers.baseApiConfig);
|
|
31120
|
-
}
|
|
31121
|
-
function resolveSwapsApiConfig(config) {
|
|
31122
|
-
const layers = config;
|
|
31123
|
-
return layerConfigs(flatLayer(layers), layers.baseApiConfig, layers.swapsApiConfig);
|
|
31124
|
-
}
|
|
31125
|
-
function isHttpUrl(value) {
|
|
31126
|
-
return value.startsWith("http://") || value.startsWith("https://");
|
|
31127
|
-
}
|
|
31128
|
-
function normalizeBaseURL(baseURL) {
|
|
31129
|
-
const trimmed = trimTrailingSlashes(baseURL);
|
|
31130
|
-
return isHttpUrl(trimmed) ? trimmed : baseURL;
|
|
31131
|
-
}
|
|
31132
|
-
function resolveSponsoringApiConfig(config) {
|
|
31133
|
-
const layers = config;
|
|
31134
|
-
const slice = layers.sponsoringApiConfig;
|
|
31135
|
-
return {
|
|
31136
|
-
baseURL: normalizeBaseURL(slice?.baseURL ?? DEFAULT_SPONSORING_API_ENDPOINT),
|
|
31137
|
-
timeout: slice?.timeout ?? resolveBaseApiConfig(config).timeout,
|
|
31138
|
-
headers: { ...DEFAULT_BACKEND_API_HEADERS, ...slice?.headers },
|
|
31139
|
-
...slice?.apiKey === void 0 ? {} : { apiKey: slice.apiKey }
|
|
31140
|
-
};
|
|
31141
|
-
}
|
|
31142
|
-
function resolveBridgeApiConfig(config) {
|
|
31143
|
-
return resolveBaseApiConfig(config);
|
|
31144
|
-
}
|
|
31145
|
-
var ChainKeySchema = v7__namespace.custom((input) => typeof input === "string");
|
|
31146
|
-
var SpokeChainKeySchema = v7__namespace.custom((input) => typeof input === "string");
|
|
31147
|
-
var AddressSchema2 = v7__namespace.custom((input) => typeof input === "string");
|
|
31148
|
-
var XTokenSchema = v7__namespace.object({
|
|
31149
|
-
symbol: v7__namespace.string(),
|
|
31150
|
-
name: v7__namespace.string(),
|
|
31151
|
-
decimals: v7__namespace.number(),
|
|
31152
|
-
address: v7__namespace.string(),
|
|
31153
|
-
chainKey: ChainKeySchema,
|
|
31154
|
-
hubAsset: AddressSchema2,
|
|
31155
|
-
vault: AddressSchema2,
|
|
31156
|
-
access: v7__namespace.optional(v7__namespace.picklist(["withdrawOnly", "depositOnly"]))
|
|
31157
|
-
});
|
|
31158
|
-
var IntentStructSchema = v7__namespace.object({
|
|
31159
|
-
intentId: v7__namespace.string(),
|
|
31160
|
-
creator: v7__namespace.string(),
|
|
31161
|
-
inputToken: v7__namespace.string(),
|
|
31162
|
-
outputToken: v7__namespace.string(),
|
|
31163
|
-
inputAmount: v7__namespace.string(),
|
|
31164
|
-
minOutputAmount: v7__namespace.string(),
|
|
31165
|
-
deadline: v7__namespace.string(),
|
|
31166
|
-
allowPartialFill: v7__namespace.boolean(),
|
|
31167
|
-
srcChain: v7__namespace.number(),
|
|
31168
|
-
dstChain: v7__namespace.number(),
|
|
31169
|
-
srcAddress: v7__namespace.string(),
|
|
31170
|
-
dstAddress: v7__namespace.string(),
|
|
31171
|
-
solver: v7__namespace.string(),
|
|
31172
|
-
data: v7__namespace.string()
|
|
31173
|
-
});
|
|
31174
|
-
var IntentResponseSchema = v7__namespace.object({
|
|
31175
|
-
intentHash: v7__namespace.string(),
|
|
31176
|
-
txHash: v7__namespace.string(),
|
|
31177
|
-
logIndex: v7__namespace.number(),
|
|
31178
|
-
chainId: v7__namespace.number(),
|
|
31179
|
-
blockNumber: v7__namespace.number(),
|
|
31180
|
-
open: v7__namespace.boolean(),
|
|
31181
|
-
intent: IntentStructSchema,
|
|
31182
|
-
events: v7__namespace.array(v7__namespace.unknown())
|
|
31183
|
-
});
|
|
31184
|
-
var UserIntentsResponseSchema = v7__namespace.object({
|
|
31185
|
-
total: v7__namespace.number(),
|
|
31186
|
-
offset: v7__namespace.number(),
|
|
31187
|
-
limit: v7__namespace.number(),
|
|
31188
|
-
items: v7__namespace.array(IntentResponseSchema)
|
|
31189
|
-
});
|
|
31190
|
-
var OrderbookResponseSchema = v7__namespace.object({
|
|
31191
|
-
total: v7__namespace.number(),
|
|
31192
|
-
data: v7__namespace.array(
|
|
31193
|
-
v7__namespace.object({
|
|
31194
|
-
intentState: v7__namespace.object({
|
|
31195
|
-
exists: v7__namespace.boolean(),
|
|
31196
|
-
remainingInput: v7__namespace.string(),
|
|
31197
|
-
receivedOutput: v7__namespace.string(),
|
|
31198
|
-
pendingPayment: v7__namespace.boolean()
|
|
31199
|
-
}),
|
|
31200
|
-
intentData: v7__namespace.object({
|
|
31201
|
-
intentId: v7__namespace.string(),
|
|
31202
|
-
creator: v7__namespace.string(),
|
|
31203
|
-
inputToken: v7__namespace.string(),
|
|
31204
|
-
outputToken: v7__namespace.string(),
|
|
31205
|
-
inputAmount: v7__namespace.string(),
|
|
31206
|
-
minOutputAmount: v7__namespace.string(),
|
|
31207
|
-
deadline: v7__namespace.string(),
|
|
31208
|
-
allowPartialFill: v7__namespace.boolean(),
|
|
31209
|
-
srcChain: v7__namespace.number(),
|
|
31210
|
-
dstChain: v7__namespace.number(),
|
|
31211
|
-
srcAddress: v7__namespace.string(),
|
|
31212
|
-
dstAddress: v7__namespace.string(),
|
|
31213
|
-
solver: v7__namespace.string(),
|
|
31214
|
-
data: v7__namespace.string(),
|
|
31215
|
-
intentHash: v7__namespace.string(),
|
|
31216
|
-
txHash: v7__namespace.string(),
|
|
31217
|
-
blockNumber: v7__namespace.number()
|
|
31218
|
-
})
|
|
31219
|
-
})
|
|
31220
|
-
)
|
|
31221
|
-
});
|
|
31222
|
-
var MoneyMarketPositionSchema = v7__namespace.object({
|
|
31223
|
-
userAddress: v7__namespace.string(),
|
|
31224
|
-
positions: v7__namespace.array(
|
|
31225
|
-
v7__namespace.object({
|
|
31226
|
-
reserveAddress: v7__namespace.string(),
|
|
31227
|
-
aTokenAddress: v7__namespace.string(),
|
|
31228
|
-
variableDebtTokenAddress: v7__namespace.string(),
|
|
31229
|
-
aTokenBalance: v7__namespace.string(),
|
|
31230
|
-
variableDebtTokenBalance: v7__namespace.string(),
|
|
31231
|
-
blockNumber: v7__namespace.number()
|
|
31232
|
-
})
|
|
31233
|
-
)
|
|
31234
|
-
});
|
|
31235
|
-
var MoneyMarketAssetSchema = v7__namespace.object({
|
|
31236
|
-
reserveAddress: v7__namespace.string(),
|
|
31237
|
-
aTokenAddress: v7__namespace.string(),
|
|
31238
|
-
totalATokenBalance: v7__namespace.string(),
|
|
31239
|
-
variableDebtTokenAddress: v7__namespace.string(),
|
|
31240
|
-
totalVariableDebtTokenBalance: v7__namespace.string(),
|
|
31241
|
-
liquidityRate: v7__namespace.string(),
|
|
31242
|
-
symbol: v7__namespace.string(),
|
|
31243
|
-
totalSuppliers: v7__namespace.number(),
|
|
31244
|
-
totalBorrowers: v7__namespace.number(),
|
|
31245
|
-
variableBorrowRate: v7__namespace.string(),
|
|
31246
|
-
stableBorrowRate: v7__namespace.string(),
|
|
31247
|
-
liquidityIndex: v7__namespace.string(),
|
|
31248
|
-
variableBorrowIndex: v7__namespace.string(),
|
|
31249
|
-
blockNumber: v7__namespace.number()
|
|
31250
|
-
});
|
|
31251
|
-
var MoneyMarketAssetsSchema = v7__namespace.array(MoneyMarketAssetSchema);
|
|
31252
|
-
var MoneyMarketAssetBorrowersSchema = v7__namespace.object({
|
|
31253
|
-
borrowers: v7__namespace.array(v7__namespace.string()),
|
|
31254
|
-
total: v7__namespace.number(),
|
|
31255
|
-
offset: v7__namespace.number(),
|
|
31256
|
-
limit: v7__namespace.number()
|
|
31257
|
-
});
|
|
31258
|
-
var MoneyMarketAssetSuppliersSchema = v7__namespace.object({
|
|
31259
|
-
suppliers: v7__namespace.array(v7__namespace.string()),
|
|
31260
|
-
total: v7__namespace.number(),
|
|
31261
|
-
offset: v7__namespace.number(),
|
|
31262
|
-
limit: v7__namespace.number()
|
|
31263
|
-
});
|
|
31264
|
-
var MoneyMarketBorrowersSchema = v7__namespace.object({
|
|
31265
|
-
borrowers: v7__namespace.array(v7__namespace.string()),
|
|
31266
|
-
total: v7__namespace.number(),
|
|
31267
|
-
offset: v7__namespace.number(),
|
|
31268
|
-
limit: v7__namespace.number()
|
|
31269
|
-
});
|
|
31270
|
-
var GetChainsResponseSchema = v7__namespace.array(SpokeChainKeySchema);
|
|
31271
|
-
var TokensByChainMapSchema = v7__namespace.custom(
|
|
31272
|
-
(input) => typeof input === "object" && input !== null && Object.values(input).every((tokens) => Array.isArray(tokens) && tokens.every((t) => v7__namespace.is(XTokenSchema, t)))
|
|
31273
|
-
);
|
|
31274
|
-
var TokensListSchema = v7__namespace.array(XTokenSchema);
|
|
31275
|
-
var ReserveAssetsSchema = v7__namespace.array(AddressSchema2);
|
|
31276
|
-
|
|
31277
31513
|
// src/backendApi/BackendApiService.ts
|
|
31278
31514
|
var BackendApiService = class {
|
|
31279
31515
|
// sub-services exposing domain-specific APIs
|
|
31280
31516
|
swaps;
|
|
31281
31517
|
sponsoring;
|
|
31282
31518
|
bridge;
|
|
31283
|
-
// resolved base-API config: the flat fields of the ApiConfig union with any `baseApiConfig` layered on
|
|
31519
|
+
// resolved base-API config: the flat fields of the ApiConfig union with any `baseApiConfig` layered on
|
|
31520
|
+
// top. `baseURL` is the gateway root; `basePath` is this service's own mount below it.
|
|
31284
31521
|
config;
|
|
31285
31522
|
headers;
|
|
31286
31523
|
logger;
|
|
31524
|
+
/**
|
|
31525
|
+
* The resolved request timeout. Exposed so a caller wanting a *shorter* per-call budget can clamp
|
|
31526
|
+
* to it: a `RequestOverrideConfig.timeout` replaces the configured value rather than capping it,
|
|
31527
|
+
* so passing a fixed override would silently lengthen requests for a consumer who configured a
|
|
31528
|
+
* stricter timeout.
|
|
31529
|
+
*/
|
|
31530
|
+
get requestTimeoutMs() {
|
|
31531
|
+
return this.config.timeout;
|
|
31532
|
+
}
|
|
31533
|
+
/**
|
|
31534
|
+
* Whether a legacy `/be` suffix is trimmed off a per-call `baseURL` override. Mirrors the config-level
|
|
31535
|
+
* decision: an explicit `basePath` means the consumer writes complete roots, so their per-call value is
|
|
31536
|
+
* left exactly as given rather than having a real path segment eaten.
|
|
31537
|
+
*/
|
|
31538
|
+
trimsLegacyOverrides;
|
|
31287
31539
|
constructor(config, logger = consoleLogger) {
|
|
31288
31540
|
this.config = resolveBaseApiConfig(config);
|
|
31289
31541
|
this.headers = { ...this.config.headers };
|
|
31290
31542
|
this.logger = logger;
|
|
31291
|
-
this.
|
|
31292
|
-
|
|
31293
|
-
|
|
31543
|
+
this.trimsLegacyOverrides = !hasExplicitBasePath(config);
|
|
31544
|
+
const swapsConfig2 = resolveSwapsApiConfig(config);
|
|
31545
|
+
const sponsoringConfig = resolveSponsoringApiConfig(config);
|
|
31546
|
+
const bridgeConfig2 = resolveBridgeApiConfig(config);
|
|
31547
|
+
const shortRoots = [
|
|
31548
|
+
["backendApi", this.config.baseURL],
|
|
31549
|
+
["api.swaps", swapsConfig2.baseURL],
|
|
31550
|
+
["api.bridge", bridgeConfig2.baseURL],
|
|
31551
|
+
["api.sponsoring", sponsoringConfig.baseURL]
|
|
31552
|
+
].filter(([, baseURL]) => isMissingVersionPrefix(baseURL));
|
|
31553
|
+
if (shortRoots.length > 0) {
|
|
31554
|
+
const named = shortRoots.map(([service, baseURL]) => `${service} ("${baseURL}")`).join(", ");
|
|
31555
|
+
this.logger.warn(
|
|
31556
|
+
`[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.`
|
|
31557
|
+
);
|
|
31558
|
+
}
|
|
31559
|
+
if (hasLegacyBackendBaseURL(config)) {
|
|
31560
|
+
this.logger.warn(
|
|
31561
|
+
`[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.`
|
|
31562
|
+
);
|
|
31563
|
+
}
|
|
31564
|
+
const overrideOptions = { trimLegacyOverrides: this.trimsLegacyOverrides };
|
|
31565
|
+
this.swaps = new SwapsApiService(swapsConfig2, this.logger, overrideOptions);
|
|
31566
|
+
this.sponsoring = new SponsoringApiService(sponsoringConfig, this.logger);
|
|
31567
|
+
this.bridge = new BridgeApiService(bridgeConfig2, this.logger, overrideOptions);
|
|
31568
|
+
}
|
|
31569
|
+
/**
|
|
31570
|
+
* Issue the HTTP call for a route.
|
|
31571
|
+
*
|
|
31572
|
+
* The mount is applied here rather than at each route literal, so `error.context.endpoint` stays
|
|
31573
|
+
* route-relative and the mount survives a per-call `baseURL` override — that retargets the gateway
|
|
31574
|
+
* root, not which service the route belongs to. For the same reason an override is put through the
|
|
31575
|
+
* legacy-mount trim: without it, passing the old `…/v1/be` value per call would yield `/be/be/…`.
|
|
31576
|
+
*
|
|
31577
|
+
* Defaults are listed field by field so `basePath` cannot cross into `RequestConfig`, where it has no
|
|
31578
|
+
* meaning — a spread would pass it silently, since TypeScript skips excess-property checks on spreads.
|
|
31579
|
+
*/
|
|
31580
|
+
async send(endpoint, config) {
|
|
31581
|
+
const { baseURL, ...rest } = config;
|
|
31582
|
+
const overrideBaseURL = baseURL !== void 0 && this.trimsLegacyOverrides ? stripLegacyBackendMount(baseURL) : baseURL;
|
|
31583
|
+
return makeRequest({
|
|
31584
|
+
endpoint: `${this.config.basePath}${endpoint}`,
|
|
31585
|
+
config: resolveRequestConfig(
|
|
31586
|
+
{ ...rest, ...overrideBaseURL === void 0 ? {} : { baseURL: overrideBaseURL } },
|
|
31587
|
+
{ baseURL: this.config.baseURL, timeout: this.config.timeout, headers: this.headers }
|
|
31588
|
+
),
|
|
31589
|
+
logger: this.logger,
|
|
31590
|
+
serviceLabel: "BackendApiService"
|
|
31591
|
+
});
|
|
31294
31592
|
}
|
|
31295
31593
|
/**
|
|
31296
31594
|
* Issue a request and validate the JSON body against `schema`, wrapping the result in `Result<T>`.
|
|
@@ -31301,13 +31599,8 @@ var BackendApiService = class {
|
|
|
31301
31599
|
*/
|
|
31302
31600
|
async request(endpoint, config, schema) {
|
|
31303
31601
|
try {
|
|
31304
|
-
const raw = await
|
|
31305
|
-
|
|
31306
|
-
config: resolveRequestConfig(config, { ...this.config, headers: this.headers }),
|
|
31307
|
-
logger: this.logger,
|
|
31308
|
-
serviceLabel: "BackendApiService"
|
|
31309
|
-
});
|
|
31310
|
-
const parsed = v7__namespace.safeParse(schema, raw);
|
|
31602
|
+
const raw = await this.send(endpoint, config);
|
|
31603
|
+
const parsed = v__namespace.safeParse(schema, raw);
|
|
31311
31604
|
if (!parsed.success) {
|
|
31312
31605
|
return {
|
|
31313
31606
|
ok: false,
|
|
@@ -31315,7 +31608,7 @@ var BackendApiService = class {
|
|
|
31315
31608
|
api: "backend",
|
|
31316
31609
|
feature: "backend",
|
|
31317
31610
|
endpoint,
|
|
31318
|
-
issues:
|
|
31611
|
+
issues: v__namespace.flatten(parsed.issues)
|
|
31319
31612
|
})
|
|
31320
31613
|
};
|
|
31321
31614
|
}
|
|
@@ -31333,12 +31626,7 @@ var BackendApiService = class {
|
|
|
31333
31626
|
*/
|
|
31334
31627
|
async requestUnvalidated(endpoint, config) {
|
|
31335
31628
|
try {
|
|
31336
|
-
const value = await
|
|
31337
|
-
endpoint,
|
|
31338
|
-
config: resolveRequestConfig(config, { ...this.config, headers: this.headers }),
|
|
31339
|
-
logger: this.logger,
|
|
31340
|
-
serviceLabel: "BackendApiService"
|
|
31341
|
-
});
|
|
31629
|
+
const value = await this.send(endpoint, config);
|
|
31342
31630
|
return { ok: true, value };
|
|
31343
31631
|
} catch (error) {
|
|
31344
31632
|
return { ok: false, error: toExternalApiError({ api: "backend", feature: "backend", endpoint, error }) };
|
|
@@ -31640,8 +31928,9 @@ var BackendApiService = class {
|
|
|
31640
31928
|
* without constructing a new service instance. Existing header keys are
|
|
31641
31929
|
* overwritten; keys absent from `headers` are preserved.
|
|
31642
31930
|
*
|
|
31643
|
-
* Headers also reach `swaps
|
|
31644
|
-
*
|
|
31931
|
+
* Headers also reach `swaps` and `bridge`, but never `sponsoring`: it is configured independently, so
|
|
31932
|
+
* base-API credentials must not be forwarded to whatever origin it points at. Note `swaps` can also be
|
|
31933
|
+
* retargeted to another origin via `swapsApiConfig`, in which case a header set here follows it.
|
|
31645
31934
|
*
|
|
31646
31935
|
* @param headers - Key-value pairs to add or overwrite in the default headers.
|
|
31647
31936
|
*/
|
|
@@ -31653,13 +31942,22 @@ var BackendApiService = class {
|
|
|
31653
31942
|
this.bridge.setHeaders(headers);
|
|
31654
31943
|
}
|
|
31655
31944
|
/**
|
|
31656
|
-
* Return the
|
|
31945
|
+
* Return the gateway root the service is currently pointing at — WITHOUT this service's own mount.
|
|
31946
|
+
* Requests go to `getBaseURL() + getBasePath() + <route>`.
|
|
31657
31947
|
*
|
|
31658
|
-
* @returns The `baseURL` from the `ApiConfig` this instance was
|
|
31948
|
+
* @returns The resolved gateway root, i.e. the `baseURL` from the `ApiConfig` this instance was
|
|
31949
|
+
* constructed with, minus a legacy `/be` suffix if one was supplied.
|
|
31659
31950
|
*/
|
|
31660
31951
|
getBaseURL() {
|
|
31661
31952
|
return this.config.baseURL;
|
|
31662
31953
|
}
|
|
31954
|
+
/**
|
|
31955
|
+
* Return the backend data API's mount below {@link getBaseURL} — `/be` by default, or whatever
|
|
31956
|
+
* `basePath` the `ApiConfig` supplied (`''` for a service addressed directly at its origin).
|
|
31957
|
+
*/
|
|
31958
|
+
getBasePath() {
|
|
31959
|
+
return this.config.basePath;
|
|
31960
|
+
}
|
|
31663
31961
|
};
|
|
31664
31962
|
|
|
31665
31963
|
// src/bridge/errors.ts
|
|
@@ -40532,7 +40830,7 @@ var LeverageYieldService = class {
|
|
|
40532
40830
|
}
|
|
40533
40831
|
/** Looks up a vault by its `name` field. Returns `undefined` when not registered. */
|
|
40534
40832
|
getVault(name) {
|
|
40535
|
-
return this.listVaults().find((
|
|
40833
|
+
return this.listVaults().find((v10) => v10.name === name);
|
|
40536
40834
|
}
|
|
40537
40835
|
/**
|
|
40538
40836
|
* Looks up a registered vault by its on-chain proxy address (case-insensitive).
|
|
@@ -40540,7 +40838,7 @@ var LeverageYieldService = class {
|
|
|
40540
40838
|
*/
|
|
40541
40839
|
getVaultByAddress(address) {
|
|
40542
40840
|
const normalized = address.toLowerCase();
|
|
40543
|
-
return this.listVaults().find((
|
|
40841
|
+
return this.listVaults().find((v10) => v10.vault.toLowerCase() === normalized);
|
|
40544
40842
|
}
|
|
40545
40843
|
/**
|
|
40546
40844
|
* Resolves the intent `deadline`: returns the caller-supplied value verbatim, otherwise
|
|
@@ -42104,6 +42402,7 @@ Object.defineProperty(exports, "SwapsApiError", {
|
|
|
42104
42402
|
exports.ALLOWANCE_CHECK_CODES = ALLOWANCE_CHECK_CODES;
|
|
42105
42403
|
exports.APPROVE_CODES = APPROVE_CODES;
|
|
42106
42404
|
exports.AssetService = AssetService;
|
|
42405
|
+
exports.BACKEND_API_BASE_PATH = BACKEND_API_BASE_PATH;
|
|
42107
42406
|
exports.BITCOIN_CHAIN_KEYS = BITCOIN_CHAIN_KEYS;
|
|
42108
42407
|
exports.BITCOIN_CHAIN_KEYS_SET = BITCOIN_CHAIN_KEYS_SET;
|
|
42109
42408
|
exports.BITCOIN_DUST_SATS = BITCOIN_DUST_SATS;
|
|
@@ -42127,6 +42426,7 @@ exports.ClService = ClService;
|
|
|
42127
42426
|
exports.ConfigService = ConfigService;
|
|
42128
42427
|
exports.CustomSorobanServer = CustomSorobanServer;
|
|
42129
42428
|
exports.CustomStellarAccount = CustomStellarAccount;
|
|
42429
|
+
exports.DEFAULT_API_BASE_URL = DEFAULT_API_BASE_URL;
|
|
42130
42430
|
exports.DEFAULT_BACKEND_API_ENDPOINT = DEFAULT_BACKEND_API_ENDPOINT;
|
|
42131
42431
|
exports.DEFAULT_BACKEND_API_HEADERS = DEFAULT_BACKEND_API_HEADERS;
|
|
42132
42432
|
exports.DEFAULT_BACKEND_API_TIMEOUT = DEFAULT_BACKEND_API_TIMEOUT;
|
|
@@ -42136,6 +42436,7 @@ exports.DEFAULT_RELAYER_API_ENDPOINT = DEFAULT_RELAYER_API_ENDPOINT;
|
|
|
42136
42436
|
exports.DEFAULT_RELAY_TX_TIMEOUT = DEFAULT_RELAY_TX_TIMEOUT;
|
|
42137
42437
|
exports.DEFAULT_RETRY_DELAY_MS = DEFAULT_RETRY_DELAY_MS;
|
|
42138
42438
|
exports.DEFAULT_SPONSORING_API_ENDPOINT = DEFAULT_SPONSORING_API_ENDPOINT;
|
|
42439
|
+
exports.DETAILED_STATUS_NOT_DELIVERED = DETAILED_STATUS_NOT_DELIVERED;
|
|
42139
42440
|
exports.DexService = DexService;
|
|
42140
42441
|
exports.EVM_CHAIN_ID_TO_KEY = EVM_CHAIN_ID_TO_KEY;
|
|
42141
42442
|
exports.EVM_CHAIN_KEYS = EVM_CHAIN_KEYS;
|
|
@@ -42200,6 +42501,7 @@ exports.RAY = RAY;
|
|
|
42200
42501
|
exports.RAY_DECIMALS = RAY_DECIMALS;
|
|
42201
42502
|
exports.RELAY_ERROR_CODES = RELAY_ERROR_CODES;
|
|
42202
42503
|
exports.RELAY_FALLBACK_FLOOR_MS = RELAY_FALLBACK_FLOOR_MS;
|
|
42504
|
+
exports.RELAY_REQUEST_TIMEOUT_MS = RELAY_REQUEST_TIMEOUT_MS;
|
|
42203
42505
|
exports.RadfiApiError = RadfiApiError;
|
|
42204
42506
|
exports.RadfiProvider = RadfiProvider;
|
|
42205
42507
|
exports.RecoveryService = RecoveryService;
|
|
@@ -42372,6 +42674,7 @@ exports.isEvmSpokeOnlyChainKey = isEvmSpokeOnlyChainKey;
|
|
|
42372
42674
|
exports.isEvmSpokeOnlyChainKeyType = isEvmSpokeOnlyChainKeyType;
|
|
42373
42675
|
exports.isEvmWalletProviderType = isEvmWalletProviderType;
|
|
42374
42676
|
exports.isFeatureError = isFeatureError;
|
|
42677
|
+
exports.isFillEvent = isFillEvent;
|
|
42375
42678
|
exports.isHookSupportedToken = isHookSupportedToken;
|
|
42376
42679
|
exports.isHubChainKey = isHubChainKey;
|
|
42377
42680
|
exports.isHubChainKeyType = isHubChainKeyType;
|