@gala-chain/gswap-sdk 2.1.0-beta.4 → 2.1.0-beta.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.d.cts CHANGED
@@ -1195,6 +1195,16 @@ export interface DexFeeQuote {
1195
1195
  }>;
1196
1196
  source: 'dry-run' | 'default';
1197
1197
  }
1198
+ /**
1199
+ * The backend root a fee quote is built on: `base` without trailing slashes and without a trailing
1200
+ * `/api/v1` (the wallet passes the versioned base, the SDK presets the host root). Idempotent.
1201
+ *
1202
+ * @example
1203
+ * ```typescript
1204
+ * dexBackendRoot('https://swap-backend.stage.defi.ovh.gala.com/api/v1/'); // 'https://swap-backend.stage.defi.ovh.gala.com'
1205
+ * ```
1206
+ */
1207
+ export declare function dexBackendRoot(base: string): string;
1198
1208
  /**
1199
1209
  * Reduces an EIP-712 approval `message` to the DTO the chain actually receives: drops the signing
1200
1210
  * envelope (`signature`, `prefix`, `types`, `domain`), the `dtoOperation` it was signed to call (a
@@ -1215,7 +1225,11 @@ export declare function toChainDto(message: Record<string, unknown>): Record<str
1215
1225
  export declare function buildDryRunWrapper(signer: GalaChainSigner, callerPublicKey: string, method: string, dto: Record<string, unknown>, uniqueKeyPrefix?: string, contractPath?: ChainContractPath): Promise<Record<string, unknown>>;
1216
1226
  /** The transport and backend a fee quote reads from. */
1217
1227
  export interface DexFeesClient {
1218
- /** Swap backend origin, e.g. `https://dex-backend-prod1.defi.gala.com`. */
1228
+ /**
1229
+ * Swap backend origin, e.g. `https://dex-backend-prod1.defi.gala.com`. A base that already ends in
1230
+ * `/api/v1` (what the wallet passes) and trailing slashes are accepted: the request goes to the
1231
+ * same URL either way (see {@link dexBackendRoot}).
1232
+ */
1219
1233
  dexBackendBaseUrl: string;
1220
1234
  /** Defaults to the global `fetch`. */
1221
1235
  httpRequestor?: HttpRequestor | undefined;
@@ -1268,7 +1282,10 @@ export declare class DexFees {
1268
1282
  * malformed body): a transport outcome, not a fee. Deciding what to charge when the chain is
1269
1283
  * silent is the backend's job (it serves `source: 'default'`), so the client never substitutes
1270
1284
  * a fee of its own, with ONE exception that mirrors the wallet: a `dex-contract` quote answered
1271
- * 403 or 404 means the contract has no fee route yet and resolves `{ source: 'default', '0' }`.
1285
+ * 403 means the contract has no fee route yet and resolves `{ source: 'default', '0' }`. A 404 is
1286
+ * a wrong path, not "no fee route": it resolves `null`, never a default. The request always goes
1287
+ * to `<root>/api/v1/wallet/connect/galachain/api/{channel}/{contract}/{method}/fee`, whether the
1288
+ * client's base URL is the host root or already ends in `/api/v1`.
1272
1289
  * Never throws on transport, so a fee lookup cannot block or break a signing screen.
1273
1290
  *
1274
1291
  * @throws GSwapSDKError NO_SIGNER when constructed without a signer; `SIGNING_FAILED` or
package/dist/index.d.ts CHANGED
@@ -1195,6 +1195,16 @@ export interface DexFeeQuote {
1195
1195
  }>;
1196
1196
  source: 'dry-run' | 'default';
1197
1197
  }
1198
+ /**
1199
+ * The backend root a fee quote is built on: `base` without trailing slashes and without a trailing
1200
+ * `/api/v1` (the wallet passes the versioned base, the SDK presets the host root). Idempotent.
1201
+ *
1202
+ * @example
1203
+ * ```typescript
1204
+ * dexBackendRoot('https://swap-backend.stage.defi.ovh.gala.com/api/v1/'); // 'https://swap-backend.stage.defi.ovh.gala.com'
1205
+ * ```
1206
+ */
1207
+ export declare function dexBackendRoot(base: string): string;
1198
1208
  /**
1199
1209
  * Reduces an EIP-712 approval `message` to the DTO the chain actually receives: drops the signing
1200
1210
  * envelope (`signature`, `prefix`, `types`, `domain`), the `dtoOperation` it was signed to call (a
@@ -1215,7 +1225,11 @@ export declare function toChainDto(message: Record<string, unknown>): Record<str
1215
1225
  export declare function buildDryRunWrapper(signer: GalaChainSigner, callerPublicKey: string, method: string, dto: Record<string, unknown>, uniqueKeyPrefix?: string, contractPath?: ChainContractPath): Promise<Record<string, unknown>>;
1216
1226
  /** The transport and backend a fee quote reads from. */
1217
1227
  export interface DexFeesClient {
1218
- /** Swap backend origin, e.g. `https://dex-backend-prod1.defi.gala.com`. */
1228
+ /**
1229
+ * Swap backend origin, e.g. `https://dex-backend-prod1.defi.gala.com`. A base that already ends in
1230
+ * `/api/v1` (what the wallet passes) and trailing slashes are accepted: the request goes to the
1231
+ * same URL either way (see {@link dexBackendRoot}).
1232
+ */
1219
1233
  dexBackendBaseUrl: string;
1220
1234
  /** Defaults to the global `fetch`. */
1221
1235
  httpRequestor?: HttpRequestor | undefined;
@@ -1268,7 +1282,10 @@ export declare class DexFees {
1268
1282
  * malformed body): a transport outcome, not a fee. Deciding what to charge when the chain is
1269
1283
  * silent is the backend's job (it serves `source: 'default'`), so the client never substitutes
1270
1284
  * a fee of its own, with ONE exception that mirrors the wallet: a `dex-contract` quote answered
1271
- * 403 or 404 means the contract has no fee route yet and resolves `{ source: 'default', '0' }`.
1285
+ * 403 means the contract has no fee route yet and resolves `{ source: 'default', '0' }`. A 404 is
1286
+ * a wrong path, not "no fee route": it resolves `null`, never a default. The request always goes
1287
+ * to `<root>/api/v1/wallet/connect/galachain/api/{channel}/{contract}/{method}/fee`, whether the
1288
+ * client's base URL is the host root or already ends in `/api/v1`.
1272
1289
  * Never throws on transport, so a fee lookup cannot block or break a signing screen.
1273
1290
  *
1274
1291
  * @throws GSwapSDKError NO_SIGNER when constructed without a signer; `SIGNING_FAILED` or
package/dist/index.mjs CHANGED
@@ -1700,6 +1700,20 @@ function isDexFeeMethod(method) {
1700
1700
  function isCurrentContractDexMessage(message, method) {
1701
1701
  return isDexFeeMethod(method) && typeof (message === null || message === void 0 ? void 0 : message["token0"]) === "string" && typeof message["token1"] === "string";
1702
1702
  }
1703
+ /** The wallet-connect proxy's fee route, below the backend root (stage, 2026-11-02: only this prefix exists). */
1704
+ const FEE_ROUTE_PREFIX = "/api/v1/wallet/connect/galachain/api";
1705
+ /**
1706
+ * The backend root a fee quote is built on: `base` without trailing slashes and without a trailing
1707
+ * `/api/v1` (the wallet passes the versioned base, the SDK presets the host root). Idempotent.
1708
+ *
1709
+ * @example
1710
+ * ```typescript
1711
+ * dexBackendRoot('https://swap-backend.stage.defi.ovh.gala.com/api/v1/'); // 'https://swap-backend.stage.defi.ovh.gala.com'
1712
+ * ```
1713
+ */
1714
+ function dexBackendRoot(base) {
1715
+ return base.replace(/(?:\/+|\/api\/v1(?=\/|$))+$/u, "");
1716
+ }
1703
1717
  /**
1704
1718
  * Reduces an EIP-712 approval `message` to the DTO the chain actually receives: drops the signing
1705
1719
  * envelope (`signature`, `prefix`, `types`, `domain`), the `dtoOperation` it was signed to call (a
@@ -1761,7 +1775,7 @@ var DexFees = class {
1761
1775
  constructor(client, signer) {
1762
1776
  this.signer = signer;
1763
1777
  this.requestor = client.httpRequestor ?? fetchRequestor;
1764
- this.baseUrl = client.dexBackendBaseUrl.replace(/\/$/u, "");
1778
+ this.baseUrl = dexBackendRoot(client.dexBackendBaseUrl);
1765
1779
  this.requestTimeoutMs = client.requestTimeoutMs ?? 3e4;
1766
1780
  this.wire = client.wire;
1767
1781
  }
@@ -1773,7 +1787,10 @@ var DexFees = class {
1773
1787
  * malformed body): a transport outcome, not a fee. Deciding what to charge when the chain is
1774
1788
  * silent is the backend's job (it serves `source: 'default'`), so the client never substitutes
1775
1789
  * a fee of its own, with ONE exception that mirrors the wallet: a `dex-contract` quote answered
1776
- * 403 or 404 means the contract has no fee route yet and resolves `{ source: 'default', '0' }`.
1790
+ * 403 means the contract has no fee route yet and resolves `{ source: 'default', '0' }`. A 404 is
1791
+ * a wrong path, not "no fee route": it resolves `null`, never a default. The request always goes
1792
+ * to `<root>/api/v1/wallet/connect/galachain/api/{channel}/{contract}/{method}/fee`, whether the
1793
+ * client's base URL is the host root or already ends in `/api/v1`.
1777
1794
  * Never throws on transport, so a fee lookup cannot block or break a signing screen.
1778
1795
  *
1779
1796
  * @throws GSwapSDKError NO_SIGNER when constructed without a signer; `SIGNING_FAILED` or
@@ -1784,8 +1801,8 @@ var DexFees = class {
1784
1801
  if (this.signer === void 0) throw GSwapSDKError.noSignerError();
1785
1802
  const channel = options.channel ?? "asset";
1786
1803
  const contract = options.contract ?? "dexv3-contract";
1787
- const wrapper = await buildDryRunWrapper(this.signer, callerPublicKey, method, toChainDto(message), void 0, `asset/${contract}`);
1788
- const url = `${this.baseUrl}/wallet/connect/galachain/api/${encodeURIComponent(channel)}/${encodeURIComponent(contract)}/${encodeURIComponent(method)}/fee`;
1804
+ const wrapper = await buildDryRunWrapper(this.signer, callerPublicKey, method, toChainDto(message), void 0, `${channel}/${contract}`);
1805
+ const url = `${this.baseUrl}${FEE_ROUTE_PREFIX}/${encodeURIComponent(channel)}/${encodeURIComponent(contract)}/${encodeURIComponent(method)}/fee`;
1789
1806
  let status;
1790
1807
  let ok;
1791
1808
  let body;
@@ -1805,7 +1822,7 @@ var DexFees = class {
1805
1822
  return null;
1806
1823
  }
1807
1824
  if (!ok) {
1808
- if (contract === "dex-contract" && (status === 403 || status === 404)) return {
1825
+ if (contract === "dex-contract" && status === 403) return {
1809
1826
  source: "default",
1810
1827
  fees: [{ feeInGala: "0" }]
1811
1828
  };
@@ -6674,5 +6691,5 @@ function classifySubmitEnvelope(envelope) {
6674
6691
  }
6675
6692
 
6676
6693
  //#endregion
6677
- export { ALL_FEE_TIERS, AppliedTradeError, Assets, CanonicalSymbols, ChainGateway, DEX_FEE_METHODS, DRY_RUN_METHOD, DRY_RUN_UNIQUE_KEY_PREFIX, DexFees, FEE_TIER, GC_MAX_TICK, GC_MIN_TICK, GSWAP_ENVIRONMENTS, GSWAP_ERROR_CATALOG, GSWAP_ERROR_PHASE_BY_CODE, GSwap, GSwapSDKError, GdexStreamError, GdexStreamService, Leaderboard, MARKET_PRICE_BATCH_LIMIT, MARKET_PRICE_QUERY_BYTES, Market, NOT_QUEUED_FINAL, ONRAMPER_MODES, Onramper, PENDING_SWAPS_STORAGE_KEY, PENDING_SWAP_EXPIRY_MS, PENDING_SWAP_FATES, PENDING_SWAP_PRUNE_REASONS, PRICE_SERIES_TIMEFRAMES, PendingSwapStore, Pools, Positions, Quoting, SHADOW_FAILURE_KINDS, SHADOW_SUBMIT_CODES, SUBMISSION_OUTCOME_UNKNOWN_REASONS, SubmittedTransaction, Swaps, Symbols, TICK_SPACING_BY_FEE, UPDATE_REQUIRED_STATUS, alignTickDown, alignTickDownOrNaN, alignTickUp, alignTickUpOrNaN, assertCanonicalPair, assertCanonicalV2Dto, assertTickRange, buildAddLiquidityDto, buildCollectPositionFeesDto, buildCreatePoolDto, buildDryRunWrapper, buildRemoveLiquidityDto, buildRequestTradeDto, chainErrorKeyOf, classification, classifyFailure, classifyShadowSubmitError, classifyShadowSubmitStatus, classifySubmitEnvelope, confirmAppliedTrade, confirmationStateOf, createOnramper, frameSlot0, getObjectProperty, getStringProperty, gswapErrorTemplates, isConfirmationAborted, isConfirmationTimeout, isCurrentContractDexMessage, isDexFeeMethod, isGSwapError, isGdexLiquidityEvent, isNoMarket, isPreSendError, isProposableTradingSymbol, isRelayableRefusal, isShadowError, isSqrtPriceInRange, isSubmitExecuted, isSubmitQueued, isSubmitRejected, isTickInRange, isUninterpretedAnswer, isUniqueKeyConsumed, isUnprovenAcknowledgement, mayHaveBeenQueued, notSentClassification, orderSymbols, parseTokenClassKey, pendingSwapFateFor, pendingSwapFateOfOutcome, priceBatches, queryTokenOf, rawTokenOf, readOrderedSymbols, readShadowSubmitOutcome, requireUserRef, sqrtPriceToTick, storageAdapterFromChromeStorage, swapRouteFromQuote, tickFromPrice, tickToPrice, tickToSqrtPrice, toChainDto, tradingSymbolOf, userRef, validateFee, validateNumericAmount, validatePriceValues, validateTickRange, validateTickSpacing, validateTokenDecimals, webStorageAdapter };
6694
+ export { ALL_FEE_TIERS, AppliedTradeError, Assets, CanonicalSymbols, ChainGateway, DEX_FEE_METHODS, DRY_RUN_METHOD, DRY_RUN_UNIQUE_KEY_PREFIX, DexFees, FEE_TIER, GC_MAX_TICK, GC_MIN_TICK, GSWAP_ENVIRONMENTS, GSWAP_ERROR_CATALOG, GSWAP_ERROR_PHASE_BY_CODE, GSwap, GSwapSDKError, GdexStreamError, GdexStreamService, Leaderboard, MARKET_PRICE_BATCH_LIMIT, MARKET_PRICE_QUERY_BYTES, Market, NOT_QUEUED_FINAL, ONRAMPER_MODES, Onramper, PENDING_SWAPS_STORAGE_KEY, PENDING_SWAP_EXPIRY_MS, PENDING_SWAP_FATES, PENDING_SWAP_PRUNE_REASONS, PRICE_SERIES_TIMEFRAMES, PendingSwapStore, Pools, Positions, Quoting, SHADOW_FAILURE_KINDS, SHADOW_SUBMIT_CODES, SUBMISSION_OUTCOME_UNKNOWN_REASONS, SubmittedTransaction, Swaps, Symbols, TICK_SPACING_BY_FEE, UPDATE_REQUIRED_STATUS, alignTickDown, alignTickDownOrNaN, alignTickUp, alignTickUpOrNaN, assertCanonicalPair, assertCanonicalV2Dto, assertTickRange, buildAddLiquidityDto, buildCollectPositionFeesDto, buildCreatePoolDto, buildDryRunWrapper, buildRemoveLiquidityDto, buildRequestTradeDto, chainErrorKeyOf, classification, classifyFailure, classifyShadowSubmitError, classifyShadowSubmitStatus, classifySubmitEnvelope, confirmAppliedTrade, confirmationStateOf, createOnramper, dexBackendRoot, frameSlot0, getObjectProperty, getStringProperty, gswapErrorTemplates, isConfirmationAborted, isConfirmationTimeout, isCurrentContractDexMessage, isDexFeeMethod, isGSwapError, isGdexLiquidityEvent, isNoMarket, isPreSendError, isProposableTradingSymbol, isRelayableRefusal, isShadowError, isSqrtPriceInRange, isSubmitExecuted, isSubmitQueued, isSubmitRejected, isTickInRange, isUninterpretedAnswer, isUniqueKeyConsumed, isUnprovenAcknowledgement, mayHaveBeenQueued, notSentClassification, orderSymbols, parseTokenClassKey, pendingSwapFateFor, pendingSwapFateOfOutcome, priceBatches, queryTokenOf, rawTokenOf, readOrderedSymbols, readShadowSubmitOutcome, requireUserRef, sqrtPriceToTick, storageAdapterFromChromeStorage, swapRouteFromQuote, tickFromPrice, tickToPrice, tickToSqrtPrice, toChainDto, tradingSymbolOf, userRef, validateFee, validateNumericAmount, validatePriceValues, validateTickRange, validateTickSpacing, validateTokenDecimals, webStorageAdapter };
6678
6695
  //# sourceMappingURL=index.mjs.map