@polyester/sdk 0.36.0-devnet-20261118141710 → 0.36.0-devnet-20261119010940
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/CHANGELOG.md +32 -2
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -0
- package/dist/client.js.map +1 -1
- package/dist/gen/ai/v1/assistant_pb.d.ts +5 -6
- package/dist/gen/ai/v1/assistant_pb.d.ts.map +1 -1
- package/dist/gen/ai/v1/assistant_pb.js.map +1 -1
- package/dist/gen/auth/v1/address_book_pb.d.ts +1 -1
- package/dist/gen/auth/v1/address_book_pb.js +1 -1
- package/dist/gen/auth/v1/address_book_pb.js.map +1 -1
- package/dist/gen/auth/v1/api_keys_pb.d.ts +70 -9
- package/dist/gen/auth/v1/api_keys_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/api_keys_pb.js +16 -1
- package/dist/gen/auth/v1/api_keys_pb.js.map +1 -1
- package/dist/gen/auth/v1/auth_pb.d.ts +74 -5
- package/dist/gen/auth/v1/auth_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/auth_pb.js +58 -6
- package/dist/gen/auth/v1/auth_pb.js.map +1 -1
- package/dist/gen/auth/v1/connected_apps_pb.d.ts +382 -0
- package/dist/gen/auth/v1/connected_apps_pb.d.ts.map +1 -0
- package/dist/gen/auth/v1/connected_apps_pb.js +107 -0
- package/dist/gen/auth/v1/connected_apps_pb.js.map +1 -0
- package/dist/gen/auth/v1/mfa_pb.d.ts +2 -140
- package/dist/gen/auth/v1/mfa_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/mfa_pb.js +8 -80
- package/dist/gen/auth/v1/mfa_pb.js.map +1 -1
- package/dist/gen/auth/v1/policies_pb.d.ts +164 -41
- package/dist/gen/auth/v1/policies_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/policies_pb.js +36 -3
- package/dist/gen/auth/v1/policies_pb.js.map +1 -1
- package/dist/gen/auth/v1/social_verification_pb.d.ts +4 -4
- package/dist/gen/auth/v1/social_verification_pb.js.map +1 -1
- package/dist/gen/chain/lifecycle/v1/lifecycle_read_pb.d.ts +17 -10
- package/dist/gen/chain/lifecycle/v1/lifecycle_read_pb.d.ts.map +1 -1
- package/dist/gen/chain/lifecycle/v1/lifecycle_read_pb.js.map +1 -1
- package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts +3 -1
- package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts.map +1 -1
- package/dist/gen/chain/withdraw/v1/withdraw_pb.js.map +1 -1
- package/dist/gen/fees/v1/fees_pb.d.ts +2 -1
- package/dist/gen/fees/v1/fees_pb.d.ts.map +1 -1
- package/dist/gen/fees/v1/fees_pb.js.map +1 -1
- package/dist/gen/index.d.ts +8 -5
- package/dist/gen/index.js +8 -5
- package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts +3 -2
- package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts.map +1 -1
- package/dist/gen/ledger/read/v1/ledger_read_pb.js.map +1 -1
- package/dist/gen/marketdata/v1/heatmap_pb.d.ts +9 -58
- package/dist/gen/marketdata/v1/heatmap_pb.d.ts.map +1 -1
- package/dist/gen/marketdata/v1/heatmap_pb.js +8 -57
- package/dist/gen/marketdata/v1/heatmap_pb.js.map +1 -1
- package/dist/gen/notifications/v1/notifications_pb.d.ts +141 -4
- package/dist/gen/notifications/v1/notifications_pb.d.ts.map +1 -1
- package/dist/gen/notifications/v1/notifications_pb.js +94 -16
- package/dist/gen/notifications/v1/notifications_pb.js.map +1 -1
- package/dist/gen/orderbook/v1/orderbook_pb.d.ts +14 -12
- package/dist/gen/orderbook/v1/orderbook_pb.d.ts.map +1 -1
- package/dist/gen/orderbook/v1/orderbook_pb.js +6 -1
- package/dist/gen/orderbook/v1/orderbook_pb.js.map +1 -1
- package/dist/gen/orders/v1/orders_pb.d.ts +66 -18
- package/dist/gen/orders/v1/orders_pb.d.ts.map +1 -1
- package/dist/gen/orders/v1/orders_pb.js +1 -1
- package/dist/gen/orders/v1/orders_pb.js.map +1 -1
- package/dist/gen/orders/v1/orders_read_pb.d.ts +8 -0
- package/dist/gen/orders/v1/orders_read_pb.d.ts.map +1 -1
- package/dist/gen/orders/v1/orders_read_pb.js.map +1 -1
- package/dist/gen/polyester/api/options_pb.d.ts +2 -1
- package/dist/gen/polyester/api/options_pb.d.ts.map +1 -1
- package/dist/gen/polyester/api/options_pb.js +2 -1
- package/dist/gen/polyester/api/options_pb.js.map +1 -1
- package/dist/gen/polyester/api/v1/request_error_pb.d.ts +66 -0
- package/dist/gen/polyester/api/v1/request_error_pb.d.ts.map +1 -0
- package/dist/gen/polyester/api/v1/request_error_pb.js +49 -0
- package/dist/gen/polyester/api/v1/request_error_pb.js.map +1 -0
- package/dist/gen/polyester/type/v1/depth_tier_pb.d.ts +98 -0
- package/dist/gen/polyester/type/v1/depth_tier_pb.d.ts.map +1 -0
- package/dist/gen/polyester/type/v1/depth_tier_pb.js +104 -0
- package/dist/gen/polyester/type/v1/depth_tier_pb.js.map +1 -0
- package/dist/gen/ratelimit/v1/ratelimit_pb.d.ts +42 -23
- package/dist/gen/ratelimit/v1/ratelimit_pb.d.ts.map +1 -1
- package/dist/gen/ratelimit/v1/ratelimit_pb.js +14 -2
- package/dist/gen/ratelimit/v1/ratelimit_pb.js.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts +126 -13
- package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_pb.js +100 -28
- package/dist/gen/swap/quickswap/v1/quickswap_pb.js.map +1 -1
- package/dist/gen/transfer/v1/internal_transfer_pb.d.ts +5 -3
- package/dist/gen/transfer/v1/internal_transfer_pb.d.ts.map +1 -1
- package/dist/gen/transfer/v1/internal_transfer_pb.js.map +1 -1
- package/dist/gen/triggers/v1/triggers_pb.d.ts +25 -3
- package/dist/gen/triggers/v1/triggers_pb.d.ts.map +1 -1
- package/dist/gen/triggers/v1/triggers_pb.js +18 -1
- package/dist/gen/triggers/v1/triggers_pb.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/realtime/ready-gated-subscription.js +1 -1
- package/dist/realtime/snapshot-then-stream.js +2 -0
- package/dist/realtime/snapshot-then-stream.js.map +1 -1
- package/dist/services/account-activity/account-activity.schemas.d.ts +4 -4
- package/dist/services/address-book/address-book.js +1 -1
- package/dist/services/address-book/address-book.schemas.d.ts +2 -2
- package/dist/services/api-keys/api-keys.codecs.d.ts +6 -1
- package/dist/services/api-keys/api-keys.codecs.d.ts.map +1 -1
- package/dist/services/api-keys/api-keys.codecs.js +19 -7
- package/dist/services/api-keys/api-keys.codecs.js.map +1 -1
- package/dist/services/api-keys/api-keys.js +1 -1
- package/dist/services/api-keys/api-keys.schemas.d.ts +12 -4
- package/dist/services/api-keys/api-keys.schemas.d.ts.map +1 -1
- package/dist/services/api-keys/api-keys.schemas.js +15 -6
- package/dist/services/api-keys/api-keys.schemas.js.map +1 -1
- package/dist/services/api-keys/api-keys.types.d.ts +2 -2
- package/dist/services/assistant/assistant-events.schemas.d.ts +30 -30
- package/dist/services/assistant/assistant.schemas.d.ts +2 -2
- package/dist/services/auth/auth.d.ts +4 -0
- package/dist/services/auth/auth.d.ts.map +1 -1
- package/dist/services/auth/auth.js +12 -2
- package/dist/services/auth/auth.js.map +1 -1
- package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts +3 -3
- package/dist/services/balances/balances.js +1 -1
- package/dist/services/candles/candles.schemas.d.ts +10 -10
- package/dist/services/changelog/changelog.schemas.d.ts +22 -22
- package/dist/services/checkpoints/checkpoints.schemas.d.ts +1 -1
- package/dist/services/connected-apps/connected-apps.d.ts +46 -0
- package/dist/services/connected-apps/connected-apps.d.ts.map +1 -0
- package/dist/services/connected-apps/connected-apps.js +69 -0
- package/dist/services/connected-apps/connected-apps.js.map +1 -0
- package/dist/services/connected-apps/connected-apps.schemas.d.ts +132 -0
- package/dist/services/connected-apps/connected-apps.schemas.d.ts.map +1 -0
- package/dist/services/connected-apps/connected-apps.schemas.js +68 -0
- package/dist/services/connected-apps/connected-apps.schemas.js.map +1 -0
- package/dist/services/connected-apps/connected-apps.types.d.ts +2 -0
- package/dist/services/connected-apps/service.d.ts +8 -0
- package/dist/services/connected-apps/service.d.ts.map +1 -0
- package/dist/services/connected-apps/service.js +9 -0
- package/dist/services/connected-apps/service.js.map +1 -0
- package/dist/services/dust-conversion/dust-conversion.schemas.d.ts +2 -2
- package/dist/services/heatmap/heatmap.codecs.d.ts +1 -0
- package/dist/services/heatmap/heatmap.codecs.d.ts.map +1 -1
- package/dist/services/heatmap/heatmap.codecs.js +2 -27
- package/dist/services/heatmap/heatmap.codecs.js.map +1 -1
- package/dist/services/heatmap/heatmap.schemas.d.ts +9 -8
- package/dist/services/heatmap/heatmap.schemas.d.ts.map +1 -1
- package/dist/services/heatmap/heatmap.schemas.js +4 -3
- package/dist/services/heatmap/heatmap.schemas.js.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +6 -6
- package/dist/services/lifecycle/lifecycle.js +1 -1
- package/dist/services/lifecycle/lifecycle.js.map +1 -1
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +91 -91
- package/dist/services/notifications/notifications.codecs.d.ts +6 -3
- package/dist/services/notifications/notifications.codecs.d.ts.map +1 -1
- package/dist/services/notifications/notifications.codecs.js +14 -3
- package/dist/services/notifications/notifications.codecs.js.map +1 -1
- package/dist/services/notifications/notifications.schemas.d.ts +97 -3
- package/dist/services/notifications/notifications.schemas.d.ts.map +1 -1
- package/dist/services/notifications/notifications.schemas.js +18 -1
- package/dist/services/notifications/notifications.schemas.js.map +1 -1
- package/dist/services/notifications/notifications.types.d.ts +2 -2
- package/dist/services/orderbook/orderbook.codecs.js +1 -1
- package/dist/services/orderbook/orderbook.codecs.js.map +1 -1
- package/dist/services/orderbook/orderbook.d.ts +2 -2
- package/dist/services/orderbook/orderbook.d.ts.map +1 -1
- package/dist/services/orderbook/orderbook.js +8 -10
- package/dist/services/orderbook/orderbook.js.map +1 -1
- package/dist/services/orderbook/orderbook.schemas.d.ts +3 -6
- package/dist/services/orderbook/orderbook.schemas.d.ts.map +1 -1
- package/dist/services/orderbook/orderbook.schemas.js +5 -5
- package/dist/services/orderbook/orderbook.schemas.js.map +1 -1
- package/dist/services/orders/order-errors.schemas.d.ts +9 -9
- package/dist/services/orders/orders-batch.schemas.d.ts +106 -102
- package/dist/services/orders/orders-batch.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-batch.schemas.js +2 -0
- package/dist/services/orders/orders-batch.schemas.js.map +1 -1
- package/dist/services/orders/orders-input.schemas.d.ts +23 -15
- package/dist/services/orders/orders-input.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-input.schemas.js +7 -2
- package/dist/services/orders/orders-input.schemas.js.map +1 -1
- package/dist/services/orders/orders-output.schemas.d.ts +8 -8
- package/dist/services/orders/orders.d.ts.map +1 -1
- package/dist/services/orders/orders.js +47 -43
- package/dist/services/orders/orders.js.map +1 -1
- package/dist/services/policies/api-key-policies/api-key-policies.d.ts +4 -1
- package/dist/services/policies/api-key-policies/api-key-policies.d.ts.map +1 -1
- package/dist/services/policies/api-key-policies/api-key-policies.js +5 -2
- package/dist/services/policies/api-key-policies/api-key-policies.js.map +1 -1
- package/dist/services/policies/api-key-policies/api-key-policies.schemas.d.ts +25 -15
- package/dist/services/policies/api-key-policies/api-key-policies.schemas.d.ts.map +1 -1
- package/dist/services/policies/api-key-policies/api-key-policies.schemas.js +3 -0
- package/dist/services/policies/api-key-policies/api-key-policies.schemas.js.map +1 -1
- package/dist/services/policies/shared.codecs.js +25 -5
- package/dist/services/policies/shared.codecs.js.map +1 -1
- package/dist/services/policies/shared.d.ts +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.d.ts +4 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.d.ts.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.js +5 -2
- package/dist/services/policies/subaccount-policies/subaccount-policies.js.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts +11 -3
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js +4 -0
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js.map +1 -1
- package/dist/services/rate-limits/rate-limits.codecs.d.ts +1 -1
- package/dist/services/rate-limits/rate-limits.codecs.js +2 -1
- package/dist/services/rate-limits/rate-limits.codecs.js.map +1 -1
- package/dist/services/rate-limits/rate-limits.schemas.d.ts +4 -4
- package/dist/services/statement-exports/statement-exports.schemas.d.ts +6 -6
- package/dist/services/subaccounts/subaccounts.js +2 -2
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +20 -20
- package/dist/services/system/system.schemas.d.ts +13 -13
- package/dist/services/trades/trades.d.ts.map +1 -1
- package/dist/services/trades/trades.js +12 -4
- package/dist/services/trades/trades.js.map +1 -1
- package/dist/services/trades/trades.schemas.d.ts +1 -1
- package/dist/services/transfers/transfers.js +1 -1
- package/dist/services/triggers/trigger-input.schemas.d.ts +1 -1
- package/dist/services/triggers/triggers-output.schemas.d.ts +57 -57
- package/dist/services/triggers/triggers.codecs.d.ts.map +1 -1
- package/dist/services/triggers/triggers.codecs.js +2 -0
- package/dist/services/triggers/triggers.codecs.js.map +1 -1
- package/dist/services/triggers/triggers.d.ts.map +1 -1
- package/dist/services/triggers/triggers.js +14 -10
- package/dist/services/triggers/triggers.js.map +1 -1
- package/dist/shared/connect-error-mapping.d.ts.map +1 -1
- package/dist/shared/connect-error-mapping.js +5 -2
- package/dist/shared/connect-error-mapping.js.map +1 -1
- package/dist/shared/decimal-surface.d.ts +6 -0
- package/dist/shared/decimal-surface.d.ts.map +1 -1
- package/dist/shared/decimal-surface.js +65 -1
- package/dist/shared/decimal-surface.js.map +1 -1
- package/dist/shared/depth-tier.js +46 -0
- package/dist/shared/depth-tier.js.map +1 -0
- package/dist/shared/error-detail.d.ts +6 -0
- package/dist/shared/error-detail.d.ts.map +1 -1
- package/dist/shared/error-detail.js +2 -1
- package/dist/shared/error-detail.js.map +1 -1
- package/dist/shared/error-details/request.js +16 -0
- package/dist/shared/error-details/request.js.map +1 -0
- package/dist/shared/rate-limit.schemas.d.ts +1 -1
- package/dist/wired-services.d.ts.map +1 -1
- package/dist/wired-services.js +6 -4
- package/dist/wired-services.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,77 @@
|
|
|
1
1
|
import "./wire-bounds.js";
|
|
2
2
|
import { scaledToDecimal, tryDecimalToScaled } from "../catalogs/decimal.js";
|
|
3
3
|
import { CatalogConversionError, CatalogLookupError, CatalogNotReadyError } from "../catalogs/types.js";
|
|
4
|
+
import { publicationHandlerErrorContext } from "./subscription-errors.js";
|
|
4
5
|
import { U128_MAX } from "../utils/u128.js";
|
|
6
|
+
/** Least time between catalog refreshes that lookup misses start. */
|
|
7
|
+
const CATALOG_MISS_REFRESH_INTERVAL_MS = 3e4;
|
|
8
|
+
/** Longest a lookup miss waits for its catalog refresh before it fails with the current catalog. */
|
|
9
|
+
const CATALOG_MISS_REFRESH_TIMEOUT_MS = 1e4;
|
|
10
|
+
/** Runs `read`; on a catalog miss, refreshes the catalog and runs it once more, so a second miss throws. */
|
|
11
|
+
async function withCatalogRefresh(scales, read) {
|
|
12
|
+
try {
|
|
13
|
+
return read();
|
|
14
|
+
} catch (error) {
|
|
15
|
+
if (!(error instanceof CatalogLookupError) || !scales.refreshAfterMiss) throw error;
|
|
16
|
+
await scales.refreshAfterMiss();
|
|
17
|
+
return read();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** True when the catalog can scale quantities of `symbolId`. */
|
|
21
|
+
function hasKnownSymbol(scales, symbolId) {
|
|
22
|
+
try {
|
|
23
|
+
scales.baseQty(symbolId);
|
|
24
|
+
return true;
|
|
25
|
+
} catch {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Keeps a stream's publications in order across catalog refreshes. Call the returned function
|
|
31
|
+
* with each publication's handler: one naming a symbol the catalog lacks waits for a refresh,
|
|
32
|
+
* and every later one waits behind it. A symbol still missing then fails in the handler, which
|
|
33
|
+
* reports it to `onError`; nothing runs after the subscription closed.
|
|
34
|
+
*/
|
|
35
|
+
function createCatalogRefreshQueue(scales, channel, onError, isOpen) {
|
|
36
|
+
let tail;
|
|
37
|
+
return (missesCatalog, handle) => {
|
|
38
|
+
const wait = tail ?? (missesCatalog ? scales.refreshAfterMiss?.() : void 0);
|
|
39
|
+
if (!wait) return handle();
|
|
40
|
+
const next = wait.then(() => {
|
|
41
|
+
if (!isOpen()) return;
|
|
42
|
+
try {
|
|
43
|
+
handle();
|
|
44
|
+
} catch (error) {
|
|
45
|
+
try {
|
|
46
|
+
onError?.(publicationHandlerErrorContext(channel, error));
|
|
47
|
+
} catch {}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
tail = next;
|
|
51
|
+
next.then(() => {
|
|
52
|
+
if (tail === next) tail = void 0;
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
}
|
|
5
56
|
/**
|
|
6
57
|
* Catalog-backed scale resolver. Takes a getter so it can be constructed
|
|
7
58
|
* before the owning client has assigned its catalog.
|
|
8
59
|
*/
|
|
9
60
|
function createCatalogSdkScales(getCatalog) {
|
|
61
|
+
let lastMissRefresh;
|
|
10
62
|
return {
|
|
63
|
+
refreshAfterMiss: () => {
|
|
64
|
+
if (lastMissRefresh && Date.now() - lastMissRefresh.at < 3e4) return lastMissRefresh.done;
|
|
65
|
+
let timer;
|
|
66
|
+
const done = Promise.race([getCatalog().refresh(), new Promise((resolve) => {
|
|
67
|
+
timer = setTimeout(resolve, CATALOG_MISS_REFRESH_TIMEOUT_MS);
|
|
68
|
+
})]).then(() => clearTimeout(timer), () => clearTimeout(timer));
|
|
69
|
+
lastMissRefresh = {
|
|
70
|
+
at: Date.now(),
|
|
71
|
+
done
|
|
72
|
+
};
|
|
73
|
+
return done;
|
|
74
|
+
},
|
|
11
75
|
ready: async () => {
|
|
12
76
|
await getCatalog().ensureReady();
|
|
13
77
|
},
|
|
@@ -124,6 +188,6 @@ function createReadyGate(ready, handlers) {
|
|
|
124
188
|
};
|
|
125
189
|
}
|
|
126
190
|
//#endregion
|
|
127
|
-
export { createCatalogSdkScales, createReadyGate, decimalInputToScaled, positiveDecimalInputToScaled, quantityInputToE18, scaledToDecimalOutput };
|
|
191
|
+
export { CATALOG_MISS_REFRESH_INTERVAL_MS, CATALOG_MISS_REFRESH_TIMEOUT_MS, createCatalogRefreshQueue, createCatalogSdkScales, createReadyGate, decimalInputToScaled, hasKnownSymbol, positiveDecimalInputToScaled, quantityInputToE18, scaledToDecimalOutput, withCatalogRefresh };
|
|
128
192
|
|
|
129
193
|
//# sourceMappingURL=decimal-surface.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decimal-surface.js","names":[],"sources":["../../src/shared/decimal-surface.ts"],"sourcesContent":["/**\n * Internal scaled⇄decimal bridge for the SDK's public decimal-string surface.\n *\n * The wire protocol carries scaled integers (price ticks, per-asset scaled\n * quantities); the public SDK surface carries plain decimal strings. Output\n * schemas convert exactly (no rounding, trailing zeros trimmed); input schemas\n * accept zero padding but reject fractional precision that remains above the\n * scale after trailing zeros are removed. Scaled integers must not escape\n * through any service input or output.\n */\nimport {\n scaledToDecimal,\n tryDecimalToScaled,\n type DecimalToScaledFailure,\n} from \"../catalogs/decimal.js\";\nimport {\n CatalogConversionError,\n CatalogLookupError,\n CatalogNotReadyError,\n type ClientCatalog,\n type PairCatalogKey,\n} from \"../catalogs/types.js\";\nimport { PRICE_SCALE } from \"../catalogs/readers.js\";\nimport { PROTOBUF_INT64_MAX } from \"./wire-bounds.js\";\nimport { U128_MAX } from \"../utils/u128.js\";\n\n/** On-chain unified-asset amounts (`amountE18`) are always 18-decimal scaled. */\nexport const E18_SCALE = 18;\n\n/**\n * Policy notional caps (`max_order_notional`) are canonical quote microunits:\n * one unit is 0.000001 USDT, per the `auth.v1` policy contract. Fixed by the\n * protocol rather than per-pair, so it needs no catalog lookup.\n */\nexport const QUOTE_NOTIONAL_SCALE = 6;\n\n/**\n * Resolves wire scales for the SDK's internal decimal conversion. Backed by\n * the client catalog; `ready()` must be awaited before the synchronous lookups\n * are used so the catalog can answer them.\n */\nexport interface SdkScales {\n ready(): Promise<void>;\n price(): number;\n baseQty(pair: PairCatalogKey): number;\n quoteAmount(pair: PairCatalogKey): number;\n /** Base volume in public candles and market overview; falls back to the base quantity scale. */\n marketDataVolume(pair: PairCatalogKey): number;\n /** Composite reference candle prices; falls back to the primary price scale. */\n referencePrice(pair: PairCatalogKey): number;\n ledgerAmount(ledgerAssetId: number): number;\n zippedAssetAmount(zippedAssetId: number): number;\n}\n\n/**\n * Catalog-backed scale resolver. Takes a getter so it can be constructed\n * before the owning client has assigned its catalog.\n */\nexport function createCatalogSdkScales(getCatalog: () => ClientCatalog): SdkScales {\n return {\n ready: async () => {\n await getCatalog().ensureReady();\n },\n price: () => PRICE_SCALE,\n baseQty: (pair) => requirePair(getCatalog(), pair).baseAsset.quantityScale,\n quoteAmount: (pair) => requirePair(getCatalog(), pair).quoteAsset.quantityScale,\n marketDataVolume: (pair) => {\n const { baseAsset } = requirePair(getCatalog(), pair);\n return baseAsset.marketDataVolumeScale ?? baseAsset.quantityScale;\n },\n referencePrice: (pair) =>\n requirePair(getCatalog(), pair).referencePriceScale ?? PRICE_SCALE,\n ledgerAmount: (ledgerAssetId) => {\n const ledger = getCatalog().ledger;\n if (!ledger.isKnownAssetId(ledgerAssetId)) {\n throw new CatalogLookupError(\"ledger\", \"ledgerId\", ledgerAssetId);\n }\n return ledger.requireAssetByLedgerId(ledgerAssetId).quantityScale;\n },\n zippedAssetAmount: (zippedAssetId) =>\n getCatalog().zipper.requireAssetChainByZippedAssetId(zippedAssetId).asset.quantityScale,\n };\n}\n\nfunction requirePair(catalog: ClientCatalog, pair: PairCatalogKey) {\n return typeof pair === \"string\" || (typeof pair === \"object\" && \"symbol\" in pair)\n ? catalog.market.requirePairBySymbol(typeof pair === \"string\" ? pair : pair.symbol)\n : catalog.market.requirePairBySymbolId(typeof pair === \"number\" ? pair : pair.symbolId);\n}\n\n/** Output direction: exact scaled→decimal conversion (`1500000n`@6 → `\"1.5\"`). */\nexport function scaledToDecimalOutput(value: bigint, scale: number): string {\n return scaledToDecimal(value, scale);\n}\n\nfunction conversionFailureMessage(\n field: string,\n value: string,\n failure: DecimalToScaledFailure,\n): string {\n return failure.reason === \"precision\"\n ? `${field} supports at most ${failure.maxDecimals} decimal places: ${value}`\n : `${field} must be a non-negative decimal number: ${value}`;\n}\n\n/**\n * Input direction: strict decimal→scaled conversion. Throws\n * CatalogConversionError for non-decimal input or inexact excess precision.\n */\nexport function decimalInputToScaled(field: string, value: string, scale: number): bigint {\n const result = tryDecimalToScaled(value.trim(), scale);\n if (!result.ok) {\n throw new CatalogConversionError(\n field,\n conversionFailureMessage(field, value, result.failure),\n );\n }\n return result.scaled;\n}\n\nfunction unboundedPositiveDecimalInputToScaled(\n field: string,\n value: string,\n scale: number,\n): bigint {\n const scaled = decimalInputToScaled(field, value, scale);\n if (scaled <= 0n) {\n throw new CatalogConversionError(field, `${field} must be greater than 0: ${value}`);\n }\n return scaled;\n}\n\n/**\n * Converts a positive decimal input to a scaled protobuf `int64` value.\n * Rejects values above the wire-format ceiling before serialization.\n */\nexport function positiveDecimalInputToScaled(field: string, value: string, scale: number): bigint {\n const scaled = unboundedPositiveDecimalInputToScaled(field, value, scale);\n if (scaled > PROTOBUF_INT64_MAX) {\n throw new CatalogConversionError(\n field,\n `${field} exceeds the maximum supported value: ${value}`,\n );\n }\n return scaled;\n}\n\n/**\n * Decimal quantity → PolyesterChain E18 ledger units.\n * Input precision is capped at the asset's quantityScale; the wire value is\n * always upscaled to E18 (trading balances / amount_e18 convention).\n */\nexport function quantityInputToE18(params: {\n scales: SdkScales;\n assetId: number;\n quantity: string;\n field?: string;\n}): bigint {\n const field = params.field ?? \"quantity\";\n const assetScale = params.scales.ledgerAmount(params.assetId);\n if (assetScale > E18_SCALE) {\n throw new CatalogConversionError(\n field,\n `${field} asset quantityScale ${assetScale} exceeds E18 ledger scale`,\n );\n }\n const scaled =\n unboundedPositiveDecimalInputToScaled(field, params.quantity, assetScale) *\n 10n ** BigInt(E18_SCALE - assetScale);\n if (scaled > U128_MAX) {\n throw new CatalogConversionError(\n field,\n `${field} exceeds the maximum supported value: ${params.quantity}`,\n );\n }\n return scaled;\n}\n\nexport interface ReadyGate {\n /** Queues or delivers one transition while the gate remains active. */\n run(deliver: () => void): void;\n /** Drops pending transitions and permanently prevents future delivery. */\n close(): void;\n}\n\ninterface ReadyGateHandlers {\n onDeliveryError?: (error: unknown) => void;\n onTerminalError: (error: unknown) => void;\n}\n\nconst READY_GATE_MAX_PENDING_DELIVERIES = 1_024;\n\n/**\n * Transition event delivery behind catalog readiness. Events arriving before the\n * catalog can resolve scales are queued and flushed in arrival order once it\n * is ready. Delivery errors are isolated from the transport. Readiness failure\n * or queue overflow is terminal because dropping an event would break stream\n * continuity; the owning subscription must visibly terminate when notified.\n */\nexport function createReadyGate(\n ready: () => Promise<void>,\n handlers: ReadyGateHandlers,\n): ReadyGate {\n let state: \"pending\" | \"open\" | \"closed\" = \"pending\";\n const queue: Array<() => void> = [];\n\n const deliverIsolated = (deliver: () => void) => {\n try {\n deliver();\n } catch (error) {\n handlers.onDeliveryError?.(error);\n }\n };\n\n const closeWithError = (error: unknown) => {\n if (state === \"closed\") return;\n state = \"closed\";\n queue.length = 0;\n handlers.onTerminalError(error);\n };\n\n Promise.resolve()\n .then(ready)\n .then(\n () => {\n if (state !== \"pending\") return;\n state = \"open\";\n for (const deliver of queue.splice(0)) deliverIsolated(deliver);\n },\n (error) => {\n if (state !== \"pending\") return;\n closeWithError(error);\n },\n );\n\n return {\n run(deliver) {\n if (state === \"open\") deliverIsolated(deliver);\n else if (state === \"pending\") {\n if (queue.length === READY_GATE_MAX_PENDING_DELIVERIES) {\n closeWithError(new CatalogNotReadyError());\n return;\n }\n queue.push(deliver);\n }\n },\n close() {\n if (state === \"closed\") return;\n state = \"closed\";\n queue.length = 0;\n },\n };\n}\n"],"mappings":";;;;;;;;AA0DA,SAAgB,uBAAuB,YAA4C;CAC/E,OAAO;EACH,OAAO,YAAY;GACf,MAAM,WAAW,CAAC,CAAC,YAAY;EACnC;EACA,aAAA;EACA,UAAU,SAAS,YAAY,WAAW,GAAG,IAAI,CAAC,CAAC,UAAU;EAC7D,cAAc,SAAS,YAAY,WAAW,GAAG,IAAI,CAAC,CAAC,WAAW;EAClE,mBAAmB,SAAS;GACxB,MAAM,EAAE,cAAc,YAAY,WAAW,GAAG,IAAI;GACpD,OAAO,UAAU,yBAAyB,UAAU;EACxD;EACA,iBAAiB,SACb,YAAY,WAAW,GAAG,IAAI,CAAC,CAAC,uBAAA;EACpC,eAAe,kBAAkB;GAC7B,MAAM,SAAS,WAAW,CAAC,CAAC;GAC5B,IAAI,CAAC,OAAO,eAAe,aAAa,GACpC,MAAM,IAAI,mBAAmB,UAAU,YAAY,aAAa;GAEpE,OAAO,OAAO,uBAAuB,aAAa,CAAC,CAAC;EACxD;EACA,oBAAoB,kBAChB,WAAW,CAAC,CAAC,OAAO,iCAAiC,aAAa,CAAC,CAAC,MAAM;CAClF;AACJ;AAEA,SAAS,YAAY,SAAwB,MAAsB;CAC/D,OAAO,OAAO,SAAS,YAAa,OAAO,SAAS,YAAY,YAAY,OACtE,QAAQ,OAAO,oBAAoB,OAAO,SAAS,WAAW,OAAO,KAAK,MAAM,IAChF,QAAQ,OAAO,sBAAsB,OAAO,SAAS,WAAW,OAAO,KAAK,QAAQ;AAC9F;;AAGA,SAAgB,sBAAsB,OAAe,OAAuB;CACxE,OAAO,gBAAgB,OAAO,KAAK;AACvC;AAEA,SAAS,yBACL,OACA,OACA,SACM;CACN,OAAO,QAAQ,WAAW,cACpB,GAAG,MAAM,oBAAoB,QAAQ,YAAY,mBAAmB,UACpE,GAAG,MAAM,0CAA0C;AAC7D;;;;;AAMA,SAAgB,qBAAqB,OAAe,OAAe,OAAuB;CACtF,MAAM,SAAS,mBAAmB,MAAM,KAAK,GAAG,KAAK;CACrD,IAAI,CAAC,OAAO,IACR,MAAM,IAAI,uBACN,OACA,yBAAyB,OAAO,OAAO,OAAO,OAAO,CACzD;CAEJ,OAAO,OAAO;AAClB;AAEA,SAAS,sCACL,OACA,OACA,OACM;CACN,MAAM,SAAS,qBAAqB,OAAO,OAAO,KAAK;CACvD,IAAI,UAAU,IACV,MAAM,IAAI,uBAAuB,OAAO,GAAG,MAAM,2BAA2B,OAAO;CAEvF,OAAO;AACX;;;;;AAMA,SAAgB,6BAA6B,OAAe,OAAe,OAAuB;CAC9F,MAAM,SAAS,sCAAsC,OAAO,OAAO,KAAK;CACxE,IAAI,SAAA,sBACA,MAAM,IAAI,uBACN,OACA,GAAG,MAAM,wCAAwC,OACrD;CAEJ,OAAO;AACX;;;;;;AAOA,SAAgB,mBAAmB,QAKxB;CACP,MAAM,QAAQ,OAAO,SAAS;CAC9B,MAAM,aAAa,OAAO,OAAO,aAAa,OAAO,OAAO;CAC5D,IAAI,aAAA,IACA,MAAM,IAAI,uBACN,OACA,GAAG,MAAM,uBAAuB,WAAW,0BAC/C;CAEJ,MAAM,SACF,sCAAsC,OAAO,OAAO,UAAU,UAAU,IACxE,OAAO,OAAA,KAAmB,UAAU;CACxC,IAAI,SAAS,UACT,MAAM,IAAI,uBACN,OACA,GAAG,MAAM,wCAAwC,OAAO,UAC5D;CAEJ,OAAO;AACX;AAcA,MAAM,oCAAoC;;;;;;;;AAS1C,SAAgB,gBACZ,OACA,UACS;CACT,IAAI,QAAuC;CAC3C,MAAM,QAA2B,CAAC;CAElC,MAAM,mBAAmB,YAAwB;EAC7C,IAAI;GACA,QAAQ;EACZ,SAAS,OAAO;GACZ,SAAS,kBAAkB,KAAK;EACpC;CACJ;CAEA,MAAM,kBAAkB,UAAmB;EACvC,IAAI,UAAU,UAAU;EACxB,QAAQ;EACR,MAAM,SAAS;EACf,SAAS,gBAAgB,KAAK;CAClC;CAEA,QAAQ,QAAQ,CAAC,CACZ,KAAK,KAAK,CAAC,CACX,WACS;EACF,IAAI,UAAU,WAAW;EACzB,QAAQ;EACR,KAAK,MAAM,WAAW,MAAM,OAAO,CAAC,GAAG,gBAAgB,OAAO;CAClE,IACC,UAAU;EACP,IAAI,UAAU,WAAW;EACzB,eAAe,KAAK;CACxB,CACJ;CAEJ,OAAO;EACH,IAAI,SAAS;GACT,IAAI,UAAU,QAAQ,gBAAgB,OAAO;QACxC,IAAI,UAAU,WAAW;IAC1B,IAAI,MAAM,WAAW,mCAAmC;KACpD,eAAe,IAAI,qBAAqB,CAAC;KACzC;IACJ;IACA,MAAM,KAAK,OAAO;GACtB;EACJ;EACA,QAAQ;GACJ,IAAI,UAAU,UAAU;GACxB,QAAQ;GACR,MAAM,SAAS;EACnB;CACJ;AACJ"}
|
|
1
|
+
{"version":3,"file":"decimal-surface.js","names":[],"sources":["../../src/shared/decimal-surface.ts"],"sourcesContent":["/**\n * Internal scaled⇄decimal bridge for the SDK's public decimal-string surface.\n *\n * The wire protocol carries scaled integers (price ticks, per-asset scaled\n * quantities); the public SDK surface carries plain decimal strings. Output\n * schemas convert exactly (no rounding, trailing zeros trimmed); input schemas\n * accept zero padding but reject fractional precision that remains above the\n * scale after trailing zeros are removed. Scaled integers must not escape\n * through any service input or output.\n */\nimport {\n scaledToDecimal,\n tryDecimalToScaled,\n type DecimalToScaledFailure,\n} from \"../catalogs/decimal.js\";\nimport {\n CatalogConversionError,\n CatalogLookupError,\n CatalogNotReadyError,\n type ClientCatalog,\n type PairCatalogKey,\n} from \"../catalogs/types.js\";\nimport { PRICE_SCALE } from \"../catalogs/readers.js\";\nimport { PROTOBUF_INT64_MAX } from \"./wire-bounds.js\";\nimport {\n publicationHandlerErrorContext,\n type SdkSubscriptionErrorContext,\n} from \"./subscription-errors.js\";\nimport { U128_MAX } from \"../utils/u128.js\";\n\n/** On-chain unified-asset amounts (`amountE18`) are always 18-decimal scaled. */\nexport const E18_SCALE = 18;\n\n/**\n * Policy notional caps (`max_order_notional`) are canonical quote microunits:\n * one unit is 0.000001 USDT, per the `auth.v1` policy contract. Fixed by the\n * protocol rather than per-pair, so it needs no catalog lookup.\n */\nexport const QUOTE_NOTIONAL_SCALE = 6;\n\n/**\n * Resolves wire scales for the SDK's internal decimal conversion. Backed by\n * the client catalog; `ready()` must be awaited before the synchronous lookups\n * are used so the catalog can answer them.\n */\nexport interface SdkScales {\n ready(): Promise<void>;\n price(): number;\n baseQty(pair: PairCatalogKey): number;\n quoteAmount(pair: PairCatalogKey): number;\n /** Base volume in public candles and market overview; falls back to the base quantity scale. */\n marketDataVolume(pair: PairCatalogKey): number;\n /** Composite reference candle prices; falls back to the primary price scale. */\n referencePrice(pair: PairCatalogKey): number;\n ledgerAmount(ledgerAssetId: number): number;\n zippedAssetAmount(zippedAssetId: number): number;\n /**\n * Refreshes the catalog after a lookup miss, so a pair listed after startup resolves.\n * Misses within {@link CATALOG_MISS_REFRESH_INTERVAL_MS} share one refresh; never rejects.\n */\n refreshAfterMiss?(): Promise<void>;\n}\n\n/** Least time between catalog refreshes that lookup misses start. */\nexport const CATALOG_MISS_REFRESH_INTERVAL_MS = 30_000;\n\n/** Longest a lookup miss waits for its catalog refresh before it fails with the current catalog. */\nexport const CATALOG_MISS_REFRESH_TIMEOUT_MS = 10_000;\n\n/** Runs `read`; on a catalog miss, refreshes the catalog and runs it once more, so a second miss throws. */\nexport async function withCatalogRefresh<T>(scales: SdkScales, read: () => T): Promise<T> {\n try {\n return read();\n } catch (error) {\n if (!(error instanceof CatalogLookupError) || !scales.refreshAfterMiss) throw error;\n await scales.refreshAfterMiss();\n return read();\n }\n}\n\n/** True when the catalog can scale quantities of `symbolId`. */\nexport function hasKnownSymbol(scales: SdkScales, symbolId: number): boolean {\n try {\n scales.baseQty(symbolId);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Keeps a stream's publications in order across catalog refreshes. Call the returned function\n * with each publication's handler: one naming a symbol the catalog lacks waits for a refresh,\n * and every later one waits behind it. A symbol still missing then fails in the handler, which\n * reports it to `onError`; nothing runs after the subscription closed.\n */\nexport function createCatalogRefreshQueue(\n scales: SdkScales,\n channel: string,\n onError: ((error: SdkSubscriptionErrorContext) => void) | undefined,\n isOpen: () => boolean,\n): (missesCatalog: boolean, handle: () => void) => void {\n let tail: Promise<void> | undefined;\n return (missesCatalog, handle) => {\n const wait = tail ?? (missesCatalog ? scales.refreshAfterMiss?.() : undefined);\n if (!wait) return handle();\n const next = wait.then(() => {\n if (!isOpen()) return;\n try {\n handle();\n } catch (error) {\n try {\n onError?.(publicationHandlerErrorContext(channel, error));\n } catch {\n // The caller's onError threw; keep later publications flowing.\n }\n }\n });\n tail = next;\n void next.then(() => {\n if (tail === next) tail = undefined;\n });\n };\n}\n\n/**\n * Catalog-backed scale resolver. Takes a getter so it can be constructed\n * before the owning client has assigned its catalog.\n */\nexport function createCatalogSdkScales(getCatalog: () => ClientCatalog): SdkScales {\n let lastMissRefresh: { at: number; done: Promise<void> } | undefined;\n return {\n refreshAfterMiss: () => {\n if (\n lastMissRefresh &&\n Date.now() - lastMissRefresh.at < CATALOG_MISS_REFRESH_INTERVAL_MS\n ) {\n return lastMissRefresh.done;\n }\n // A failed or stalled refresh leaves the catalog as it was, so the retried lookup\n // misses again instead of holding a stream behind it.\n let timer: ReturnType<typeof setTimeout> | undefined;\n const done = Promise.race([\n getCatalog().refresh(),\n new Promise<void>((resolve) => {\n timer = setTimeout(resolve, CATALOG_MISS_REFRESH_TIMEOUT_MS);\n }),\n ]).then(\n () => clearTimeout(timer),\n () => clearTimeout(timer),\n );\n lastMissRefresh = { at: Date.now(), done };\n return done;\n },\n ready: async () => {\n await getCatalog().ensureReady();\n },\n price: () => PRICE_SCALE,\n baseQty: (pair) => requirePair(getCatalog(), pair).baseAsset.quantityScale,\n quoteAmount: (pair) => requirePair(getCatalog(), pair).quoteAsset.quantityScale,\n marketDataVolume: (pair) => {\n const { baseAsset } = requirePair(getCatalog(), pair);\n return baseAsset.marketDataVolumeScale ?? baseAsset.quantityScale;\n },\n referencePrice: (pair) =>\n requirePair(getCatalog(), pair).referencePriceScale ?? PRICE_SCALE,\n ledgerAmount: (ledgerAssetId) => {\n const ledger = getCatalog().ledger;\n if (!ledger.isKnownAssetId(ledgerAssetId)) {\n throw new CatalogLookupError(\"ledger\", \"ledgerId\", ledgerAssetId);\n }\n return ledger.requireAssetByLedgerId(ledgerAssetId).quantityScale;\n },\n zippedAssetAmount: (zippedAssetId) =>\n getCatalog().zipper.requireAssetChainByZippedAssetId(zippedAssetId).asset.quantityScale,\n };\n}\n\nfunction requirePair(catalog: ClientCatalog, pair: PairCatalogKey) {\n return typeof pair === \"string\" || (typeof pair === \"object\" && \"symbol\" in pair)\n ? catalog.market.requirePairBySymbol(typeof pair === \"string\" ? pair : pair.symbol)\n : catalog.market.requirePairBySymbolId(typeof pair === \"number\" ? pair : pair.symbolId);\n}\n\n/** Output direction: exact scaled→decimal conversion (`1500000n`@6 → `\"1.5\"`). */\nexport function scaledToDecimalOutput(value: bigint, scale: number): string {\n return scaledToDecimal(value, scale);\n}\n\nfunction conversionFailureMessage(\n field: string,\n value: string,\n failure: DecimalToScaledFailure,\n): string {\n return failure.reason === \"precision\"\n ? `${field} supports at most ${failure.maxDecimals} decimal places: ${value}`\n : `${field} must be a non-negative decimal number: ${value}`;\n}\n\n/**\n * Input direction: strict decimal→scaled conversion. Throws\n * CatalogConversionError for non-decimal input or inexact excess precision.\n */\nexport function decimalInputToScaled(field: string, value: string, scale: number): bigint {\n const result = tryDecimalToScaled(value.trim(), scale);\n if (!result.ok) {\n throw new CatalogConversionError(\n field,\n conversionFailureMessage(field, value, result.failure),\n );\n }\n return result.scaled;\n}\n\nfunction unboundedPositiveDecimalInputToScaled(\n field: string,\n value: string,\n scale: number,\n): bigint {\n const scaled = decimalInputToScaled(field, value, scale);\n if (scaled <= 0n) {\n throw new CatalogConversionError(field, `${field} must be greater than 0: ${value}`);\n }\n return scaled;\n}\n\n/**\n * Converts a positive decimal input to a scaled protobuf `int64` value.\n * Rejects values above the wire-format ceiling before serialization.\n */\nexport function positiveDecimalInputToScaled(field: string, value: string, scale: number): bigint {\n const scaled = unboundedPositiveDecimalInputToScaled(field, value, scale);\n if (scaled > PROTOBUF_INT64_MAX) {\n throw new CatalogConversionError(\n field,\n `${field} exceeds the maximum supported value: ${value}`,\n );\n }\n return scaled;\n}\n\n/**\n * Decimal quantity → PolyesterChain E18 ledger units.\n * Input precision is capped at the asset's quantityScale; the wire value is\n * always upscaled to E18 (trading balances / amount_e18 convention).\n */\nexport function quantityInputToE18(params: {\n scales: SdkScales;\n assetId: number;\n quantity: string;\n field?: string;\n}): bigint {\n const field = params.field ?? \"quantity\";\n const assetScale = params.scales.ledgerAmount(params.assetId);\n if (assetScale > E18_SCALE) {\n throw new CatalogConversionError(\n field,\n `${field} asset quantityScale ${assetScale} exceeds E18 ledger scale`,\n );\n }\n const scaled =\n unboundedPositiveDecimalInputToScaled(field, params.quantity, assetScale) *\n 10n ** BigInt(E18_SCALE - assetScale);\n if (scaled > U128_MAX) {\n throw new CatalogConversionError(\n field,\n `${field} exceeds the maximum supported value: ${params.quantity}`,\n );\n }\n return scaled;\n}\n\nexport interface ReadyGate {\n /** Queues or delivers one transition while the gate remains active. */\n run(deliver: () => void): void;\n /** Drops pending transitions and permanently prevents future delivery. */\n close(): void;\n}\n\ninterface ReadyGateHandlers {\n onDeliveryError?: (error: unknown) => void;\n onTerminalError: (error: unknown) => void;\n}\n\nconst READY_GATE_MAX_PENDING_DELIVERIES = 1_024;\n\n/**\n * Transition event delivery behind catalog readiness. Events arriving before the\n * catalog can resolve scales are queued and flushed in arrival order once it\n * is ready. Delivery errors are isolated from the transport. Readiness failure\n * or queue overflow is terminal because dropping an event would break stream\n * continuity; the owning subscription must visibly terminate when notified.\n */\nexport function createReadyGate(\n ready: () => Promise<void>,\n handlers: ReadyGateHandlers,\n): ReadyGate {\n let state: \"pending\" | \"open\" | \"closed\" = \"pending\";\n const queue: Array<() => void> = [];\n\n const deliverIsolated = (deliver: () => void) => {\n try {\n deliver();\n } catch (error) {\n handlers.onDeliveryError?.(error);\n }\n };\n\n const closeWithError = (error: unknown) => {\n if (state === \"closed\") return;\n state = \"closed\";\n queue.length = 0;\n handlers.onTerminalError(error);\n };\n\n Promise.resolve()\n .then(ready)\n .then(\n () => {\n if (state !== \"pending\") return;\n state = \"open\";\n for (const deliver of queue.splice(0)) deliverIsolated(deliver);\n },\n (error) => {\n if (state !== \"pending\") return;\n closeWithError(error);\n },\n );\n\n return {\n run(deliver) {\n if (state === \"open\") deliverIsolated(deliver);\n else if (state === \"pending\") {\n if (queue.length === READY_GATE_MAX_PENDING_DELIVERIES) {\n closeWithError(new CatalogNotReadyError());\n return;\n }\n queue.push(deliver);\n }\n },\n close() {\n if (state === \"closed\") return;\n state = \"closed\";\n queue.length = 0;\n },\n };\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import "../gen/polyester/type/v1/depth_tier_pb.js";
|
|
2
|
+
//#region src/shared/depth-tier.ts
|
|
3
|
+
/** Price levels per side that `polyester.type.v1.DepthTier` can express. */
|
|
4
|
+
const DEPTH_TIER_VALUES = [
|
|
5
|
+
1,
|
|
6
|
+
5,
|
|
7
|
+
10,
|
|
8
|
+
20,
|
|
9
|
+
50,
|
|
10
|
+
100,
|
|
11
|
+
200,
|
|
12
|
+
500,
|
|
13
|
+
1e3,
|
|
14
|
+
5e3
|
|
15
|
+
];
|
|
16
|
+
const DepthTierCodec = {
|
|
17
|
+
inputToProto: {
|
|
18
|
+
1: 1,
|
|
19
|
+
5: 2,
|
|
20
|
+
10: 3,
|
|
21
|
+
20: 4,
|
|
22
|
+
50: 5,
|
|
23
|
+
100: 6,
|
|
24
|
+
200: 7,
|
|
25
|
+
500: 8,
|
|
26
|
+
1e3: 9,
|
|
27
|
+
5e3: 10
|
|
28
|
+
},
|
|
29
|
+
protoToOutput: {
|
|
30
|
+
[0]: "unspecified",
|
|
31
|
+
[1]: 1,
|
|
32
|
+
[2]: 5,
|
|
33
|
+
[3]: 10,
|
|
34
|
+
[4]: 20,
|
|
35
|
+
[5]: 50,
|
|
36
|
+
[6]: 100,
|
|
37
|
+
[7]: 200,
|
|
38
|
+
[8]: 500,
|
|
39
|
+
[9]: 1e3,
|
|
40
|
+
[10]: 5e3
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
//#endregion
|
|
44
|
+
export { DEPTH_TIER_VALUES, DepthTierCodec };
|
|
45
|
+
|
|
46
|
+
//# sourceMappingURL=depth-tier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"depth-tier.js","names":[],"sources":["../../src/shared/depth-tier.ts"],"sourcesContent":["import { DepthTier } from \"../gen/polyester/type/v1/depth_tier_pb.js\";\nimport type { InputToProto, ProtoToOutput } from \"../utils/types.js\";\n\n/** Price levels per side that `polyester.type.v1.DepthTier` can express. */\nexport const DEPTH_TIER_VALUES = [1, 5, 10, 20, 50, 100, 200, 500, 1000, 5000] as const;\nexport type DepthTierValue = (typeof DEPTH_TIER_VALUES)[number];\n\nexport const DepthTierCodec = {\n inputToProto: {\n 1: DepthTier.DEPTH_1,\n 5: DepthTier.DEPTH_5,\n 10: DepthTier.DEPTH_10,\n 20: DepthTier.DEPTH_20,\n 50: DepthTier.DEPTH_50,\n 100: DepthTier.DEPTH_100,\n 200: DepthTier.DEPTH_200,\n 500: DepthTier.DEPTH_500,\n 1000: DepthTier.DEPTH_1000,\n 5000: DepthTier.DEPTH_5000,\n } satisfies InputToProto<DepthTierValue, DepthTier>,\n protoToOutput: {\n [DepthTier.DEPTH_UNSPECIFIED]: \"unspecified\",\n [DepthTier.DEPTH_1]: 1,\n [DepthTier.DEPTH_5]: 5,\n [DepthTier.DEPTH_10]: 10,\n [DepthTier.DEPTH_20]: 20,\n [DepthTier.DEPTH_50]: 50,\n [DepthTier.DEPTH_100]: 100,\n [DepthTier.DEPTH_200]: 200,\n [DepthTier.DEPTH_500]: 500,\n [DepthTier.DEPTH_1000]: 1000,\n [DepthTier.DEPTH_5000]: 5000,\n } satisfies ProtoToOutput<DepthTier, DepthTierValue>,\n} as const;\n"],"mappings":";;;AAIA,MAAa,oBAAoB;CAAC;CAAG;CAAG;CAAI;CAAI;CAAI;CAAK;CAAK;CAAK;CAAM;AAAI;AAG7E,MAAa,iBAAiB;CAC1B,cAAc;EACV,GAAA;EACA,GAAA;EACA,IAAA;EACA,IAAA;EACA,IAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;EACA,KAAA;CACJ;CACA,eAAe;GACoB,IAAA;GACV,IAAA;GACA,IAAA;GACC,IAAA;GACA,IAAA;GACA,IAAA;GACC,IAAA;GACA,IAAA;GACA,IAAA;GACC,IAAA;GACA,KAAA;CAC5B;AACJ"}
|
|
@@ -73,6 +73,12 @@ type PolyesterErrorDetail = {
|
|
|
73
73
|
service: "notifications";
|
|
74
74
|
code: NamedCode<typeof ErrorCode$6>;
|
|
75
75
|
} |
|
|
76
|
+
/** A request over the API's size limit; `limitBytes` is the limit it exceeded. */
|
|
77
|
+
{
|
|
78
|
+
service: "request";
|
|
79
|
+
code: "REQUEST_TOO_LARGE";
|
|
80
|
+
limitBytes: number;
|
|
81
|
+
} |
|
|
76
82
|
/** A service's quota refusal sent as a bare `RateLimitDetail`, e.g. wallet sign-in. */
|
|
77
83
|
{
|
|
78
84
|
service: "rate_limit";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-detail.d.ts","names":[],"sources":["../../src/shared/error-detail.ts"],"mappings":";;;;;;;;;;;;;;;KAuBK,UAAU,aAAa,gCAAgC;KAEhD;EAEF;EACA,MAAM,iBAAiB;EACvB;;;;;EAKA;;;;;;EAMA;IAAoB;IAAsB;IAAsB;;;EAGhE;EACA,MAAM,iBAAiB;EACvB;EACA;;EAED;IAAsB;EAErB;EACA,MAAM,iBAAiB;;EAEvB;;EAEA;;EAEA;;EAGA;EACA,MAAM,iBAAiB;;EAEzB;EAAmB,MAAM,iBAAiB;;EAExC;EACA,MAAM,iBAAiB;;EAGvB;EACA,MAAM,iBAAiB;;EAEvB;;EAEF;EAAmB,MAAM,iBAAiB;;EAC1C;EAAsB,MAAM,iBAAiB;;EAC7C;EAA0B,MAAM,iBAAiB;;;;EAEjD;EAAuB;EAA6B,WAAW;;;;;;;;
|
|
1
|
+
{"version":3,"file":"error-detail.d.ts","names":[],"sources":["../../src/shared/error-detail.ts"],"mappings":";;;;;;;;;;;;;;;KAuBK,UAAU,aAAa,gCAAgC;KAEhD;EAEF;EACA,MAAM,iBAAiB;EACvB;;;;;EAKA;;;;;;EAMA;IAAoB;IAAsB;IAAsB;;;EAGhE;EACA,MAAM,iBAAiB;EACvB;EACA;;EAED;IAAsB;EAErB;EACA,MAAM,iBAAiB;;EAEvB;;EAEA;;EAEA;;EAGA;EACA,MAAM,iBAAiB;;EAEzB;EAAmB,MAAM,iBAAiB;;EAExC;EACA,MAAM,iBAAiB;;EAGvB;EACA,MAAM,iBAAiB;;EAEvB;;EAEF;EAAmB,MAAM,iBAAiB;;EAC1C;EAAsB,MAAM,iBAAiB;;EAC7C;EAA0B,MAAM,iBAAiB;;;;EAEjD;EAAoB;EAA2B;;;;EAE/C;EAAuB;EAA6B,WAAW;;;;;;;;iBAsCjD,wBAAwB,kBAAkB"}
|
|
@@ -14,7 +14,8 @@ const DECODER_LOADERS = {
|
|
|
14
14
|
"alerts.v1.ErrorDetail": () => import("./error-details/alerts.js"),
|
|
15
15
|
"ai.v1.ErrorDetail": () => import("./error-details/assistant.js"),
|
|
16
16
|
"notifications.v1.ErrorDetail": () => import("./error-details/notifications.js"),
|
|
17
|
-
"polyester.ratelimit.v1.RateLimitDetail": () => import("./error-details/rate-limit.js")
|
|
17
|
+
"polyester.ratelimit.v1.RateLimitDetail": () => import("./error-details/rate-limit.js"),
|
|
18
|
+
"polyester.api.v1.RequestErrorDetail": () => import("./error-details/request.js")
|
|
18
19
|
};
|
|
19
20
|
/** Known detail type names, exposed so tests can pin them to the generated descriptors. */
|
|
20
21
|
const ERROR_DETAIL_TYPE_NAMES = Object.keys(DECODER_LOADERS);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-detail.js","names":[],"sources":["../../src/shared/error-detail.ts"],"sourcesContent":["import {\n create,\n fromBinary,\n type DescMessage,\n type MessageInitShape,\n type MessageShape,\n} from \"@bufbuild/protobuf\";\nimport { ConnectError } from \"@connectrpc/connect\";\n// Type-only: decoders (and the descriptors they need) load on demand, so the\n// transport layer doesn't pin every service's file descriptors into the bundle.\nimport type { ErrorCode as AssistantErrorCode } from \"../gen/ai/v1/assistant_pb.js\";\nimport type { ErrorCode as PriceAlertErrorCode } from \"../gen/alerts/v1/price_alerts_pb.js\";\nimport type { AuthErrorCode } from \"../gen/auth/v1/auth_pb.js\";\nimport type { ProfileErrorCode } from \"../gen/auth/v1/profile_pb.js\";\nimport type { ErrorCode as ClaimsErrorCode } from \"../gen/claims/v1/claims_pb.js\";\nimport type { ErrorCode as WithdrawErrorCode } from \"../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport type { ErrorCode as LedgerErrorCode } from \"../gen/ledger/read/v1/ledger_read_pb.js\";\nimport type { ErrorCode as MarketOverviewErrorCode } from \"../gen/marketoverview/v1/marketoverview_pb.js\";\nimport type { ErrorCode as NotificationErrorCode } from \"../gen/notifications/v1/notifications_pb.js\";\nimport type { ErrorCode as InternalTransferErrorCode } from \"../gen/transfer/v1/internal_transfer_pb.js\";\nimport type { OrderErrorDetail } from \"../services/orders/order-errors.schemas.js\";\nimport type { RateLimitDetail } from \"./rate-limit.schemas.js\";\n\ntype NamedCode<Enum extends Record<number, string>> = keyof Enum;\n\nexport type PolyesterErrorDetail =\n | {\n service: \"auth\";\n code: NamedCode<typeof AuthErrorCode>;\n message: string;\n /**\n * Epoch ms from which the same request may succeed; with `AUTH_SOCIAL_ACCOUNT_COOLDOWN`\n * and `AUTH_SOCIAL_CHANGE_LIMIT_REACHED`.\n */\n retryAfter?: number;\n /**\n * With `AUTH_TIMESTAMP_SKEW`: the server time (epoch ms) and the window a signed\n * request's timestamp must fall in, from `serverTimeMs - recvWindowMs` to\n * `serverTimeMs + maxFutureMs`. Compare `serverTimeMs` with the signing clock.\n */\n timestampWindow?: { serverTimeMs: number; recvWindowMs: number; maxFutureMs: number };\n }\n | {\n service: \"profile\";\n code: NamedCode<typeof ProfileErrorCode>;\n field: string;\n message: string;\n }\n | ({ service: \"orders\" } & OrderErrorDetail)\n | {\n service: \"withdraw\";\n code: NamedCode<typeof WithdrawErrorCode>;\n /** Request field the refusal concerns, such as `destinations[0].min_amount_e18`. */\n fieldPath?: string;\n /** Least amount the destination accepts, as a decimal; with `MIN_AMOUNT_BELOW_FLOOR`. */\n minFloor?: string;\n /** Epoch ms when a cooling-down destination can be paid; retry after it. */\n payableFrom?: number;\n }\n | {\n service: \"internal_transfer\";\n code: NamedCode<typeof InternalTransferErrorCode>;\n }\n | { service: \"ledger\"; code: NamedCode<typeof LedgerErrorCode> }\n | {\n service: \"market_overview\";\n code: NamedCode<typeof MarketOverviewErrorCode>;\n }\n | {\n service: \"claims\";\n code: NamedCode<typeof ClaimsErrorCode>;\n /** Claim the error concerns; set only with `CLAIM_OUTCOME_UNKNOWN`. */\n claimId?: string;\n }\n | { service: \"alerts\"; code: NamedCode<typeof PriceAlertErrorCode> }\n | { service: \"assistant\"; code: NamedCode<typeof AssistantErrorCode> }\n | { service: \"notifications\"; code: NamedCode<typeof NotificationErrorCode> }\n /** A service's quota refusal sent as a bare `RateLimitDetail`, e.g. wallet sign-in. */\n | { service: \"rate_limit\"; code: \"RATE_LIMIT_EXCEEDED\"; rateLimit: RateLimitDetail };\n\nexport type ConnectErrorDetail = ConnectError[\"details\"][number];\n\ntype ErrorDetailDecoder = (raw: ConnectErrorDetail) => PolyesterErrorDetail | undefined;\n\n/** Loads each known detail decoder, keyed by its protobuf type name. */\nconst DECODER_LOADERS: Record<string, () => Promise<{ decode: ErrorDetailDecoder }>> = {\n \"auth.v1.AuthErrorDetail\": () => import(\"./error-details/auth.js\"),\n \"auth.v1.ProfileErrorDetail\": () => import(\"./error-details/profile.js\"),\n \"orders.v1.ErrorDetail\": () => import(\"./error-details/orders.js\"),\n \"chain.withdraw.v1.ErrorDetail\": () => import(\"./error-details/withdraw.js\"),\n \"transfer.v1.ErrorDetail\": () => import(\"./error-details/internal-transfer.js\"),\n \"ledger.read.v1.ErrorDetail\": () => import(\"./error-details/ledger.js\"),\n \"marketoverview.v1.ErrorDetail\": () => import(\"./error-details/market-overview.js\"),\n \"claims.v1.ErrorDetail\": () => import(\"./error-details/claims.js\"),\n \"alerts.v1.ErrorDetail\": () => import(\"./error-details/alerts.js\"),\n \"ai.v1.ErrorDetail\": () => import(\"./error-details/assistant.js\"),\n \"notifications.v1.ErrorDetail\": () => import(\"./error-details/notifications.js\"),\n \"polyester.ratelimit.v1.RateLimitDetail\": () => import(\"./error-details/rate-limit.js\"),\n};\n\n/** Known detail type names, exposed so tests can pin them to the generated descriptors. */\nexport const ERROR_DETAIL_TYPE_NAMES: readonly string[] = Object.keys(DECODER_LOADERS);\n\nconst decoders = new Map<string, ErrorDetailDecoder>();\n\nfunction detailTypeName(raw: ConnectErrorDetail): string {\n return \"desc\" in raw ? raw.desc.typeName : raw.type;\n}\n\n/**\n * Loads the decoders for the details on `error`, or every decoder when called\n * without an error. SDK transports call this before mapping errors; call it\n * yourself before synchronously mapping a `ConnectError` that did not come\n * through an SDK transport.\n */\nexport async function loadErrorDetailDecoders(error?: unknown): Promise<void> {\n let typeNames: readonly string[];\n if (error === undefined) typeNames = ERROR_DETAIL_TYPE_NAMES;\n else if (error instanceof ConnectError) typeNames = error.details.map(detailTypeName);\n else return;\n\n await Promise.all(\n typeNames.map(async (typeName) => {\n const load = DECODER_LOADERS[typeName];\n if (!load || decoders.has(typeName)) return;\n try {\n decoders.set(typeName, (await load()).decode);\n } catch {\n // A failed chunk load only costs the structured detail; the error still maps.\n }\n }),\n );\n}\n\nexport function codeName<Enum extends Record<number, string>>(\n codes: Enum,\n code: number,\n): NamedCode<Enum> | undefined {\n if (typeof code !== \"number\") return undefined;\n const name = codes[code];\n return typeof name === \"string\" ? (name as NamedCode<Enum>) : undefined;\n}\n\nexport function decodeDetail<Desc extends DescMessage>(\n detail: ConnectErrorDetail,\n schema: Desc,\n): MessageShape<Desc> | undefined {\n try {\n if (\"desc\" in detail) {\n return create(schema, detail.value as MessageInitShape<Desc>);\n }\n return fromBinary(schema, detail.value);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Decodes the first valid backend rejection detail, preserving wire-detail order.\n * Details decode once {@link loadErrorDetailDecoders} has loaded their decoders.\n */\nexport function parseConnectErrorDetail(error: ConnectError): PolyesterErrorDetail | undefined {\n for (const raw of error.details) {\n const detail = decoders.get(detailTypeName(raw))?.(raw);\n if (detail) return detail;\n }\n return undefined;\n}\n"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"error-detail.js","names":[],"sources":["../../src/shared/error-detail.ts"],"sourcesContent":["import {\n create,\n fromBinary,\n type DescMessage,\n type MessageInitShape,\n type MessageShape,\n} from \"@bufbuild/protobuf\";\nimport { ConnectError } from \"@connectrpc/connect\";\n// Type-only: decoders (and the descriptors they need) load on demand, so the\n// transport layer doesn't pin every service's file descriptors into the bundle.\nimport type { ErrorCode as AssistantErrorCode } from \"../gen/ai/v1/assistant_pb.js\";\nimport type { ErrorCode as PriceAlertErrorCode } from \"../gen/alerts/v1/price_alerts_pb.js\";\nimport type { AuthErrorCode } from \"../gen/auth/v1/auth_pb.js\";\nimport type { ProfileErrorCode } from \"../gen/auth/v1/profile_pb.js\";\nimport type { ErrorCode as ClaimsErrorCode } from \"../gen/claims/v1/claims_pb.js\";\nimport type { ErrorCode as WithdrawErrorCode } from \"../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport type { ErrorCode as LedgerErrorCode } from \"../gen/ledger/read/v1/ledger_read_pb.js\";\nimport type { ErrorCode as MarketOverviewErrorCode } from \"../gen/marketoverview/v1/marketoverview_pb.js\";\nimport type { ErrorCode as NotificationErrorCode } from \"../gen/notifications/v1/notifications_pb.js\";\nimport type { ErrorCode as InternalTransferErrorCode } from \"../gen/transfer/v1/internal_transfer_pb.js\";\nimport type { OrderErrorDetail } from \"../services/orders/order-errors.schemas.js\";\nimport type { RateLimitDetail } from \"./rate-limit.schemas.js\";\n\ntype NamedCode<Enum extends Record<number, string>> = keyof Enum;\n\nexport type PolyesterErrorDetail =\n | {\n service: \"auth\";\n code: NamedCode<typeof AuthErrorCode>;\n message: string;\n /**\n * Epoch ms from which the same request may succeed; with `AUTH_SOCIAL_ACCOUNT_COOLDOWN`\n * and `AUTH_SOCIAL_CHANGE_LIMIT_REACHED`.\n */\n retryAfter?: number;\n /**\n * With `AUTH_TIMESTAMP_SKEW`: the server time (epoch ms) and the window a signed\n * request's timestamp must fall in, from `serverTimeMs - recvWindowMs` to\n * `serverTimeMs + maxFutureMs`. Compare `serverTimeMs` with the signing clock.\n */\n timestampWindow?: { serverTimeMs: number; recvWindowMs: number; maxFutureMs: number };\n }\n | {\n service: \"profile\";\n code: NamedCode<typeof ProfileErrorCode>;\n field: string;\n message: string;\n }\n | ({ service: \"orders\" } & OrderErrorDetail)\n | {\n service: \"withdraw\";\n code: NamedCode<typeof WithdrawErrorCode>;\n /** Request field the refusal concerns, such as `destinations[0].min_amount_e18`. */\n fieldPath?: string;\n /** Least amount the destination accepts, as a decimal; with `MIN_AMOUNT_BELOW_FLOOR`. */\n minFloor?: string;\n /** Epoch ms when a cooling-down destination can be paid; retry after it. */\n payableFrom?: number;\n }\n | {\n service: \"internal_transfer\";\n code: NamedCode<typeof InternalTransferErrorCode>;\n }\n | { service: \"ledger\"; code: NamedCode<typeof LedgerErrorCode> }\n | {\n service: \"market_overview\";\n code: NamedCode<typeof MarketOverviewErrorCode>;\n }\n | {\n service: \"claims\";\n code: NamedCode<typeof ClaimsErrorCode>;\n /** Claim the error concerns; set only with `CLAIM_OUTCOME_UNKNOWN`. */\n claimId?: string;\n }\n | { service: \"alerts\"; code: NamedCode<typeof PriceAlertErrorCode> }\n | { service: \"assistant\"; code: NamedCode<typeof AssistantErrorCode> }\n | { service: \"notifications\"; code: NamedCode<typeof NotificationErrorCode> }\n /** A request over the API's size limit; `limitBytes` is the limit it exceeded. */\n | { service: \"request\"; code: \"REQUEST_TOO_LARGE\"; limitBytes: number }\n /** A service's quota refusal sent as a bare `RateLimitDetail`, e.g. wallet sign-in. */\n | { service: \"rate_limit\"; code: \"RATE_LIMIT_EXCEEDED\"; rateLimit: RateLimitDetail };\n\nexport type ConnectErrorDetail = ConnectError[\"details\"][number];\n\ntype ErrorDetailDecoder = (raw: ConnectErrorDetail) => PolyesterErrorDetail | undefined;\n\n/** Loads each known detail decoder, keyed by its protobuf type name. */\nconst DECODER_LOADERS: Record<string, () => Promise<{ decode: ErrorDetailDecoder }>> = {\n \"auth.v1.AuthErrorDetail\": () => import(\"./error-details/auth.js\"),\n \"auth.v1.ProfileErrorDetail\": () => import(\"./error-details/profile.js\"),\n \"orders.v1.ErrorDetail\": () => import(\"./error-details/orders.js\"),\n \"chain.withdraw.v1.ErrorDetail\": () => import(\"./error-details/withdraw.js\"),\n \"transfer.v1.ErrorDetail\": () => import(\"./error-details/internal-transfer.js\"),\n \"ledger.read.v1.ErrorDetail\": () => import(\"./error-details/ledger.js\"),\n \"marketoverview.v1.ErrorDetail\": () => import(\"./error-details/market-overview.js\"),\n \"claims.v1.ErrorDetail\": () => import(\"./error-details/claims.js\"),\n \"alerts.v1.ErrorDetail\": () => import(\"./error-details/alerts.js\"),\n \"ai.v1.ErrorDetail\": () => import(\"./error-details/assistant.js\"),\n \"notifications.v1.ErrorDetail\": () => import(\"./error-details/notifications.js\"),\n \"polyester.ratelimit.v1.RateLimitDetail\": () => import(\"./error-details/rate-limit.js\"),\n \"polyester.api.v1.RequestErrorDetail\": () => import(\"./error-details/request.js\"),\n};\n\n/** Known detail type names, exposed so tests can pin them to the generated descriptors. */\nexport const ERROR_DETAIL_TYPE_NAMES: readonly string[] = Object.keys(DECODER_LOADERS);\n\nconst decoders = new Map<string, ErrorDetailDecoder>();\n\nfunction detailTypeName(raw: ConnectErrorDetail): string {\n return \"desc\" in raw ? raw.desc.typeName : raw.type;\n}\n\n/**\n * Loads the decoders for the details on `error`, or every decoder when called\n * without an error. SDK transports call this before mapping errors; call it\n * yourself before synchronously mapping a `ConnectError` that did not come\n * through an SDK transport.\n */\nexport async function loadErrorDetailDecoders(error?: unknown): Promise<void> {\n let typeNames: readonly string[];\n if (error === undefined) typeNames = ERROR_DETAIL_TYPE_NAMES;\n else if (error instanceof ConnectError) typeNames = error.details.map(detailTypeName);\n else return;\n\n await Promise.all(\n typeNames.map(async (typeName) => {\n const load = DECODER_LOADERS[typeName];\n if (!load || decoders.has(typeName)) return;\n try {\n decoders.set(typeName, (await load()).decode);\n } catch {\n // A failed chunk load only costs the structured detail; the error still maps.\n }\n }),\n );\n}\n\nexport function codeName<Enum extends Record<number, string>>(\n codes: Enum,\n code: number,\n): NamedCode<Enum> | undefined {\n if (typeof code !== \"number\") return undefined;\n const name = codes[code];\n return typeof name === \"string\" ? (name as NamedCode<Enum>) : undefined;\n}\n\nexport function decodeDetail<Desc extends DescMessage>(\n detail: ConnectErrorDetail,\n schema: Desc,\n): MessageShape<Desc> | undefined {\n try {\n if (\"desc\" in detail) {\n return create(schema, detail.value as MessageInitShape<Desc>);\n }\n return fromBinary(schema, detail.value);\n } catch {\n return undefined;\n }\n}\n\n/**\n * Decodes the first valid backend rejection detail, preserving wire-detail order.\n * Details decode once {@link loadErrorDetailDecoders} has loaded their decoders.\n */\nexport function parseConnectErrorDetail(error: ConnectError): PolyesterErrorDetail | undefined {\n for (const raw of error.details) {\n const detail = decoders.get(detailTypeName(raw))?.(raw);\n if (detail) return detail;\n }\n return undefined;\n}\n"],"mappings":";;;;AAuFA,MAAM,kBAAiF;CACnF,iCAAiC,OAAO;CACxC,oCAAoC,OAAO;CAC3C,+BAA+B,OAAO;CACtC,uCAAuC,OAAO;CAC9C,iCAAiC,OAAO;CACxC,oCAAoC,OAAO;CAC3C,uCAAuC,OAAO;CAC9C,+BAA+B,OAAO;CACtC,+BAA+B,OAAO;CACtC,2BAA2B,OAAO;CAClC,sCAAsC,OAAO;CAC7C,gDAAgD,OAAO;CACvD,6CAA6C,OAAO;AACxD;;AAGA,MAAa,0BAA6C,OAAO,KAAK,eAAe;AAErF,MAAM,2BAAW,IAAI,IAAgC;AAErD,SAAS,eAAe,KAAiC;CACrD,OAAO,UAAU,MAAM,IAAI,KAAK,WAAW,IAAI;AACnD;;;;;;;AAQA,eAAsB,wBAAwB,OAAgC;CAC1E,IAAI;CACJ,IAAI,UAAU,KAAA,GAAW,YAAY;MAChC,IAAI,iBAAiB,cAAc,YAAY,MAAM,QAAQ,IAAI,cAAc;MAC/E;CAEL,MAAM,QAAQ,IACV,UAAU,IAAI,OAAO,aAAa;EAC9B,MAAM,OAAO,gBAAgB;EAC7B,IAAI,CAAC,QAAQ,SAAS,IAAI,QAAQ,GAAG;EACrC,IAAI;GACA,SAAS,IAAI,WAAW,MAAM,KAAK,EAAA,CAAG,MAAM;EAChD,QAAQ,CAER;CACJ,CAAC,CACL;AACJ;AAEA,SAAgB,SACZ,OACA,MAC2B;CAC3B,IAAI,OAAO,SAAS,UAAU,OAAO,KAAA;CACrC,MAAM,OAAO,MAAM;CACnB,OAAO,OAAO,SAAS,WAAY,OAA2B,KAAA;AAClE;AAEA,SAAgB,aACZ,QACA,QAC8B;CAC9B,IAAI;EACA,IAAI,UAAU,QACV,OAAO,OAAO,QAAQ,OAAO,KAA+B;EAEhE,OAAO,WAAW,QAAQ,OAAO,KAAK;CAC1C,QAAQ;EACJ;CACJ;AACJ;;;;;AAMA,SAAgB,wBAAwB,OAAuD;CAC3F,KAAK,MAAM,OAAO,MAAM,SAAS;EAC7B,MAAM,SAAS,SAAS,IAAI,eAAe,GAAG,CAAC,CAAC,GAAG,GAAG;EACtD,IAAI,QAAQ,OAAO;CACvB;AAEJ"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { decodeDetail } from "../error-detail.js";
|
|
2
|
+
import { RequestErrorDetailSchema } from "../../gen/polyester/api/v1/request_error_pb.js";
|
|
3
|
+
//#region src/shared/error-details/request.ts
|
|
4
|
+
/** An unknown code decodes to nothing, so the error maps as a plain `resource_exhausted`. */
|
|
5
|
+
function decode(raw) {
|
|
6
|
+
const detail = decodeDetail(raw, RequestErrorDetailSchema);
|
|
7
|
+
return detail?.code === 1 ? {
|
|
8
|
+
service: "request",
|
|
9
|
+
code: "REQUEST_TOO_LARGE",
|
|
10
|
+
limitBytes: Number(detail.limitBytes)
|
|
11
|
+
} : void 0;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { decode };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"request.js","names":[],"sources":["../../../src/shared/error-details/request.ts"],"sourcesContent":["import {\n RequestErrorCode,\n RequestErrorDetailSchema,\n} from \"../../gen/polyester/api/v1/request_error_pb.js\";\nimport {\n decodeDetail,\n type ConnectErrorDetail,\n type PolyesterErrorDetail,\n} from \"../error-detail.js\";\n\n/** An unknown code decodes to nothing, so the error maps as a plain `resource_exhausted`. */\nexport function decode(raw: ConnectErrorDetail): PolyesterErrorDetail | undefined {\n const detail = decodeDetail(raw, RequestErrorDetailSchema);\n return detail?.code === RequestErrorCode.REQUEST_TOO_LARGE\n ? { service: \"request\", code: \"REQUEST_TOO_LARGE\", limitBytes: Number(detail.limitBytes) }\n : undefined;\n}\n"],"mappings":";;;;AAWA,SAAgB,OAAO,KAA2D;CAC9E,MAAM,SAAS,aAAa,KAAK,wBAAwB;CACzD,OAAO,QAAQ,SAAA,IACT;EAAE,SAAS;EAAW,MAAM;EAAqB,YAAY,OAAO,OAAO,UAAU;CAAE,IACvF,KAAA;AACV"}
|
|
@@ -21,7 +21,7 @@ declare const RateLimitDetailSchema: v.ObjectSchema<{
|
|
|
21
21
|
readonly policyVersion: v.SchemaWithPipe<readonly [v.OptionalSchema<v.BigintSchema<undefined>, undefined>, v.TransformAction<bigint | undefined, string | undefined>]>;
|
|
22
22
|
readonly operationId: v.StringSchema<undefined>;
|
|
23
23
|
readonly policyClass: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "auth_public" | "trading_place" | "trading_cancel" | "trading_read" | "account_admin" | "public_read" | "account_security" | "deposit_create" | "internal_transfer" | "withdraw_submit" | "withdraw_validate" | "guard_sign" | "social_provider" | "assistant_message" | "assistant_control" | "assistant_read">]>;
|
|
24
|
-
readonly scope: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "symbol" | "unspecified" | "
|
|
24
|
+
readonly scope: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "symbol" | "unspecified" | "subaccount" | "client_ip" | "api_key" | "account" | "connection" | "service" | "region" | "auth_subject">]>;
|
|
25
25
|
readonly refillModel: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "continuous" | "fixed_window" | "rolling_window">]>;
|
|
26
26
|
}, undefined>;
|
|
27
27
|
/** Structured quota state exposed by order rejections and {@link RateLimitError}. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wired-services.d.ts","names":[],"sources":["../src/wired-services.ts"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"wired-services.d.ts","names":[],"sources":["../src/wired-services.ts"],"mappings":";;;;;;;;;;;cAuDa,oCAAoC"}
|
package/dist/wired-services.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { MFAService } from "./gen/auth/v1/mfa_pb.js";
|
|
2
|
-
import { AuthService } from "./gen/auth/v1/auth_pb.js";
|
|
3
|
-
import { ProfileService } from "./gen/auth/v1/profile_pb.js";
|
|
4
1
|
import { ApiKeyService } from "./gen/auth/v1/api_keys_pb.js";
|
|
5
2
|
import { PolicyService } from "./gen/auth/v1/policies_pb.js";
|
|
6
3
|
import { LedgerReadService } from "./gen/ledger/read/v1/ledger_read_pb.js";
|
|
7
4
|
import { SubaccountRoleService, SubaccountService, SubaccountViewService } from "./gen/auth/v1/subaccounts_pb.js";
|
|
5
|
+
import { AddressBookService } from "./gen/auth/v1/address_book_pb.js";
|
|
6
|
+
import { MFAService } from "./gen/auth/v1/mfa_pb.js";
|
|
7
|
+
import { AuthService } from "./gen/auth/v1/auth_pb.js";
|
|
8
|
+
import { ProfileService } from "./gen/auth/v1/profile_pb.js";
|
|
8
9
|
import { AccountActivityService } from "./gen/auth/v1/activity_pb.js";
|
|
9
10
|
import { ResolveService } from "./gen/auth/v1/resolve_pb.js";
|
|
10
|
-
import { AddressBookService } from "./gen/auth/v1/address_book_pb.js";
|
|
11
11
|
import { PriceAlertService } from "./gen/alerts/v1/price_alerts_pb.js";
|
|
12
12
|
import { DepositAddressService } from "./gen/chain/deposit/v1/deposit_pb.js";
|
|
13
13
|
import { MarketDataService } from "./gen/marketdata/v1/marketdata_pb.js";
|
|
@@ -20,6 +20,7 @@ import { ChainAnalyticsService } from "./gen/chain/analytics/v1/analytics_read_p
|
|
|
20
20
|
import { ChangelogService } from "./gen/changelog/v1/changelog_pb.js";
|
|
21
21
|
import { CheckpointService } from "./gen/checkpoints/v1/checkpoints_pb.js";
|
|
22
22
|
import { ClaimsService } from "./gen/claims/v1/claims_pb.js";
|
|
23
|
+
import { ConnectedAppService } from "./gen/auth/v1/connected_apps_pb.js";
|
|
23
24
|
import { FeeService } from "./gen/fees/v1/fees_pb.js";
|
|
24
25
|
import { VIPService } from "./gen/vip/v1/vip_pb.js";
|
|
25
26
|
import { GuardSignerService } from "./gen/chain/guard/v1/guard_signer_pb.js";
|
|
@@ -58,6 +59,7 @@ const WIRED_SERVICE_DESCRIPTORS = [
|
|
|
58
59
|
ChangelogService,
|
|
59
60
|
CheckpointService,
|
|
60
61
|
ClaimsService,
|
|
62
|
+
ConnectedAppService,
|
|
61
63
|
DepositAddressService,
|
|
62
64
|
DustConversionService,
|
|
63
65
|
FeeService,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wired-services.js","names":[],"sources":["../src/wired-services.ts"],"sourcesContent":["import type { DescService } from \"@bufbuild/protobuf\";\nimport { AssistantService } from \"./gen/ai/v1/assistant_pb.js\";\nimport { PriceAlertService } from \"./gen/alerts/v1/price_alerts_pb.js\";\nimport { AccountActivityService } from \"./gen/auth/v1/activity_pb.js\";\nimport { AddressBookService } from \"./gen/auth/v1/address_book_pb.js\";\nimport { ApiKeyService } from \"./gen/auth/v1/api_keys_pb.js\";\nimport { AuthService } from \"./gen/auth/v1/auth_pb.js\";\nimport { MFAService } from \"./gen/auth/v1/mfa_pb.js\";\nimport { PolicyService } from \"./gen/auth/v1/policies_pb.js\";\nimport { ProfileService } from \"./gen/auth/v1/profile_pb.js\";\nimport { ResolveService } from \"./gen/auth/v1/resolve_pb.js\";\nimport { SocialVerificationService } from \"./gen/auth/v1/social_verification_pb.js\";\nimport {\n SubaccountRoleService,\n SubaccountService,\n SubaccountViewService,\n} from \"./gen/auth/v1/subaccounts_pb.js\";\nimport { ChainAnalyticsService } from \"./gen/chain/analytics/v1/analytics_read_pb.js\";\nimport { DepositAddressService } from \"./gen/chain/deposit/v1/deposit_pb.js\";\nimport { GuardSignerService } from \"./gen/chain/guard/v1/guard_signer_pb.js\";\nimport { LifecycleReadService } from \"./gen/chain/lifecycle/v1/lifecycle_read_pb.js\";\nimport { AutoWithdrawService } from \"./gen/chain/withdraw/v1/auto_withdraw_pb.js\";\nimport { WithdrawService } from \"./gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { ZipperService } from \"./gen/chain/zipper/v1/zipper_pb.js\";\nimport { ChangelogService } from \"./gen/changelog/v1/changelog_pb.js\";\nimport { CheckpointService } from \"./gen/checkpoints/v1/checkpoints_pb.js\";\nimport { ClaimsService } from \"./gen/claims/v1/claims_pb.js\";\nimport { FeeService } from \"./gen/fees/v1/fees_pb.js\";\nimport { LedgerReadService } from \"./gen/ledger/read/v1/ledger_read_pb.js\";\nimport { DustConversionService } from \"./gen/transfer/v1/dust_conversion_pb.js\";\nimport { StatementExportService } from \"./gen/ledger/read/v1/statement_export_pb.js\";\nimport { HeatmapService } from \"./gen/marketdata/v1/heatmap_pb.js\";\nimport { MarketDataService } from \"./gen/marketdata/v1/marketdata_pb.js\";\nimport { MarketOverviewService } from \"./gen/marketoverview/v1/marketoverview_pb.js\";\nimport { NotificationService } from \"./gen/notifications/v1/notifications_pb.js\";\nimport { OrderbookService } from \"./gen/orderbook/v1/orderbook_pb.js\";\nimport { OrdersService } from \"./gen/orders/v1/orders_pb.js\";\nimport { OrdersReadService } from \"./gen/orders/v1/orders_read_pb.js\";\nimport { RateLimitService } from \"./gen/ratelimit/v1/ratelimit_pb.js\";\nimport { RewardCampaignService } from \"./gen/rewards/v1/rewards_pb.js\";\nimport { InternalTransferService } from \"./gen/transfer/v1/internal_transfer_pb.js\";\nimport { SystemService } from \"./gen/system/v1/system_pb.js\";\nimport { TriggersService } from \"./gen/triggers/v1/triggers_pb.js\";\nimport { VIPService } from \"./gen/vip/v1/vip_pb.js\";\n\n/**\n * Every proto service descriptor the SDK's service layer wires a client for.\n * This is the authoritative surface for transport-level mocks: an in-memory\n * transport that routes all of these can serve the whole SDK.\n *\n * Kept in sync mechanically — `wired-services.test.ts` scans every\n * `createClient(...)` call site under `src/services` and `src/realtime` and\n * fails when this list drifts from the code.\n */\nexport const WIRED_SERVICE_DESCRIPTORS: readonly DescService[] = [\n AccountActivityService,\n AddressBookService,\n ApiKeyService,\n AssistantService,\n AuthService,\n AutoWithdrawService,\n ChainAnalyticsService,\n ChangelogService,\n CheckpointService,\n ClaimsService,\n DepositAddressService,\n DustConversionService,\n FeeService,\n GuardSignerService,\n HeatmapService,\n InternalTransferService,\n LedgerReadService,\n LifecycleReadService,\n MarketDataService,\n MarketOverviewService,\n MFAService,\n NotificationService,\n OrderbookService,\n OrdersReadService,\n OrdersService,\n PolicyService,\n PriceAlertService,\n ProfileService,\n RateLimitService,\n ResolveService,\n RewardCampaignService,\n SocialVerificationService,\n StatementExportService,\n SubaccountRoleService,\n SubaccountService,\n SubaccountViewService,\n SystemService,\n TriggersService,\n VIPService,\n WithdrawService,\n ZipperService,\n];\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"wired-services.js","names":[],"sources":["../src/wired-services.ts"],"sourcesContent":["import type { DescService } from \"@bufbuild/protobuf\";\nimport { AssistantService } from \"./gen/ai/v1/assistant_pb.js\";\nimport { PriceAlertService } from \"./gen/alerts/v1/price_alerts_pb.js\";\nimport { AccountActivityService } from \"./gen/auth/v1/activity_pb.js\";\nimport { AddressBookService } from \"./gen/auth/v1/address_book_pb.js\";\nimport { ApiKeyService } from \"./gen/auth/v1/api_keys_pb.js\";\nimport { AuthService } from \"./gen/auth/v1/auth_pb.js\";\nimport { ConnectedAppService } from \"./gen/auth/v1/connected_apps_pb.js\";\nimport { MFAService } from \"./gen/auth/v1/mfa_pb.js\";\nimport { PolicyService } from \"./gen/auth/v1/policies_pb.js\";\nimport { ProfileService } from \"./gen/auth/v1/profile_pb.js\";\nimport { ResolveService } from \"./gen/auth/v1/resolve_pb.js\";\nimport { SocialVerificationService } from \"./gen/auth/v1/social_verification_pb.js\";\nimport {\n SubaccountRoleService,\n SubaccountService,\n SubaccountViewService,\n} from \"./gen/auth/v1/subaccounts_pb.js\";\nimport { ChainAnalyticsService } from \"./gen/chain/analytics/v1/analytics_read_pb.js\";\nimport { DepositAddressService } from \"./gen/chain/deposit/v1/deposit_pb.js\";\nimport { GuardSignerService } from \"./gen/chain/guard/v1/guard_signer_pb.js\";\nimport { LifecycleReadService } from \"./gen/chain/lifecycle/v1/lifecycle_read_pb.js\";\nimport { AutoWithdrawService } from \"./gen/chain/withdraw/v1/auto_withdraw_pb.js\";\nimport { WithdrawService } from \"./gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { ZipperService } from \"./gen/chain/zipper/v1/zipper_pb.js\";\nimport { ChangelogService } from \"./gen/changelog/v1/changelog_pb.js\";\nimport { CheckpointService } from \"./gen/checkpoints/v1/checkpoints_pb.js\";\nimport { ClaimsService } from \"./gen/claims/v1/claims_pb.js\";\nimport { FeeService } from \"./gen/fees/v1/fees_pb.js\";\nimport { LedgerReadService } from \"./gen/ledger/read/v1/ledger_read_pb.js\";\nimport { DustConversionService } from \"./gen/transfer/v1/dust_conversion_pb.js\";\nimport { StatementExportService } from \"./gen/ledger/read/v1/statement_export_pb.js\";\nimport { HeatmapService } from \"./gen/marketdata/v1/heatmap_pb.js\";\nimport { MarketDataService } from \"./gen/marketdata/v1/marketdata_pb.js\";\nimport { MarketOverviewService } from \"./gen/marketoverview/v1/marketoverview_pb.js\";\nimport { NotificationService } from \"./gen/notifications/v1/notifications_pb.js\";\nimport { OrderbookService } from \"./gen/orderbook/v1/orderbook_pb.js\";\nimport { OrdersService } from \"./gen/orders/v1/orders_pb.js\";\nimport { OrdersReadService } from \"./gen/orders/v1/orders_read_pb.js\";\nimport { RateLimitService } from \"./gen/ratelimit/v1/ratelimit_pb.js\";\nimport { RewardCampaignService } from \"./gen/rewards/v1/rewards_pb.js\";\nimport { InternalTransferService } from \"./gen/transfer/v1/internal_transfer_pb.js\";\nimport { SystemService } from \"./gen/system/v1/system_pb.js\";\nimport { TriggersService } from \"./gen/triggers/v1/triggers_pb.js\";\nimport { VIPService } from \"./gen/vip/v1/vip_pb.js\";\n\n/**\n * Every proto service descriptor the SDK's service layer wires a client for.\n * This is the authoritative surface for transport-level mocks: an in-memory\n * transport that routes all of these can serve the whole SDK.\n *\n * Kept in sync mechanically — `wired-services.test.ts` scans every\n * `createClient(...)` call site under `src/services` and `src/realtime` and\n * fails when this list drifts from the code.\n */\nexport const WIRED_SERVICE_DESCRIPTORS: readonly DescService[] = [\n AccountActivityService,\n AddressBookService,\n ApiKeyService,\n AssistantService,\n AuthService,\n AutoWithdrawService,\n ChainAnalyticsService,\n ChangelogService,\n CheckpointService,\n ClaimsService,\n ConnectedAppService,\n DepositAddressService,\n DustConversionService,\n FeeService,\n GuardSignerService,\n HeatmapService,\n InternalTransferService,\n LedgerReadService,\n LifecycleReadService,\n MarketDataService,\n MarketOverviewService,\n MFAService,\n NotificationService,\n OrderbookService,\n OrdersReadService,\n OrdersService,\n PolicyService,\n PriceAlertService,\n ProfileService,\n RateLimitService,\n ResolveService,\n RewardCampaignService,\n SocialVerificationService,\n StatementExportService,\n SubaccountRoleService,\n SubaccountService,\n SubaccountViewService,\n SystemService,\n TriggersService,\n VIPService,\n WithdrawService,\n ZipperService,\n];\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAa,4BAAoD;CAC7D;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@polyester/sdk",
|
|
3
|
-
"version": "0.36.0-devnet-
|
|
3
|
+
"version": "0.36.0-devnet-20261119010940",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "TypeScript SDK providing access to APIs on Polyester Exchange.",
|
|
6
6
|
"homepage": "https://github.com/Fabric-Labs/polyester-sdk-typescript#readme",
|