@sodax/types 2.0.0-rc.2 → 2.0.0-rc.21
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 +4 -2
- package/dist/backend/backendApiV1.d.ts +28 -0
- package/dist/backend/backendApiV1.js +1 -0
- package/dist/backend/backendApiV2.d.ts +678 -0
- package/dist/backend/backendApiV2.js +38 -0
- package/dist/backend/index.d.ts +2 -2
- package/dist/backend/index.js +2 -2
- package/dist/bitcoin/bitcoin.d.ts +18 -1
- package/dist/bitcoin/bitcoin.js +13 -1
- package/dist/bitcoin/index.d.ts +0 -1
- package/dist/bitcoin/index.js +0 -1
- package/dist/chains/chain-keys.d.ts +3 -3
- package/dist/chains/chain-keys.js +1 -1
- package/dist/chains/chains.d.ts +390 -13
- package/dist/chains/chains.js +76 -5
- package/dist/chains/index.d.ts +0 -1
- package/dist/chains/index.js +0 -1
- package/dist/chains/tokens.d.ts +530 -7
- package/dist/chains/tokens.js +241 -3
- package/dist/common/common.d.ts +15 -8
- package/dist/common/common.js +0 -1
- package/dist/common/constants.d.ts +19 -2
- package/dist/common/constants.js +0 -1
- package/dist/common/index.d.ts +0 -1
- package/dist/common/index.js +0 -1
- package/dist/dex/dex.d.ts +4 -2
- package/dist/dex/dex.js +0 -1
- package/dist/dex/index.d.ts +0 -1
- package/dist/dex/index.js +0 -1
- package/dist/dex/pancakeswap-infinity.d.ts +0 -1
- package/dist/dex/pancakeswap-infinity.js +0 -1
- package/dist/evm/evm.d.ts +0 -1
- package/dist/evm/evm.js +0 -1
- package/dist/evm/index.d.ts +0 -1
- package/dist/evm/index.js +0 -1
- package/dist/hooks/hooks.d.ts +42 -0
- package/dist/hooks/hooks.js +44 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.js +1 -0
- package/dist/icon/icon.d.ts +0 -1
- package/dist/icon/icon.js +0 -1
- package/dist/icon/index.d.ts +0 -1
- package/dist/icon/index.js +0 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +3 -2
- package/dist/injective/index.d.ts +0 -1
- package/dist/injective/index.js +0 -1
- package/dist/injective/injective.d.ts +4 -1
- package/dist/injective/injective.js +0 -1
- package/dist/leverageYield/index.d.ts +1 -0
- package/dist/leverageYield/index.js +1 -0
- package/dist/leverageYield/leverageYield.d.ts +152 -0
- package/dist/leverageYield/leverageYield.js +51 -0
- package/dist/moneyMarket/index.d.ts +0 -1
- package/dist/moneyMarket/index.js +0 -1
- package/dist/moneyMarket/moneyMarket.d.ts +270 -5
- package/dist/moneyMarket/moneyMarket.js +15 -1
- package/dist/near/index.d.ts +0 -1
- package/dist/near/index.js +0 -1
- package/dist/near/near-api-js.d.ts +0 -1
- package/dist/near/near-api-js.js +0 -1
- package/dist/near/near.d.ts +5 -2
- package/dist/near/near.js +0 -1
- package/dist/shared/analytics.d.ts +119 -0
- package/dist/shared/analytics.js +1 -0
- package/dist/shared/features.d.ts +9 -0
- package/dist/shared/features.js +1 -0
- package/dist/shared/index.d.ts +3 -1
- package/dist/shared/index.js +3 -1
- package/dist/shared/logger.d.ts +27 -0
- package/dist/shared/logger.js +1 -0
- package/dist/shared/shared.d.ts +21 -1
- package/dist/shared/shared.js +0 -1
- package/dist/sodax-config/index.d.ts +0 -1
- package/dist/sodax-config/index.js +0 -1
- package/dist/sodax-config/sodax-config.d.ts +729 -77
- package/dist/sodax-config/sodax-config.js +3 -5
- package/dist/solana/index.d.ts +0 -1
- package/dist/solana/index.js +0 -1
- package/dist/solana/solana-web3.d.ts +0 -1
- package/dist/solana/solana-web3.js +0 -1
- package/dist/solana/solana.d.ts +2 -1
- package/dist/solana/solana.js +0 -1
- package/dist/stacks/index.d.ts +0 -1
- package/dist/stacks/index.js +0 -1
- package/dist/stacks/stacks.d.ts +2 -1
- package/dist/stacks/stacks.js +0 -1
- package/dist/stellar/index.d.ts +0 -1
- package/dist/stellar/index.js +0 -1
- package/dist/stellar/stellar.d.ts +4 -1
- package/dist/stellar/stellar.js +0 -1
- package/dist/sui/index.d.ts +0 -1
- package/dist/sui/index.js +0 -1
- package/dist/sui/sui.d.ts +3 -3
- package/dist/sui/sui.js +0 -1
- package/dist/swap/index.d.ts +0 -1
- package/dist/swap/index.js +0 -1
- package/dist/swap/swap.d.ts +466 -107
- package/dist/swap/swap.js +75 -14
- package/dist/utils/deep-partial.d.ts +0 -1
- package/dist/utils/deep-partial.js +0 -1
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/utils.d.ts +0 -1
- package/dist/utils/utils.js +0 -1
- package/dist/wallet/index.d.ts +0 -1
- package/dist/wallet/index.js +0 -1
- package/dist/wallet/providers.d.ts +0 -1
- package/dist/wallet/providers.js +0 -1
- package/dist/wallet/wallet.d.ts +0 -1
- package/dist/wallet/wallet.js +0 -1
- package/package.json +28 -11
- package/dist/backend/backendApi.d.ts +0 -75
- package/dist/backend/backendApi.d.ts.map +0 -1
- package/dist/backend/backendApi.js +0 -2
- package/dist/backend/backendApi.js.map +0 -1
- package/dist/backend/index.d.ts.map +0 -1
- package/dist/backend/index.js.map +0 -1
- package/dist/bitcoin/bitcoin.d.ts.map +0 -1
- package/dist/bitcoin/bitcoin.js.map +0 -1
- package/dist/bitcoin/index.d.ts.map +0 -1
- package/dist/bitcoin/index.js.map +0 -1
- package/dist/chains/chain-keys.d.ts.map +0 -1
- package/dist/chains/chain-keys.js.map +0 -1
- package/dist/chains/chains.d.ts.map +0 -1
- package/dist/chains/chains.js.map +0 -1
- package/dist/chains/index.d.ts.map +0 -1
- package/dist/chains/index.js.map +0 -1
- package/dist/chains/tokens.d.ts.map +0 -1
- package/dist/chains/tokens.js.map +0 -1
- package/dist/common/common.d.ts.map +0 -1
- package/dist/common/common.js.map +0 -1
- package/dist/common/constants.d.ts.map +0 -1
- package/dist/common/constants.js.map +0 -1
- package/dist/common/index.d.ts.map +0 -1
- package/dist/common/index.js.map +0 -1
- package/dist/dex/dex.d.ts.map +0 -1
- package/dist/dex/dex.js.map +0 -1
- package/dist/dex/index.d.ts.map +0 -1
- package/dist/dex/index.js.map +0 -1
- package/dist/dex/pancakeswap-infinity.d.ts.map +0 -1
- package/dist/dex/pancakeswap-infinity.js.map +0 -1
- package/dist/evm/evm.d.ts.map +0 -1
- package/dist/evm/evm.js.map +0 -1
- package/dist/evm/index.d.ts.map +0 -1
- package/dist/evm/index.js.map +0 -1
- package/dist/icon/icon.d.ts.map +0 -1
- package/dist/icon/icon.js.map +0 -1
- package/dist/icon/index.d.ts.map +0 -1
- package/dist/icon/index.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/injective/index.d.ts.map +0 -1
- package/dist/injective/index.js.map +0 -1
- package/dist/injective/injective.d.ts.map +0 -1
- package/dist/injective/injective.js.map +0 -1
- package/dist/moneyMarket/index.d.ts.map +0 -1
- package/dist/moneyMarket/index.js.map +0 -1
- package/dist/moneyMarket/moneyMarket.d.ts.map +0 -1
- package/dist/moneyMarket/moneyMarket.js.map +0 -1
- package/dist/near/index.d.ts.map +0 -1
- package/dist/near/index.js.map +0 -1
- package/dist/near/near-api-js.d.ts.map +0 -1
- package/dist/near/near-api-js.js.map +0 -1
- package/dist/near/near.d.ts.map +0 -1
- package/dist/near/near.js.map +0 -1
- package/dist/shared/index.d.ts.map +0 -1
- package/dist/shared/index.js.map +0 -1
- package/dist/shared/shared.d.ts.map +0 -1
- package/dist/shared/shared.js.map +0 -1
- package/dist/sodax-config/index.d.ts.map +0 -1
- package/dist/sodax-config/index.js.map +0 -1
- package/dist/sodax-config/sodax-config.d.ts.map +0 -1
- package/dist/sodax-config/sodax-config.js.map +0 -1
- package/dist/solana/index.d.ts.map +0 -1
- package/dist/solana/index.js.map +0 -1
- package/dist/solana/solana-web3.d.ts.map +0 -1
- package/dist/solana/solana-web3.js.map +0 -1
- package/dist/solana/solana.d.ts.map +0 -1
- package/dist/solana/solana.js.map +0 -1
- package/dist/stacks/index.d.ts.map +0 -1
- package/dist/stacks/index.js.map +0 -1
- package/dist/stacks/stacks.d.ts.map +0 -1
- package/dist/stacks/stacks.js.map +0 -1
- package/dist/stellar/index.d.ts.map +0 -1
- package/dist/stellar/index.js.map +0 -1
- package/dist/stellar/stellar.d.ts.map +0 -1
- package/dist/stellar/stellar.js.map +0 -1
- package/dist/sui/index.d.ts.map +0 -1
- package/dist/sui/index.js.map +0 -1
- package/dist/sui/sui.d.ts.map +0 -1
- package/dist/sui/sui.js.map +0 -1
- package/dist/swap/index.d.ts.map +0 -1
- package/dist/swap/index.js.map +0 -1
- package/dist/swap/swap.d.ts.map +0 -1
- package/dist/swap/swap.js.map +0 -1
- package/dist/utils/deep-partial.d.ts.map +0 -1
- package/dist/utils/deep-partial.js.map +0 -1
- package/dist/utils/index.d.ts.map +0 -1
- package/dist/utils/index.js.map +0 -1
- package/dist/utils/utils.d.ts.map +0 -1
- package/dist/utils/utils.js.map +0 -1
- package/dist/wallet/index.d.ts.map +0 -1
- package/dist/wallet/index.js.map +0 -1
- package/dist/wallet/providers.d.ts.map +0 -1
- package/dist/wallet/providers.js.map +0 -1
- package/dist/wallet/wallet.d.ts.map +0 -1
- package/dist/wallet/wallet.js.map +0 -1
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { SodaxFeature } from './features.js';
|
|
2
|
+
/**
|
|
3
|
+
* Analytics for the SDK — structured, opt-in tracking of user-action flows.
|
|
4
|
+
*
|
|
5
|
+
* This is deliberately separate from {@link SodaxLogger}. The logger is a developer-facing
|
|
6
|
+
* diagnostics sink that is **on by default** (`console`) and takes free-form messages. Analytics
|
|
7
|
+
* is a product-facing event stream that is **off by default**: the SDK emits nothing — and never
|
|
8
|
+
* even builds an event payload — unless a consumer explicitly enables it via
|
|
9
|
+
* `new Sodax({ analytics })`. This keeps feature code paths free of analytics overhead when it is
|
|
10
|
+
* not in use.
|
|
11
|
+
*
|
|
12
|
+
* Enable and shape it through {@link AnalyticsOption} on the `Sodax` constructor:
|
|
13
|
+
* - omitted / `false` — disabled (default).
|
|
14
|
+
* - an {@link AnalyticsConfig} — forward events to your own product-analytics backend, optionally
|
|
15
|
+
* scoped by feature and detail level.
|
|
16
|
+
*/
|
|
17
|
+
/**
|
|
18
|
+
* Lifecycle phase of a tracked feature action flow. Every event marks where in a feature's action
|
|
19
|
+
* flow it was emitted, so a sink can pair a `start` with its terminal `success` / `failure`
|
|
20
|
+
* (e.g. to measure duration or drop-off).
|
|
21
|
+
*/
|
|
22
|
+
export type AnalyticsEventPhase = 'start' | 'success' | 'failure';
|
|
23
|
+
/**
|
|
24
|
+
* Detail level an event belongs to. Consumers choose how much the SDK tracks:
|
|
25
|
+
* - `basic` — coarse action flow (feature, action, phase) only.
|
|
26
|
+
* - `detailed` — adds richer `data` payloads (amounts, tokens, chain keys, …).
|
|
27
|
+
*
|
|
28
|
+
* The SDK only builds and emits a `detailed` event when the configured level is `detailed`, so
|
|
29
|
+
* heavier payloads are never constructed when a consumer stays on `basic`.
|
|
30
|
+
*/
|
|
31
|
+
export type AnalyticsDetailLevel = 'basic' | 'detailed';
|
|
32
|
+
/**
|
|
33
|
+
* A single user-action analytics event emitted by the SDK at a feature action-flow boundary.
|
|
34
|
+
*
|
|
35
|
+
* `feature` + `action` + `phase` form the stable identity of an event — the same `(feature,
|
|
36
|
+
* action)` tagging the error layer already standardizes — so events line up with errors in a
|
|
37
|
+
* downstream sink. `data` is an optional structured payload whose richness depends on the
|
|
38
|
+
* configured {@link AnalyticsDetailLevel}.
|
|
39
|
+
*/
|
|
40
|
+
export interface AnalyticsEvent {
|
|
41
|
+
/** The high-level feature the action belongs to. */
|
|
42
|
+
feature: SodaxFeature;
|
|
43
|
+
/** The feature-level operation in flight, e.g. `'supply'`, `'createIntent'`, `'stake'`. */
|
|
44
|
+
action: string;
|
|
45
|
+
/** Where in the action flow this event was emitted. */
|
|
46
|
+
phase: AnalyticsEventPhase;
|
|
47
|
+
/** The detail level this event belongs to; gated against the configured level. */
|
|
48
|
+
level: AnalyticsDetailLevel;
|
|
49
|
+
/** Optional structured payload. Present mainly on `detailed` events. */
|
|
50
|
+
data?: Record<string, unknown>;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Consumer-supplied tracker: the SDK calls it once per emitted event, and the consumer forwards the
|
|
54
|
+
* event to their product-analytics backend (Segment, Amplitude, PostHog, a custom collector, …),
|
|
55
|
+
* e.g. `tracker: (event) => amplitude.track(event.action, event.data)`.
|
|
56
|
+
*
|
|
57
|
+
* It must be cheap and non-throwing — the SDK treats it as fire-and-forget, does not await it, and
|
|
58
|
+
* swallows any error it throws so analytics can never break a feature flow.
|
|
59
|
+
*/
|
|
60
|
+
export type AnalyticsTracker = (event: AnalyticsEvent) => void;
|
|
61
|
+
/**
|
|
62
|
+
* How much of one feature to track, in the {@link AnalyticsConfig.features} allowlist:
|
|
63
|
+
* - `true` — every action of the feature.
|
|
64
|
+
* - `{ actions }` — only the named actions (e.g. `{ actions: ['supply', 'borrow'] }`).
|
|
65
|
+
*/
|
|
66
|
+
export type AnalyticsFeatureScope = true | {
|
|
67
|
+
actions: readonly string[];
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* The set of features (and actions) to track — an **allowlist**. Two equivalent forms:
|
|
71
|
+
* - Object: per-feature {@link AnalyticsFeatureScope}. A feature **omitted from the object is OFF**.
|
|
72
|
+
* `{ swap: true, moneyMarket: { actions: ['supply'] } }`.
|
|
73
|
+
* - Array shorthand: a list of features, each fully tracked. `['swap', 'moneyMarket']`.
|
|
74
|
+
*
|
|
75
|
+
* Omitting {@link AnalyticsConfig.features} entirely tracks **everything** (all features, all
|
|
76
|
+
* actions) — scoping is opt-in.
|
|
77
|
+
*/
|
|
78
|
+
export type AnalyticsFeatures = Partial<Record<SodaxFeature, AnalyticsFeatureScope>> | readonly SodaxFeature[];
|
|
79
|
+
/**
|
|
80
|
+
* Analytics configuration passed to `new Sodax({ analytics })`.
|
|
81
|
+
*
|
|
82
|
+
* Providing this object is what turns analytics on; the {@link AnalyticsTracker} `tracker` is the
|
|
83
|
+
* only required field. `level` and `features` narrow what gets emitted so consumers track only what
|
|
84
|
+
* they care about — by detail level and by feature/action.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* new Sodax({
|
|
88
|
+
* analytics: {
|
|
89
|
+
* tracker: (event) => amplitude.track(event.action, event.data),
|
|
90
|
+
* features: {
|
|
91
|
+
* swap: true, // all swap actions
|
|
92
|
+
* moneyMarket: { actions: ['supply', 'borrow'] }, // only these
|
|
93
|
+
* // staking omitted → OFF
|
|
94
|
+
* }, // or simple form: features: ['swap', 'moneyMarket']
|
|
95
|
+
* },
|
|
96
|
+
* });
|
|
97
|
+
*/
|
|
98
|
+
export interface AnalyticsConfig {
|
|
99
|
+
/** Where events are delivered. Required — enabling analytics means supplying a tracker. */
|
|
100
|
+
tracker: AnalyticsTracker;
|
|
101
|
+
/**
|
|
102
|
+
* Highest detail level to emit. Defaults to `'basic'`. Events tagged `'detailed'` are only built
|
|
103
|
+
* and delivered when this is `'detailed'`.
|
|
104
|
+
*/
|
|
105
|
+
level?: AnalyticsDetailLevel;
|
|
106
|
+
/**
|
|
107
|
+
* Allowlist of features/actions to track. Omit to track everything; otherwise only the listed
|
|
108
|
+
* features (and, with `{ actions }`, only the listed actions) emit. See {@link AnalyticsFeatures}.
|
|
109
|
+
*/
|
|
110
|
+
features?: AnalyticsFeatures;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* The `analytics` option accepted by `new Sodax(...)`. Either a full {@link AnalyticsConfig} or
|
|
114
|
+
* `false` (the default — analytics disabled).
|
|
115
|
+
*
|
|
116
|
+
* Like `logger`, this is a client-side runtime option resolved once by the SDK; it is never
|
|
117
|
+
* fetched from or overwritten by the backend config.
|
|
118
|
+
*/
|
|
119
|
+
export type AnalyticsOption = AnalyticsConfig | false;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The set of high-level SODAX SDK features.
|
|
3
|
+
*
|
|
4
|
+
* Used as a first-class tag across cross-cutting concerns — error reporting
|
|
5
|
+
* (`SodaxError.feature` in `@sodax/sdk`) and analytics ({@link AnalyticsEvent.feature} and
|
|
6
|
+
* per-feature analytics toggles). It lives in `@sodax/types`, the lowest layer, so every package
|
|
7
|
+
* shares one source of truth instead of redefining the list; `@sodax/sdk` re-exports it.
|
|
8
|
+
*/
|
|
9
|
+
export type SodaxFeature = 'swap' | 'moneyMarket' | 'bridge' | 'staking' | 'migration' | 'dex' | 'partner' | 'recovery' | 'backend' | 'leverageYield';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/shared/index.d.ts
CHANGED
package/dist/shared/index.js
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unified logging interface for the SDK.
|
|
3
|
+
*
|
|
4
|
+
* The SDK routes all of its internal diagnostics through a `SodaxLogger` instead of
|
|
5
|
+
* calling `console.*` directly, so consumers can redirect or silence SDK output and
|
|
6
|
+
* forward it to a structured sink (Sentry, Pino, Datadog, etc.).
|
|
7
|
+
*
|
|
8
|
+
* Pass one to `new Sodax({ logger })` via {@link SodaxLoggerOption}:
|
|
9
|
+
* - `'console'` — default; mirrors the SDK's historical `console.*` behavior.
|
|
10
|
+
* - `'silent'` — drop all SDK logs.
|
|
11
|
+
* - a custom `SodaxLogger` — forward to your own sink.
|
|
12
|
+
*
|
|
13
|
+
* `error()` receives the thrown value separately from structured `data` so adapters
|
|
14
|
+
* can attach it as the exception (e.g. `Sentry.captureException(error, { extra: data })`).
|
|
15
|
+
* SDK errors are `SodaxError` instances whose `toJSON()` is the canonical serialization surface.
|
|
16
|
+
*/
|
|
17
|
+
export interface SodaxLogger {
|
|
18
|
+
debug(message: string, data?: Record<string, unknown>): void;
|
|
19
|
+
info(message: string, data?: Record<string, unknown>): void;
|
|
20
|
+
warn(message: string, data?: Record<string, unknown>): void;
|
|
21
|
+
error(message: string, error?: unknown, data?: Record<string, unknown>): void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Logger configuration accepted by `new Sodax(...)`. Either a built-in preset name or a
|
|
25
|
+
* custom {@link SodaxLogger} implementation. Resolved to a concrete `SodaxLogger` by the SDK.
|
|
26
|
+
*/
|
|
27
|
+
export type SodaxLoggerOption = SodaxLogger | 'console' | 'silent';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/shared/shared.d.ts
CHANGED
|
@@ -14,4 +14,24 @@ export type TxPollingConfig = {
|
|
|
14
14
|
pollingIntervalMs: number;
|
|
15
15
|
maxTimeoutMs: number;
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Tuning for the viem `fallback()` transport used when more than one RPC endpoint is configured.
|
|
19
|
+
* Plain serializable mirror of viem's fallback options so this type stays dependency-free.
|
|
20
|
+
*/
|
|
21
|
+
export type RpcFallbackOptions = {
|
|
22
|
+
/** Re-rank endpoints by latency instead of strict listed order (viem default: off; ignored unless more than one endpoint is configured). */
|
|
23
|
+
rank?: boolean;
|
|
24
|
+
/** Retries of the overall failover request before the error surfaces (viem default: 3); each attempt tries the endpoints in listed order. */
|
|
25
|
+
retryCount?: number;
|
|
26
|
+
/** Delay in ms between retries. */
|
|
27
|
+
retryDelay?: number;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Optional multi-endpoint RPC failover, mixed into EVM chain configs that support it.
|
|
31
|
+
* When `rpcUrls` is present and non-empty it supersedes the single `rpcUrl` (first entry is primary);
|
|
32
|
+
* an absent or empty `rpcUrls` preserves single-endpoint behavior.
|
|
33
|
+
*/
|
|
34
|
+
export type RpcFailoverConfig = {
|
|
35
|
+
rpcUrls?: readonly string[];
|
|
36
|
+
rpcOptions?: RpcFallbackOptions;
|
|
37
|
+
};
|
package/dist/shared/shared.js
CHANGED