@polyester/sdk 0.14.2 → 0.15.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 +20 -0
- package/dist/core-client.js +1 -1
- package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts +8 -0
- package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts.map +1 -1
- package/dist/gen/ledger/read/v1/ledger_read_pb.js +1 -1
- package/dist/gen/ledger/read/v1/ledger_read_pb.js.map +1 -1
- package/dist/services/address-book/address-book.schemas.d.ts +1 -1
- package/dist/services/address-book/address-book.schemas.d.ts.map +1 -1
- package/dist/services/address-book/address-book.schemas.js +2 -1
- package/dist/services/address-book/address-book.schemas.js.map +1 -1
- package/dist/services/candles/candles.d.ts.map +1 -1
- package/dist/services/candles/candles.js +2 -1
- package/dist/services/candles/candles.js.map +1 -1
- package/dist/services/candles/candles.schemas.d.ts +1 -1
- package/dist/services/candles/candles.schemas.d.ts.map +1 -1
- package/dist/services/candles/candles.schemas.js +3 -2
- package/dist/services/candles/candles.schemas.js.map +1 -1
- package/dist/services/chain-analytics/chain-analytics.schemas.d.ts.map +1 -1
- package/dist/services/chain-analytics/chain-analytics.schemas.js +5 -5
- package/dist/services/chain-analytics/chain-analytics.schemas.js.map +1 -1
- package/dist/services/deposit/deposit.schemas.d.ts +3 -3
- package/dist/services/deposit/deposit.schemas.d.ts.map +1 -1
- package/dist/services/deposit/deposit.schemas.js +4 -4
- package/dist/services/deposit/deposit.schemas.js.map +1 -1
- package/dist/services/guard-signer/guard-signer.schemas.d.ts +2 -2
- package/dist/services/guard-signer/guard-signer.schemas.d.ts.map +1 -1
- package/dist/services/guard-signer/guard-signer.schemas.js +2 -1
- 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 +2 -1
- package/dist/services/heatmap/heatmap.js.map +1 -1
- package/dist/services/heatmap/heatmap.schemas.d.ts +1 -1
- package/dist/services/heatmap/heatmap.schemas.d.ts.map +1 -1
- package/dist/services/heatmap/heatmap.schemas.js +2 -1
- package/dist/services/heatmap/heatmap.schemas.js.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +2 -2
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.schemas.js +3 -2
- package/dist/services/internal-transfers/internal-transfers.schemas.js.map +1 -1
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +42 -42
- package/dist/services/market-data/market-data.d.ts.map +1 -1
- package/dist/services/market-data/market-data.js +2 -1
- package/dist/services/market-data/market-data.js.map +1 -1
- package/dist/services/market-data/market-data.schemas.d.ts +1 -1
- package/dist/services/market-data/market-data.schemas.js +2 -2
- package/dist/services/market-data/market-data.schemas.js.map +1 -1
- package/dist/services/market-overview/market-overview.schemas.d.ts +1 -1
- package/dist/services/market-overview/market-overview.schemas.js +2 -2
- package/dist/services/market-overview/market-overview.schemas.js.map +1 -1
- package/dist/services/orders/orders-input.schemas.d.ts +1 -1
- package/dist/services/orders/orders-modify.schemas.js +1 -1
- package/dist/services/orders/orders-output.schemas.d.ts +6 -6
- package/dist/services/orders/orders-risk.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-risk.schemas.js +3 -4
- package/dist/services/orders/orders-risk.schemas.js.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts +9 -9
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js +17 -8
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js.map +1 -1
- package/dist/services/shared.js +4 -2
- package/dist/services/shared.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +5 -5
- package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts +2 -2
- package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.schemas.js +3 -2
- package/dist/services/trading-withdraws/trading-withdraws.schemas.js.map +1 -1
- package/dist/services/trailing-oneof-inputs.js +3 -1
- package/dist/services/trailing-oneof-inputs.js.map +1 -1
- package/dist/services/transfers/transfers.schemas.d.ts +7 -0
- package/dist/services/transfers/transfers.schemas.d.ts.map +1 -1
- package/dist/services/transfers/transfers.schemas.js +2 -1
- package/dist/services/transfers/transfers.schemas.js.map +1 -1
- package/dist/services/triggers/trigger-input.schemas.d.ts +2 -2
- package/dist/services/triggers/trigger-input.schemas.d.ts.map +1 -1
- package/dist/services/triggers/trigger-input.schemas.js +3 -3
- package/dist/services/triggers/trigger-input.schemas.js.map +1 -1
- package/dist/services/triggers/triggers-output.schemas.d.ts +18 -18
- package/dist/shared/decimal-surface.d.ts.map +1 -1
- package/dist/shared/decimal-surface.js.map +1 -1
- package/dist/shared/schemas.js +4 -4
- package/dist/shared/schemas.js.map +1 -1
- package/dist/utils/numbers.js +1 -10
- package/dist/utils/numbers.js.map +1 -1
- package/package.json +1 -1
|
@@ -148,7 +148,7 @@ type CandleInt = v.InferOutput<ReturnType<typeof createCandleRowIntSchema>>;
|
|
|
148
148
|
type CandleColumnar = v.InferOutput<ReturnType<typeof createCandleColumnarSchema>>;
|
|
149
149
|
type CandleColumnarInt = v.InferOutput<ReturnType<typeof createCandleColumnarIntSchema>>;
|
|
150
150
|
declare function createListCandlesInputSchema(): v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
151
|
-
readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
151
|
+
readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
|
|
152
152
|
readonly timeframe: v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["1s", "1m", "5m", "15m", "30m", "1h", "4h", "12h", "1d", "1w", "1mo"], undefined>, v.TransformAction<"1d" | "1s" | "1m" | "5m" | "15m" | "30m" | "1h" | "4h" | "12h" | "1w" | "1mo", Timeframe$1.SEC_1 | Timeframe$1.MIN_1 | Timeframe$1.MIN_5 | Timeframe$1.MIN_15 | Timeframe$1.MIN_30 | Timeframe$1.HOUR_1 | Timeframe$1.HOUR_4 | Timeframe$1.DAY_1 | Timeframe$1.HOUR_12 | Timeframe$1.WEEK_1 | Timeframe$1.MONTH_1>]>;
|
|
153
153
|
readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 10000, undefined>]>, undefined>;
|
|
154
154
|
readonly includeIncomplete: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candles.schemas.d.ts","names":[],"sources":["../../../src/services/candles/candles.schemas.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"candles.schemas.d.ts","names":[],"sources":["../../../src/services/candles/candles.schemas.ts"],"mappings":";;;;;cASa,iBAAe,EAAA;KAEhB,YAAY,EAAE,mBAAmB;KAsBxC;EAAkB;EAAiB;;iBAqBxB,sBAAsB,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAoB1C,iCAAwB;iBAqCrB,2BAA2B,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAiC5C,8BAA8B,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiCnD,SAAS,EAAE,YAAY,kBAAkB;KAGzC,YAAY,EAAE,YAAY,kBAAkB;KAC5C,iBAAiB,EAAE,YAAY,kBAAkB;KAGjD,oBAAoB,EAAE,YAAY,kBAAkB;iBAyBhD,gCAA4B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAIhC,kBAAkB,EAAE,WAAW,kBAAkB;KAEjD,yBAAyB,EAAE,WAAW,kBAAkB"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { requiredEnumLabel } from "../../shared/proto-enum-codec.js";
|
|
2
2
|
import { OptionalTimestampSecondsInputSchema } from "../../shared/schemas.js";
|
|
3
|
-
import {
|
|
3
|
+
import { SymbolIdInputSchema } from "../shared.js";
|
|
4
4
|
import { scaledToDecimalOutput } from "../../shared/decimal-surface.js";
|
|
5
|
+
import { Timeframe } from "../../gen/marketdata/v1/marketdata_pb.js";
|
|
5
6
|
import { TIMEFRAMES, TimeframeCodec } from "./candles.codecs.js";
|
|
6
7
|
import * as v from "valibot";
|
|
7
8
|
//#region src/services/candles/candles.schemas.ts
|
|
@@ -129,7 +130,7 @@ function createCandleColumnarIntSchema(scales) {
|
|
|
129
130
|
}));
|
|
130
131
|
}
|
|
131
132
|
const ListCandlesInputSchema = v.pipe(v.object({
|
|
132
|
-
symbolId:
|
|
133
|
+
symbolId: SymbolIdInputSchema,
|
|
133
134
|
timeframe: TimeframeInputSchema,
|
|
134
135
|
limit: OptionalPositiveNumberSchema,
|
|
135
136
|
includeIncomplete: v.optional(v.boolean(), false),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"candles.schemas.js","names":["Proto.Timeframe"],"sources":["../../../src/services/candles/candles.schemas.ts"],"sourcesContent":["import * as Proto from \"../../gen/marketdata/v1/marketdata_pb.js\";\nimport * as v from \"valibot\";\nimport type { DecodedEnum } from \"../../utils/types.js\";\nimport { OptionalTimestampSecondsInputSchema } from \"../../shared/schemas.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport { scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { TIMEFRAMES, TimeframeCodec } from \"./candles.codecs.js\";\n\nexport const TimeframeSchema = v.picklist(TIMEFRAMES);\n\nexport type Timeframe = v.InferOutput<typeof TimeframeSchema>;\n\nfunction timeframeFromProto(value: Proto.Timeframe, schemaName: string): DecodedEnum<Timeframe> {\n return requiredEnumLabel(\n TimeframeCodec.protoToOutput,\n value,\n `CandlesService.${schemaName}`,\n \"timeframe\",\n );\n}\n\nconst TimeframeInputSchema = v.pipe(\n TimeframeSchema,\n v.transform((value) => TimeframeCodec.inputToProto[value]),\n);\n\nconst OptionalPositiveNumberSchema = v.optional(\n v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(10_000)),\n);\n\nconst OptionalBooleanSchema = v.optional(v.boolean(), false);\n\ntype TimestampInit = { seconds: bigint; nanos: number };\n\nfunction timestampFromTsSec(tsSec: bigint): TimestampInit {\n return { seconds: tsSec, nanos: 0 };\n}\n\nconst CandleRowRawSchema = v.object({\n symbolId: v.number(),\n timeframe: v.pipe(\n v.enum(Proto.Timeframe),\n v.transform((v) => timeframeFromProto(v, \"CandleRowSchema\")),\n ),\n tsSec: v.bigint(),\n open: v.bigint(),\n high: v.bigint(),\n low: v.bigint(),\n close: v.bigint(),\n volume: v.bigint(),\n isClosed: v.optional(v.boolean(), false),\n});\n\nexport function createCandleRowSchema(scales: SdkScales) {\n return v.pipe(\n CandleRowRawSchema,\n v.transform((data) => {\n const priceScale = scales.price();\n return {\n symbolId: data.symbolId,\n timeframe: data.timeframe,\n time: Number(data.tsSec),\n open: scaledToDecimalOutput(data.open, priceScale),\n high: scaledToDecimalOutput(data.high, priceScale),\n low: scaledToDecimalOutput(data.low, priceScale),\n close: scaledToDecimalOutput(data.close, priceScale),\n volume: scaledToDecimalOutput(data.volume, scales.baseQty(data.symbolId)),\n isClosed: data.isClosed,\n };\n }),\n );\n}\n\nexport const createCandleRowIntSchema = createCandleRowSchema;\n\nexport const CandlePointSchema = v.object({\n tsSec: v.bigint(),\n open: v.bigint(),\n high: v.bigint(),\n low: v.bigint(),\n close: v.bigint(),\n volume: v.bigint(),\n isClosed: v.optional(v.boolean(), false),\n});\n\nconst CandleColumnarRawSchema = v.object({\n symbolId: v.number(),\n timeframe: v.pipe(\n v.enum(Proto.Timeframe),\n v.transform((v) => timeframeFromProto(v, \"CandleColumnarSchema\")),\n ),\n tsSec: v.array(v.bigint()),\n open: v.array(v.bigint()),\n high: v.array(v.bigint()),\n low: v.array(v.bigint()),\n close: v.array(v.bigint()),\n volume: v.array(v.bigint()),\n referenceTsSec: v.optional(v.array(v.bigint()), []),\n referenceOpen: v.optional(v.array(v.bigint()), []),\n referenceHigh: v.optional(v.array(v.bigint()), []),\n referenceLow: v.optional(v.array(v.bigint()), []),\n referenceClose: v.optional(v.array(v.bigint()), []),\n referenceVolume: v.optional(v.array(v.bigint()), []),\n nextPageToken: v.optional(v.string(), \"\"),\n});\n\nfunction scaledArrayToDecimal(values: bigint[], scale: number): string[] {\n return values.map((value) => scaledToDecimalOutput(value, scale));\n}\n\nexport function createCandleColumnarSchema(scales: SdkScales) {\n return v.pipe(\n CandleColumnarRawSchema,\n v.transform((d) => {\n const priceScale = scales.price();\n const volumeScale = scales.baseQty(d.symbolId);\n const referenceTsSec = d.referenceTsSec ?? [];\n const hasReference = referenceTsSec.length > 0;\n return {\n symbolId: d.symbolId,\n timeframe: d.timeframe,\n time: d.tsSec.map((t) => Number(t)),\n open: scaledArrayToDecimal(d.open, priceScale),\n high: scaledArrayToDecimal(d.high, priceScale),\n low: scaledArrayToDecimal(d.low, priceScale),\n close: scaledArrayToDecimal(d.close, priceScale),\n volume: scaledArrayToDecimal(d.volume, volumeScale),\n nextPageToken: d.nextPageToken,\n reference: hasReference\n ? {\n time: referenceTsSec.map((t) => Number(t)),\n open: scaledArrayToDecimal(d.referenceOpen ?? [], priceScale),\n high: scaledArrayToDecimal(d.referenceHigh ?? [], priceScale),\n low: scaledArrayToDecimal(d.referenceLow ?? [], priceScale),\n close: scaledArrayToDecimal(d.referenceClose ?? [], priceScale),\n volume: scaledArrayToDecimal(d.referenceVolume ?? [], volumeScale),\n }\n : null,\n };\n }),\n );\n}\n\nexport function createCandleColumnarIntSchema(scales: SdkScales) {\n return v.pipe(\n CandleColumnarRawSchema,\n v.transform((d) => {\n const priceScale = scales.price();\n const volumeScale = scales.baseQty(d.symbolId);\n const referenceTsSec = d.referenceTsSec ?? [];\n return {\n symbolId: d.symbolId,\n timeframe: d.timeframe,\n tsSec: d.tsSec.map((t) => Number(t)),\n open: scaledArrayToDecimal(d.open, priceScale),\n high: scaledArrayToDecimal(d.high, priceScale),\n low: scaledArrayToDecimal(d.low, priceScale),\n close: scaledArrayToDecimal(d.close, priceScale),\n volume: scaledArrayToDecimal(d.volume, volumeScale),\n nextPageToken: d.nextPageToken,\n reference:\n referenceTsSec.length > 0\n ? {\n tsSec: referenceTsSec.map((t) => Number(t)),\n open: scaledArrayToDecimal(d.referenceOpen ?? [], priceScale),\n high: scaledArrayToDecimal(d.referenceHigh ?? [], priceScale),\n low: scaledArrayToDecimal(d.referenceLow ?? [], priceScale),\n close: scaledArrayToDecimal(d.referenceClose ?? [], priceScale),\n volume: scaledArrayToDecimal(d.referenceVolume ?? [], volumeScale),\n }\n : null,\n };\n }),\n );\n}\n\nexport type Candle = v.InferOutput<ReturnType<typeof createCandleRowSchema>>;\nexport type CandleInput = v.InferInput<ReturnType<typeof createCandleRowSchema>>;\nexport type CandleIntInput = v.InferInput<ReturnType<typeof createCandleRowIntSchema>>;\nexport type CandleInt = v.InferOutput<ReturnType<typeof createCandleRowIntSchema>>;\nexport type CandleColumnar = v.InferOutput<ReturnType<typeof createCandleColumnarSchema>>;\nexport type CandleColumnarInput = v.InferInput<ReturnType<typeof createCandleColumnarSchema>>;\nexport type CandleColumnarIntInput = v.InferInput<ReturnType<typeof createCandleColumnarIntSchema>>;\nexport type CandleColumnarInt = v.InferOutput<ReturnType<typeof createCandleColumnarIntSchema>>;\n\nexport const ListCandlesInputSchema = v.pipe(\n v.object({\n symbolId: v.pipe(v.number(), v.integer(), v.gtValue(0)),\n timeframe: TimeframeInputSchema,\n limit: OptionalPositiveNumberSchema,\n includeIncomplete: v.optional(v.boolean(), false),\n includeReference: OptionalBooleanSchema,\n startTsSec: OptionalTimestampSecondsInputSchema,\n endTsSec: OptionalTimestampSecondsInputSchema,\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform((d) => ({\n symbolId: d.symbolId,\n timeframe: d.timeframe,\n limit: d.limit,\n includeIncomplete: d.includeIncomplete,\n includeReference: d.includeReference,\n startTime: d.startTsSec != null ? timestampFromTsSec(d.startTsSec) : undefined,\n endTime: d.endTsSec != null ? timestampFromTsSec(d.endTsSec) : undefined,\n pageToken: d.pageToken,\n })),\n);\n\nexport function createListCandlesInputSchema() {\n return ListCandlesInputSchema;\n}\n\nexport type GetCandlesInput = v.InferInput<ReturnType<typeof createListCandlesInputSchema>>;\nexport const createGetCandlesColumnsInputSchema = createListCandlesInputSchema;\nexport type GetCandlesColumnsInput = v.InferInput<ReturnType<typeof createListCandlesInputSchema>>;\n"],"mappings":";;;;;;;AAQA,MAAa,kBAAkB,EAAE,SAAS,UAAU;AAIpD,SAAS,mBAAmB,OAAwB,YAA4C;CAC5F,OAAO,kBACH,eAAe,eACf,OACA,kBAAkB,cAClB,WACJ;AACJ;AAEA,MAAM,uBAAuB,EAAE,KAC3B,iBACA,EAAE,WAAW,UAAU,eAAe,aAAa,MAAM,CAC7D;AAEA,MAAM,+BAA+B,EAAE,SACnC,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,GAAM,CAAC,CACpE;AAEA,MAAM,wBAAwB,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK;AAI3D,SAAS,mBAAmB,OAA8B;CACtD,OAAO;EAAE,SAAS;EAAO,OAAO;CAAE;AACtC;AAEA,MAAM,qBAAqB,EAAE,OAAO;CAChC,UAAU,EAAE,OAAO;CACn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qBAAqB,EAAE,kBAAkB,CAAC,GAAG,UAAU;IAC9D,QAAQ,qBAAqB,EAAE,mBAAmB,CAAC,GAAG,WAAW;GACrE,IACA;EACd;CACJ,CAAC,CACL;AACJ;AAWA,MAAa,yBAAyB,EAAE,KACpC,EAAE,OAAO;CACL,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,QAAQ,CAAC,CAAC;CACtD,WAAW;CACX,OAAO;CACP,mBAAmB,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK;CAChD,kBAAkB;CAClB,YAAY;CACZ,UAAU;CACV,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE;AAC1D,CAAC,GACD,EAAE,WAAW,OAAO;CAChB,UAAU,EAAE;CACZ,WAAW,EAAE;CACb,OAAO,EAAE;CACT,mBAAmB,EAAE;CACrB,kBAAkB,EAAE;CACpB,WAAW,EAAE,cAAc,OAAO,mBAAmB,EAAE,UAAU,IAAI,KAAA;CACrE,SAAS,EAAE,YAAY,OAAO,mBAAmB,EAAE,QAAQ,IAAI,KAAA;CAC/D,WAAW,EAAE;AACjB,EAAE,CACN"}
|
|
1
|
+
{"version":3,"file":"candles.schemas.js","names":["Proto.Timeframe"],"sources":["../../../src/services/candles/candles.schemas.ts"],"sourcesContent":["import * as Proto from \"../../gen/marketdata/v1/marketdata_pb.js\";\nimport { SymbolIdInputSchema } from \"../shared.js\";\nimport * as v from \"valibot\";\nimport type { DecodedEnum } from \"../../utils/types.js\";\nimport { OptionalTimestampSecondsInputSchema } from \"../../shared/schemas.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport { scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { TIMEFRAMES, TimeframeCodec } from \"./candles.codecs.js\";\n\nexport const TimeframeSchema = v.picklist(TIMEFRAMES);\n\nexport type Timeframe = v.InferOutput<typeof TimeframeSchema>;\n\nfunction timeframeFromProto(value: Proto.Timeframe, schemaName: string): DecodedEnum<Timeframe> {\n return requiredEnumLabel(\n TimeframeCodec.protoToOutput,\n value,\n `CandlesService.${schemaName}`,\n \"timeframe\",\n );\n}\n\nconst TimeframeInputSchema = v.pipe(\n TimeframeSchema,\n v.transform((value) => TimeframeCodec.inputToProto[value]),\n);\n\nconst OptionalPositiveNumberSchema = v.optional(\n v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(10_000)),\n);\n\nconst OptionalBooleanSchema = v.optional(v.boolean(), false);\n\ntype TimestampInit = { seconds: bigint; nanos: number };\n\nfunction timestampFromTsSec(tsSec: bigint): TimestampInit {\n return { seconds: tsSec, nanos: 0 };\n}\n\nconst CandleRowRawSchema = v.object({\n symbolId: v.number(),\n timeframe: v.pipe(\n v.enum(Proto.Timeframe),\n v.transform((v) => timeframeFromProto(v, \"CandleRowSchema\")),\n ),\n tsSec: v.bigint(),\n open: v.bigint(),\n high: v.bigint(),\n low: v.bigint(),\n close: v.bigint(),\n volume: v.bigint(),\n isClosed: v.optional(v.boolean(), false),\n});\n\nexport function createCandleRowSchema(scales: SdkScales) {\n return v.pipe(\n CandleRowRawSchema,\n v.transform((data) => {\n const priceScale = scales.price();\n return {\n symbolId: data.symbolId,\n timeframe: data.timeframe,\n time: Number(data.tsSec),\n open: scaledToDecimalOutput(data.open, priceScale),\n high: scaledToDecimalOutput(data.high, priceScale),\n low: scaledToDecimalOutput(data.low, priceScale),\n close: scaledToDecimalOutput(data.close, priceScale),\n volume: scaledToDecimalOutput(data.volume, scales.baseQty(data.symbolId)),\n isClosed: data.isClosed,\n };\n }),\n );\n}\n\nexport const createCandleRowIntSchema = createCandleRowSchema;\n\nexport const CandlePointSchema = v.object({\n tsSec: v.bigint(),\n open: v.bigint(),\n high: v.bigint(),\n low: v.bigint(),\n close: v.bigint(),\n volume: v.bigint(),\n isClosed: v.optional(v.boolean(), false),\n});\n\nconst CandleColumnarRawSchema = v.object({\n symbolId: v.number(),\n timeframe: v.pipe(\n v.enum(Proto.Timeframe),\n v.transform((v) => timeframeFromProto(v, \"CandleColumnarSchema\")),\n ),\n tsSec: v.array(v.bigint()),\n open: v.array(v.bigint()),\n high: v.array(v.bigint()),\n low: v.array(v.bigint()),\n close: v.array(v.bigint()),\n volume: v.array(v.bigint()),\n referenceTsSec: v.optional(v.array(v.bigint()), []),\n referenceOpen: v.optional(v.array(v.bigint()), []),\n referenceHigh: v.optional(v.array(v.bigint()), []),\n referenceLow: v.optional(v.array(v.bigint()), []),\n referenceClose: v.optional(v.array(v.bigint()), []),\n referenceVolume: v.optional(v.array(v.bigint()), []),\n nextPageToken: v.optional(v.string(), \"\"),\n});\n\nfunction scaledArrayToDecimal(values: bigint[], scale: number): string[] {\n return values.map((value) => scaledToDecimalOutput(value, scale));\n}\n\nexport function createCandleColumnarSchema(scales: SdkScales) {\n return v.pipe(\n CandleColumnarRawSchema,\n v.transform((d) => {\n const priceScale = scales.price();\n const volumeScale = scales.baseQty(d.symbolId);\n const referenceTsSec = d.referenceTsSec ?? [];\n const hasReference = referenceTsSec.length > 0;\n return {\n symbolId: d.symbolId,\n timeframe: d.timeframe,\n time: d.tsSec.map((t) => Number(t)),\n open: scaledArrayToDecimal(d.open, priceScale),\n high: scaledArrayToDecimal(d.high, priceScale),\n low: scaledArrayToDecimal(d.low, priceScale),\n close: scaledArrayToDecimal(d.close, priceScale),\n volume: scaledArrayToDecimal(d.volume, volumeScale),\n nextPageToken: d.nextPageToken,\n reference: hasReference\n ? {\n time: referenceTsSec.map((t) => Number(t)),\n open: scaledArrayToDecimal(d.referenceOpen ?? [], priceScale),\n high: scaledArrayToDecimal(d.referenceHigh ?? [], priceScale),\n low: scaledArrayToDecimal(d.referenceLow ?? [], priceScale),\n close: scaledArrayToDecimal(d.referenceClose ?? [], priceScale),\n volume: scaledArrayToDecimal(d.referenceVolume ?? [], volumeScale),\n }\n : null,\n };\n }),\n );\n}\n\nexport function createCandleColumnarIntSchema(scales: SdkScales) {\n return v.pipe(\n CandleColumnarRawSchema,\n v.transform((d) => {\n const priceScale = scales.price();\n const volumeScale = scales.baseQty(d.symbolId);\n const referenceTsSec = d.referenceTsSec ?? [];\n return {\n symbolId: d.symbolId,\n timeframe: d.timeframe,\n tsSec: d.tsSec.map((t) => Number(t)),\n open: scaledArrayToDecimal(d.open, priceScale),\n high: scaledArrayToDecimal(d.high, priceScale),\n low: scaledArrayToDecimal(d.low, priceScale),\n close: scaledArrayToDecimal(d.close, priceScale),\n volume: scaledArrayToDecimal(d.volume, volumeScale),\n nextPageToken: d.nextPageToken,\n reference:\n referenceTsSec.length > 0\n ? {\n tsSec: referenceTsSec.map((t) => Number(t)),\n open: scaledArrayToDecimal(d.referenceOpen ?? [], priceScale),\n high: scaledArrayToDecimal(d.referenceHigh ?? [], priceScale),\n low: scaledArrayToDecimal(d.referenceLow ?? [], priceScale),\n close: scaledArrayToDecimal(d.referenceClose ?? [], priceScale),\n volume: scaledArrayToDecimal(d.referenceVolume ?? [], volumeScale),\n }\n : null,\n };\n }),\n );\n}\n\nexport type Candle = v.InferOutput<ReturnType<typeof createCandleRowSchema>>;\nexport type CandleInput = v.InferInput<ReturnType<typeof createCandleRowSchema>>;\nexport type CandleIntInput = v.InferInput<ReturnType<typeof createCandleRowIntSchema>>;\nexport type CandleInt = v.InferOutput<ReturnType<typeof createCandleRowIntSchema>>;\nexport type CandleColumnar = v.InferOutput<ReturnType<typeof createCandleColumnarSchema>>;\nexport type CandleColumnarInput = v.InferInput<ReturnType<typeof createCandleColumnarSchema>>;\nexport type CandleColumnarIntInput = v.InferInput<ReturnType<typeof createCandleColumnarIntSchema>>;\nexport type CandleColumnarInt = v.InferOutput<ReturnType<typeof createCandleColumnarIntSchema>>;\n\nexport const ListCandlesInputSchema = v.pipe(\n v.object({\n symbolId: SymbolIdInputSchema,\n timeframe: TimeframeInputSchema,\n limit: OptionalPositiveNumberSchema,\n includeIncomplete: v.optional(v.boolean(), false),\n includeReference: OptionalBooleanSchema,\n startTsSec: OptionalTimestampSecondsInputSchema,\n endTsSec: OptionalTimestampSecondsInputSchema,\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform((d) => ({\n symbolId: d.symbolId,\n timeframe: d.timeframe,\n limit: d.limit,\n includeIncomplete: d.includeIncomplete,\n includeReference: d.includeReference,\n startTime: d.startTsSec != null ? timestampFromTsSec(d.startTsSec) : undefined,\n endTime: d.endTsSec != null ? timestampFromTsSec(d.endTsSec) : undefined,\n pageToken: d.pageToken,\n })),\n);\n\nexport function createListCandlesInputSchema() {\n return ListCandlesInputSchema;\n}\n\nexport type GetCandlesInput = v.InferInput<ReturnType<typeof createListCandlesInputSchema>>;\nexport const createGetCandlesColumnsInputSchema = createListCandlesInputSchema;\nexport type GetCandlesColumnsInput = v.InferInput<ReturnType<typeof createListCandlesInputSchema>>;\n"],"mappings":";;;;;;;;AASA,MAAa,kBAAkB,EAAE,SAAS,UAAU;AAIpD,SAAS,mBAAmB,OAAwB,YAA4C;CAC5F,OAAO,kBACH,eAAe,eACf,OACA,kBAAkB,cAClB,WACJ;AACJ;AAEA,MAAM,uBAAuB,EAAE,KAC3B,iBACA,EAAE,WAAW,UAAU,eAAe,aAAa,MAAM,CAC7D;AAEA,MAAM,+BAA+B,EAAE,SACnC,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,GAAM,CAAC,CACpE;AAEA,MAAM,wBAAwB,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK;AAI3D,SAAS,mBAAmB,OAA8B;CACtD,OAAO;EAAE,SAAS;EAAO,OAAO;CAAE;AACtC;AAEA,MAAM,qBAAqB,EAAE,OAAO;CAChC,UAAU,EAAE,OAAO;CACnB,WAAW,EAAE,KACT,EAAE,KAAKA,SAAe,GACtB,EAAE,WAAW,MAAM,mBAAmB,GAAG,iBAAiB,CAAC,CAC/D;CACA,OAAO,EAAE,OAAO;CAChB,MAA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J;AAWA,MAAa,yBAAyB,EAAE,KACpC,EAAE,OAAO;CACL,UAAU;CACV,WAAW;CACX,OAAO;CACP,mBAAmB,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK;CAChD,kBAAkB;CAClB,YAAY;CACZ,UAAU;CACV,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE;AAC1D,CAAC,GACD,EAAE,WAAW,OAAO;CAChB,UAAU,EAAE;CACZ,WAAW,EAAE;CACb,OAAO,EAAE;CACT,mBAAmB,EAAE;CACrB,kBAAkB,EAAE;CACpB,WAAW,EAAE,cAAc,OAAO,mBAAmB,EAAE,UAAU,IAAI,KAAA;CACrE,SAAS,EAAE,YAAY,OAAO,mBAAmB,EAAE,QAAQ,IAAI,KAAA;CAC/D,WAAW,EAAE;AACjB,EAAE,CACN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain-analytics.schemas.d.ts","names":[],"sources":["../../../src/services/chain-analytics/chain-analytics.schemas.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"chain-analytics.schemas.d.ts","names":[],"sources":["../../../src/services/chain-analytics/chain-analytics.schemas.ts"],"mappings":";;;;;cAqBa,2BAAyB,EAAA;KAE1B,sBAAsB,EAAE,mBAAmB;cAwC1C,iCAA+B,EAAA;;;;;;;cAK/B,sCAAoC,EAAA;;;;;;;cAKpC,oCAAkC,EAAA;;;;;;;iBAK/B,sCAAsC,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8BvD,oCAAoC,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;iBAgBrD,2CAA2C,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA4B5D,yCAAyC,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2B9D,4BAA4B,EAAE,kBAAkB;KAEhD,iCAAiC,EAAE,kBACpC;KAGC,+BAA+B,EAAE,kBAAkB;KAEnD,4BAA4B,EAAE,YACtC,kBAAkB;KAEV,0BAA0B,EAAE,YACpC,kBAAkB;KAEV,iCAAiC,EAAE,YAC3C,kBAAkB;KAEV,+BAA+B,EAAE,YACzC,kBAAkB"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { requiredEnumLabel } from "../../shared/proto-enum-codec.js";
|
|
2
|
+
import { PROTOBUF_UINT32_MAX } from "../../shared/wire-bounds.js";
|
|
3
|
+
import { PositiveUint32InputSchema } from "../shared.js";
|
|
2
4
|
import { scaledToDecimalOutput } from "../../shared/decimal-surface.js";
|
|
3
5
|
import { ChainAnalyticsRange } from "../../gen/chain/analytics/v1/analytics_read_pb.js";
|
|
4
6
|
import { CHAIN_ANALYTICS_RANGE_VALUES, ChainAnalyticsRangeCodec } from "./chain-analytics.codecs.js";
|
|
5
7
|
import * as v from "valibot";
|
|
6
8
|
//#region src/services/chain-analytics/chain-analytics.schemas.ts
|
|
7
|
-
const
|
|
8
|
-
const PositiveUint32Schema = v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(maxUint32));
|
|
9
|
-
const NonNegativeUint32Schema = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(maxUint32));
|
|
9
|
+
const NonNegativeUint32Schema = v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(PROTOBUF_UINT32_MAX));
|
|
10
10
|
const OptionalUint32Schema = v.optional(NonNegativeUint32Schema);
|
|
11
11
|
const ChainAnalyticsRangeSchema = v.picklist(CHAIN_ANALYTICS_RANGE_VALUES);
|
|
12
12
|
const ChainAnalyticsRangeInputSchema = v.pipe(v.optional(ChainAnalyticsRangeSchema, "1d"), v.transform((value) => ChainAnalyticsRangeCodec.inputToProto[value]));
|
|
@@ -28,7 +28,7 @@ function scaledArray(values, scale) {
|
|
|
28
28
|
return values.map((value) => scaledToDecimalOutput(value, scale));
|
|
29
29
|
}
|
|
30
30
|
const GetZippedAssetSupplyInputSchema = v.strictObject({
|
|
31
|
-
zippedAssetId:
|
|
31
|
+
zippedAssetId: PositiveUint32InputSchema,
|
|
32
32
|
...ChainAnalyticsWindowInputEntries
|
|
33
33
|
});
|
|
34
34
|
const GetZippedAssetSupplyGroupInputSchema = v.strictObject({
|
|
@@ -36,7 +36,7 @@ const GetZippedAssetSupplyGroupInputSchema = v.strictObject({
|
|
|
36
36
|
...ChainAnalyticsWindowInputEntries
|
|
37
37
|
});
|
|
38
38
|
const GetUnifiedAssetBalancesInputSchema = v.strictObject({
|
|
39
|
-
assetId:
|
|
39
|
+
assetId: PositiveUint32InputSchema,
|
|
40
40
|
...ChainAnalyticsWindowInputEntries
|
|
41
41
|
});
|
|
42
42
|
function createZippedAssetSupplyResponseSchema(scales) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chain-analytics.schemas.js","names":["Proto.ChainAnalyticsRange"],"sources":["../../../src/services/chain-analytics/chain-analytics.schemas.ts"],"sourcesContent":["import * as Proto from \"../../gen/chain/analytics/v1/analytics_read_pb.js\";\nimport { scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport * as v from \"valibot\";\nimport {\n CHAIN_ANALYTICS_RANGE_VALUES,\n ChainAnalyticsRangeCodec,\n} from \"./chain-analytics.codecs.js\";\n\nexport { CHAIN_ANALYTICS_RANGE_VALUES } from \"./chain-analytics.codecs.js\";\n\nconst
|
|
1
|
+
{"version":3,"file":"chain-analytics.schemas.js","names":["Proto.ChainAnalyticsRange"],"sources":["../../../src/services/chain-analytics/chain-analytics.schemas.ts"],"sourcesContent":["import * as Proto from \"../../gen/chain/analytics/v1/analytics_read_pb.js\";\nimport { scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport * as v from \"valibot\";\nimport { PositiveUint32InputSchema } from \"../shared.js\";\nimport { PROTOBUF_UINT32_MAX } from \"../../shared/wire-bounds.js\";\nimport {\n CHAIN_ANALYTICS_RANGE_VALUES,\n ChainAnalyticsRangeCodec,\n} from \"./chain-analytics.codecs.js\";\n\nexport { CHAIN_ANALYTICS_RANGE_VALUES } from \"./chain-analytics.codecs.js\";\n\nconst NonNegativeUint32Schema = v.pipe(\n v.number(),\n v.integer(),\n v.minValue(0),\n v.maxValue(PROTOBUF_UINT32_MAX),\n);\nconst OptionalUint32Schema = v.optional(NonNegativeUint32Schema);\n\nexport const ChainAnalyticsRangeSchema = v.picklist(CHAIN_ANALYTICS_RANGE_VALUES);\n\nexport type ChainAnalyticsRange = v.InferOutput<typeof ChainAnalyticsRangeSchema>;\n\nconst ChainAnalyticsRangeInputSchema = v.pipe(\n v.optional(ChainAnalyticsRangeSchema, \"1d\"),\n v.transform((value) => ChainAnalyticsRangeCodec.inputToProto[value]),\n);\n\nconst ChainAnalyticsRangeOutputSchema = v.pipe(\n v.enum(Proto.ChainAnalyticsRange),\n v.transform((value) =>\n requiredEnumLabel(\n ChainAnalyticsRangeCodec.protoToOutput,\n value,\n \"ChainAnalyticsRangeSchema\",\n \"range\",\n ),\n ),\n);\n\nconst OptionalBucketInputSchema = v.optional(v.pipe(v.string(), v.trim()), \"\");\n\nconst ChainAnalyticsWindowInputEntries = {\n range: ChainAnalyticsRangeInputSchema,\n bucket: OptionalBucketInputSchema,\n startTsSec: OptionalUint32Schema,\n endTsSec: OptionalUint32Schema,\n};\n\nconst ChainAnalyticsResponseEntries = {\n range: ChainAnalyticsRangeOutputSchema,\n bucket: v.string(),\n startTsSec: NonNegativeUint32Schema,\n endTsSec: NonNegativeUint32Schema,\n points: NonNegativeUint32Schema,\n};\n\nfunction scaledArray(values: readonly bigint[], scale: number): string[] {\n return values.map((value) => scaledToDecimalOutput(value, scale));\n}\n\nexport const GetZippedAssetSupplyInputSchema = v.strictObject({\n zippedAssetId: PositiveUint32InputSchema,\n ...ChainAnalyticsWindowInputEntries,\n});\n\nexport const GetZippedAssetSupplyGroupInputSchema = v.strictObject({\n groupId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n ...ChainAnalyticsWindowInputEntries,\n});\n\nexport const GetUnifiedAssetBalancesInputSchema = v.strictObject({\n assetId: PositiveUint32InputSchema,\n ...ChainAnalyticsWindowInputEntries,\n});\n\nexport function createZippedAssetSupplyResponseSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n zippedAssetId: v.number(),\n ...ChainAnalyticsResponseEntries,\n totalSupplyQ: v.array(v.bigint()),\n }),\n v.check(\n (data) => data.endTsSec >= data.startTsSec,\n \"endTsSec must be greater than or equal to startTsSec\",\n ),\n v.check(\n (data) => data.totalSupplyQ.length === data.points,\n \"points must match totalSupply column length\",\n ),\n v.transform((data) => ({\n zippedAssetId: data.zippedAssetId,\n range: data.range,\n bucket: data.bucket,\n startTsSec: data.startTsSec,\n endTsSec: data.endTsSec,\n points: data.points,\n totalSupply: scaledArray(\n data.totalSupplyQ,\n scales.zippedAssetAmount(data.zippedAssetId),\n ),\n })),\n );\n}\n\nexport function createZippedAssetSupplySeriesSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n zippedAssetId: v.number(),\n totalSupplyQ: v.array(v.bigint()),\n }),\n v.transform((series) => ({\n zippedAssetId: series.zippedAssetId,\n totalSupply: scaledArray(\n series.totalSupplyQ,\n scales.zippedAssetAmount(series.zippedAssetId),\n ),\n })),\n );\n}\n\nexport function createZippedAssetSupplyGroupResponseSchema(scales: SdkScales) {\n const seriesSchema = createZippedAssetSupplySeriesSchema(scales);\n return v.pipe(\n v.object({\n groupId: v.string(),\n ...ChainAnalyticsResponseEntries,\n series: v.array(seriesSchema),\n }),\n v.check(\n (data) => data.endTsSec >= data.startTsSec,\n \"endTsSec must be greater than or equal to startTsSec\",\n ),\n v.check(\n (data) => data.series.every((series) => series.totalSupply.length === data.points),\n \"points must match each totalSupply column length\",\n ),\n v.transform((data) => ({\n groupId: data.groupId,\n range: data.range,\n bucket: data.bucket,\n startTsSec: data.startTsSec,\n endTsSec: data.endTsSec,\n points: data.points,\n series: data.series,\n })),\n );\n}\n\nexport function createUnifiedAssetBalancesResponseSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n assetId: v.number(),\n ...ChainAnalyticsResponseEntries,\n totalBalanceQ: v.array(v.bigint()),\n }),\n v.check(\n (data) => data.endTsSec >= data.startTsSec,\n \"endTsSec must be greater than or equal to startTsSec\",\n ),\n v.check(\n (data) => data.totalBalanceQ.length === data.points,\n \"points must match totalBalance column length\",\n ),\n v.transform((data) => ({\n assetId: data.assetId,\n range: data.range,\n bucket: data.bucket,\n startTsSec: data.startTsSec,\n endTsSec: data.endTsSec,\n points: data.points,\n totalBalance: scaledArray(data.totalBalanceQ, scales.ledgerAmount(data.assetId)),\n })),\n );\n}\n\nexport type GetZippedAssetSupplyInput = v.InferInput<typeof GetZippedAssetSupplyInputSchema>;\n\nexport type GetZippedAssetSupplyGroupInput = v.InferInput<\n typeof GetZippedAssetSupplyGroupInputSchema\n>;\n\nexport type GetUnifiedAssetBalancesInput = v.InferInput<typeof GetUnifiedAssetBalancesInputSchema>;\n\nexport type ZippedAssetSupplyResponse = v.InferOutput<\n ReturnType<typeof createZippedAssetSupplyResponseSchema>\n>;\nexport type ZippedAssetSupplySeries = v.InferOutput<\n ReturnType<typeof createZippedAssetSupplySeriesSchema>\n>;\nexport type ZippedAssetSupplyGroupResponse = v.InferOutput<\n ReturnType<typeof createZippedAssetSupplyGroupResponseSchema>\n>;\nexport type UnifiedAssetBalancesResponse = v.InferOutput<\n ReturnType<typeof createUnifiedAssetBalancesResponseSchema>\n>;\n"],"mappings":";;;;;;;;AAaA,MAAM,0BAA0B,EAAE,KAC9B,EAAE,OAAO,GACT,EAAE,QAAQ,GACV,EAAE,SAAS,CAAC,GACZ,EAA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WAAW,UAAU;EACnB,SAAS,KAAK;EACd,OAAO,KAAK;EACZ,QAAQ,KAAK;EACb,YAAY,KAAK;EACjB,UAAU,KAAK;EACf,QAAQ,KAAK;EACb,cAAc,YAAY,KAAK,eAAe,OAAO,aAAa,KAAK,OAAO,CAAC;CACnF,EAAE,CACN;AACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
2
|
//#region src/services/deposit/deposit.schemas.d.ts
|
|
3
3
|
declare function createCreateDepositAddressInputSchema(): v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
4
|
-
readonly chainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
4
|
+
readonly chainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
|
|
5
5
|
readonly account: v.OptionalSchema<v.UnionSchema<[v.PicklistSchema<["active", "main"], undefined>, v.StrictObjectSchema<{
|
|
6
6
|
readonly subaccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
7
7
|
}, undefined>], undefined>, undefined>;
|
|
@@ -16,7 +16,7 @@ declare function createCreateDepositAddressInputSchema(): v.SchemaWithPipe<reado
|
|
|
16
16
|
}>]>;
|
|
17
17
|
type CreateDepositAddressInput = v.InferInput<ReturnType<typeof createCreateDepositAddressInputSchema>>;
|
|
18
18
|
declare function createListDepositAddressesInputSchema(): v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
|
|
19
|
-
readonly chainId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>, undefined>;
|
|
19
|
+
readonly chainId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>;
|
|
20
20
|
readonly account: v.OptionalSchema<v.UnionSchema<[v.PicklistSchema<["active", "main"], undefined>, v.StrictObjectSchema<{
|
|
21
21
|
readonly subaccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
22
22
|
}, undefined>], undefined>, undefined>;
|
|
@@ -31,7 +31,7 @@ declare function createListDepositAddressesInputSchema(): v.SchemaWithPipe<reado
|
|
|
31
31
|
}>]>;
|
|
32
32
|
type ListDepositAddressesInput = v.InferInput<ReturnType<typeof createListDepositAddressesInputSchema>>;
|
|
33
33
|
declare const DepositAddressSchema: v.ObjectSchema<{
|
|
34
|
-
readonly chainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
34
|
+
readonly chainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
|
|
35
35
|
readonly depositAddress: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
36
36
|
}, undefined>;
|
|
37
37
|
type DepositAddress = v.InferOutput<typeof DepositAddressSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deposit.schemas.d.ts","names":[],"sources":["../../../src/services/deposit/deposit.schemas.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"deposit.schemas.d.ts","names":[],"sources":["../../../src/services/deposit/deposit.schemas.ts"],"mappings":";;iBAkBgB,yCAAqC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;KAIzC,4BAA4B,EAAE,WACtC,kBAAkB;iBAiBN,yCAAqC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;KAIzC,4BAA4B,EAAE,WACtC,kBAAkB;cAMT,sBAAoB,EAAA;;;;KAKrB,iBAAiB,EAAE,mBAAmB"}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
+
import { PositiveUint32InputSchema } from "../shared.js";
|
|
1
2
|
import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
|
|
2
3
|
import * as v from "valibot";
|
|
3
4
|
//#region src/services/deposit/deposit.schemas.ts
|
|
4
|
-
const ChainIdSchema = v.pipe(v.number(), v.integer(), v.gtValue(0));
|
|
5
5
|
const CreateDepositAddressInputSchema = v.pipe(v.strictObject({
|
|
6
6
|
...AccountScopeInputEntries,
|
|
7
|
-
chainId:
|
|
7
|
+
chainId: PositiveUint32InputSchema
|
|
8
8
|
}), v.transform(({ account, ...input }) => ({
|
|
9
9
|
...input,
|
|
10
10
|
subaccountId: accountScopeToSubaccountId(account)
|
|
11
11
|
})));
|
|
12
12
|
const ListDepositAddressesInputSchema = v.pipe(v.strictObject({
|
|
13
13
|
...AccountScopeInputEntries,
|
|
14
|
-
chainId: v.optional(
|
|
14
|
+
chainId: v.optional(PositiveUint32InputSchema)
|
|
15
15
|
}), v.transform(({ account, ...input }) => ({
|
|
16
16
|
...input,
|
|
17
17
|
subaccountId: accountScopeToSubaccountId(account)
|
|
18
18
|
})));
|
|
19
19
|
const DepositAddressSchema = v.object({
|
|
20
|
-
chainId:
|
|
20
|
+
chainId: PositiveUint32InputSchema,
|
|
21
21
|
depositAddress: v.pipe(v.string(), v.trim(), v.minLength(1))
|
|
22
22
|
});
|
|
23
23
|
const DepositAddressesSchema = v.array(DepositAddressSchema);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deposit.schemas.js","names":[],"sources":["../../../src/services/deposit/deposit.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\n\
|
|
1
|
+
{"version":3,"file":"deposit.schemas.js","names":[],"sources":["../../../src/services/deposit/deposit.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { PositiveUint32InputSchema } from \"../shared.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\n\nexport const CreateDepositAddressInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n chainId: PositiveUint32InputSchema,\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport function createCreateDepositAddressInputSchema() {\n return CreateDepositAddressInputSchema;\n}\n\nexport type CreateDepositAddressInput = v.InferInput<\n ReturnType<typeof createCreateDepositAddressInputSchema>\n>;\nexport type CreateDepositAddressRequest = v.InferOutput<\n ReturnType<typeof createCreateDepositAddressInputSchema>\n>;\n\nexport const ListDepositAddressesInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n chainId: v.optional(PositiveUint32InputSchema),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport function createListDepositAddressesInputSchema() {\n return ListDepositAddressesInputSchema;\n}\n\nexport type ListDepositAddressesInput = v.InferInput<\n ReturnType<typeof createListDepositAddressesInputSchema>\n>;\nexport type ListDepositAddressesRequest = v.InferOutput<\n ReturnType<typeof createListDepositAddressesInputSchema>\n>;\n\nexport const DepositAddressSchema = v.object({\n chainId: PositiveUint32InputSchema,\n depositAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n});\n\nexport type DepositAddress = v.InferOutput<typeof DepositAddressSchema>;\n\nexport const DepositAddressesSchema = v.array(DepositAddressSchema);\n"],"mappings":";;;;AAOA,MAAa,kCAAkC,EAAE,KAC7C,EAAE,aAAa;CACX,GAAG;CACH,SAAS;AACb,CAAC,GACD,EAAE,WAAW,EAAE,SAAS,GAAG,aAAa;CACpC,GAAG;CACH,cAAc,2BAA2B,OAAO;AACpD,EAAE,CACN;AAaA,MAAa,kCAAkC,EAAE,KAC7C,EAAE,aAAa;CACX,GAAG;CACH,SAAS,EAAE,SAAS,yBAAyB;AACjD,CAAC,GACD,EAAE,WAAW,EAAE,SAAS,GAAG,aAAa;CACpC,GAAG;CACH,cAAc,2BAA2B,OAAO;AACpD,EAAE,CACN;AAaA,MAAa,uBAAuB,EAAE,OAAO;CACzC,SAAS;CACT,gBAAgB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;AAC/D,CAAC;AAID,MAAa,yBAAyB,EAAE,MAAM,oBAAoB"}
|
|
@@ -17,7 +17,7 @@ declare const SignProtectedActionInputSchema: v.SchemaWithPipe<readonly [v.Stric
|
|
|
17
17
|
readonly action: v.PicklistSchema<readonly ["fundingSetExternalWhitelistRequired", "fundingAddExternalWhitelist", "fundingRemoveExternalWhitelist", "fundingAddInternalWhitelist", "fundingRemoveInternalWhitelist", "fundingSetInternalWhitelistRequired"], undefined>;
|
|
18
18
|
readonly args: v.OptionalSchema<v.VariantSchema<"case", [v.StrictObjectSchema<{
|
|
19
19
|
readonly case: v.LiteralSchema<"externalWhitelist", undefined>;
|
|
20
|
-
readonly polychainChainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
20
|
+
readonly polychainChainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
|
|
21
21
|
readonly addresses: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
|
|
22
22
|
}, undefined>, v.StrictObjectSchema<{
|
|
23
23
|
readonly case: v.LiteralSchema<"internalWhitelist", undefined>;
|
|
@@ -83,7 +83,7 @@ declare const BatchSignProtectedActionInputSchema: v.SchemaWithPipe<readonly [v.
|
|
|
83
83
|
readonly action: v.PicklistSchema<readonly ["fundingSetExternalWhitelistRequired", "fundingAddExternalWhitelist", "fundingRemoveExternalWhitelist", "fundingAddInternalWhitelist", "fundingRemoveInternalWhitelist", "fundingSetInternalWhitelistRequired"], undefined>;
|
|
84
84
|
readonly args: v.OptionalSchema<v.VariantSchema<"case", [v.StrictObjectSchema<{
|
|
85
85
|
readonly case: v.LiteralSchema<"externalWhitelist", undefined>;
|
|
86
|
-
readonly polychainChainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
86
|
+
readonly polychainChainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
|
|
87
87
|
readonly addresses: v.SchemaWithPipe<readonly [v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>, undefined>, v.MinLengthAction<string[], 1, undefined>]>;
|
|
88
88
|
}, undefined>, v.StrictObjectSchema<{
|
|
89
89
|
readonly case: v.LiteralSchema<"internalWhitelist", undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard-signer.schemas.d.ts","names":[],"sources":["../../../src/services/guard-signer/guard-signer.schemas.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"guard-signer.schemas.d.ts","names":[],"sources":["../../../src/services/guard-signer/guard-signer.schemas.ts"],"mappings":";;;cAaa,8BAA4B,EAAA,yBAAA,EAAA;;;;;;;;;;;KAS7B,yBAAyB,EAAE,kBAAkB;cAoD5C,gCAA8B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAa/B,2BAA2B,EAAE,kBAAkB;cAE9C,qCAAmC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsBpC,gCAAgC,EAAE,kBACnC;cAGE,yBAAuB,EAAA;;;;;;;KAQxB,oBAAoB,EAAE,mBAAmB;cAExC,qBAAmB,EAAA,yBAAA,EAAA;;;;;;;;;;;EAS4B;;;;;;;KAKhD,gBAAgB,EAAE,mBAAmB;cAEpC,2BAAyB,EAAA;;;;;;;;;;;;IAPsB;;;;;;;;KAWhD,sBAAsB,EAAE,mBAAmB;cAE1C,qCAAmC,EAAA;;;KAIpC,gCAAgC,EAAE,mBACnC;cAGE,qCAAmC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;IArBY;;;;;;;;;;;;IAAA;;;;;;;;;;;;IAAA;;;;;;;;KAgChD,gCAAgC,EAAE,mBACnC;cAGE,qCAAmC,EAAA;;;KAIpC,gCAAgC,EAAE,mBACnC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { PositiveUint32InputSchema } from "../shared.js";
|
|
1
2
|
import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
|
|
2
3
|
import { PROTECTED_ACTION_VALUES, ProtectedActionCodec } from "./guard-signer.codecs.js";
|
|
3
4
|
import * as v from "valibot";
|
|
@@ -9,7 +10,7 @@ const GuardSignerScopedInputSchema = v.pipe(v.strictObject({ ...AccountScopeInpu
|
|
|
9
10
|
const ProtectedActionArgsInputSchema = v.variant("case", [
|
|
10
11
|
v.strictObject({
|
|
11
12
|
case: v.literal("externalWhitelist"),
|
|
12
|
-
polychainChainId:
|
|
13
|
+
polychainChainId: PositiveUint32InputSchema,
|
|
13
14
|
addresses: v.pipe(v.array(WhitelistAddressSchema), v.minLength(1))
|
|
14
15
|
}),
|
|
15
16
|
v.strictObject({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"guard-signer.schemas.js","names":[],"sources":["../../../src/services/guard-signer/guard-signer.schemas.ts"],"sourcesContent":["import { bytesToHex } from \"@noble/hashes/utils.js\";\nimport * as v from \"valibot\";\nimport { PROTECTED_ACTION_VALUES, ProtectedActionCodec } from \"./guard-signer.codecs.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\n\nconst HexAddressSchema = v.pipe(v.string(), v.trim(), v.regex(/^0x[0-9a-fA-F]{40}$/));\n\nconst WhitelistAddressSchema = v.pipe(v.string(), v.trim(), v.minLength(1));\n\nexport const GuardSignerScopedInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n }),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type GuardSignerScopedInput = v.InferInput<typeof GuardSignerScopedInputSchema>;\n\nconst ProtectedActionArgsInputSchema = v.variant(\"case\", [\n v.strictObject({\n case: v.literal(\"externalWhitelist\"),\n polychainChainId:
|
|
1
|
+
{"version":3,"file":"guard-signer.schemas.js","names":[],"sources":["../../../src/services/guard-signer/guard-signer.schemas.ts"],"sourcesContent":["import { bytesToHex } from \"@noble/hashes/utils.js\";\nimport { PositiveUint32InputSchema } from \"../shared.js\";\nimport * as v from \"valibot\";\nimport { PROTECTED_ACTION_VALUES, ProtectedActionCodec } from \"./guard-signer.codecs.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\n\nconst HexAddressSchema = v.pipe(v.string(), v.trim(), v.regex(/^0x[0-9a-fA-F]{40}$/));\n\nconst WhitelistAddressSchema = v.pipe(v.string(), v.trim(), v.minLength(1));\n\nexport const GuardSignerScopedInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n }),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type GuardSignerScopedInput = v.InferInput<typeof GuardSignerScopedInputSchema>;\n\nconst ProtectedActionArgsInputSchema = v.variant(\"case\", [\n v.strictObject({\n case: v.literal(\"externalWhitelist\"),\n polychainChainId: PositiveUint32InputSchema,\n addresses: v.pipe(v.array(WhitelistAddressSchema), v.minLength(1)),\n }),\n v.strictObject({\n case: v.literal(\"internalWhitelist\"),\n addresses: v.pipe(v.array(WhitelistAddressSchema), v.minLength(1)),\n }),\n v.strictObject({\n case: v.literal(\"whitelistRequirement\"),\n required: v.boolean(),\n }),\n]);\n\nfunction toProtectedActionArgs(args: v.InferOutput<typeof ProtectedActionArgsInputSchema>) {\n if (args.case === \"externalWhitelist\") {\n return {\n args: {\n case: \"externalWhitelist\" as const,\n value: {\n polychainChainId: args.polychainChainId,\n addresses: args.addresses,\n },\n },\n };\n }\n\n if (args.case === \"internalWhitelist\") {\n return {\n args: {\n case: \"internalWhitelist\" as const,\n value: {\n addresses: args.addresses,\n },\n },\n };\n }\n\n return {\n args: {\n case: \"whitelistRequirement\" as const,\n value: {\n required: args.required,\n },\n },\n };\n}\n\nexport const SignProtectedActionInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n action: v.picklist(PROTECTED_ACTION_VALUES),\n args: v.optional(ProtectedActionArgsInputSchema),\n }),\n v.transform(({ account, action, args }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n action: ProtectedActionCodec.inputToProto[action],\n args: args ? toProtectedActionArgs(args) : undefined,\n })),\n);\n\nexport type SignProtectedActionInput = v.InferInput<typeof SignProtectedActionInputSchema>;\n\nexport const BatchSignProtectedActionInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n actions: v.pipe(\n v.array(\n v.strictObject({\n action: v.picklist(PROTECTED_ACTION_VALUES),\n args: v.optional(ProtectedActionArgsInputSchema),\n }),\n ),\n v.minLength(1, \"At least one protected action is required.\"),\n ),\n }),\n v.transform(({ account, actions }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n actions: actions.map(({ action, args }) => ({\n action: ProtectedActionCodec.inputToProto[action],\n args: args ? toProtectedActionArgs(args) : undefined,\n })),\n })),\n);\n\nexport type BatchSignProtectedActionInput = v.InferInput<\n typeof BatchSignProtectedActionInputSchema\n>;\n\nexport const GuardSignerStatusSchema = v.object({\n signerAddress: v.string(),\n onchainSignerAddress: v.string(),\n initialized: v.boolean(),\n nonce: v.string(),\n nonceSpace: v.bigint(),\n});\n\nexport type GuardSignerStatus = v.InferOutput<typeof GuardSignerStatusSchema>;\n\nexport const GuardApprovalSchema = v.pipe(\n v.object({\n nonceSpace: v.bigint(),\n deadlineUnix: v.bigint(),\n signature: v.instance(Uint8Array),\n }),\n v.transform((approval) => ({\n nonceSpace: approval.nonceSpace.toString(),\n deadlineUnix: approval.deadlineUnix.toString(),\n signature: `0x${bytesToHex(approval.signature)}` as `0x${string}`,\n raw: approval,\n })),\n);\n\nexport type GuardApproval = v.InferOutput<typeof GuardApprovalSchema>;\n\nexport const BatchGuardApprovalsSchema = v.object({\n approvals: v.array(GuardApprovalSchema),\n});\n\nexport type BatchGuardApprovals = v.InferOutput<typeof BatchGuardApprovalsSchema>;\n\nexport const CreateGuardSignerWalletResultSchema = v.object({\n signerAddress: HexAddressSchema,\n});\n\nexport type CreateGuardSignerWalletResult = v.InferOutput<\n typeof CreateGuardSignerWalletResultSchema\n>;\n\nexport const RotateGuardSignerWalletResultSchema = v.pipe(\n v.object({\n newSignerAddress: HexAddressSchema,\n approval: v.optional(GuardApprovalSchema),\n }),\n v.transform((result) => ({\n newSignerAddress: result.newSignerAddress,\n approval: result.approval ?? null,\n })),\n);\n\nexport type RotateGuardSignerWalletResult = v.InferOutput<\n typeof RotateGuardSignerWalletResultSchema\n>;\n\nexport const ExportGuardSignerWalletResultSchema = v.object({\n privateKey: v.pipe(v.string(), v.trim(), v.regex(/^0x[0-9a-fA-F]{64}$/)),\n});\n\nexport type ExportGuardSignerWalletResult = v.InferOutput<\n typeof ExportGuardSignerWalletResultSchema\n>;\n"],"mappings":";;;;;;AASA,MAAM,mBAAmB,EAAE,KAAK,EA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,SAAS,mBAAmB;AAC5C,CAAC,GACD,EAAE,WAAW,YAAY;CACrB,kBAAkB,OAAO;CACzB,UAAU,OAAO,YAAY;AACjC,EAAE,CACN;AAMA,MAAa,sCAAsC,EAAE,OAAO,EACxD,YAAY,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,MAAM,qBAAqB,CAAC,EAC3E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heatmap.d.ts","names":[],"sources":["../../../src/services/heatmap/heatmap.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"heatmap.d.ts","names":[],"sources":["../../../src/services/heatmap/heatmap.ts"],"mappings":";;;;;;;;UA6BiB;EACb,oBACI,OAAO,0BACP,UAAU,0BACX,QAAQ;;UAGL,kCAAkC,mBAAmB;EAC3D;EACA,UAAU;;;;;cAWD,0BAA0B;;EAOvB,YAAA,YAAY,qBAAqB,UAAU,mBAAmB,QAAQ;;;;EAW5E,oBACF,OAAO,0BACP,UAAU,0BACX,QAAQ;;;;EA4BX,cAAc,OAAO"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { parse } from "../../shared/validation.js";
|
|
2
2
|
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
3
|
+
import { SymbolIdInputSchema } from "../shared.js";
|
|
3
4
|
import { connectReadyGatedProtoChannel } from "../../realtime/ready-gated-subscription.js";
|
|
4
5
|
import { HeatmapLiveBucketSchema, HeatmapService as HeatmapService$1, HeatmapTimeRangeSchema } from "../../gen/marketdata/v1/heatmap_pb.js";
|
|
5
6
|
import { HEATMAP_INTERVAL_VALUES } from "./heatmap.codecs.js";
|
|
@@ -9,7 +10,7 @@ import { createClient } from "@connectrpc/connect";
|
|
|
9
10
|
import * as v from "valibot";
|
|
10
11
|
//#region src/services/heatmap/heatmap.ts
|
|
11
12
|
const SubscribeHeatmapLiveParamsSchema = v.object({
|
|
12
|
-
symbolId:
|
|
13
|
+
symbolId: SymbolIdInputSchema,
|
|
13
14
|
interval: v.picklist(HEATMAP_INTERVAL_VALUES)
|
|
14
15
|
});
|
|
15
16
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heatmap.js","names":["#client","HeatmapRpc","#realtime","#scales","#responseSchema","#liveBucketSchema","ProtoHeatmapLiveBucketSchema"],"sources":["../../../src/services/heatmap/heatmap.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport { create } from \"@bufbuild/protobuf\";\nimport {\n HeatmapService as HeatmapRpc,\n HeatmapLiveBucketSchema as ProtoHeatmapLiveBucketSchema,\n HeatmapTimeRangeSchema,\n} from \"../../gen/marketdata/v1/heatmap_pb.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport { connectReadyGatedProtoChannel } from \"../../realtime/ready-gated-subscription.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport type { PublicApiTransports } from \"../../shared/transports.js\";\nimport { HEATMAP_INTERVAL_VALUES, type HeatmapIntervalValue } from \"./heatmap.codecs.js\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport {\n GetOrderbookHeatmapInputSchema,\n createOrderbookHeatmapLiveBucketSchema,\n createOrderbookHeatmapResponseSchema,\n type GetOrderbookHeatmapInput,\n type OrderbookHeatmapLiveBucket,\n type OrderbookHeatmapResponse,\n} from \"./heatmap.schemas.js\";\n\nexport interface OrderbookHeatmapProvider {\n getOrderbookHeatmap(\n input: GetOrderbookHeatmapInput,\n options?: PolyesterRequestOptions,\n ): Promise<OrderbookHeatmapResponse>;\n}\n\ninterface SubscribeHeatmapLiveInput extends BaseSubscribeInput<OrderbookHeatmapLiveBucket> {\n symbolId: number;\n interval: HeatmapIntervalValue;\n}\n\nconst SubscribeHeatmapLiveParamsSchema = v.object({\n symbolId:
|
|
1
|
+
{"version":3,"file":"heatmap.js","names":["#client","HeatmapRpc","#realtime","#scales","#responseSchema","#liveBucketSchema","ProtoHeatmapLiveBucketSchema"],"sources":["../../../src/services/heatmap/heatmap.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport { SymbolIdInputSchema } from \"../shared.js\";\nimport { create } from \"@bufbuild/protobuf\";\nimport {\n HeatmapService as HeatmapRpc,\n HeatmapLiveBucketSchema as ProtoHeatmapLiveBucketSchema,\n HeatmapTimeRangeSchema,\n} from \"../../gen/marketdata/v1/heatmap_pb.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport { connectReadyGatedProtoChannel } from \"../../realtime/ready-gated-subscription.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport type { PublicApiTransports } from \"../../shared/transports.js\";\nimport { HEATMAP_INTERVAL_VALUES, type HeatmapIntervalValue } from \"./heatmap.codecs.js\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport {\n GetOrderbookHeatmapInputSchema,\n createOrderbookHeatmapLiveBucketSchema,\n createOrderbookHeatmapResponseSchema,\n type GetOrderbookHeatmapInput,\n type OrderbookHeatmapLiveBucket,\n type OrderbookHeatmapResponse,\n} from \"./heatmap.schemas.js\";\n\nexport interface OrderbookHeatmapProvider {\n getOrderbookHeatmap(\n input: GetOrderbookHeatmapInput,\n options?: PolyesterRequestOptions,\n ): Promise<OrderbookHeatmapResponse>;\n}\n\ninterface SubscribeHeatmapLiveInput extends BaseSubscribeInput<OrderbookHeatmapLiveBucket> {\n symbolId: number;\n interval: HeatmapIntervalValue;\n}\n\nconst SubscribeHeatmapLiveParamsSchema = v.object({\n symbolId: SymbolIdInputSchema,\n interval: v.picklist(HEATMAP_INTERVAL_VALUES),\n});\n\n/**\n * Reads historical order book heatmap chains and streams live heatmap buckets.\n */\nexport class HeatmapService implements OrderbookHeatmapProvider {\n #client: Client<typeof HeatmapRpc>;\n #realtime: PolyesterRealtime;\n #scales: SdkScales;\n #responseSchema: ReturnType<typeof createOrderbookHeatmapResponseSchema>;\n #liveBucketSchema: ReturnType<typeof createOrderbookHeatmapLiveBucketSchema>;\n\n constructor(transports: PublicApiTransports, realtime: PolyesterRealtime, scales: SdkScales) {\n this.#client = createClient(HeatmapRpc, transports.publicApi);\n this.#realtime = realtime;\n this.#scales = scales;\n this.#responseSchema = createOrderbookHeatmapResponseSchema(scales);\n this.#liveBucketSchema = createOrderbookHeatmapLiveBucketSchema(scales);\n }\n\n /**\n * Fetches order book heatmap data for a symbol, interval, depth, and quantity mode using either an absolute time range or cursor pagination. The response includes a keyframe anchor, delta buckets, pagination metadata, and live-anchor fields when available.\n */\n async getOrderbookHeatmap(\n input: GetOrderbookHeatmapInput,\n options?: PolyesterRequestOptions,\n ): Promise<OrderbookHeatmapResponse> {\n const parsed = parse(GetOrderbookHeatmapInputSchema, input);\n await this.#scales.ready();\n\n const res = await this.#client.getOrderbookHeatmap(\n {\n symbolId: parsed.symbolId,\n interval: parsed.interval,\n depth: parsed.depth,\n quantityMode: parsed.quantityMode,\n limit: parsed.limit,\n pageToken: parsed.pageToken,\n timeRange:\n parsed.timeRange != null\n ? create(HeatmapTimeRangeSchema, {\n startTime: parsed.timeRange.startTime,\n endTime: parsed.timeRange.endTime,\n })\n : undefined,\n },\n toConnectCallOptions(options),\n );\n return parse(this.#responseSchema, res);\n }\n\n /**\n * Subscribes to live heatmap buckets on public:spot:market:heatmap:{interval}:{symbolId}:proto and emits parsed bid/ask delta buckets for the selected interval.\n */\n subscribeLive(input: SubscribeHeatmapLiveInput): () => void {\n const params = parse(SubscribeHeatmapLiveParamsSchema, {\n symbolId: input.symbolId,\n interval: input.interval,\n });\n const channel = `public:spot:market:heatmap:${params.interval}:${params.symbolId}:proto`;\n return connectReadyGatedProtoChannel(this.#realtime, {\n channel,\n schema: ProtoHeatmapLiveBucketSchema,\n ready: () => this.#scales.ready(),\n onPublication: (data) => {\n const bucket = parse(this.#liveBucketSchema, data);\n input.onEvent(bucket);\n },\n onConnected: input.onOpen,\n onDisconnected: input.onClose,\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;AAyCA,MAAM,mCAAmC,EAAE,OAAO;CAC9C,UAAU;CACV,UAAU,EAAE,SAAS,uBAAuB;AAChD,CAAC;;;;AAKD,IAAa,iBAAb,MAAgE;CAC5D;CACA;CACA;CACA;CACA;CAEA,YAAY,YAAiC,UAA6B,QAAmB;EACzF,KAAKA,UAAU,aAAaC,kBAAY,WAAW,SAAS;EAC5D,KAAKC,YAAY;EACjB,KAAKC,UAAU;EACf,KAAKC,kBAAkB,qCAAqC,MAAM;EAClE,KAAKC,oBAAoB,uCAAuC,MAAM;CAC1E;;;;CAKA,MAAM,oBACF,OACA,SACiC;EACjC,MAAM,SAAS,MAAM,gCAAgC,KAAK;EAC1D,MAAM,KAAKF,QAAQ,MAAM;EAEzB,MAAM,MAAM,MAAM,KAAKH,QAAQ,oBAC3B;GACI,UAAU,OAAO;GACjB,UAAU,OAAO;GACjB,OAAO,OAAO;GACd,cAAc,OAAO;GACrB,OAAO,OAAO;GACd,WAAW,OAAO;GAClB,WACI,OAAO,aAAa,OACd,OAAO,wBAAwB;IAC3B,WAAW,OAAO,UAAU;IAC5B,SAAS,OAAO,UAAU;GAC9B,CAAC,IACD,KAAA;EACd,GACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,KAAKI,iBAAiB,GAAG;CAC1C;;;;CAKA,cAAc,OAA8C;EACxD,MAAM,SAAS,MAAM,kCAAkC;GACnD,UAAU,MAAM;GAChB,UAAU,MAAM;EACpB,CAAC;EACD,MAAM,UAAU,8BAA8B,OAAO,SAAS,GAAG,OAAO,SAAS;EACjF,OAAO,8BAA8B,KAAKF,WAAW;GACjD;GACA,QAAQI;GACR,aAAa,KAAKH,QAAQ,MAAM;GAChC,gBAAgB,SAAS;IACrB,MAAM,SAAS,MAAM,KAAKE,mBAAmB,IAAI;IACjD,MAAM,QAAQ,MAAM;GACxB;GACA,aAAa,MAAM;GACnB,gBAAgB,MAAM;GACtB,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
|
|
@@ -12,7 +12,7 @@ type TimestampInit = {
|
|
|
12
12
|
nanos: number;
|
|
13
13
|
};
|
|
14
14
|
declare const GetOrderbookHeatmapInputSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
15
|
-
readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
15
|
+
readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
|
|
16
16
|
readonly interval: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["1s", "1m", "5m", "1h"], undefined>, "1s">, v.TransformAction<"1s" | "1m" | "5m" | "1h", HeatmapInterval>]>;
|
|
17
17
|
readonly depth: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly [1, 5, 10, 20, 50, 100, 200, 500, 1000], undefined>, 50>, v.TransformAction<5 | 10 | 20 | 1 | 200 | 1000 | 500 | 100 | 50, HeatmapDepth>]>;
|
|
18
18
|
readonly quantityMode: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["close", "peak"], undefined>, "close">, v.TransformAction<"close" | "peak", HeatmapQuantityMode>]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heatmap.schemas.d.ts","names":[],"sources":["../../../src/services/heatmap/heatmap.schemas.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"heatmap.schemas.d.ts","names":[],"sources":["../../../src/services/heatmap/heatmap.schemas.ts"],"mapp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
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { requiredEnumLabel } from "../../shared/proto-enum-codec.js";
|
|
2
2
|
import { OptionalTimestampSecondsInputSchema } from "../../shared/schemas.js";
|
|
3
|
+
import { SymbolIdInputSchema } from "../shared.js";
|
|
3
4
|
import { scaledToDecimalOutput } from "../../shared/decimal-surface.js";
|
|
4
5
|
import { HEATMAP_DEPTH_VALUES, HEATMAP_INTERVAL_VALUES, HEATMAP_QUANTITY_MODE_VALUES, HeatmapDepthCodec, HeatmapIntervalCodec, HeatmapQuantityModeCodec } from "./heatmap.codecs.js";
|
|
5
6
|
import * as v from "valibot";
|
|
@@ -14,7 +15,7 @@ function timestampFromTsSec(tsSec) {
|
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
17
|
const GetOrderbookHeatmapInputSchema = v.pipe(v.object({
|
|
17
|
-
symbolId:
|
|
18
|
+
symbolId: SymbolIdInputSchema,
|
|
18
19
|
interval: IntervalInputSchema,
|
|
19
20
|
depth: DepthInputSchema,
|
|
20
21
|
quantityMode: QuantityModeInputSchema,
|
|
@@ -1 +1 @@
|
|
|
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;CACd,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,QAAQ,CAAC,GAAG,EAAE,SAAS,GAAM,CAAC;CACvE,YAAY;CACZ,UAAU;CACV,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE;AAC1D,CAAC,GACD,EAAE,OACG,UAAU,MAAM,cAAc,MAAM,MAAM,cAAc,QAAQ,MAAM,YAAY,MACnF,gDACJ,GACA,EAAE,WAAW,UAAU;CACnB,MAAM,YACF,MAAM,cAAc,KACd,KAAA,IACA;EACI,WACI,MAAM,cAAc,OACd,mBAAmB,MAAM,UAAU,IACnC,KAAA;EACV,SACI,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ACL,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
|
+
{"version":3,"file":"heatmap.schemas.js","names":[],"sources":["../../../src/services/heatmap/heatmap.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { SymbolIdInputSchema } from \"../shared.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: SymbolIdInputSchema,\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":";;;;;;;AA6BA,MAAM,sBAAsB,EAAE,KAC1B,EAAE,SAAS,EAAE,SAAS,uBAAuB,GAAG,IAAI,GAC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IAAI;GACnB,eAAe,IAAI;GACnB,cAAc,IAAI;GAClB,YAAY,IAAI,aACV,yBAAyB,IAAI,YAAY,MAAM,IAC/C,KAAA;EACV;CACJ,CAAC,CACL;AACJ"}
|
|
@@ -60,7 +60,7 @@ declare function createCreateInternalTransferInputSchema(scales: SdkScales): v.S
|
|
|
60
60
|
readonly case: "destinationSmartAccountAddress";
|
|
61
61
|
readonly value: string;
|
|
62
62
|
}>]>;
|
|
63
|
-
readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
63
|
+
readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
|
|
64
64
|
readonly quantity: v.StringSchema<undefined>;
|
|
65
65
|
readonly idempotencyKey: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
66
66
|
readonly account: v.OptionalSchema<v.UnionSchema<[v.PicklistSchema<["active", "main"], undefined>, v.StrictObjectSchema<{
|
|
@@ -118,7 +118,7 @@ declare function createCreateInternalTransferResultSchema(): v.SchemaWithPipe<re
|
|
|
118
118
|
readonly requestId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
119
119
|
readonly transferId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
120
120
|
readonly acceptedAtTsNs: v.BigintSchema<undefined>;
|
|
121
|
-
readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
|
|
121
|
+
readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
|
|
122
122
|
readonly assetCode: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
123
123
|
readonly uAssetId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
124
124
|
readonly amountE18: v.ObjectSchema<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal-transfers.schemas.d.ts","names":[],"sources":["../../../src/services/internal-transfers/internal-transfers.schemas.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"internal-transfers.schemas.d.ts","names":[],"sources":["../../../src/services/internal-transfers/internal-transfers.schemas.ts"],"mappings":";;;;cA0Ba,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,5 +1,6 @@
|
|
|
1
1
|
import { tsNsToMs } from "../../utils/time.js";
|
|
2
2
|
import { idInputSchema } from "../../shared/schemas.js";
|
|
3
|
+
import { PositiveUint32InputSchema } from "../shared.js";
|
|
3
4
|
import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
|
|
4
5
|
import { quantityInputToE18, scaledToDecimalOutput } from "../../shared/decimal-surface.js";
|
|
5
6
|
import { fromU128, toU128 } from "../../utils/u128.js";
|
|
@@ -44,7 +45,7 @@ function createCreateInternalTransferInputSchema(scales) {
|
|
|
44
45
|
return v.pipe(v.strictObject({
|
|
45
46
|
...AccountScopeInputEntries,
|
|
46
47
|
destination: InternalTransferDestinationInputSchema,
|
|
47
|
-
assetId:
|
|
48
|
+
assetId: PositiveUint32InputSchema,
|
|
48
49
|
quantity: v.string(),
|
|
49
50
|
idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1))
|
|
50
51
|
}), v.transform(({ account, quantity, ...input }) => ({
|
|
@@ -73,7 +74,7 @@ function createCreateInternalTransferResultSchema() {
|
|
|
73
74
|
requestId: NonEmptyResponseStringSchema,
|
|
74
75
|
transferId: NonEmptyResponseStringSchema,
|
|
75
76
|
acceptedAtTsNs: v.bigint(),
|
|
76
|
-
assetId:
|
|
77
|
+
assetId: PositiveUint32InputSchema,
|
|
77
78
|
assetCode: NonEmptyResponseStringSchema,
|
|
78
79
|
uAssetId: NonEmptyResponseStringSchema,
|
|
79
80
|
amountE18: U128Schema,
|