@sodax/types 2.2.0-rc.5 → 2.2.0-rc.7

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/README.md CHANGED
@@ -12,12 +12,18 @@ pnpm add @sodax/types
12
12
 
13
13
  ## Usage
14
14
 
15
+ > SDK consumers should import these from `@sodax/sdk` (`import { ... } from '@sodax/sdk'`), which re-exports `@sodax/types`; reserve a direct `@sodax/types` install for standalone or type-only use.
16
+
15
17
  Import shared types, constants, configuration, and helpers from the root package:
16
18
 
17
19
  ```typescript
18
20
  import {
19
21
  ChainKeys,
20
22
  CONFIG_VERSION,
23
+ SDK_VERSION,
24
+ configVersionFor,
25
+ formatConfigVersion,
26
+ parseConfigVersion,
21
27
  getEvmChainKeyByChainId,
22
28
  sodaxConfig,
23
29
  supportedTokensByChain,
@@ -54,8 +60,10 @@ The package currently exposes only the root export (`@sodax/types`) and the DEX
54
60
  | Chains and tokens | `ChainKeys`, `SpokeChainKey`, `ChainType`, `baseChainInfo`, `spokeChainConfig` [^cfg], `supportedTokensByChain` |
55
61
  | Wallet providers | `WalletAddressProvider`, `ICoreWallet`, `IWalletProvider`, `GetWalletProviderType` |
56
62
  | Chain transaction types | `EvmRawTransaction`, `BitcoinRawTransaction`, `SolanaRawTransaction`, `StellarRawTransaction`, `SuiRawTransaction`, `IconRawTransaction`, `InjectiveRawTransaction`, `NearRawTransaction`, `StacksRawTransaction` |
57
- | Backend API contracts | `IConfigApi`, `GetAllConfigApiResponse`, `SubmitSwapTxRequest`, `SubmitSwapTxResponse`, `SubmitSwapTxStatusResponse` |
63
+ | Backend API contracts | `IConfigApiV1`, `IConfigApiV2`, `GetAllConfigApiResponse`, `SubmitTxRequestV2`, `SubmitTxResponseV2`, `SubmitTxStatusResponseV2`, `SubmitIntentRequestV2`, `SubmitIntentResponseV2` |
58
64
  | Product configuration | `sodaxConfig` [^cfg], `bridgeConfig`, `swapsConfig`, `moneyMarketConfig`, `dexConfig`, `concentratedLiquidityConfig` |
65
+ | Leverage yield | leverage-yield param and response types (`leverageYield`) |
66
+ | Hooks | shared hook types (`hooks`) |
59
67
  | Utilities | `DeepPartial`, `getChainType`, `getEvmChainKeyByChainId`, chain guard helpers, bnUSD token helpers |
60
68
 
61
69
  [^cfg]: `spokeChainConfig` and `sodaxConfig` (and the related `hubConfig`, etc.) are **packaged-default snapshots** frozen at SDK release time. They are safe to import at module scope, but **direct imports do NOT reflect overrides passed to `new Sodax(config)` or dynamic config loaded by `sodax.config.initialize()`** — those flow into the `ConfigService` only. Once a `Sodax` instance exists, prefer the instance-scope readers: `sodax.config.spokeChainConfig`, `sodax.config.getChainConfig(chainKey)`, `sodax.config.sodaxConfig`, `sodax.config.getHubChainConfig()`, etc. Mixing a static import with a custom-configured `Sodax` instance will silently fall back to defaults for any chain you customized.
@@ -122,3 +130,43 @@ type AddressForChain<C extends SpokeChainKey> = GetAddressType<C>;
122
130
  ```
123
131
 
124
132
  `GetTokenAddressType<C>` is the token-address counterpart: `Address` for EVM chains, `string` everywhere else.
133
+
134
+ ## Config version
135
+
136
+ `CONFIG_VERSION` identifies the SDK release a SODAX config belongs to. The backend does not maintain
137
+ its own number — it serves this constant from the `@sodax/sdk` release it has installed — so comparing
138
+ it against `GetAllConfigResponseV2.version` answers *do the SDK and the API run the same release?*
139
+
140
+ It is **derived from this package's version**, never hand-edited:
141
+
142
+ ```
143
+ CONFIG_VERSION = major * 1_000_000 + minor * 10_000 + patch * 100 + (rc ?? 99)
144
+ ```
145
+
146
+ The `99` rc slot is the sentinel for a stable release, so it outranks every rc of the same triple.
147
+ Each field is capped — major `1..99`, minor and patch `0..99`, rc `0..98` — because one past any
148
+ boundary the packing would carry into the next field and collide with a different release.
149
+
150
+ | version | `CONFIG_VERSION` |
151
+ | --- | --- |
152
+ | `2.2.0-rc.6` | `2_020_006` |
153
+ | `2.2.0` | `2_020_099` |
154
+ | `2.2.1` | `2_020_199` |
155
+ | `2.10.0` | `2_100_099` |
156
+
157
+ Read it back rather than unpacking it by hand. All three helpers are total — they return `null` for
158
+ anything outside the encoding, including the small counter values an API on an older SDK still serves:
159
+
160
+ ```typescript
161
+ import { CONFIG_VERSION, SDK_VERSION, configVersionFor, formatConfigVersion, parseConfigVersion } from '@sodax/types';
162
+
163
+ SDK_VERSION; // '2.2.0-rc.6' — computed from CONFIG_VERSION, never written
164
+ formatConfigVersion(2_020_099); // '2.2.0'
165
+ parseConfigVersion(2_020_006); // { major: 2, minor: 2, patch: 0, rc: 6 }
166
+ configVersionFor('2.2.0'); // 2_020_099
167
+ configVersionFor('2.3.0-beta.1'); // null — outside the grammar
168
+ parseConfigVersion(235); // null — a legacy counter value, not a config version
169
+ ```
170
+
171
+ `rc` is `null` for a stable release; `rc: 0` is legal, so test it against `null` rather than for
172
+ truthiness.
@@ -20,9 +20,10 @@
20
20
  // - `Hex` / `Address` / `Hash` / `SpokeChainKey` are plain `string` everywhere.
21
21
  // - The unsigned `tx` is typed as the SDK domain union `RawTxReturnType`. It
22
22
  // travels as pure JSON (bigints stringified; Injective byte arrays as
23
- // `{ "0": N, … }` index objects), and the SDK client's response schema
24
- // (`@sodax/sdk` `rawTxSchemas`) rebuilds the domain shape (`bigint`,
25
- // `Uint8Array`) on parse — the inverse of the backend's `stringifyBigInts`.
23
+ // `{ "0": N, … }` index objects), and the wire clients' response schemas
24
+ // (the `rawTxSchemas` module in `@sodax/swaps-api` / `@sodax/bridge-api`)
25
+ // rebuild the domain shape (`bigint`, `Uint8Array`) on parse — the inverse
26
+ // of the backend's `stringifyBigInts`.
26
27
  // - The remaining chain-specific opaque payloads (gas estimate, raw relay
27
28
  // `result`) stay `unknown` because their shape varies by chain family.
28
29
  //