@gala-chain/gswap-sdk 2.0.0-rc.2 → 2.0.0-rc.4

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 CHANGED
@@ -1569,21 +1569,26 @@ function validateTickSpacing(tickSpacing) {
1569
1569
  /**
1570
1570
  * The GalaChain user reference an owner, user or wallet address names, in the one spelling the
1571
1571
  * gateway and the swap backend accept: `eth|<EIP-55 checksummed digits>` for an Ethereum account
1572
- * (given as `eth|<40 hex>` in any casing, `eth|0x<40 hex>`, `0x<40 hex>` or bare hex), `client|<id>`
1573
- * as written. This is `galaChainUserRef` of `@gala-chain/gala-core-sdk`, the one implementation;
1574
- * only the error is this package's. Every place this SDK puts a user identity on the wire goes
1572
+ * (given as `eth|<40 hex>` in any casing, `0x<40 hex>` or bare hex), `client|<id>` as written.
1573
+ * `eth|0x<hex>` is not an address form. This is `galaChainUserRef` of
1574
+ * `@gala-chain/gala-core-sdk`, the one implementation; only the error for a spelling that is no
1575
+ * address at all is this package's. Every place this SDK puts a user identity on the wire goes
1575
1576
  * through it, so what is signed, sent and compared on the backend (`owner === position.owner`,
1576
1577
  * strict) is always the chain's own spelling.
1577
1578
  *
1578
1579
  * @param value - The identity the caller gave.
1579
1580
  * @param field - The field name reported in the error's `params.field`.
1580
- * @throws GSwapSDKError `INVALID_WALLET_ADDRESS` for anything else, a mixed-case spelling whose
1581
- * casing is not the EIP-55 checksum included (a typo); nothing is signed or sent.
1581
+ * @throws GalaSDKError core's `INVALID_ETH_USER_REF_PREFIX` (passed through as it is: its message
1582
+ * says an `eth|` reference takes the 40 hex digits with no `0x` and names the correct spelling,
1583
+ * `params.expected`) for `eth|0x...`; GSwapSDKError `INVALID_WALLET_ADDRESS` for anything else, a
1584
+ * mixed-case spelling whose casing is not the EIP-55 checksum included (a typo); nothing is
1585
+ * signed or sent.
1582
1586
  */
1583
1587
  function userRef(value, field) {
1584
1588
  try {
1585
1589
  return (0, _gala_chain_gala_core_sdk.galaChainUserRef)(value, field);
1586
- } catch {
1590
+ } catch (cause) {
1591
+ if ((0, _gala_chain_gala_core_sdk.isGalaError)(cause) && cause.code === "INVALID_ETH_USER_REF_PREFIX") throw cause;
1587
1592
  throw new GSwapSDKError("INVALID_WALLET_ADDRESS", {
1588
1593
  field,
1589
1594
  value: String(value)
@@ -1593,7 +1598,8 @@ function userRef(value, field) {
1593
1598
  /**
1594
1599
  * {@link userRef} of an address that must be there.
1595
1600
  *
1596
- * @throws GSwapSDKError `MISSING_WALLET_ADDRESS` (undefined) or `INVALID_WALLET_ADDRESS`.
1601
+ * @throws GSwapSDKError `MISSING_WALLET_ADDRESS` (undefined) or `INVALID_WALLET_ADDRESS`; core's
1602
+ * `INVALID_ETH_USER_REF_PREFIX` for `eth|0x...` (see {@link userRef}).
1597
1603
  */
1598
1604
  function requireUserRef(address, field) {
1599
1605
  if (address === void 0) throw new GSwapSDKError("MISSING_WALLET_ADDRESS", {});
@@ -2147,7 +2153,7 @@ var ChainGateway = class {
2147
2153
  }
2148
2154
  /**
2149
2155
  * Submit a signed v2 DTO as a SHADOW (dark) write: the same route and body as {@link submit},
2150
- * plus `X-Wallet-Address` and `X-Shadow: true`, so defi-backend marks the transaction private
2156
+ * plus `X-Wallet-Address` and `X-Shadow: true`, so the swap backend marks the transaction private
2151
2157
  * before it reaches the contract. The wallet address is required (the backend resolves the
2152
2158
  * owner from it).
2153
2159
  *
@@ -5387,7 +5393,7 @@ function toDecimalString(amount) {
5387
5393
  //#endregion
5388
5394
  //#region src/classes/shadow_submit.ts
5389
5395
  /**
5390
- * Machine-readable codes defi-backend returns in a shadow failure body (`{ code, message }`, with
5396
+ * Machine-readable codes the swap backend returns in a shadow failure body (`{ code, message }`, with
5391
5397
  * no `statusCode`; the HTTP status carries the number).
5392
5398
  *
5393
5399
  * - `SHADOW_UNAVAILABLE` (503): marking failed or infra not configured; retryable. Never fall back
@@ -5546,7 +5552,7 @@ var Swaps = class {
5546
5552
  }
5547
5553
  /**
5548
5554
  * Signs and submits a SHADOW (dark) swap: the same RequestTrade as {@link swap}, relayed with
5549
- * `X-Shadow: true` so defi-backend marks it private before it reaches the contract. Requires a
5555
+ * `X-Shadow: true` so the swap backend marks it private before it reaches the contract. Requires a
5550
5556
  * `walletAddress`. Resolves the normalized outcome instead of throwing on a gateway refusal:
5551
5557
  * `ok: false` carries `unavailable` (retryable), `disabled`, `rejected` (with the gateway's
5552
5558
  * message) or `unknown`. A success carries `queued`, to be confirmed with
@@ -6131,8 +6137,8 @@ function pendingSwapFateOfOutcome(outcome) {
6131
6137
  * from the SDK's classification alone: `forget` for a chain rejection (`rejected`), `forget_quietly`
6132
6138
  * for a key that can never be confirmed (`invalid_input`), `keep` for every other outcome
6133
6139
  * (`unknown`, `not_queued`, `not_sent`, `transient`) and for any value the SDK cannot judge. It
6134
- * accepts an SDK error or a plain-object view of one (see `FailureView`). It replaces the wallet's
6135
- * `pendingSwapActionFor` and frontend_v2's `confirmationStanceOf`.
6140
+ * accepts an SDK error or a plain-object view of one (see `FailureView`). It replaces the
6141
+ * hand-written "forget it or keep it" table an app would otherwise keep.
6136
6142
  *
6137
6143
  * @example
6138
6144
  * ```ts
@@ -6149,7 +6155,7 @@ function pendingSwapFateFor(error) {
6149
6155
 
6150
6156
  //#endregion
6151
6157
  //#region src/classes/pending_swaps.ts
6152
- /** Key the wallet_extension has always used; its storage value is a plain array of entries. */
6158
+ /** Default storage key; the stored value is a plain array of entries. */
6153
6159
  const PENDING_SWAPS_STORAGE_KEY = "pendingSwaps.v1";
6154
6160
  /** Entries older than this are dropped the next time a wallet's swaps are listed. */
6155
6161
  const PENDING_SWAP_EXPIRY_MS = 6048e5;
@@ -6183,17 +6189,16 @@ const PENDING_SWAP_PRUNE_REASONS = [
6183
6189
  * cannot lose each other's write (read-modify-write over an async adapter). Two store instances
6184
6190
  * over the same storage (for example popup and service worker) are not coordinated.
6185
6191
  * - Entries that do not match the expected shape are ignored and dropped on the next write.
6186
- * - Entries expire after seven days (an entry exactly seven days old is expired; frontend_v2
6187
- * kept it for that one millisecond); `list` removes them from storage, which frontend_v2 never
6188
- * did on read.
6192
+ * - Entries expire after seven days (an entry exactly seven days old is expired); `list` removes
6193
+ * them from storage.
6189
6194
  * - An entry whose `uniqueKey` is not a valid apply-results key is terminal, not pending:
6190
6195
  * `confirmAppliedTrade` fails it with `INVALID_UNIQUE_KEY` every time, so a resume loop would
6191
6196
  * retry it forever. `list` prunes it like an expired one, and `remember` refuses to save it;
6192
6197
  * both tell `onPrune` the reason (`PENDING_SWAP_PRUNE_REASONS`).
6193
6198
  * - New entries go to the end (or `insertAt: 'start'`); `list` returns the wallet's entries in
6194
6199
  * stored order (or `listOrder: 'newest-first'`).
6195
- * - The stored shape is wallet_extension's by default; `storageKey`, `darkFlagField`, `insertAt`
6196
- * and `listOrder` reproduce frontend_v2's. JSON key order inside an entry is not preserved.
6200
+ * - `storageKey`, `darkFlagField`, `insertAt` and `listOrder` adapt the stored layout to an
6201
+ * existing storage. JSON key order inside an entry is not preserved.
6197
6202
  *
6198
6203
  * Passing no `storage` yields a store that remembers nothing.
6199
6204
  *
@@ -6403,7 +6408,7 @@ function storageAdapterFromChromeStorage(area) {
6403
6408
  }
6404
6409
  /**
6405
6410
  * A {@link StorageAdapter} over a Web Storage area (`localStorage`, `sessionStorage`), the shape
6406
- * frontend_v2 stores pending swaps in: the value lands under the key as JSON text. A missing key
6411
+ * a web app stores pending swaps in: the value lands under the key as JSON text. A missing key
6407
6412
  * resolves `undefined`. CORRUPT JSON resolves as the raw string, never a rejection (the store
6408
6413
  * reads a value that is not an array as "no entries" and the next write repairs it, whereas a
6409
6414
  * `get` that rejects forever would make every `remember` a no-op). A throwing area (storage blocked