@polyester/sdk 0.4.0 → 0.4.1
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 +6 -0
- package/dist/_virtual/_rolldown/runtime.js +1 -15
- package/dist/catalogs/snapshot-validation.js +63 -63
- package/dist/catalogs/snapshot-validation.js.map +1 -1
- package/dist/services/accounts/accounts.js +1 -1
- package/dist/services/accounts/accounts.js.map +1 -1
- package/dist/services/accounts/accounts.schemas.d.ts +13 -13
- package/dist/services/accounts/accounts.schemas.d.ts.map +1 -1
- package/dist/services/accounts/accounts.schemas.js +11 -11
- package/dist/services/accounts/accounts.schemas.js.map +1 -1
- package/dist/services/address-book/address-book.js.map +1 -1
- package/dist/services/address-book/address-book.schemas.d.ts +751 -751
- package/dist/services/address-book/address-book.schemas.d.ts.map +1 -1
- package/dist/services/address-book/address-book.schemas.js +160 -159
- package/dist/services/address-book/address-book.schemas.js.map +1 -1
- package/dist/services/api-keys/api-keys.d.ts +6 -6
- package/dist/services/api-keys/api-keys.d.ts.map +1 -1
- package/dist/services/api-keys/api-keys.js.map +1 -1
- package/dist/services/api-keys/api-keys.schemas.d.ts +62 -62
- package/dist/services/api-keys/api-keys.schemas.d.ts.map +1 -1
- package/dist/services/api-keys/api-keys.schemas.js +34 -34
- package/dist/services/api-keys/api-keys.schemas.js.map +1 -1
- package/dist/services/auth/auth.d.ts +39 -39
- package/dist/services/auth/auth.d.ts.map +1 -1
- package/dist/services/auth/auth.js +19 -18
- package/dist/services/auth/auth.js.map +1 -1
- package/dist/services/auth/profile/profile.d.ts +2 -2
- package/dist/services/auth/profile/profile.d.ts.map +1 -1
- package/dist/services/auth/profile/profile.js +3 -2
- package/dist/services/auth/profile/profile.js.map +1 -1
- package/dist/services/auth/profile/profile.schemas.d.ts +41 -41
- package/dist/services/auth/profile/profile.schemas.d.ts.map +1 -1
- package/dist/services/auth/profile/profile.schemas.js +27 -27
- package/dist/services/auth/profile/profile.schemas.js.map +1 -1
- package/dist/services/auth/session.schemas.js +17 -17
- package/dist/services/auth/session.schemas.js.map +1 -1
- package/dist/services/balances/balances.d.ts.map +1 -1
- package/dist/services/balances/balances.js +3 -2
- package/dist/services/balances/balances.js.map +1 -1
- package/dist/services/balances/balances.schemas.d.ts +95 -95
- package/dist/services/balances/balances.schemas.d.ts.map +1 -1
- package/dist/services/balances/balances.schemas.js +61 -61
- package/dist/services/balances/balances.schemas.js.map +1 -1
- package/dist/services/candles/candles.d.ts.map +1 -1
- package/dist/services/candles/candles.js +5 -4
- package/dist/services/candles/candles.js.map +1 -1
- package/dist/services/candles/candles.schemas.d.ts +64 -64
- package/dist/services/candles/candles.schemas.d.ts.map +1 -1
- package/dist/services/candles/candles.schemas.js +47 -47
- package/dist/services/candles/candles.schemas.js.map +1 -1
- package/dist/services/chain-analytics/chain-analytics.js.map +1 -1
- package/dist/services/chain-analytics/chain-analytics.schemas.d.ts +68 -68
- package/dist/services/chain-analytics/chain-analytics.schemas.d.ts.map +1 -1
- package/dist/services/chain-analytics/chain-analytics.schemas.js +29 -29
- package/dist/services/chain-analytics/chain-analytics.schemas.js.map +1 -1
- package/dist/services/deposit/deposit.js.map +1 -1
- package/dist/services/deposit/deposit.schemas.d.ts +17 -17
- package/dist/services/deposit/deposit.schemas.d.ts.map +1 -1
- package/dist/services/deposit/deposit.schemas.js +11 -11
- package/dist/services/deposit/deposit.schemas.js.map +1 -1
- package/dist/services/guard-signer/guard-signer.js.map +1 -1
- package/dist/services/guard-signer/guard-signer.schemas.d.ts +75 -75
- package/dist/services/guard-signer/guard-signer.schemas.d.ts.map +1 -1
- package/dist/services/guard-signer/guard-signer.schemas.js +42 -42
- package/dist/services/guard-signer/guard-signer.schemas.js.map +1 -1
- package/dist/services/heatmap/heatmap.d.ts.map +1 -1
- package/dist/services/heatmap/heatmap.js +5 -4
- package/dist/services/heatmap/heatmap.js.map +1 -1
- package/dist/services/heatmap/heatmap.schemas.d.ts +138 -138
- package/dist/services/heatmap/heatmap.schemas.d.ts.map +1 -1
- package/dist/services/heatmap/heatmap.schemas.js +47 -47
- package/dist/services/heatmap/heatmap.schemas.js.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.js.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +53 -53
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.schemas.js +27 -27
- package/dist/services/internal-transfers/internal-transfers.schemas.js.map +1 -1
- package/dist/services/lifecycle/lifecycle.d.ts.map +1 -1
- package/dist/services/lifecycle/lifecycle.js +3 -2
- package/dist/services/lifecycle/lifecycle.js.map +1 -1
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +614 -614
- package/dist/services/lifecycle/lifecycle.schemas.d.ts.map +1 -1
- package/dist/services/lifecycle/lifecycle.schemas.js +146 -146
- package/dist/services/lifecycle/lifecycle.schemas.js.map +1 -1
- package/dist/services/market-data/market-data.d.ts.map +1 -1
- package/dist/services/market-data/market-data.js +4 -3
- package/dist/services/market-data/market-data.js.map +1 -1
- package/dist/services/market-data/market-data.schemas.d.ts +19 -19
- package/dist/services/market-data/market-data.schemas.d.ts.map +1 -1
- package/dist/services/market-data/market-data.schemas.js +50 -50
- package/dist/services/market-data/market-data.schemas.js.map +1 -1
- package/dist/services/market-overview/market-overview.d.ts.map +1 -1
- package/dist/services/market-overview/market-overview.js +3 -2
- package/dist/services/market-overview/market-overview.js.map +1 -1
- package/dist/services/market-overview/market-overview.schemas.d.ts +37 -37
- package/dist/services/market-overview/market-overview.schemas.d.ts.map +1 -1
- package/dist/services/market-overview/market-overview.schemas.js +33 -33
- package/dist/services/market-overview/market-overview.schemas.js.map +1 -1
- package/dist/services/mfa/mfa.js +1 -1
- package/dist/services/mfa/mfa.js.map +1 -1
- package/dist/services/mfa/mfa.schemas.d.ts +206 -206
- package/dist/services/mfa/mfa.schemas.d.ts.map +1 -1
- package/dist/services/mfa/mfa.schemas.js +83 -83
- package/dist/services/mfa/mfa.schemas.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 +3 -2
- package/dist/services/orderbook/orderbook.js.map +1 -1
- package/dist/services/orderbook/orderbook.schemas.d.ts +23 -23
- package/dist/services/orderbook/orderbook.schemas.d.ts.map +1 -1
- package/dist/services/orderbook/orderbook.schemas.js +15 -15
- package/dist/services/orderbook/orderbook.schemas.js.map +1 -1
- package/dist/services/orders/order-errors.schemas.d.ts +18 -18
- package/dist/services/orders/order-errors.schemas.d.ts.map +1 -1
- package/dist/services/orders/order-errors.schemas.js +8 -8
- package/dist/services/orders/order-errors.schemas.js.map +1 -1
- package/dist/services/orders/orders-batch.schemas.d.ts +504 -504
- package/dist/services/orders/orders-batch.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-batch.schemas.js +117 -117
- package/dist/services/orders/orders-batch.schemas.js.map +1 -1
- package/dist/services/orders/orders-identifiers.schemas.js +5 -5
- package/dist/services/orders/orders-identifiers.schemas.js.map +1 -1
- package/dist/services/orders/orders-input.schemas.d.ts +648 -648
- package/dist/services/orders/orders-input.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-input.schemas.js +95 -95
- package/dist/services/orders/orders-input.schemas.js.map +1 -1
- package/dist/services/orders/orders-modify.schemas.d.ts +351 -351
- package/dist/services/orders/orders-modify.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-modify.schemas.js +44 -44
- package/dist/services/orders/orders-modify.schemas.js.map +1 -1
- package/dist/services/orders/orders-output.schemas.d.ts +183 -183
- package/dist/services/orders/orders-output.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-output.schemas.js +49 -49
- package/dist/services/orders/orders-output.schemas.js.map +1 -1
- package/dist/services/orders/orders-risk.schemas.d.ts +226 -226
- package/dist/services/orders/orders-risk.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-risk.schemas.js +69 -69
- package/dist/services/orders/orders-risk.schemas.js.map +1 -1
- package/dist/services/orders/orders.d.ts +6 -6
- package/dist/services/orders/orders.d.ts.map +1 -1
- package/dist/services/orders/orders.js +4 -3
- package/dist/services/orders/orders.js.map +1 -1
- package/dist/services/policies/api-key-policies/api-key-policies.d.ts +6 -6
- 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.map +1 -1
- package/dist/services/policies/api-key-policies/api-key-policies.schemas.d.ts +105 -105
- 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 +49 -49
- package/dist/services/policies/api-key-policies/api-key-policies.schemas.js.map +1 -1
- package/dist/services/policies/shared.d.ts +5 -5
- package/dist/services/policies/shared.d.ts.map +1 -1
- package/dist/services/policies/shared.js +10 -10
- package/dist/services/policies/shared.js.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.d.ts +6 -6
- package/dist/services/policies/subaccount-policies/subaccount-policies.d.ts.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.js +3 -2
- package/dist/services/policies/subaccount-policies/subaccount-policies.js.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts +124 -124
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js +75 -75
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js.map +1 -1
- package/dist/services/shared.js +11 -11
- package/dist/services/shared.js.map +1 -1
- package/dist/services/social-verification/social-verification.d.ts +3 -3
- package/dist/services/social-verification/social-verification.d.ts.map +1 -1
- package/dist/services/social-verification/social-verification.js.map +1 -1
- package/dist/services/social-verification/social-verification.schemas.d.ts +54 -54
- package/dist/services/social-verification/social-verification.schemas.d.ts.map +1 -1
- package/dist/services/social-verification/social-verification.schemas.js +28 -28
- package/dist/services/social-verification/social-verification.schemas.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.d.ts +14 -14
- package/dist/services/subaccounts/subaccounts.d.ts.map +1 -1
- package/dist/services/subaccounts/subaccounts.js +9 -8
- package/dist/services/subaccounts/subaccounts.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +135 -135
- package/dist/services/subaccounts/subaccounts.schemas.d.ts.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.js +72 -72
- package/dist/services/subaccounts/subaccounts.schemas.js.map +1 -1
- package/dist/services/trades/trades.d.ts +2 -2
- package/dist/services/trades/trades.d.ts.map +1 -1
- package/dist/services/trades/trades.js +3 -2
- package/dist/services/trades/trades.js.map +1 -1
- package/dist/services/trades/trades.schemas.d.ts +31 -31
- package/dist/services/trades/trades.schemas.d.ts.map +1 -1
- package/dist/services/trades/trades.schemas.js +24 -24
- package/dist/services/trades/trades.schemas.js.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.js +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.js.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts +45 -45
- package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.schemas.js +36 -36
- package/dist/services/trading-withdraws/trading-withdraws.schemas.js.map +1 -1
- package/dist/services/transfers/transfers.d.ts.map +1 -1
- package/dist/services/transfers/transfers.js +3 -2
- package/dist/services/transfers/transfers.js.map +1 -1
- package/dist/services/transfers/transfers.schemas.d.ts +42 -42
- package/dist/services/transfers/transfers.schemas.d.ts.map +1 -1
- package/dist/services/transfers/transfers.schemas.js +30 -30
- package/dist/services/transfers/transfers.schemas.js.map +1 -1
- package/dist/services/triggers/trigger-child-order.schemas.js +23 -23
- package/dist/services/triggers/trigger-child-order.schemas.js.map +1 -1
- package/dist/services/triggers/trigger-input.schemas.d.ts +226 -226
- package/dist/services/triggers/trigger-input.schemas.d.ts.map +1 -1
- package/dist/services/triggers/trigger-input.schemas.js +53 -53
- package/dist/services/triggers/trigger-input.schemas.js.map +1 -1
- package/dist/services/triggers/triggers-output.schemas.d.ts +209 -209
- package/dist/services/triggers/triggers-output.schemas.d.ts.map +1 -1
- package/dist/services/triggers/triggers-output.schemas.js +152 -152
- package/dist/services/triggers/triggers-output.schemas.js.map +1 -1
- package/dist/services/triggers/triggers.d.ts.map +1 -1
- package/dist/services/triggers/triggers.js +4 -3
- package/dist/services/triggers/triggers.js.map +1 -1
- package/dist/services/whiteboard/whiteboard.js.map +1 -1
- package/dist/services/whiteboard/whiteboard.schemas.d.ts +379 -379
- package/dist/services/whiteboard/whiteboard.schemas.d.ts.map +1 -1
- package/dist/services/whiteboard/whiteboard.schemas.js +71 -71
- package/dist/services/whiteboard/whiteboard.schemas.js.map +1 -1
- package/dist/services/zipper/zipper.js.map +1 -1
- package/dist/services/zipper/zipper.schemas.d.ts +1 -1
- package/dist/services/zipper/zipper.schemas.js +54 -54
- package/dist/services/zipper/zipper.schemas.js.map +1 -1
- package/dist/shared/account-scope.d.ts +6 -6
- package/dist/shared/account-scope.d.ts.map +1 -1
- package/dist/shared/account-scope.js +3 -3
- package/dist/shared/account-scope.js.map +1 -1
- package/dist/shared/connect-error-mapping.js +2 -2
- package/dist/shared/connect-error-mapping.js.map +1 -1
- package/dist/shared/rate-limit.schemas.d.ts +12 -12
- package/dist/shared/rate-limit.schemas.d.ts.map +1 -1
- package/dist/shared/rate-limit.schemas.js +7 -7
- package/dist/shared/rate-limit.schemas.js.map +1 -1
- package/dist/shared/schemas.js +26 -26
- package/dist/shared/schemas.js.map +1 -1
- package/dist/shared/validation.js +1 -6
- package/dist/shared/validation.js.map +1 -1
- package/dist/utils/connect-order-errors.js +2 -2
- package/dist/utils/connect-order-errors.js.map +1 -1
- package/package.json +3 -3
- package/dist/shared/validation.d.ts +0 -14
- package/dist/shared/validation.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heatmap.schemas.js","names":["v"],"sources":["../../../src/services/heatmap/heatmap.schemas.ts"],"sourcesContent":["import * as v from \"../../shared/validation.js\";\nimport type {\n HeatmapDepth,\n HeatmapInterval,\n HeatmapQuantityMode,\n} from \"../../gen/marketdata/v1/heatmap_pb.js\";\nimport { OptionalTimestampSecondsInputSchema } from \"../../shared/schemas.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport type { DecodedEnum } from \"../../utils/types.js\";\nimport { scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport {\n HEATMAP_DEPTH_VALUES,\n HEATMAP_INTERVAL_VALUES,\n HEATMAP_QUANTITY_MODE_VALUES,\n HeatmapDepthCodec,\n HeatmapIntervalCodec,\n HeatmapQuantityModeCodec,\n type HeatmapIntervalValue,\n type HeatmapQuantityModeValue,\n} from \"./heatmap.codecs.js\";\n\ntype HeatmapTimeRangeInit = {\n startTime?: TimestampInit;\n endTime?: TimestampInit;\n};\n\ntype TimestampInit = { seconds: bigint; nanos: number };\n\nconst IntervalInputSchema = v.pipe(\n v.optional(v.picklist(HEATMAP_INTERVAL_VALUES), \"1s\"),\n v.transform((value): HeatmapInterval => HeatmapIntervalCodec.inputToProto[value]),\n);\n\nconst DepthInputSchema = v.pipe(\n v.optional(v.picklist(HEATMAP_DEPTH_VALUES), 50),\n v.transform((value): HeatmapDepth => HeatmapDepthCodec.inputToProto[value]),\n);\n\nconst QuantityModeInputSchema = v.pipe(\n v.optional(v.picklist(HEATMAP_QUANTITY_MODE_VALUES), \"close\"),\n v.transform((value): HeatmapQuantityMode => HeatmapQuantityModeCodec.inputToProto[value]),\n);\n\nfunction timestampFromTsSec(tsSec: bigint): TimestampInit {\n return { seconds: tsSec, nanos: 0 };\n}\n\nexport const GetOrderbookHeatmapInputSchema = v.pipe(\n v.object({\n symbolId: v.pipe(v.number(), v.integer(), v.gtValue(0)),\n interval: IntervalInputSchema,\n depth: DepthInputSchema,\n quantityMode: QuantityModeInputSchema,\n limit: v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(20_000)),\n startTsSec: OptionalTimestampSecondsInputSchema,\n endTsSec: OptionalTimestampSecondsInputSchema,\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.check(\n (value) => value.pageToken !== \"\" || value.startTsSec != null || value.endTsSec != null,\n \"pageToken, startTsSec, or endTsSec is required\",\n ),\n v.transform((value) => {\n const timeRange: HeatmapTimeRangeInit | undefined =\n value.pageToken !== \"\"\n ? undefined\n : {\n startTime:\n value.startTsSec != null\n ? timestampFromTsSec(value.startTsSec)\n : undefined,\n endTime:\n value.endTsSec != null ? timestampFromTsSec(value.endTsSec) : undefined,\n };\n\n return {\n symbolId: value.symbolId,\n interval: value.interval,\n depth: value.depth,\n quantityMode: value.quantityMode,\n limit: value.limit,\n pageToken: value.pageToken,\n timeRange,\n };\n }),\n);\n\nfunction requiredIntervalLabelFor(value: number): DecodedEnum<HeatmapIntervalValue> {\n return requiredEnumLabel(\n HeatmapIntervalCodec.protoToOutput,\n value,\n \"OrderbookHeatmapResponseSchema\",\n \"interval\",\n );\n}\n\nfunction requiredQuantityModeLabelFor(value: number): DecodedEnum<HeatmapQuantityModeValue> {\n return requiredEnumLabel(\n HeatmapQuantityModeCodec.protoToOutput,\n value,\n \"OrderbookHeatmapResponseSchema\",\n \"quantity mode\",\n );\n}\n\nconst TimestampSecondsSchema = v.pipe(\n v.bigint(),\n v.transform((value) => Number(value)),\n);\n\nconst Uint64StringSchema = v.pipe(\n v.bigint(),\n v.transform((value) => value.toString()),\n);\n\nconst OrderbookHeatmapLevelsRawSchema = v.object({\n priceTicks: v.array(v.bigint()),\n qtyScaled: v.array(v.bigint()),\n});\n\ntype OrderbookHeatmapLevelsRaw = v.InferOutput<typeof OrderbookHeatmapLevelsRawSchema>;\n\nfunction convertHeatmapLevels(\n levels: OrderbookHeatmapLevelsRaw,\n priceScale: number,\n qtyScale: number,\n) {\n return {\n price: levels.priceTicks.map((tick) => scaledToDecimalOutput(tick, priceScale)),\n qty: levels.qtyScaled.map((qty) => scaledToDecimalOutput(qty, qtyScale)),\n };\n}\n\nexport type OrderbookHeatmapLevels = ReturnType<typeof convertHeatmapLevels>;\n\nexport type OrderbookHeatmapDeltaLevels = OrderbookHeatmapLevels;\n\nconst OrderbookHeatmapKeyframeRawSchema = v.object({\n tsSec: TimestampSecondsSchema,\n bestBidTicks: v.bigint(),\n bestAskTicks: v.bigint(),\n midTicks: v.bigint(),\n bids: v.optional(OrderbookHeatmapLevelsRawSchema),\n asks: v.optional(OrderbookHeatmapLevelsRawSchema),\n bookSeq: Uint64StringSchema,\n});\n\ntype OrderbookHeatmapKeyframeRaw = v.InferOutput<typeof OrderbookHeatmapKeyframeRawSchema>;\n\nfunction convertHeatmapKeyframe(\n keyframe: OrderbookHeatmapKeyframeRaw,\n priceScale: number,\n qtyScale: number,\n) {\n return {\n tsSec: keyframe.tsSec,\n bestBid: scaledToDecimalOutput(keyframe.bestBidTicks, priceScale),\n bestAsk: scaledToDecimalOutput(keyframe.bestAskTicks, priceScale),\n mid: scaledToDecimalOutput(keyframe.midTicks, priceScale),\n bids: keyframe.bids ? convertHeatmapLevels(keyframe.bids, priceScale, qtyScale) : undefined,\n asks: keyframe.asks ? convertHeatmapLevels(keyframe.asks, priceScale, qtyScale) : undefined,\n bookSeq: keyframe.bookSeq,\n };\n}\n\nexport type OrderbookHeatmapKeyframe = ReturnType<typeof convertHeatmapKeyframe>;\n\nconst OrderbookHeatmapDeltaBucketRawSchema = v.object({\n tsSec: TimestampSecondsSchema,\n bids: v.optional(OrderbookHeatmapLevelsRawSchema),\n asks: v.optional(OrderbookHeatmapLevelsRawSchema),\n updatesInBucket: v.number(),\n bookSeqStart: Uint64StringSchema,\n bookSeqEnd: Uint64StringSchema,\n});\n\ntype OrderbookHeatmapDeltaBucketRaw = v.InferOutput<typeof OrderbookHeatmapDeltaBucketRawSchema>;\n\nfunction convertHeatmapDeltaBucket(\n bucket: OrderbookHeatmapDeltaBucketRaw,\n priceScale: number,\n qtyScale: number,\n) {\n return {\n tsSec: bucket.tsSec,\n bids: bucket.bids ? convertHeatmapLevels(bucket.bids, priceScale, qtyScale) : undefined,\n asks: bucket.asks ? convertHeatmapLevels(bucket.asks, priceScale, qtyScale) : undefined,\n updatesInBucket: bucket.updatesInBucket,\n bookSeqStart: bucket.bookSeqStart,\n bookSeqEnd: bucket.bookSeqEnd,\n };\n}\n\nexport type OrderbookHeatmapDeltaBucket = ReturnType<typeof convertHeatmapDeltaBucket>;\n\nconst OrderbookHeatmapLiveBucketRawSchema = v.object({\n symbolId: v.number(),\n interval: v.pipe(v.number(), v.transform(requiredIntervalLabelFor)),\n tsSec: TimestampSecondsSchema,\n isFinal: v.boolean(),\n bids: v.optional(OrderbookHeatmapLevelsRawSchema),\n asks: v.optional(OrderbookHeatmapLevelsRawSchema),\n updatesInBucket: v.number(),\n bookSeqStart: Uint64StringSchema,\n bookSeqEnd: Uint64StringSchema,\n quantityMode: v.pipe(v.number(), v.transform(requiredQuantityModeLabelFor)),\n effectiveBinTicks: v.bigint(),\n});\n\ntype OrderbookHeatmapLiveBucketRaw = v.InferOutput<typeof OrderbookHeatmapLiveBucketRawSchema>;\n\nfunction convertHeatmapLiveBucket(bucket: OrderbookHeatmapLiveBucketRaw, scales: SdkScales) {\n const priceScale = scales.price();\n const qtyScale = scales.baseQty(bucket.symbolId);\n return {\n symbolId: bucket.symbolId,\n interval: bucket.interval,\n tsSec: bucket.tsSec,\n isFinal: bucket.isFinal,\n bids: bucket.bids ? convertHeatmapLevels(bucket.bids, priceScale, qtyScale) : undefined,\n asks: bucket.asks ? convertHeatmapLevels(bucket.asks, priceScale, qtyScale) : undefined,\n updatesInBucket: bucket.updatesInBucket,\n bookSeqStart: bucket.bookSeqStart,\n bookSeqEnd: bucket.bookSeqEnd,\n quantityMode: bucket.quantityMode,\n effectiveBinSize: scaledToDecimalOutput(bucket.effectiveBinTicks, priceScale),\n };\n}\n\nexport type OrderbookHeatmapLiveBucket = ReturnType<typeof convertHeatmapLiveBucket>;\n\nexport function createOrderbookHeatmapLiveBucketSchema(scales: SdkScales) {\n return v.pipe(\n OrderbookHeatmapLiveBucketRawSchema,\n v.transform((bucket) => convertHeatmapLiveBucket(bucket, scales)),\n );\n}\n\nconst OrderbookHeatmapDeltaChainRawSchema = v.object({\n baseKeyframe: v.optional(OrderbookHeatmapKeyframeRawSchema),\n deltas: v.optional(v.array(OrderbookHeatmapDeltaBucketRawSchema), []),\n});\n\ntype OrderbookHeatmapDeltaChainRaw = v.InferOutput<typeof OrderbookHeatmapDeltaChainRawSchema>;\n\nfunction convertHeatmapDeltaChain(\n chain: OrderbookHeatmapDeltaChainRaw,\n priceScale: number,\n qtyScale: number,\n) {\n return {\n baseKeyframe: chain.baseKeyframe\n ? convertHeatmapKeyframe(chain.baseKeyframe, priceScale, qtyScale)\n : undefined,\n deltas: chain.deltas.map((bucket) =>\n convertHeatmapDeltaBucket(bucket, priceScale, qtyScale),\n ),\n };\n}\n\nexport type OrderbookHeatmapDeltaChain = ReturnType<typeof convertHeatmapDeltaChain>;\n\nconst OrderbookHeatmapResponseRawSchema = v.object({\n symbolId: v.number(),\n interval: v.pipe(v.number(), v.transform(requiredIntervalLabelFor)),\n depth: v.pipe(\n v.number(),\n v.transform((value) =>\n requiredEnumLabel(\n HeatmapDepthCodec.protoToOutput,\n value,\n \"OrderbookHeatmapResponseSchema\",\n \"depth\",\n ),\n ),\n ),\n chain: v.optional(OrderbookHeatmapDeltaChainRawSchema),\n lastPersistedTsSec: TimestampSecondsSchema,\n liveFromBookSeqEnd: Uint64StringSchema,\n hasLiveAnchor: v.boolean(),\n nextPageToken: v.optional(v.string(), \"\"),\n serverTimeSec: TimestampSecondsSchema,\n quantityMode: v.pipe(v.number(), v.transform(requiredQuantityModeLabelFor)),\n liveBucket: v.optional(OrderbookHeatmapLiveBucketRawSchema),\n});\n\nexport function createOrderbookHeatmapResponseSchema(scales: SdkScales) {\n return v.pipe(\n OrderbookHeatmapResponseRawSchema,\n v.transform((res) => {\n const priceScale = scales.price();\n const qtyScale = scales.baseQty(res.symbolId);\n return {\n symbolId: res.symbolId,\n interval: res.interval,\n depth: res.depth,\n chain: res.chain\n ? convertHeatmapDeltaChain(res.chain, priceScale, qtyScale)\n : undefined,\n lastPersistedTsSec: res.lastPersistedTsSec,\n liveFromBookSeqEnd: res.liveFromBookSeqEnd,\n hasLiveAnchor: res.hasLiveAnchor,\n nextPageToken: res.nextPageToken,\n serverTimeSec: res.serverTimeSec,\n quantityMode: res.quantityMode,\n liveBucket: res.liveBucket\n ? convertHeatmapLiveBucket(res.liveBucket, scales)\n : undefined,\n };\n }),\n );\n}\n\nexport type GetOrderbookHeatmapInput = v.InferInput<typeof GetOrderbookHeatmapInputSchema>;\nexport type ParsedGetOrderbookHeatmapInput = v.InferOutput<typeof GetOrderbookHeatmapInputSchema>;\nexport type OrderbookHeatmapResponse = v.InferOutput<\n ReturnType<typeof createOrderbookHeatmapResponseSchema>\n>;\nexport type ParsedHeatmapTimeRange = HeatmapTimeRangeInit;\n"],"mappings":";;;;;;AA4BA,MAAM,sBAAsBA,mBAAE,KAC1BA,mBAAE,SAASA,mBAAE,SAAS,uBAAuB,GAAG,IAAI,GACpDA,mBAAE,WAAW,UAA2B,qBAAqB,aAAa,MAAM,CACpF;AAEA,MAAM,mBAAmBA,mBAAE,KACvBA,mBAAE,SAASA,mBAAE,SAAS,oBAAoB,GAAG,EAAE,GAC/CA,mBAAE,WAAW,UAAwB,kBAAkB,aAAa,MAAM,CAC9E;AAEA,MAAM,0BAA0BA,mBAAE,KAC9BA,mBAAE,SAASA,mBAAE,SAAS,4BAA4B,GAAG,OAAO,GAC5DA,mBAAE,WAAW,UAA+B,yBAAyB,aAAa,MAAM,CAC5F;AAEA,SAAS,mBAAmB,OAA8B;CACtD,OAAO;EAAE,SAAS;EAAO,OAAO;CAAE;AACtC;AAEA,MAAa,iCAAiCA,mBAAE,KAC5CA,mBAAE,OAAO;CACL,UAAUA,mBAAE,KAAKA,mBAAE,OAAO,GAAGA,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YAAY,QAAQ,IAC/D,KAAA;EACN,QAAQ,MAAM,OAAO,KAAK,WACtB,0BAA0B,QAAQ,YAAY,QAAQ,CAC1D;CACJ;AACJ;AAIA,MAAM,oCAAoCA,mBAAE,OAAO;CAC/C,UAAUA,mBAAE,OAAO;CACnB,UAAUA,mBAAE,KAAKA,mBAAE,OAAO,GAAGA,mBAAE,UAAU,wBAAwB,CAAC;CAClE,OAAOA,mBAAE,KACLA,mBAAE,OAAO,GACTA,mBAAE,WAAW,UACT,kBACI,kBAAkB,eAClB,OACA,kCACA,OACJ,CACJ,CACJ;CACA,OAAOA,mBAAE,SAAS,mCAAmC;CACrD,oBAAoB;CACpB,oBAAoB;CACpB,eAAeA,mBAAE,QAAQ;CACzB,eAAeA,mBAAE,SAASA,mBAAE,OAAO,GAAG,EAAE;CACxC,eAAe;CACf,cAAcA,mBAAE,KAAKA,mBAAE,OAAO,GAAGA,mBAAE,UAAU,4BAA4B,CAAC;CAC1E,YAAYA,mBAAE,SAAS,mCAAmC;AAC9D,CAAC;AAED,SAAgB,qCAAqC,QAAmB;CACpE,OAAOA,mBAAE,KACL,mCACAA,mBAAE,WAAW,QAAQ;EACjB,MAAM,aAAa,OAAO,MAAM;EAChC,MAAM,WAAW,OAAO,QAAQ,IAAI,QAAQ;EAC5C,OAAO;GACH,UAAU,IAAI;GACd,UAAU,IAAI;GACd,OAAO,IAAI;GACX,OAAO,IAAI,QACL,yBAAyB,IAAI,OAAO,YAAY,QAAQ,IACxD,KAAA;GACN,oBAAoB,IAAI;GACxB,oBAAoB,IAAI;GACxB,eAAe,IAAI;GACnB,eAAe,IAAI;GACnB,eAAe,IAAI;GACnB,cAAc,IAAI;GAClB,YAAY,IAAI,aACV,yBAAyB,IAAI,YAAY,MAAM,IAC/C,KAAA;EACV;CACJ,CAAC,CACL;AACJ"}
|
|
1
|
+
{"version":3,"file":"heatmap.schemas.js","names":[],"sources":["../../../src/services/heatmap/heatmap.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport type {\n HeatmapDepth,\n HeatmapInterval,\n HeatmapQuantityMode,\n} from \"../../gen/marketdata/v1/heatmap_pb.js\";\nimport { OptionalTimestampSecondsInputSchema } from \"../../shared/schemas.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport type { DecodedEnum } from \"../../utils/types.js\";\nimport { scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport {\n HEATMAP_DEPTH_VALUES,\n HEATMAP_INTERVAL_VALUES,\n HEATMAP_QUANTITY_MODE_VALUES,\n HeatmapDepthCodec,\n HeatmapIntervalCodec,\n HeatmapQuantityModeCodec,\n type HeatmapIntervalValue,\n type HeatmapQuantityModeValue,\n} from \"./heatmap.codecs.js\";\n\ntype HeatmapTimeRangeInit = {\n startTime?: TimestampInit;\n endTime?: TimestampInit;\n};\n\ntype TimestampInit = { seconds: bigint; nanos: number };\n\nconst IntervalInputSchema = v.pipe(\n v.optional(v.picklist(HEATMAP_INTERVAL_VALUES), \"1s\"),\n v.transform((value): HeatmapInterval => HeatmapIntervalCodec.inputToProto[value]),\n);\n\nconst DepthInputSchema = v.pipe(\n v.optional(v.picklist(HEATMAP_DEPTH_VALUES), 50),\n v.transform((value): HeatmapDepth => HeatmapDepthCodec.inputToProto[value]),\n);\n\nconst QuantityModeInputSchema = v.pipe(\n v.optional(v.picklist(HEATMAP_QUANTITY_MODE_VALUES), \"close\"),\n v.transform((value): HeatmapQuantityMode => HeatmapQuantityModeCodec.inputToProto[value]),\n);\n\nfunction timestampFromTsSec(tsSec: bigint): TimestampInit {\n return { seconds: tsSec, nanos: 0 };\n}\n\nexport const GetOrderbookHeatmapInputSchema = v.pipe(\n v.object({\n symbolId: v.pipe(v.number(), v.integer(), v.gtValue(0)),\n interval: IntervalInputSchema,\n depth: DepthInputSchema,\n quantityMode: QuantityModeInputSchema,\n limit: v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(20_000)),\n startTsSec: OptionalTimestampSecondsInputSchema,\n endTsSec: OptionalTimestampSecondsInputSchema,\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.check(\n (value) => value.pageToken !== \"\" || value.startTsSec != null || value.endTsSec != null,\n \"pageToken, startTsSec, or endTsSec is required\",\n ),\n v.transform((value) => {\n const timeRange: HeatmapTimeRangeInit | undefined =\n value.pageToken !== \"\"\n ? undefined\n : {\n startTime:\n value.startTsSec != null\n ? timestampFromTsSec(value.startTsSec)\n : undefined,\n endTime:\n value.endTsSec != null ? timestampFromTsSec(value.endTsSec) : undefined,\n };\n\n return {\n symbolId: value.symbolId,\n interval: value.interval,\n depth: value.depth,\n quantityMode: value.quantityMode,\n limit: value.limit,\n pageToken: value.pageToken,\n timeRange,\n };\n }),\n);\n\nfunction requiredIntervalLabelFor(value: number): DecodedEnum<HeatmapIntervalValue> {\n return requiredEnumLabel(\n HeatmapIntervalCodec.protoToOutput,\n value,\n \"OrderbookHeatmapResponseSchema\",\n \"interval\",\n );\n}\n\nfunction requiredQuantityModeLabelFor(value: number): DecodedEnum<HeatmapQuantityModeValue> {\n return requiredEnumLabel(\n HeatmapQuantityModeCodec.protoToOutput,\n value,\n \"OrderbookHeatmapResponseSchema\",\n \"quantity mode\",\n );\n}\n\nconst TimestampSecondsSchema = v.pipe(\n v.bigint(),\n v.transform((value) => Number(value)),\n);\n\nconst Uint64StringSchema = v.pipe(\n v.bigint(),\n v.transform((value) => value.toString()),\n);\n\nconst OrderbookHeatmapLevelsRawSchema = v.object({\n priceTicks: v.array(v.bigint()),\n qtyScaled: v.array(v.bigint()),\n});\n\ntype OrderbookHeatmapLevelsRaw = v.InferOutput<typeof OrderbookHeatmapLevelsRawSchema>;\n\nfunction convertHeatmapLevels(\n levels: OrderbookHeatmapLevelsRaw,\n priceScale: number,\n qtyScale: number,\n) {\n return {\n price: levels.priceTicks.map((tick) => scaledToDecimalOutput(tick, priceScale)),\n qty: levels.qtyScaled.map((qty) => scaledToDecimalOutput(qty, qtyScale)),\n };\n}\n\nexport type OrderbookHeatmapLevels = ReturnType<typeof convertHeatmapLevels>;\n\nexport type OrderbookHeatmapDeltaLevels = OrderbookHeatmapLevels;\n\nconst OrderbookHeatmapKeyframeRawSchema = v.object({\n tsSec: TimestampSecondsSchema,\n bestBidTicks: v.bigint(),\n bestAskTicks: v.bigint(),\n midTicks: v.bigint(),\n bids: v.optional(OrderbookHeatmapLevelsRawSchema),\n asks: v.optional(OrderbookHeatmapLevelsRawSchema),\n bookSeq: Uint64StringSchema,\n});\n\ntype OrderbookHeatmapKeyframeRaw = v.InferOutput<typeof OrderbookHeatmapKeyframeRawSchema>;\n\nfunction convertHeatmapKeyframe(\n keyframe: OrderbookHeatmapKeyframeRaw,\n priceScale: number,\n qtyScale: number,\n) {\n return {\n tsSec: keyframe.tsSec,\n bestBid: scaledToDecimalOutput(keyframe.bestBidTicks, priceScale),\n bestAsk: scaledToDecimalOutput(keyframe.bestAskTicks, priceScale),\n mid: scaledToDecimalOutput(keyframe.midTicks, priceScale),\n bids: keyframe.bids ? convertHeatmapLevels(keyframe.bids, priceScale, qtyScale) : undefined,\n asks: keyframe.asks ? convertHeatmapLevels(keyframe.asks, priceScale, qtyScale) : undefined,\n bookSeq: keyframe.bookSeq,\n };\n}\n\nexport type OrderbookHeatmapKeyframe = ReturnType<typeof convertHeatmapKeyframe>;\n\nconst OrderbookHeatmapDeltaBucketRawSchema = v.object({\n tsSec: TimestampSecondsSchema,\n bids: v.optional(OrderbookHeatmapLevelsRawSchema),\n asks: v.optional(OrderbookHeatmapLevelsRawSchema),\n updatesInBucket: v.number(),\n bookSeqStart: Uint64StringSchema,\n bookSeqEnd: Uint64StringSchema,\n});\n\ntype OrderbookHeatmapDeltaBucketRaw = v.InferOutput<typeof OrderbookHeatmapDeltaBucketRawSchema>;\n\nfunction convertHeatmapDeltaBucket(\n bucket: OrderbookHeatmapDeltaBucketRaw,\n priceScale: number,\n qtyScale: number,\n) {\n return {\n tsSec: bucket.tsSec,\n bids: bucket.bids ? convertHeatmapLevels(bucket.bids, priceScale, qtyScale) : undefined,\n asks: bucket.asks ? convertHeatmapLevels(bucket.asks, priceScale, qtyScale) : undefined,\n updatesInBucket: bucket.updatesInBucket,\n bookSeqStart: bucket.bookSeqStart,\n bookSeqEnd: bucket.bookSeqEnd,\n };\n}\n\nexport type OrderbookHeatmapDeltaBucket = ReturnType<typeof convertHeatmapDeltaBucket>;\n\nconst OrderbookHeatmapLiveBucketRawSchema = v.object({\n symbolId: v.number(),\n interval: v.pipe(v.number(), v.transform(requiredIntervalLabelFor)),\n tsSec: TimestampSecondsSchema,\n isFinal: v.boolean(),\n bids: v.optional(OrderbookHeatmapLevelsRawSchema),\n asks: v.optional(OrderbookHeatmapLevelsRawSchema),\n updatesInBucket: v.number(),\n bookSeqStart: Uint64StringSchema,\n bookSeqEnd: Uint64StringSchema,\n quantityMode: v.pipe(v.number(), v.transform(requiredQuantityModeLabelFor)),\n effectiveBinTicks: v.bigint(),\n});\n\ntype OrderbookHeatmapLiveBucketRaw = v.InferOutput<typeof OrderbookHeatmapLiveBucketRawSchema>;\n\nfunction convertHeatmapLiveBucket(bucket: OrderbookHeatmapLiveBucketRaw, scales: SdkScales) {\n const priceScale = scales.price();\n const qtyScale = scales.baseQty(bucket.symbolId);\n return {\n symbolId: bucket.symbolId,\n interval: bucket.interval,\n tsSec: bucket.tsSec,\n isFinal: bucket.isFinal,\n bids: bucket.bids ? convertHeatmapLevels(bucket.bids, priceScale, qtyScale) : undefined,\n asks: bucket.asks ? convertHeatmapLevels(bucket.asks, priceScale, qtyScale) : undefined,\n updatesInBucket: bucket.updatesInBucket,\n bookSeqStart: bucket.bookSeqStart,\n bookSeqEnd: bucket.bookSeqEnd,\n quantityMode: bucket.quantityMode,\n effectiveBinSize: scaledToDecimalOutput(bucket.effectiveBinTicks, priceScale),\n };\n}\n\nexport type OrderbookHeatmapLiveBucket = ReturnType<typeof convertHeatmapLiveBucket>;\n\nexport function createOrderbookHeatmapLiveBucketSchema(scales: SdkScales) {\n return v.pipe(\n OrderbookHeatmapLiveBucketRawSchema,\n v.transform((bucket) => convertHeatmapLiveBucket(bucket, scales)),\n );\n}\n\nconst OrderbookHeatmapDeltaChainRawSchema = v.object({\n baseKeyframe: v.optional(OrderbookHeatmapKeyframeRawSchema),\n deltas: v.optional(v.array(OrderbookHeatmapDeltaBucketRawSchema), []),\n});\n\ntype OrderbookHeatmapDeltaChainRaw = v.InferOutput<typeof OrderbookHeatmapDeltaChainRawSchema>;\n\nfunction convertHeatmapDeltaChain(\n chain: OrderbookHeatmapDeltaChainRaw,\n priceScale: number,\n qtyScale: number,\n) {\n return {\n baseKeyframe: chain.baseKeyframe\n ? convertHeatmapKeyframe(chain.baseKeyframe, priceScale, qtyScale)\n : undefined,\n deltas: chain.deltas.map((bucket) =>\n convertHeatmapDeltaBucket(bucket, priceScale, qtyScale),\n ),\n };\n}\n\nexport type OrderbookHeatmapDeltaChain = ReturnType<typeof convertHeatmapDeltaChain>;\n\nconst OrderbookHeatmapResponseRawSchema = v.object({\n symbolId: v.number(),\n interval: v.pipe(v.number(), v.transform(requiredIntervalLabelFor)),\n depth: v.pipe(\n v.number(),\n v.transform((value) =>\n requiredEnumLabel(\n HeatmapDepthCodec.protoToOutput,\n value,\n \"OrderbookHeatmapResponseSchema\",\n \"depth\",\n ),\n ),\n ),\n chain: v.optional(OrderbookHeatmapDeltaChainRawSchema),\n lastPersistedTsSec: TimestampSecondsSchema,\n liveFromBookSeqEnd: Uint64StringSchema,\n hasLiveAnchor: v.boolean(),\n nextPageToken: v.optional(v.string(), \"\"),\n serverTimeSec: TimestampSecondsSchema,\n quantityMode: v.pipe(v.number(), v.transform(requiredQuantityModeLabelFor)),\n liveBucket: v.optional(OrderbookHeatmapLiveBucketRawSchema),\n});\n\nexport function createOrderbookHeatmapResponseSchema(scales: SdkScales) {\n return v.pipe(\n OrderbookHeatmapResponseRawSchema,\n v.transform((res) => {\n const priceScale = scales.price();\n const qtyScale = scales.baseQty(res.symbolId);\n return {\n symbolId: res.symbolId,\n interval: res.interval,\n depth: res.depth,\n chain: res.chain\n ? convertHeatmapDeltaChain(res.chain, priceScale, qtyScale)\n : undefined,\n lastPersistedTsSec: res.lastPersistedTsSec,\n liveFromBookSeqEnd: res.liveFromBookSeqEnd,\n hasLiveAnchor: res.hasLiveAnchor,\n nextPageToken: res.nextPageToken,\n serverTimeSec: res.serverTimeSec,\n quantityMode: res.quantityMode,\n liveBucket: res.liveBucket\n ? convertHeatmapLiveBucket(res.liveBucket, scales)\n : undefined,\n };\n }),\n );\n}\n\nexport type GetOrderbookHeatmapInput = v.InferInput<typeof GetOrderbookHeatmapInputSchema>;\nexport type ParsedGetOrderbookHeatmapInput = v.InferOutput<typeof GetOrderbookHeatmapInputSchema>;\nexport type OrderbookHeatmapResponse = v.InferOutput<\n ReturnType<typeof createOrderbookHeatmapResponseSchema>\n>;\nexport type ParsedHeatmapTimeRange = HeatmapTimeRangeInit;\n"],"mappings":";;;;;;AA4BA,MAAM,sBAAsB,EAAE,KAC1B,EAAE,SAAS,EAAE,SAAS,uBAAuB,GAAG,IAAI,GACpD,EAAE,WAAW,UAA2B,qBAAqB,aAAa,MAAM,CACpF;AAEA,MAAM,mBAAmB,EAAE,KACvB,EAAE,SAAS,EAAE,SAAS,oBAAoB,GAAG,EAAE,GAC/C,EAAE,WAAW,UAAwB,kBAAkB,aAAa,MAAM,CAC9E;AAEA,MAAM,0BAA0B,EAAE,KAC9B,EAAE,SAAS,EAAE,SAAS,4BAA4B,GAAG,OAAO,GAC5D,EAAE,WAAW,UAA+B,yBAAyB,aAAa,MAAM,CAC5F;AAEA,SAAS,mBAAmB,OAA8B;CACtD,OAAO;EAAE,SAAS;EAAO,OAAO;CAAE;AACtC;AAEA,MAAa,iCAAiC,EAAE,KAC5C,EAAE,OAAO;CACL,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,QAAQ,CAAC,CAAC;CACtD,UAAU;CACV,OAAO;CACP,cAAc;CAC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O,GAAG,EAAE,UAAU,wBAAwB,CAAC;CAClE,OAAO,EAAE,KACL,EAAE,OAAO,GACT,EAAE,WAAW,UACT,kBACI,kBAAkB,eAClB,OACA,kCACA,OACJ,CACJ,CACJ;CACA,OAAO,EAAE,SAAS,mCAAmC;CACrD,oBAAoB;CACpB,oBAAoB;CACpB,eAAe,EAAE,QAAQ;CACzB,eAAe,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACxC,eAAe;CACf,cAAc,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,UAAU,4BAA4B,CAAC;CAC1E,YAAY,EAAE,SAAS,mCAAmC;AAC9D,CAAC;AAED,SAAgB,qCAAqC,QAAmB;CACpE,OAAO,EAAE,KACL,mCACA,EAAE,WAAW,QAAQ;EACjB,MAAM,aAAa,OAAO,MAAM;EAChC,MAAM,WAAW,OAAO,QAAQ,IAAI,QAAQ;EAC5C,OAAO;GACH,UAAU,IAAI;GACd,UAAU,IAAI;GACd,OAAO,IAAI;GACX,OAAO,IAAI,QACL,yBAAyB,IAAI,OAAO,YAAY,QAAQ,IACxD,KAAA;GACN,oBAAoB,IAAI;GACxB,oBAAoB,IAAI;GACxB,eAAe,IAAI;GACnB,eAAe,IAAI;GACnB,eAAe,IAAI;GACnB,cAAc,IAAI;GAClB,YAAY,IAAI,aACV,yBAAyB,IAAI,YAAY,MAAM,IAC/C,KAAA;EACV;CACJ,CAAC,CACL;AACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-transfers.js","names":["#client","Proto.InternalTransferService","#resolver","#scales","#inputSchema","#resultSchema"
|
|
1
|
+
{"version":3,"file":"internal-transfers.js","names":["#client","Proto.InternalTransferService","#resolver","#scales","#inputSchema","#resultSchema"],"sources":["../../../src/services/internal-transfers/internal-transfers.ts"],"sourcesContent":["import { createClient, type Client, type Transport } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/transfer/v1/internal_transfer_pb.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n} from \"../../shared/request-options.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport {\n createCreateInternalTransferInputSchema,\n createCreateInternalTransferResultSchema,\n type CreateInternalTransferInput,\n type CreateInternalTransferResult,\n} from \"./internal-transfers.schemas.js\";\n\n/**\n * Creates authenticated Trading-to-Trading internal transfer requests.\n */\nexport class InternalTransfersService {\n #client: Client<typeof Proto.InternalTransferService>;\n #resolver?: SubaccountResolver;\n #scales: SdkScales;\n #inputSchema: ReturnType<typeof createCreateInternalTransferInputSchema>;\n #resultSchema: ReturnType<typeof createCreateInternalTransferResultSchema>;\n\n constructor(transport: Transport, resolver: SubaccountResolver | undefined, scales: SdkScales) {\n this.#client = createClient(Proto.InternalTransferService, transport);\n this.#resolver = resolver;\n this.#scales = scales;\n this.#inputSchema = createCreateInternalTransferInputSchema(scales);\n this.#resultSchema = createCreateInternalTransferResultSchema();\n }\n\n /**\n * Creates or returns an idempotent internal transfer from the resolved source account to a destination root account, subaccount, or smart-account address. The request carries asset id, a decimal quantity, and a stable idempotency key; the response includes request/transfer ids, resolved destination, and status.\n */\n async create(\n input: CreateInternalTransferInput,\n options?: PolyesterMutationOptions,\n ): Promise<CreateInternalTransferResult> {\n await this.#scales.ready();\n const resolvedInput = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(this.#inputSchema, resolvedInput);\n const res = await this.#client.createInternalTransfer(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n return parse(this.#resultSchema, res);\n }\n}\n"],"mappings":";;;;;;;;;;;AAoBA,IAAa,2BAAb,MAAsC;CAClC;CACA;CACA;CACA;CACA;CAEA,YAAY,WAAsB,UAA0C,QAAmB;EAC3F,KAAKA,UAAU,aAAaC,yBAA+B,SAAS;EACpE,KAAKC,YAAY;EACjB,KAAKC,UAAU;EACf,KAAKC,eAAe,wCAAwC,MAAM;EAClE,KAAKC,gBAAgB,yCAAyC;CAClE;;;;CAKA,MAAM,OACF,OACA,SACqC;EACrC,MAAM,KAAKF,QAAQ,MAAM;EACzB,MAAM,gBAAgB,0BAA0B,OAAO,KAAKD,SAAS;EACrE,MAAM,iBAAiB,MAAM,KAAKE,cAAc,aAAa;EAC7D,MAAM,MAAM,MAAM,KAAKJ,QAAQ,uBAC3B,gBAAgB,cAAc,GAC9B,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,KAAKK,eAAe,GAAG;CACxC;AACJ"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { validation_d_exports } from "../../shared/validation.js";
|
|
2
1
|
import { SdkScales } from "../../shared/decimal-surface.js";
|
|
3
2
|
import { U128Value } from "../../utils/u128.js";
|
|
3
|
+
import * as v from "valibot";
|
|
4
4
|
//#region src/services/internal-transfers/internal-transfers.schemas.d.ts
|
|
5
|
-
declare const InternalTransferDestinationInputSchema:
|
|
6
|
-
readonly type:
|
|
7
|
-
readonly accountId:
|
|
8
|
-
}, undefined>,
|
|
9
|
-
readonly type:
|
|
10
|
-
readonly subaccountId:
|
|
11
|
-
}, undefined>,
|
|
12
|
-
readonly type:
|
|
13
|
-
readonly address:
|
|
14
|
-
}, undefined>], undefined>,
|
|
5
|
+
declare const InternalTransferDestinationInputSchema: v.SchemaWithPipe<readonly [v.VariantSchema<"type", [v.StrictObjectSchema<{
|
|
6
|
+
readonly type: v.LiteralSchema<"account", undefined>;
|
|
7
|
+
readonly accountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
|
|
8
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
9
|
+
readonly type: v.LiteralSchema<"subaccount", undefined>;
|
|
10
|
+
readonly subaccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
|
|
11
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
12
|
+
readonly type: v.LiteralSchema<"smartAccountAddress", undefined>;
|
|
13
|
+
readonly address: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
14
|
+
}, undefined>], undefined>, v.TransformAction<{
|
|
15
15
|
type: "account";
|
|
16
16
|
accountId: bigint;
|
|
17
17
|
} | {
|
|
@@ -30,18 +30,18 @@ declare const InternalTransferDestinationInputSchema: validation_d_exports.Schem
|
|
|
30
30
|
readonly case: "destinationSmartAccountAddress";
|
|
31
31
|
readonly value: string;
|
|
32
32
|
}>]>;
|
|
33
|
-
type InternalTransferDestination =
|
|
34
|
-
declare function createCreateInternalTransferInputSchema(scales: SdkScales):
|
|
35
|
-
readonly destination:
|
|
36
|
-
readonly type:
|
|
37
|
-
readonly accountId:
|
|
38
|
-
}, undefined>,
|
|
39
|
-
readonly type:
|
|
40
|
-
readonly subaccountId:
|
|
41
|
-
}, undefined>,
|
|
42
|
-
readonly type:
|
|
43
|
-
readonly address:
|
|
44
|
-
}, undefined>], undefined>,
|
|
33
|
+
type InternalTransferDestination = v.InferInput<typeof InternalTransferDestinationInputSchema>;
|
|
34
|
+
declare function createCreateInternalTransferInputSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
35
|
+
readonly destination: v.SchemaWithPipe<readonly [v.VariantSchema<"type", [v.StrictObjectSchema<{
|
|
36
|
+
readonly type: v.LiteralSchema<"account", undefined>;
|
|
37
|
+
readonly accountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
|
|
38
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
39
|
+
readonly type: v.LiteralSchema<"subaccount", undefined>;
|
|
40
|
+
readonly subaccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
|
|
41
|
+
}, undefined>, v.StrictObjectSchema<{
|
|
42
|
+
readonly type: v.LiteralSchema<"smartAccountAddress", undefined>;
|
|
43
|
+
readonly address: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
44
|
+
}, undefined>], undefined>, v.TransformAction<{
|
|
45
45
|
type: "account";
|
|
46
46
|
accountId: bigint;
|
|
47
47
|
} | {
|
|
@@ -60,13 +60,13 @@ declare function createCreateInternalTransferInputSchema(scales: SdkScales): val
|
|
|
60
60
|
readonly case: "destinationSmartAccountAddress";
|
|
61
61
|
readonly value: string;
|
|
62
62
|
}>]>;
|
|
63
|
-
readonly assetId:
|
|
64
|
-
readonly quantity:
|
|
65
|
-
readonly idempotencyKey:
|
|
66
|
-
readonly account:
|
|
67
|
-
readonly subaccountId:
|
|
63
|
+
readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
64
|
+
readonly quantity: v.StringSchema<undefined>;
|
|
65
|
+
readonly idempotencyKey: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
66
|
+
readonly account: v.OptionalSchema<v.UnionSchema<[v.PicklistSchema<["active", "main"], undefined>, v.StrictObjectSchema<{
|
|
67
|
+
readonly subaccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
68
68
|
}, undefined>], undefined>, undefined>;
|
|
69
|
-
}, undefined>,
|
|
69
|
+
}, undefined>, v.TransformAction<{
|
|
70
70
|
destination: {
|
|
71
71
|
readonly case: "destinationAccountId";
|
|
72
72
|
readonly value: bigint;
|
|
@@ -99,12 +99,12 @@ declare function createCreateInternalTransferInputSchema(scales: SdkScales): val
|
|
|
99
99
|
assetId: number;
|
|
100
100
|
idempotencyKey: string;
|
|
101
101
|
}>]>;
|
|
102
|
-
type CreateInternalTransferInput =
|
|
103
|
-
declare const ResolvedInternalTransferDestinationSchema:
|
|
104
|
-
readonly rootAccountPublicId:
|
|
105
|
-
readonly subaccountPublicId:
|
|
106
|
-
readonly smartAccountAddress:
|
|
107
|
-
}, undefined>,
|
|
102
|
+
type CreateInternalTransferInput = v.InferInput<ReturnType<typeof createCreateInternalTransferInputSchema>>;
|
|
103
|
+
declare const ResolvedInternalTransferDestinationSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
104
|
+
readonly rootAccountPublicId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, string | undefined>]>;
|
|
105
|
+
readonly subaccountPublicId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, string | undefined>]>;
|
|
106
|
+
readonly smartAccountAddress: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, string | undefined>]>;
|
|
107
|
+
}, undefined>, v.TransformAction<{
|
|
108
108
|
rootAccountPublicId?: string | undefined;
|
|
109
109
|
subaccountPublicId?: string | undefined;
|
|
110
110
|
smartAccountAddress?: string | undefined;
|
|
@@ -113,23 +113,23 @@ declare const ResolvedInternalTransferDestinationSchema: validation_d_exports.Sc
|
|
|
113
113
|
subaccountId: string | undefined;
|
|
114
114
|
smartAccountAddress: string | undefined;
|
|
115
115
|
}>]>;
|
|
116
|
-
type ResolvedInternalTransferDestination =
|
|
117
|
-
declare function createCreateInternalTransferResultSchema():
|
|
118
|
-
readonly requestId:
|
|
119
|
-
readonly transferId:
|
|
120
|
-
readonly acceptedAtTsNs:
|
|
121
|
-
readonly assetId:
|
|
122
|
-
readonly assetCode:
|
|
123
|
-
readonly uAssetId:
|
|
124
|
-
readonly amountE18:
|
|
125
|
-
readonly hi:
|
|
126
|
-
readonly lo:
|
|
116
|
+
type ResolvedInternalTransferDestination = v.InferOutput<typeof ResolvedInternalTransferDestinationSchema>;
|
|
117
|
+
declare function createCreateInternalTransferResultSchema(): v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
118
|
+
readonly requestId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
119
|
+
readonly transferId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
120
|
+
readonly acceptedAtTsNs: v.BigintSchema<undefined>;
|
|
121
|
+
readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
122
|
+
readonly assetCode: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
123
|
+
readonly uAssetId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
124
|
+
readonly amountE18: v.ObjectSchema<{
|
|
125
|
+
readonly hi: v.BigintSchema<undefined>;
|
|
126
|
+
readonly lo: v.BigintSchema<undefined>;
|
|
127
127
|
}, undefined>;
|
|
128
|
-
readonly destination:
|
|
129
|
-
readonly rootAccountPublicId:
|
|
130
|
-
readonly subaccountPublicId:
|
|
131
|
-
readonly smartAccountAddress:
|
|
132
|
-
}, undefined>,
|
|
128
|
+
readonly destination: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
129
|
+
readonly rootAccountPublicId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, string | undefined>]>;
|
|
130
|
+
readonly subaccountPublicId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, string | undefined>]>;
|
|
131
|
+
readonly smartAccountAddress: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, string | undefined>]>;
|
|
132
|
+
}, undefined>, v.TransformAction<{
|
|
133
133
|
rootAccountPublicId?: string | undefined;
|
|
134
134
|
subaccountPublicId?: string | undefined;
|
|
135
135
|
smartAccountAddress?: string | undefined;
|
|
@@ -138,7 +138,7 @@ declare function createCreateInternalTransferResultSchema(): validation_d_export
|
|
|
138
138
|
subaccountId: string | undefined;
|
|
139
139
|
smartAccountAddress: string | undefined;
|
|
140
140
|
}>]>, undefined>;
|
|
141
|
-
}, undefined>,
|
|
141
|
+
}, undefined>, v.TransformAction<{
|
|
142
142
|
requestId: string;
|
|
143
143
|
transferId: string;
|
|
144
144
|
acceptedAtTsNs: bigint;
|
|
@@ -168,7 +168,7 @@ declare function createCreateInternalTransferResultSchema(): validation_d_export
|
|
|
168
168
|
smartAccountAddress: string | undefined;
|
|
169
169
|
} | undefined;
|
|
170
170
|
}>]>;
|
|
171
|
-
type CreateInternalTransferResult =
|
|
171
|
+
type CreateInternalTransferResult = v.InferOutput<ReturnType<typeof createCreateInternalTransferResultSchema>>;
|
|
172
172
|
//#endregion
|
|
173
173
|
export { CreateInternalTransferInput, CreateInternalTransferResult, InternalTransferDestination, InternalTransferDestinationInputSchema, ResolvedInternalTransferDestination, ResolvedInternalTransferDestinationSchema, createCreateInternalTransferInputSchema, createCreateInternalTransferResultSchema };
|
|
174
174
|
//# sourceMappingURL=internal-transfers.schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-transfers.schemas.d.ts","names":[],"sources":["../../../src/services/internal-transfers/internal-transfers.schemas.ts"],"mappings":";;;;cAyBa,wCAAsC,
|
|
1
|
+
{"version":3,"file":"internal-transfers.schemas.d.ts","names":[],"sources":["../../../src/services/internal-transfers/internal-transfers.schemas.ts"],"mappings":";;;;cAyBa,wCAAsC,EAAA,yBAAA,EAAA,uBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoCvC,8BAA8B,EAAE,kBACjC;iBAGK,wCAAwC,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAAA;;;;;;;;;;;;;;;KA0B7D,8BAA8B,EAAE,WACxC,kBAAkB;cAYT,2CAAyC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;KAa1C,sCAAsC,EAAE,mBACzC;iBAGK,4CAAwC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAoB5C,+BAA+B,EAAE,YACzC,kBAAkB"}
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { validation_exports } from "../../shared/validation.js";
|
|
2
1
|
import { tsNsToMs } from "../../utils/time.js";
|
|
3
2
|
import { idInputSchema } from "../../shared/schemas.js";
|
|
4
3
|
import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
|
|
5
4
|
import { quantityInputToE18, scaledToDecimalOutput } from "../../shared/decimal-surface.js";
|
|
6
5
|
import { fromU128, toU128 } from "../../utils/u128.js";
|
|
7
6
|
import { InternalTransferDestinationCodec } from "./internal-transfers.codecs.js";
|
|
7
|
+
import * as v from "valibot";
|
|
8
8
|
//#region src/services/internal-transfers/internal-transfers.schemas.ts
|
|
9
|
-
const U128Schema =
|
|
10
|
-
hi:
|
|
11
|
-
lo:
|
|
9
|
+
const U128Schema = v.object({
|
|
10
|
+
hi: v.bigint(),
|
|
11
|
+
lo: v.bigint()
|
|
12
12
|
});
|
|
13
13
|
const IdSchema = idInputSchema;
|
|
14
|
-
const InternalTransferDestinationInputSchema =
|
|
15
|
-
|
|
16
|
-
type:
|
|
14
|
+
const InternalTransferDestinationInputSchema = v.pipe(v.variant("type", [
|
|
15
|
+
v.strictObject({
|
|
16
|
+
type: v.literal("account"),
|
|
17
17
|
accountId: IdSchema("accountId")
|
|
18
18
|
}),
|
|
19
|
-
|
|
20
|
-
type:
|
|
19
|
+
v.strictObject({
|
|
20
|
+
type: v.literal("subaccount"),
|
|
21
21
|
subaccountId: IdSchema("subaccountId")
|
|
22
22
|
}),
|
|
23
|
-
|
|
24
|
-
type:
|
|
25
|
-
address:
|
|
23
|
+
v.strictObject({
|
|
24
|
+
type: v.literal("smartAccountAddress"),
|
|
25
|
+
address: v.pipe(v.string(), v.trim(), v.minLength(1))
|
|
26
26
|
})
|
|
27
|
-
]),
|
|
27
|
+
]), v.transform((destination) => {
|
|
28
28
|
switch (destination.type) {
|
|
29
29
|
case "account": return {
|
|
30
30
|
case: InternalTransferDestinationCodec.inputToProtoCase.account,
|
|
@@ -41,13 +41,13 @@ const InternalTransferDestinationInputSchema = validation_exports.pipe(validatio
|
|
|
41
41
|
}
|
|
42
42
|
}));
|
|
43
43
|
function createCreateInternalTransferInputSchema(scales) {
|
|
44
|
-
return
|
|
44
|
+
return v.pipe(v.strictObject({
|
|
45
45
|
...AccountScopeInputEntries,
|
|
46
46
|
destination: InternalTransferDestinationInputSchema,
|
|
47
|
-
assetId:
|
|
48
|
-
quantity:
|
|
49
|
-
idempotencyKey:
|
|
50
|
-
}),
|
|
47
|
+
assetId: v.pipe(v.number(), v.integer(), v.gtValue(0)),
|
|
48
|
+
quantity: v.string(),
|
|
49
|
+
idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1))
|
|
50
|
+
}), v.transform(({ account, quantity, ...input }) => ({
|
|
51
51
|
...input,
|
|
52
52
|
amountE18: toU128(quantityInputToE18({
|
|
53
53
|
scales,
|
|
@@ -57,28 +57,28 @@ function createCreateInternalTransferInputSchema(scales) {
|
|
|
57
57
|
subaccountId: accountScopeToSubaccountId(account)
|
|
58
58
|
})));
|
|
59
59
|
}
|
|
60
|
-
const NonEmptyResponseStringSchema =
|
|
61
|
-
const OptionalResponseStringSchema =
|
|
62
|
-
const ResolvedInternalTransferDestinationSchema =
|
|
60
|
+
const NonEmptyResponseStringSchema = v.pipe(v.string(), v.trim(), v.minLength(1));
|
|
61
|
+
const OptionalResponseStringSchema = v.pipe(v.optional(v.pipe(v.string(), v.trim())), v.transform((value) => value ? value : void 0));
|
|
62
|
+
const ResolvedInternalTransferDestinationSchema = v.pipe(v.object({
|
|
63
63
|
rootAccountPublicId: OptionalResponseStringSchema,
|
|
64
64
|
subaccountPublicId: OptionalResponseStringSchema,
|
|
65
65
|
smartAccountAddress: OptionalResponseStringSchema
|
|
66
|
-
}),
|
|
66
|
+
}), v.transform(({ rootAccountPublicId, subaccountPublicId, smartAccountAddress }) => ({
|
|
67
67
|
rootAccountId: rootAccountPublicId,
|
|
68
68
|
subaccountId: subaccountPublicId,
|
|
69
69
|
smartAccountAddress
|
|
70
70
|
})));
|
|
71
71
|
function createCreateInternalTransferResultSchema() {
|
|
72
|
-
return
|
|
72
|
+
return v.pipe(v.object({
|
|
73
73
|
requestId: NonEmptyResponseStringSchema,
|
|
74
74
|
transferId: NonEmptyResponseStringSchema,
|
|
75
|
-
acceptedAtTsNs:
|
|
76
|
-
assetId:
|
|
75
|
+
acceptedAtTsNs: v.bigint(),
|
|
76
|
+
assetId: v.pipe(v.number(), v.integer(), v.gtValue(0)),
|
|
77
77
|
assetCode: NonEmptyResponseStringSchema,
|
|
78
78
|
uAssetId: NonEmptyResponseStringSchema,
|
|
79
79
|
amountE18: U128Schema,
|
|
80
|
-
destination:
|
|
81
|
-
}),
|
|
80
|
+
destination: v.optional(ResolvedInternalTransferDestinationSchema)
|
|
81
|
+
}), v.transform(({ acceptedAtTsNs, amountE18, ...result }) => ({
|
|
82
82
|
...result,
|
|
83
83
|
acceptedAtUnixMs: tsNsToMs(acceptedAtTsNs),
|
|
84
84
|
quantity: scaledToDecimalOutput(fromU128(amountE18), 18)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-transfers.schemas.js","names":[
|
|
1
|
+
{"version":3,"file":"internal-transfers.schemas.js","names":[],"sources":["../../../src/services/internal-transfers/internal-transfers.schemas.ts"],"sourcesContent":["import type { MessageInitShape } from \"@bufbuild/protobuf\";\nimport * as v from \"valibot\";\nimport type * as Proto from \"../../gen/transfer/v1/internal_transfer_pb.js\";\nimport { idInputSchema } from \"../../shared/schemas.js\";\nimport { tsNsToMs } from \"../../utils/time.js\";\nimport {\n E18_SCALE,\n quantityInputToE18,\n scaledToDecimalOutput,\n type SdkScales,\n} from \"../../shared/decimal-surface.js\";\nimport { InternalTransferDestinationCodec } from \"./internal-transfers.codecs.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { fromU128, toU128 } from \"../../utils/u128.js\";\n\nconst U128Schema = v.object({\n hi: v.bigint(),\n lo: v.bigint(),\n});\n\nconst IdSchema = idInputSchema;\n\nexport const InternalTransferDestinationInputSchema = v.pipe(\n v.variant(\"type\", [\n v.strictObject({\n type: v.literal(\"account\"),\n accountId: IdSchema(\"accountId\"),\n }),\n v.strictObject({\n type: v.literal(\"subaccount\"),\n subaccountId: IdSchema(\"subaccountId\"),\n }),\n v.strictObject({\n type: v.literal(\"smartAccountAddress\"),\n address: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n ]),\n v.transform((destination) => {\n switch (destination.type) {\n case \"account\":\n return {\n case: InternalTransferDestinationCodec.inputToProtoCase.account,\n value: destination.accountId,\n } as const;\n case \"subaccount\":\n return {\n case: InternalTransferDestinationCodec.inputToProtoCase.subaccount,\n value: destination.subaccountId,\n } as const;\n case \"smartAccountAddress\":\n return {\n case: InternalTransferDestinationCodec.inputToProtoCase.smartAccountAddress,\n value: destination.address,\n } as const;\n }\n }),\n);\n\nexport type InternalTransferDestination = v.InferInput<\n typeof InternalTransferDestinationInputSchema\n>;\n\nexport function createCreateInternalTransferInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n destination: InternalTransferDestinationInputSchema,\n assetId: v.pipe(v.number(), v.integer(), v.gtValue(0)),\n quantity: v.string(),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform(\n ({ account, quantity, ...input }) =>\n ({\n ...input,\n amountE18: toU128(\n quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity,\n }),\n ),\n subaccountId: accountScopeToSubaccountId(account),\n }) satisfies MessageInitShape<typeof Proto.CreateInternalTransferRequestSchema>,\n ),\n );\n}\n\nexport type CreateInternalTransferInput = v.InferInput<\n ReturnType<typeof createCreateInternalTransferInputSchema>\n>;\nexport type CreateInternalTransferRequest = v.InferOutput<\n ReturnType<typeof createCreateInternalTransferInputSchema>\n>;\n\nconst NonEmptyResponseStringSchema = v.pipe(v.string(), v.trim(), v.minLength(1));\nconst OptionalResponseStringSchema = v.pipe(\n v.optional(v.pipe(v.string(), v.trim())),\n v.transform((value) => (value ? value : undefined)),\n);\n\nexport const ResolvedInternalTransferDestinationSchema = v.pipe(\n v.object({\n rootAccountPublicId: OptionalResponseStringSchema,\n subaccountPublicId: OptionalResponseStringSchema,\n smartAccountAddress: OptionalResponseStringSchema,\n }),\n v.transform(({ rootAccountPublicId, subaccountPublicId, smartAccountAddress }) => ({\n rootAccountId: rootAccountPublicId,\n subaccountId: subaccountPublicId,\n smartAccountAddress,\n })),\n);\n\nexport type ResolvedInternalTransferDestination = v.InferOutput<\n typeof ResolvedInternalTransferDestinationSchema\n>;\n\nexport function createCreateInternalTransferResultSchema() {\n return v.pipe(\n v.object({\n requestId: NonEmptyResponseStringSchema,\n transferId: NonEmptyResponseStringSchema,\n acceptedAtTsNs: v.bigint(),\n assetId: v.pipe(v.number(), v.integer(), v.gtValue(0)),\n assetCode: NonEmptyResponseStringSchema,\n uAssetId: NonEmptyResponseStringSchema,\n amountE18: U128Schema,\n destination: v.optional(ResolvedInternalTransferDestinationSchema),\n }),\n v.transform(({ acceptedAtTsNs, amountE18, ...result }) => ({\n ...result,\n acceptedAtUnixMs: tsNsToMs(acceptedAtTsNs),\n quantity: scaledToDecimalOutput(fromU128(amountE18), E18_SCALE),\n })),\n );\n}\n\nexport type CreateInternalTransferResult = v.InferOutput<\n ReturnType<typeof createCreateInternalTransferResultSchema>\n>;\n"],"mappings":";;;;;;;;AAkBA,MAAM,aAAa,EAAE,OAAO;CACxB,IAAI,EAAE,OAAO;CACb,IAAI,EAAE,OAAO;AACjB,CAAC;AAED,MAAM,WAAW;AAEjB,MAAa,yCAAyC,EAAE,KACpD,EAAE,QAAQ,QAAQ;CACd,EAAE,aAAa;EACX,MAAM,EAAE,QAAQ,SAAS;EACzB,WAAW,SAAS,WAAW;CACnC,CAAC;CACD,EAAE,aAAa;EACX,MAAM,EAAE,QAAQ,YAAY;EAC5B,cAAc,SAAS,cAAc;CACzC,CAAC;CACD,EAAE,aAAa;EACX,MAAM,EAAE,QAAQ,qBAAqB;EACrC,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;CACxD,CAAC;AACL,CAAC,GACD,EAAE,WAAW,gBAAgB;CACzB,QAAQ,YAAY,MAApB;EACI,KAAK,WACD,OAAO;GACH,MAAM,iCAAiC,iBAAiB;GACxD,OAAO,YAAY;EACvB;EACJ,KAAK,cACD,OAAO;GACH,MAAM,iCAAiC,iBAAiB;GACxD,OAAO,YAAY;EACvB;EACJ,KAAK,uBACD,OAAO;GACH,MAAM,iCAAiC,iBAAiB;GACxD,OAAO,YAAY;EACvB;CACR;AACJ,CAAC,CACL;AAMA,SAAgB,wCAAwC,QAAmB;CACvE,OAAO,EAAE,KACL,EAAE,aAAa;EACX,GAAG;EACH,aAAa;EACb,SAAS,EAAE,KAAK,EAAE,OAAO,G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
|
1
|
-
{"version":3,"file":"lifecycle.d.ts","names":[],"sources":["../../../src/services/lifecycle/lifecycle.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"lifecycle.d.ts","names":[],"sources":["../../../src/services/lifecycle/lifecycle.ts"],"mappings":";;;;;;UAoCU,yCAAyC,mBAAmB;EAClE;;UAGM,0CAA0C,mBAAmB;EACnE;;;;;cAMS;;EAIG,YAAA,WAAW,WAAW,UAAU;;;;EAQtC,UACF,OAAO,yBACP,UAAU,0BACX,QAAQ;;;;EAUL,QACF,OAAO,uBACP,UAAU,0BACX,QAAQ;;;;EAYL,cACF,OAAO,6BACP,UAAU,0BACX,QAAQ;;;;EAYX,mBAAmB,OAAO;;;;EAqB1B,oBAAoB,OAAO"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { parse
|
|
1
|
+
import { parse } from "../../shared/validation.js";
|
|
2
2
|
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
3
3
|
import { isDev } from "../../utils/is-dev.js";
|
|
4
4
|
import { FlowDetailViewSchema, FlowSummaryViewSchema, GetFlowByIdRequestSchema, LifecycleReadService } from "../../gen/chain/lifecycle/v1/lifecycle_read_pb.js";
|
|
5
5
|
import { GetLifecycleFlowInputSchema, GetLifecycleFlowOutputSchema, LifecycleFlowDetailSchema, LifecycleFlowSummarySchema, ListLifecycleFlowsByTxInputSchema, ListLifecycleFlowsByTxOutputSchema, ListLifecycleFlowsInputSchema, ListLifecycleFlowsOutputSchema } from "./lifecycle.schemas.js";
|
|
6
6
|
import { create } from "@bufbuild/protobuf";
|
|
7
7
|
import { createClient } from "@connectrpc/connect";
|
|
8
|
+
import * as v from "valibot";
|
|
8
9
|
//#region src/services/lifecycle/lifecycle.ts
|
|
9
10
|
/**
|
|
10
11
|
* Reads and streams chain lifecycle flow state, history, progress, and transaction matches.
|
|
@@ -62,7 +63,7 @@ var LifecycleService = class {
|
|
|
62
63
|
* Subscribes to detail updates for one lifecycle flow on public:chain:lifecycle:flow:{flowId}:proto. Invalid flow ids are rejected locally with a no-op unsubscribe function.
|
|
63
64
|
*/
|
|
64
65
|
subscribeFlowDetail(input) {
|
|
65
|
-
const parsedFlowId =
|
|
66
|
+
const parsedFlowId = v.safeParse(GetLifecycleFlowInputSchema, { flowId: input.flowId });
|
|
66
67
|
if (!parsedFlowId.success) {
|
|
67
68
|
if (isDev()) console.error("[LifecycleService] flowId is required for flow detail subscription.");
|
|
68
69
|
return () => {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lifecycle.js","names":["#client","#realtime"
|
|
1
|
+
{"version":3,"file":"lifecycle.js","names":["#client","#realtime"],"sources":["../../../src/services/lifecycle/lifecycle.ts"],"sourcesContent":["import { createClient, type Client, type Transport } from \"@connectrpc/connect\";\nimport { create } from \"@bufbuild/protobuf\";\nimport {\n FlowDetailViewSchema,\n FlowSummaryViewSchema,\n GetFlowByIdRequestSchema,\n LifecycleReadService,\n} from \"../../gen/chain/lifecycle/v1/lifecycle_read_pb.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { isDev } from \"../../utils/is-dev.js\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport {\n GetLifecycleFlowInputSchema,\n GetLifecycleFlowOutputSchema,\n LifecycleFlowDetailSchema,\n LifecycleFlowSummarySchema,\n ListLifecycleFlowsByTxOutputSchema,\n ListLifecycleFlowsByTxInputSchema,\n ListLifecycleFlowsOutputSchema,\n ListLifecycleFlowsInputSchema,\n type GetLifecycleFlowInput,\n type GetLifecycleFlowOutput,\n type LifecycleFlowDetail,\n type LifecycleFlowSummary,\n type ListLifecycleFlowsByTxInput,\n type ListLifecycleFlowsByTxOutput,\n type ListLifecycleFlowsInput,\n type ListLifecycleFlowsOutput,\n} from \"./lifecycle.schemas.js\";\n\ninterface SubscribeOpenLifecycleFlowsInput extends BaseSubscribeInput<LifecycleFlowSummary> {\n accountId?: string;\n}\n\ninterface SubscribeLifecycleFlowDetailInput extends BaseSubscribeInput<LifecycleFlowDetail> {\n flowId: string;\n}\n\n/**\n * Reads and streams chain lifecycle flow state, history, progress, and transaction matches.\n */\nexport class LifecycleService {\n #client: Client<typeof LifecycleReadService>;\n #realtime: PolyesterRealtime;\n\n constructor(transport: Transport, realtime: PolyesterRealtime) {\n this.#client = createClient(LifecycleReadService, transport);\n this.#realtime = realtime;\n }\n\n /**\n * Returns paginated lifecycle flow summaries filtered by kind, state, scope, account selector, transaction reference, chain ids, and asset ids. The response is ordered by the selected timestamp and includes an opaque next page token.\n */\n async listFlows(\n input: ListLifecycleFlowsInput,\n options?: PolyesterRequestOptions,\n ): Promise<ListLifecycleFlowsOutput> {\n const parsedInput = parse(ListLifecycleFlowsInputSchema, input);\n const response = await this.#client.listFlows(parsedInput, toConnectCallOptions(options));\n const res = parse(ListLifecycleFlowsOutputSchema, response);\n return res;\n }\n\n /**\n * Fetches one lifecycle flow by its public flow id and returns summary, factual steps, timeline, and live-state detail when available.\n */\n async getFlow(\n input: GetLifecycleFlowInput,\n options?: PolyesterRequestOptions,\n ): Promise<GetLifecycleFlowOutput> {\n const parsedInput = parse(GetLifecycleFlowInputSchema, input);\n const response = await this.#client.getFlowById(\n create(GetFlowByIdRequestSchema, parsedInput),\n toConnectCallOptions(options),\n );\n return parse(GetLifecycleFlowOutputSchema, response);\n }\n\n /**\n * Searches lifecycle flows that reference a 0x-prefixed transaction hash, using source-only or any-reference lookup mode. A single transaction may match zero, one, or many flows.\n */\n async listFlowsByTx(\n input: ListLifecycleFlowsByTxInput,\n options?: PolyesterRequestOptions,\n ): Promise<ListLifecycleFlowsByTxOutput> {\n const parsedInput = parse(ListLifecycleFlowsByTxInputSchema, input);\n const response = await this.#client.listFlowsByTx(\n parsedInput,\n toConnectCallOptions(options),\n );\n return parse(ListLifecycleFlowsByTxOutputSchema, response);\n }\n\n /**\n * Subscribes to open lifecycle flow summary updates, using private:chain:lifecycle:flows:{accountId}:proto when an account id is provided and the public flow channel otherwise.\n */\n subscribeOpenFlows(input: SubscribeOpenLifecycleFlowsInput): () => void {\n const accountId = input.accountId?.trim();\n const channel = accountId\n ? `private:chain:lifecycle:flows:${accountId}:proto`\n : \"public:chain:lifecycle:flows:proto\";\n return this.#realtime.connectProtoChannel({\n channel,\n schema: FlowSummaryViewSchema,\n onPublication: (data) => {\n const flow = parse(LifecycleFlowSummarySchema, data);\n input.onEvent(flow);\n },\n onConnected: input.onOpen,\n onDisconnected: input.onClose,\n onError: input.onError,\n });\n }\n\n /**\n * Subscribes to detail updates for one lifecycle flow on public:chain:lifecycle:flow:{flowId}:proto. Invalid flow ids are rejected locally with a no-op unsubscribe function.\n */\n subscribeFlowDetail(input: SubscribeLifecycleFlowDetailInput): () => void {\n const parsedFlowId = v.safeParse(GetLifecycleFlowInputSchema, { flowId: input.flowId });\n if (!parsedFlowId.success) {\n if (isDev()) {\n console.error(\n \"[LifecycleService] flowId is required for flow detail subscription.\",\n );\n }\n return () => {};\n }\n\n const channel = `public:chain:lifecycle:flow:${parsedFlowId.output.flowId}:proto`;\n return this.#realtime.connectProtoChannel({\n channel,\n schema: FlowDetailViewSchema,\n onPublication: (data) => {\n const flow = parse(LifecycleFlowDetailSchema, data);\n input.onEvent(flow);\n },\n onConnected: input.onOpen,\n onDisconnected: input.onClose,\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;AA+CA,IAAa,mBAAb,MAA8B;CAC1B;CACA;CAEA,YAAY,WAAsB,UAA6B;EAC3D,KAAKA,UAAU,aAAa,sBAAsB,SAAS;EAC3D,KAAKC,YAAY;CACrB;;;;CAKA,MAAM,UACF,OACA,SACiC;EACjC,MAAM,cAAc,MAAM,+BAA+B,KAAK;EAC9D,MAAM,WAAW,MAAM,KAAKD,QAAQ,UAAU,aAAa,qBAAqB,OAAO,CAAC;EAExF,OADY,MAAM,g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