@sodax/sdk 2.0.0-rc.3 → 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.
Files changed (57) hide show
  1. package/README.md +8 -60
  2. package/dist/index.cjs +28 -39
  3. package/dist/index.d.cts +21 -108
  4. package/dist/index.d.ts +21 -108
  5. package/dist/index.mjs +34 -43
  6. package/package.json +22 -22
  7. package/ai-exported/AGENTS.md +0 -99
  8. package/ai-exported/integration/README.md +0 -41
  9. package/ai-exported/integration/ai-rules.md +0 -75
  10. package/ai-exported/integration/architecture.md +0 -533
  11. package/ai-exported/integration/chain-specifics.md +0 -189
  12. package/ai-exported/integration/features/README.md +0 -19
  13. package/ai-exported/integration/features/auxiliary-services.md +0 -189
  14. package/ai-exported/integration/features/bridge.md +0 -136
  15. package/ai-exported/integration/features/dex.md +0 -182
  16. package/ai-exported/integration/features/icx-bnusd-baln.md +0 -181
  17. package/ai-exported/integration/features/money-market.md +0 -198
  18. package/ai-exported/integration/features/staking.md +0 -166
  19. package/ai-exported/integration/features/swap.md +0 -207
  20. package/ai-exported/integration/quickstart.md +0 -213
  21. package/ai-exported/integration/recipes/README.md +0 -21
  22. package/ai-exported/integration/recipes/backend-server-init.md +0 -69
  23. package/ai-exported/integration/recipes/chain-key-narrowing.md +0 -65
  24. package/ai-exported/integration/recipes/gas-estimation.md +0 -33
  25. package/ai-exported/integration/recipes/initialize-sodax.md +0 -78
  26. package/ai-exported/integration/recipes/raw-tx-flow.md +0 -71
  27. package/ai-exported/integration/recipes/result-and-errors.md +0 -104
  28. package/ai-exported/integration/recipes/signed-tx-flow.md +0 -46
  29. package/ai-exported/integration/recipes/testing.md +0 -101
  30. package/ai-exported/integration/reference/README.md +0 -18
  31. package/ai-exported/integration/reference/chain-keys.md +0 -67
  32. package/ai-exported/integration/reference/error-codes.md +0 -165
  33. package/ai-exported/integration/reference/glossary.md +0 -32
  34. package/ai-exported/integration/reference/public-api.md +0 -138
  35. package/ai-exported/integration/reference/wallet-providers.md +0 -62
  36. package/ai-exported/migration/README.md +0 -58
  37. package/ai-exported/migration/ai-rules.md +0 -80
  38. package/ai-exported/migration/breaking-changes/architecture.md +0 -344
  39. package/ai-exported/migration/breaking-changes/result-and-errors.md +0 -363
  40. package/ai-exported/migration/breaking-changes/type-system.md +0 -341
  41. package/ai-exported/migration/checklist.md +0 -67
  42. package/ai-exported/migration/features/README.md +0 -35
  43. package/ai-exported/migration/features/auxiliary-services.md +0 -156
  44. package/ai-exported/migration/features/bridge.md +0 -128
  45. package/ai-exported/migration/features/dex.md +0 -143
  46. package/ai-exported/migration/features/icx-bnusd-baln.md +0 -151
  47. package/ai-exported/migration/features/money-market.md +0 -214
  48. package/ai-exported/migration/features/staking.md +0 -138
  49. package/ai-exported/migration/features/swap.md +0 -198
  50. package/ai-exported/migration/recipes.md +0 -350
  51. package/ai-exported/migration/reference/README.md +0 -18
  52. package/ai-exported/migration/reference/deleted-exports.md +0 -127
  53. package/ai-exported/migration/reference/error-code-crosswalk.md +0 -104
  54. package/ai-exported/migration/reference/return-shapes.md +0 -49
  55. package/ai-exported/migration/reference/sodax-config.md +0 -145
  56. package/dist/index.cjs.map +0 -1
  57. package/dist/index.mjs.map +0 -1
@@ -1,145 +0,0 @@
1
- # `SodaxConfig` constructor reshape
2
-
3
- The v2 `Sodax` constructor accepts a `DeepPartial<SodaxConfig>`. Several config fields renamed, moved, or were added between v1 and v2; if your project passed a custom config, check these.
4
-
5
- ## v2 `SodaxConfig` shape (source of truth)
6
-
7
- Defined in `@sodax/types` (`packages/types/src/sodax-config/sodax-config.ts`):
8
-
9
- ```ts
10
- type SodaxConfig = {
11
- fee: PartnerFee | undefined; // global partner fee (overridable per-feature)
12
- chains: Record<SpokeChainKey, SpokeChainConfig>; // per-spoke-chain config (rpcUrl + tx polling + chain-specific shape)
13
- swaps: SwapsConfig; // supported swap tokens per chain
14
- moneyMarket: MoneyMarketConfig; // money market service config
15
- bridge: BridgeConfig; // bridge partner-fee override
16
- dex: DexConfig; // DEX service config
17
- hub: HubConfig; // hub-chain (Sonic) provider config
18
- api: ApiConfig; // backend API endpoint
19
- solver: SolverConfig; // intent solver endpoint + contracts
20
- relay: RelayConfig; // intent-relay endpoint
21
- };
22
- ```
23
-
24
- A matching default `sodaxConfig` const is exported from the same module — `new Sodax()` deep-merges your `DeepPartial<SodaxConfig>` over it.
25
-
26
- ## v1 shape (for reference)
27
-
28
- ```ts
29
- // v1 — packages/sdk/src/shared/entities/Sodax.ts
30
- type SodaxConfig = {
31
- swaps?: SolverConfigParams; // { intentsContract, solverApiEndpoint, protocolIntentsContract?, partnerFee? }
32
- moneyMarket?: MoneyMarketConfigParams;
33
- migration?: MigrationServiceConfig;
34
- bridge?: BridgeServiceConfig;
35
- dex?: DexServiceConfig;
36
- hubProviderConfig?: EvmHubProviderConfig; // { hubRpcUrl, chainConfig }
37
- relayerApiEndpoint?: HttpUrl; // single URL string
38
- backendApiConfig?: BackendApiConfig;
39
- partners?: PartnerServiceConfig;
40
- sharedConfig?: typeof defaultSharedConfig;
41
- };
42
- ```
43
-
44
- All v1 fields were **optional**. v1 had **no** top-level `rpcConfig` on `SodaxConfig` — RPC URLs were a separate prop accepted by the framework-layer `SodaxProvider` (alongside the `config` prop carrying `SodaxConfig`); the `Sodax` class constructor itself never received `rpcConfig`.
45
-
46
- ## v1 → v2 field map
47
-
48
- | v1 location | v2 location | Notes |
49
- |---|---|---|
50
- | `SodaxConfig.swaps` (`SolverConfigParams` — `{ intentsContract, solverApiEndpoint, protocolIntentsContract?, partnerFee? }`) | **Split into two:** `SodaxConfig.solver: SolverConfig` (`{ intentsContract, solverApiEndpoint, protocolIntentsContract }`) and `SodaxConfig.swaps: SwapsConfig` (supported tokens per chain — new in v2). | v1 partner-fee inside `SolverConfigParams` moves to the global `SodaxConfig.fee` slot or per-feature configs. |
51
- | `SodaxConfig.hubProviderConfig` (`EvmHubProviderConfig` — `{ hubRpcUrl, chainConfig }`) | **`SodaxConfig.hub`** (`HubConfig` — full hub addresses + native token + bnUSD + polling + RPC URL). | Field renamed `hubProviderConfig` → `hub`. Shape expanded: v1 just had RPC URL + chain config; v2 ships the full hub-contract address map. |
52
- | `SodaxConfig.moneyMarket` (`MoneyMarketConfigParams`) | `SodaxConfig.moneyMarket` (`MoneyMarketConfig` — required, shape changed). | Reshape, see `@sodax/types/src/common/common.ts` MoneyMarketConfig. |
53
- | `SodaxConfig.bridge` (`BridgeServiceConfig`) | `SodaxConfig.bridge` (`BridgeConfig` — `{ partnerFee }`). | Reshape; smaller. |
54
- | `SodaxConfig.dex` (`DexServiceConfig`) | `SodaxConfig.dex` (`DexConfig`). | Reshape. |
55
- | `SodaxConfig.relayerApiEndpoint: HttpUrl` (string) | **`SodaxConfig.relay`** (`RelayConfig` — object with relayer URL + chain-id map). | Renamed + reshaped from string to object. |
56
- | `SodaxConfig.backendApiConfig` (`BackendApiConfig`) | **`SodaxConfig.api`** (`ApiConfig`). | Renamed. |
57
- | (Separate `rpcConfig` prop on the framework-layer SodaxProvider, NOT a `SodaxConfig` field) | **`SodaxConfig.chains`** (`Record<SpokeChainKey, SpokeChainConfig>`). | v2 absorbs RPC URLs + polling + chain-specific extras into the `SodaxConfig.chains` mapped type. v1's separate `rpcConfig` provider prop is gone. The standalone `RpcConfig` type still ships from `@sodax/types` for utility use (e.g. the demo's `providers.tsx` declares a local `RpcConfig` then maps values into `chains`), but it is not a `SodaxConfig` field. |
58
- | `SodaxConfig.migration` (`MigrationServiceConfig`) | **Removed.** Migration service runs with hard-coded defaults. | No replacement on `SodaxConfig`. v2 surfaces customization via per-method params on `sodax.migration.*`, not constructor config — see [`../features/icx-bnusd-baln.md`](../features/icx-bnusd-baln.md). |
59
- | `SodaxConfig.partners` (`PartnerServiceConfig`) | **Removed.** Partner service runs with defaults. | Per-claim partner-fee config now flows via call-level params on `sodax.partners.*` methods. |
60
- | `SodaxConfig.sharedConfig` (`typeof defaultSharedConfig`) | **Removed.** | Absorbed into `ConfigService` + per-chain `SpokeChainConfig`. Override individual chains via `SodaxConfig.chains[key]`. |
61
- | (none in v1) | **`SodaxConfig.fee: PartnerFee \| undefined`** (new). | Global partner-fee, applies to all features unless overridden by feature-level config (`bridge.partnerFee`, money market, etc.). |
62
- | (v1 had no top-level `configService` injection slot on `SodaxConfig` — `ConfigService` was always constructed internally from `backendApiConfig` + `sharedConfig`.) | Same — `ConfigService` is internal. v2 does **not** expose a typed slot to inject a custom `IConfigApi` either. To swap the backend in tests, point `SodaxConfig.api.baseURL` at a mock server. | See Pitfall below. |
63
-
64
- Migration:
65
-
66
- ```diff
67
- - // v1 — typical SodaxConfig literal
68
- - const sodaxConfig = {
69
- - hubProviderConfig: { hubRpcUrl: 'https://…', chainConfig: getHubChainConfig() },
70
- - moneyMarket: getMoneyMarketConfig(hubChainId),
71
- - swaps: {
72
- - intentsContract: '0x…',
73
- - solverApiEndpoint: 'https://…',
74
- - protocolIntentsContract: '0x…',
75
- - partnerFee: { address: '0x…', percentage: 10 },
76
- - },
77
- - relayerApiEndpoint: 'https://relay.example.com',
78
- - } satisfies SodaxConfig;
79
- - // RPC URLs were passed as a SEPARATE prop on the framework-layer SodaxProvider
80
- - // (alongside the sodaxConfig). The Sodax constructor itself never saw rpcConfig.
81
-
82
- + // v2 — DeepPartial<SodaxConfig> passed directly to new Sodax(...)
83
- + const sodax = new Sodax({
84
- + hub: { /* HubConfig — usually omit, default ships full hub addresses */ },
85
- + solver: {
86
- + intentsContract: '0x…',
87
- + solverApiEndpoint: 'https://…',
88
- + protocolIntentsContract: '0x…',
89
- + },
90
- + swaps: {
91
- + supportedTokens: { /* per-chain table */ },
92
- + },
93
- + relay: { /* RelayConfig — relayer URL + chain-id map */ },
94
- + fee: { address: '0x…', percentage: 10 }, // global partner fee (moved out of swaps)
95
- + chains: {
96
- + [ChainKeys.SONIC_MAINNET]: { rpcUrl: 'https://…' },
97
- + [ChainKeys.ARBITRUM_MAINNET]: { rpcUrl: 'https://…' },
98
- + [ChainKeys.BITCOIN_MAINNET]: { /* BitcoinSpokeChainConfig shape */ },
99
- + // …
100
- + },
101
- + });
102
- + await sodax.config.initialize();
103
- ```
104
-
105
- ## Per-chain `SpokeChainConfig` shape
106
-
107
- `SodaxConfig.chains` is keyed by `SpokeChainKey`; each entry's value type varies by chain family. The user-overridable surface (`rpcUrl`, polling config, chain-specific extras) is the same set of fields `RpcConfig` covers in v1, but nested inside `SpokeChainConfig` rather than flat. Inspect the type at:
108
-
109
- - `packages/types/src/chains/chains.ts` — `SpokeChainConfig` discriminated union
110
- - `packages/types/src/common/common.ts` — `BitcoinRpcConfig`, `StellarRpcConfig`, `InjectiveRpcConfig` (used inside the EVM-non-EVM branches)
111
-
112
- See [`../breaking-changes/type-system.md`](../breaking-changes/type-system.md) § 5 for the chain-family-specific entry shapes.
113
-
114
- ### Pitfall
115
-
116
- If you previously injected a custom `ConfigService` for testing (a v1 escape hatch), v2 doesn't accept one at the top level — and unlike what earlier doc versions claimed, **v2 also doesn't expose a typed slot to inject a custom `IConfigApi`**. The realistic options:
117
-
118
- - Point `SodaxConfig.api.baseURL` at a local mock backend server.
119
- - Construct your own `BackendApiService`-compatible object in your app/test bootstrap and swap it in where you control the `Sodax` instance.
120
-
121
- The `SodaxConfig.api` field is `ApiConfig` (`{ baseURL, timeout, headers }`) — there is no `api.api` sub-field for IConfigApi injection.
122
-
123
- ### Pitfall — module-scope reads
124
-
125
- If your code reads hub addresses or default configs **before** the `Sodax` instance exists (module-scope constants), use the re-exported defaults from `@sodax/types` (also flow through `@sodax/sdk` since it re-exports the entire types surface):
126
-
127
- ```ts
128
- import { hubConfig, sodaxConfig } from '@sodax/sdk';
129
-
130
- const HUB_WALLET = hubConfig.addresses.hubWallet; // module-scope OK
131
- const DEFAULT_RELAY = sodaxConfig.relay; // module-scope OK
132
- ```
133
-
134
- `hubConfig` / `sodaxConfig` are the **packaged defaults** — the same values `ConfigService` falls back to if the backend is unreachable. Once you have a `Sodax` instance, prefer `sodax.config.getHubChainConfig()` / `sodax.config.*` so backend-driven updates take effect.
135
-
136
- ---
137
-
138
-
139
- ## Cross-references
140
-
141
- - [`README.md`](README.md) — migration reference index.
142
- - [`../README.md`](../README.md) — migration overview.
143
- - [`../checklist.md`](../checklist.md) — top-level migration checklist.
144
- - [`../breaking-changes/type-system.md`](../breaking-changes/type-system.md) § 5 — per-chain config entry shapes.
145
- - [`deleted-exports.md`](deleted-exports.md) — `getHubChainConfig()` and other deleted symbols.