@polyester/sdk 0.36.0-devnet-20261116002603 → 0.36.0-devnet-20261116010019
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 +5 -1
- package/dist/browser-core.js +1 -1
- package/dist/gen/ai/v1/assistant_pb.d.ts +1 -1
- package/dist/gen/ai/v1/assistant_pb.js +1 -1
- package/dist/gen/alerts/v1/price_alerts_pb.d.ts +1 -1
- package/dist/gen/auth/v1/address_book_pb.d.ts +1 -1
- package/dist/gen/auth/v1/api_keys_pb.d.ts +1 -1
- package/dist/gen/auth/v1/auth_pb.d.ts +1 -1
- package/dist/gen/auth/v1/mfa_pb.d.ts +1 -1
- package/dist/gen/auth/v1/policies_pb.d.ts +1 -1
- package/dist/gen/auth/v1/profile_pb.d.ts +1 -1
- package/dist/gen/auth/v1/resolve_pb.d.ts +1 -1
- package/dist/gen/auth/v1/social_verification_pb.d.ts +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.d.ts +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.js +1 -1
- package/dist/gen/chain/analytics/v1/analytics_read_pb.d.ts +1 -1
- package/dist/gen/chain/deposit/v1/deposit_pb.d.ts +1 -1
- package/dist/gen/chain/guard/v1/guard_signer_pb.d.ts +1 -1
- package/dist/gen/chain/lifecycle/v1/lifecycle_read_pb.d.ts +1 -1
- package/dist/gen/chain/lifecycle/v1/types_pb.d.ts +1 -1
- package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.d.ts +1 -1
- package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts +1 -1
- package/dist/gen/chain/zipper/v1/reason_pb.d.ts +1 -1
- package/dist/gen/chain/zipper/v1/zipper_pb.d.ts +1 -1
- package/dist/gen/changelog/v1/changelog_pb.d.ts +1 -1
- package/dist/gen/checkpoints/v1/checkpoints_pb.d.ts +1 -1
- package/dist/gen/claims/v1/claims_pb.d.ts +1 -1
- package/dist/gen/fees/v1/fees_pb.d.ts +1 -1
- package/dist/gen/index.js +21 -21
- package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts +1 -1
- package/dist/gen/ledger/read/v1/statement_export_pb.d.ts +1 -1
- package/dist/gen/marketdata/v1/asset_info_pb.d.ts +1 -1
- package/dist/gen/marketdata/v1/heatmap_pb.d.ts +1 -1
- package/dist/gen/marketdata/v1/marketdata_pb.d.ts +1 -1
- package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts +1 -1
- package/dist/gen/notifications/v1/notifications_pb.d.ts +1 -1
- package/dist/gen/orderbook/v1/orderbook_pb.d.ts +1 -1
- package/dist/gen/orders/v1/orders_pb.d.ts +1 -1
- package/dist/gen/orders/v1/orders_read_pb.d.ts +1 -1
- package/dist/gen/polyester/ratelimit/v1/types_pb.d.ts +1 -1
- package/dist/gen/polyester/type/v1/u128_pb.d.ts +1 -1
- package/dist/gen/privatews/v1/private_ws_pb.d.ts +1 -1
- package/dist/gen/ratelimit/v1/ratelimit_pb.d.ts +1 -1
- package/dist/gen/rewards/v1/rewards_pb.d.ts +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_referral_pb.d.ts +1 -1
- package/dist/gen/swap/v1/swap_pb.d.ts +1 -1
- package/dist/gen/system/v1/system_pb.d.ts +1 -1
- package/dist/gen/tradews/v1/trade_ws_pb.d.ts +1 -1
- package/dist/gen/transfer/v1/dust_conversion_pb.d.ts +1 -1
- package/dist/gen/transfer/v1/internal_transfer_pb.d.ts +1 -1
- package/dist/gen/triggers/v1/triggers_pb.d.ts +1 -1
- package/dist/gen/vip/v1/vip_pb.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/realtime/snapshot-then-stream.js +1 -1
- package/dist/server-core.js +3 -3
- package/dist/services/accounts/accounts.js +1 -1
- package/dist/services/accounts/accounts.schemas.js +1 -1
- package/dist/services/address-book/address-book.js +1 -1
- package/dist/services/address-book/address-book.schemas.d.ts +2 -2
- package/dist/services/api-keys/api-keys.js +1 -1
- package/dist/services/api-keys/api-keys.schemas.js +1 -1
- package/dist/services/assistant/assistant-events.schemas.d.ts +70 -70
- package/dist/services/assistant/assistant.js +1 -1
- package/dist/services/assistant/assistant.schemas.js +1 -1
- package/dist/services/auth/account-signer-auth.js +2 -2
- package/dist/services/auth/auth.js +1 -1
- package/dist/services/auth/profile/profile.js +2 -2
- package/dist/services/auto-withdraw/auto-withdraw.js +1 -1
- package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts +22 -22
- package/dist/services/auto-withdraw/auto-withdraw.schemas.js +2 -2
- package/dist/services/balances/balances.js +1 -1
- package/dist/services/balances/balances.schemas.js +1 -1
- package/dist/services/candles/candles.js +2 -2
- package/dist/services/candles/candles.schemas.d.ts +10 -10
- package/dist/services/chain-analytics/chain-analytics.js +1 -1
- package/dist/services/changelog/changelog.js +1 -1
- package/dist/services/changelog/changelog.schemas.d.ts +22 -22
- package/dist/services/checkpoints/checkpoints.js +1 -1
- package/dist/services/checkpoints/checkpoints.schemas.d.ts +2 -2
- package/dist/services/claims/claims.js +1 -1
- package/dist/services/claims/claims.schemas.d.ts +2 -2
- package/dist/services/claims/claims.schemas.js +2 -2
- package/dist/services/deposit/deposit.js +1 -1
- package/dist/services/dust-conversion/dust-conversion.js +1 -1
- package/dist/services/dust-conversion/dust-conversion.schemas.d.ts +2 -2
- package/dist/services/dust-conversion/dust-conversion.schemas.js +2 -2
- package/dist/services/fees/fees.js +1 -1
- package/dist/services/guard-signer/guard-signer.js +1 -1
- package/dist/services/guard-signer/guard-signer.schemas.js +1 -1
- package/dist/services/heatmap/heatmap.js +2 -2
- package/dist/services/heatmap/heatmap.schemas.d.ts +3 -3
- package/dist/services/internal-transfers/internal-transfers.js +1 -1
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +9 -9
- package/dist/services/internal-transfers/internal-transfers.schemas.js +1 -1
- package/dist/services/lifecycle/lifecycle.js +3 -3
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +54 -54
- package/dist/services/lifecycle/lifecycle.schemas.js +3 -3
- package/dist/services/market-data/market-data.js +3 -3
- package/dist/services/market-overview/market-overview.js +2 -2
- package/dist/services/market-overview/market-overview.schemas.js +1 -1
- package/dist/services/notifications/notifications.js +1 -1
- package/dist/services/orderbook/orderbook.js +1 -1
- package/dist/services/orders/order-errors.schemas.d.ts +2 -2
- package/dist/services/orders/order-errors.schemas.js +1 -1
- package/dist/services/orders/orders-batch.schemas.d.ts +47 -47
- package/dist/services/orders/orders-batch.schemas.js +2 -2
- package/dist/services/orders/orders-input.schemas.d.ts +6 -6
- package/dist/services/orders/orders-input.schemas.js +2 -2
- package/dist/services/orders/orders-modify.schemas.js +2 -2
- package/dist/services/orders/orders-output.schemas.d.ts +17 -17
- package/dist/services/orders/orders-output.schemas.js +1 -1
- package/dist/services/orders/orders-risk.schemas.js +3 -3
- package/dist/services/orders/orders.js +2 -2
- package/dist/services/policies/api-key-policies/api-key-policies.js +1 -1
- package/dist/services/policies/shared.codecs.js +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.js +2 -2
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts +2 -2
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js +2 -3
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js.map +1 -1
- package/dist/services/price-alerts/price-alerts.js +1 -1
- package/dist/services/rate-limits/rate-limits.js +1 -1
- package/dist/services/rewards/rewards.js +1 -1
- package/dist/services/rewards/rewards.schemas.d.ts +4 -4
- package/dist/services/social-verification/social-verification.js +1 -1
- package/dist/services/social-verification/social-verification.schemas.js +1 -1
- package/dist/services/statement-exports/statement-exports.js +1 -1
- package/dist/services/statement-exports/statement-exports.schemas.d.ts +12 -12
- package/dist/services/subaccounts/subaccounts.js +3 -3
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +15 -15
- package/dist/services/system/system.js +1 -1
- package/dist/services/system/system.schemas.d.ts +7 -7
- package/dist/services/trades/trades.js +2 -2
- package/dist/services/trades/trades.schemas.d.ts +2 -2
- package/dist/services/trades/trades.schemas.js +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.js +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.schemas.js +2 -2
- package/dist/services/trading-withdraws/wallet-message.js +1 -1
- package/dist/services/transfers/transfers.js +2 -2
- package/dist/services/transfers/transfers.schemas.js +1 -1
- package/dist/services/triggers/trigger-child-order.schemas.js +3 -3
- package/dist/services/triggers/trigger-input.schemas.d.ts +1 -1
- package/dist/services/triggers/trigger-input.schemas.js +2 -2
- package/dist/services/triggers/triggers-output.schemas.d.ts +40 -40
- package/dist/services/triggers/triggers.js +2 -2
- package/dist/services/vip/vip.js +1 -1
- package/dist/services/vip/vip.schemas.js +1 -1
- package/dist/services/zipper/zipper.js +1 -1
- package/dist/services/zipper/zipper.schemas.js +1 -1
- package/dist/shared/decimal-surface.d.ts.map +1 -1
- package/dist/shared/decimal-surface.js +4 -1
- package/dist/shared/decimal-surface.js.map +1 -1
- package/dist/shared/error-details/alerts.js +1 -1
- package/dist/shared/error-details/assistant.js +1 -1
- package/dist/shared/error-details/auth.js +1 -1
- package/dist/shared/error-details/claims.js +1 -1
- package/dist/shared/error-details/internal-transfer.js +1 -1
- package/dist/shared/error-details/ledger.js +1 -1
- package/dist/shared/error-details/market-overview.js +1 -1
- package/dist/shared/error-details/notifications.js +1 -1
- package/dist/shared/error-details/orders.js +1 -1
- package/dist/shared/error-details/profile.js +1 -1
- package/dist/shared/error-details/rate-limit.js +1 -1
- package/dist/shared/error-details/withdraw.js +2 -2
- package/dist/shared/rate-limit.schemas.js +1 -1
- package/dist/shared/schemas.js +2 -2
- package/dist/shared/schemas.js.map +1 -1
- package/dist/utils/cookies.js +1 -1
- package/dist/utils/numbers.js +1 -10
- package/dist/utils/numbers.js.map +1 -1
- package/dist/utils/u128.js +1 -1
- package/dist/utils/u128.js.map +1 -1
- package/dist/wired-services.js +18 -18
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { enumLabel } from "../../shared/proto-enum-codec.js";
|
|
2
1
|
import "../../gen/auth/v1/policies_pb.js";
|
|
2
|
+
import { enumLabel } from "../../shared/proto-enum-codec.js";
|
|
3
3
|
//#region src/services/policies/shared.codecs.ts
|
|
4
4
|
/** Product actions, accepted by sub-account and API-key policies. */
|
|
5
5
|
const PRODUCT_POLICY_ACTION_LABELS = [
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
+
import { PolicyService, SubaccountPolicyViewSchema } from "../../../gen/auth/v1/policies_pb.js";
|
|
1
2
|
import { parse } from "../../../shared/validation.js";
|
|
2
3
|
import { removeUndefined } from "../../../utils/remove-undefined.js";
|
|
3
4
|
import { toConnectCallOptions } from "../../../shared/request-options.js";
|
|
4
|
-
import { PolicyService, SubaccountPolicyViewSchema } from "../../../gen/auth/v1/policies_pb.js";
|
|
5
5
|
import { resolveAccountScopedInput } from "../../subaccount-resolver.js";
|
|
6
6
|
import { ApplySubaccountPolicyInputSchema, CreateSubaccountPolicyInputSchema, GetSubaccountPolicyInputSchema, ListSubaccountPoliciesInputSchema, PolicyIdSchema, SubaccountPolicySchema, UpdateSubaccountPolicyInputSchema } from "./subaccount-policies.schemas.js";
|
|
7
|
-
import { createClient } from "@connectrpc/connect";
|
|
8
7
|
import * as v from "valibot";
|
|
8
|
+
import { createClient } from "@connectrpc/connect";
|
|
9
9
|
//#region src/services/policies/subaccount-policies/subaccount-policies.ts
|
|
10
10
|
/**
|
|
11
11
|
* Manages reusable subaccount policy templates, assignments, and realtime policy updates.
|
|
@@ -126,7 +126,7 @@ declare const CreateSubaccountPolicyInputSchema: v.SchemaWithPipe<readonly [v.St
|
|
|
126
126
|
readonly spotMarketScope: v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["all", "allowlist"], undefined>, v.TransformAction<"all" | "allowlist", MarketScope_Value.ALL | MarketScope_Value.ALLOWLIST>]>;
|
|
127
127
|
readonly actions: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["trade-spot", "internal-transfer", "external-withdraw", "read-balances", "read-spot", "read-internal-transfers", "read-address-book", "manage-address-book", "read-auto-withdraw", "manage-auto-withdraw", "swap"], undefined>, undefined>, readonly []>, v.TransformAction<("swap" | "trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book" | "read-auto-withdraw" | "manage-auto-withdraw")[], (PolicyAction.TRADE_SPOT | PolicyAction.INTERNAL_TRANSFER | PolicyAction.EXTERNAL_WITHDRAW | PolicyAction.READ_BALANCES | PolicyAction.READ_SPOT | PolicyAction.READ_INTERNAL_TRANSFERS | PolicyAction.READ_ADDRESS_BOOK | PolicyAction.MANAGE_ADDRESS_BOOK | PolicyAction.READ_AUTO_WITHDRAW | PolicyAction.MANAGE_AUTO_WITHDRAW | PolicyAction.SWAP)[]>]>;
|
|
128
128
|
readonly maxOrderSize: v.SchemaWithPipe<readonly [v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, bigint>]>, undefined>, null>, v.TransformAction<bigint | null, bigint>]>;
|
|
129
|
-
readonly maxOpenOrders: v.SchemaWithPipe<readonly [v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>, null>, v.TransformAction<number | null, number>]>;
|
|
129
|
+
readonly maxOpenOrders: v.SchemaWithPipe<readonly [v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>, null>, v.TransformAction<number | null, number>]>;
|
|
130
130
|
readonly tradingHalted: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
131
131
|
readonly policyLocked: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
132
132
|
readonly reviewAt: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>, undefined>;
|
|
@@ -177,7 +177,7 @@ declare const UpdateSubaccountPolicyInputSchema: v.SchemaWithPipe<readonly [v.St
|
|
|
177
177
|
readonly spotMarketScope: v.OptionalSchema<v.PicklistSchema<readonly ["all", "allowlist"], undefined>, undefined>;
|
|
178
178
|
readonly actions: v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["trade-spot", "internal-transfer", "external-withdraw", "read-balances", "read-spot", "read-internal-transfers", "read-address-book", "manage-address-book", "read-auto-withdraw", "manage-auto-withdraw", "swap"], undefined>, undefined>, undefined>;
|
|
179
179
|
readonly maxOrderSize: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TransformAction<string, bigint>]>, undefined>, undefined>;
|
|
180
|
-
readonly maxOpenOrders: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>, undefined>;
|
|
180
|
+
readonly maxOpenOrders: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>, undefined>;
|
|
181
181
|
readonly tradingHalted: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
182
182
|
readonly policyLocked: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
183
183
|
readonly reviewAt: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, undefined>, undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccount-policies.schemas.d.ts","names":[],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.schemas.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"subaccount-policies.schemas.d.ts","names":[],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.schemas.ts"],"mappings":";;;;cAyCa,mCAAiC,EAAA,yBAAA,EAAA;;;;;;;;;;;cASjC,gCAA8B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;cAgB9B,wBAAsB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqCvB,mBAAmB,EAAE,mBAAmB;cA+DvC,mCAAiC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAOlC,8BAA8B,EAAE,kBAAkB;cA+DjD,mCAAiC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2BlC,8BAA8B,EAAE,kBAAkB;cASjD,kCAAgC,EAAA;;;;KAQjC,6BAA6B,EAAE,kBAAkB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { idToBigInt } from "../../../utils/base58-id.js";
|
|
2
2
|
import { PROTOBUF_UINT32_MAX } from "../../../shared/wire-bounds.js";
|
|
3
|
-
import { toIntOrZero } from "../../../utils/numbers.js";
|
|
4
3
|
import { tsObjToMs, tsObjToNsString } from "../../../utils/time.js";
|
|
5
4
|
import { BigIntStringSchema, OptionalNumberToIntOrZeroSchema, OptionalPublicIdSchema, OptionalTimestampMsSchema, PublicIdSchema, TimestampMsSchema, TimestampSchema, idInputSchema, optionalSubaccountIdInputSchema, positiveBigintStringInputSchema } from "../../../shared/schemas.js";
|
|
6
5
|
import { decimalInputToScaled, scaledToDecimalOutput } from "../../../shared/decimal-surface.js";
|
|
@@ -92,7 +91,7 @@ const SubaccountPolicyPatchSchema = v.strictObject({
|
|
|
92
91
|
spotMarketScope: v.optional(PolicyMarketScopeEnumSchema),
|
|
93
92
|
actions: v.optional(v.array(SubaccountPolicyActionEnumSchema)),
|
|
94
93
|
maxOrderSize: v.optional(v.nullable(MaxOrderSizeInputSchema)),
|
|
95
|
-
maxOpenOrders: v.optional(v.nullable(v.pipe(v.number(), v.maxValue(PROTOBUF_UINT32_MAX)))),
|
|
94
|
+
maxOpenOrders: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(PROTOBUF_UINT32_MAX)))),
|
|
96
95
|
tradingHalted: v.optional(v.boolean()),
|
|
97
96
|
policyLocked: v.optional(v.boolean()),
|
|
98
97
|
reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),
|
|
@@ -125,7 +124,7 @@ const SUBACCOUNT_POLICY_PATCH_FIELDS = defineProtoPatchFields()({
|
|
|
125
124
|
},
|
|
126
125
|
maxOpenOrders: {
|
|
127
126
|
path: "max_open_orders",
|
|
128
|
-
encode: (value) => ({ maxOpenOrders:
|
|
127
|
+
encode: (value) => ({ maxOpenOrders: value ?? 0 })
|
|
129
128
|
},
|
|
130
129
|
tradingHalted: {
|
|
131
130
|
path: "trading_halted",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccount-policies.schemas.js","names":[],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport {\n PolicyMarketScopeEnumSchema,\n ProtoPolicyActionEnumSchema,\n ProtoPolicyMarketScopeEnumSchema,\n SpotMarketRuleSchema,\n SubaccountPolicyActionEnumSchema,\n} from \"../shared.js\";\nimport {\n PolicyMarketScopeCodec,\n PolicyActionCodec,\n policyMarketScopeLabelFor,\n policyActionLabelFor,\n} from \"../shared.codecs.js\";\nimport { idToBigInt } from \"../../../utils/base58-id.js\";\nimport {\n OptionalNumberToIntOrZeroSchema,\n OptionalPublicIdSchema,\n OptionalTimestampMsSchema,\n BigIntStringSchema,\n PublicIdSchema,\n TimestampSchema,\n TimestampMsSchema,\n idInputSchema,\n optionalSubaccountIdInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../../shared/schemas.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../../utils/time.js\";\nimport { msToTimestamp } from \"../../../utils/timestamp.js\";\nimport { toIntOrZero } from \"../../../utils/numbers.js\";\nimport {\n QUOTE_NOTIONAL_SCALE,\n decimalInputToScaled,\n scaledToDecimalOutput,\n} from \"../../../shared/decimal-surface.js\";\nimport { PROTOBUF_UINT32_MAX } from \"../../../shared/wire-bounds.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../../shared/account-scope.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../../utils/proto-patch.js\";\n\nexport const ListSubaccountPoliciesInputSchema = v.pipe(\n v.strictObject(AccountScopeInputEntries),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type ListSubaccountPoliciesInput = v.InferInput<typeof ListSubaccountPoliciesInputSchema>;\n\nexport const GetSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n policyId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n ...AccountScopeInputEntries,\n }),\n v.transform(({ policyId, account }) => ({\n policyId: idToBigInt(policyId, \"policyId\"),\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type GetSubaccountPolicyInput = v.InferInput<typeof GetSubaccountPolicyInputSchema>;\n\n/**\n * From the backend format to a usable frontend/UI format, so big ints to numbers, etc.\n */\nexport const SubaccountPolicySchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n name: v.string(),\n description: v.string(),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n ProtoPolicyMarketScopeEnumSchema,\n v.transform((v) => policyMarketScopeLabelFor(v)),\n ),\n actions: v.pipe(\n v.optional(v.array(ProtoPolicyActionEnumSchema), []),\n v.transform((v) => v.map((action) => policyActionLabelFor(action))),\n ),\n isTemplate: v.optional(v.boolean(), false),\n sourceTemplateId: OptionalPublicIdSchema,\n maxOrderNotional: v.pipe(\n v.bigint(),\n v.transform((value) => scaledToDecimalOutput(value, QUOTE_NOTIONAL_SCALE)),\n ),\n maxOpenOrders: v.number(),\n tradingHalted: v.boolean(),\n locked: v.boolean(),\n reviewAt: OptionalTimestampMsSchema,\n expiresAt: OptionalTimestampMsSchema,\n createdAt: TimestampMsSchema,\n updatedAt: TimestampSchema,\n revision: BigIntStringSchema,\n }),\n v.transform(({ maxOrderNotional, updatedAt, ...rest }) => ({\n maxOrderSize: maxOrderNotional,\n ...rest,\n updatedAt: tsObjToMs(updatedAt),\n updatedAtNs: tsObjToNsString(updatedAt),\n })),\n);\n\nexport type SubaccountPolicy = v.InferOutput<typeof SubaccountPolicySchema>;\n\n/**\n * Max spot order notional as a decimal USDT string (e.g. `\"100000.5\"`). The wire\n * field is canonical quote microunits, so `\"100000\"` caps orders at 100,000 USDT.\n * `\"0\"` means no cap.\n */\nconst MaxOrderSizeInputSchema = v.pipe(\n v.string(),\n v.transform((value) => decimalInputToScaled(\"maxOrderSize\", value, QUOTE_NOTIONAL_SCALE)),\n);\n\nconst OptionalMaxOrderSizeInputSchema = v.pipe(\n v.optional(v.nullable(MaxOrderSizeInputSchema), null),\n v.transform((value) => value ?? 0n),\n);\n\nconst SubaccountPolicyInputBaseSchema = v.strictObject({\n name: v.string(),\n description: v.optional(v.string(), \"\"),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n PolicyMarketScopeEnumSchema,\n v.transform((v) => PolicyMarketScopeCodec.inputToProto[v]),\n ),\n actions: v.pipe(\n v.optional(v.array(SubaccountPolicyActionEnumSchema), []),\n v.transform((v) => (v ?? []).map((action) => PolicyActionCodec.inputToProto[action])),\n ),\n maxOrderSize: OptionalMaxOrderSizeInputSchema,\n maxOpenOrders: OptionalNumberToIntOrZeroSchema,\n tradingHalted: v.optional(v.boolean(), false),\n policyLocked: v.optional(v.boolean(), false),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n subaccountId: optionalSubaccountIdInputSchema(),\n});\n\nfunction timestampFromMs(value: number | null | undefined) {\n if (value == null) return undefined;\n return msToTimestamp(value);\n}\n\nfunction createSubaccountPolicyBaseTransform(\n input: v.InferOutput<typeof SubaccountPolicyInputBaseSchema>,\n) {\n const {\n subaccountId: _subaccountId,\n reviewAt,\n expiresAt,\n maxOrderSize,\n policyLocked,\n ...rest\n } = input;\n return {\n ...rest,\n maxOrderNotional: maxOrderSize,\n locked: policyLocked,\n reviewAt: timestampFromMs(reviewAt),\n expiresAt: timestampFromMs(expiresAt),\n };\n}\n\nexport const CreateSubaccountPolicyInputSchema = v.pipe(\n SubaccountPolicyInputBaseSchema,\n v.transform((input) => ({\n policy: createSubaccountPolicyBaseTransform(input),\n subaccountId: input.subaccountId,\n })),\n);\nexport type SubaccountPolicyCreateInput = v.InferInput<typeof CreateSubaccountPolicyInputSchema>;\n\nconst SubaccountPolicyPatchSchema = v.strictObject({\n name: v.optional(v.string()),\n description: v.optional(v.string()),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema)),\n spotMarketScope: v.optional(PolicyMarketScopeEnumSchema),\n actions: v.optional(v.array(SubaccountPolicyActionEnumSchema)),\n maxOrderSize: v.optional(v.nullable(MaxOrderSizeInputSchema)),\n maxOpenOrders: v.optional(v.nullable(v.pipe(v.number(), v.maxValue(PROTOBUF_UINT32_MAX)))),\n tradingHalted: v.optional(v.boolean()),\n policyLocked: v.optional(v.boolean()),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n});\n\ntype SubaccountPolicyPatch = v.InferOutput<typeof SubaccountPolicyPatchSchema>;\n\nconst SUBACCOUNT_POLICY_PATCH_FIELDS = defineProtoPatchFields<SubaccountPolicyPatch>()({\n name: { path: \"name\", encode: (name) => ({ name }) },\n description: { path: \"description\", encode: (description) => ({ description }) },\n spotMarkets: { path: \"spot_markets\", encode: (spotMarkets) => ({ spotMarkets }) },\n spotMarketScope: {\n path: \"spot_market_scope\",\n encode: (scope) => ({ spotMarketScope: PolicyMarketScopeCodec.inputToProto[scope] }),\n },\n actions: {\n path: \"actions\",\n encode: (actions) => ({\n actions: actions.map((action) => PolicyActionCodec.inputToProto[action]),\n }),\n },\n maxOrderSize: {\n path: \"max_order_notional\",\n encode: (value) => ({ maxOrderNotional: value ?? 0n }),\n },\n maxOpenOrders: {\n path: \"max_open_orders\",\n encode: (value) => ({ maxOpenOrders: toIntOrZero(value) }),\n },\n tradingHalted: {\n path: \"trading_halted\",\n encode: (tradingHalted) => ({ tradingHalted }),\n },\n policyLocked: { path: \"locked\", encode: (locked) => ({ locked }) },\n reviewAt: {\n path: \"review_at\",\n encode: (reviewAt) => {\n const timestamp = timestampFromMs(reviewAt);\n return timestamp === undefined ? {} : { reviewAt: timestamp };\n },\n },\n expiresAt: {\n path: \"expires_at\",\n encode: (expiresAt) => {\n const timestamp = timestampFromMs(expiresAt);\n return timestamp === undefined ? {} : { expiresAt: timestamp };\n },\n },\n});\n\nexport const UpdateSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n ...SubaccountPolicyPatchSchema.entries,\n policyId: v.pipe(\n v.string(),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n ),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n }),\n v.check(\n ({ policyId: _policyId, expectedRevision: _expectedRevision, ...patch }) =>\n Object.values(patch).some((value) => value !== undefined),\n \"At least one subaccount policy field must be provided\",\n ),\n v.transform(({ policyId, expectedRevision, ...patch }) => {\n const { patch: policy, updateMask } = buildProtoPatch(\n patch,\n SUBACCOUNT_POLICY_PATCH_FIELDS,\n );\n return {\n policyId,\n policy,\n updateMask,\n expectedRevision,\n };\n }),\n);\nexport type SubaccountPolicyUpdateInput = v.InferInput<typeof UpdateSubaccountPolicyInputSchema>;\n\nexport const PolicyIdSchema = v.pipe(\n v.string(),\n v.trim(),\n v.minLength(1),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n);\n\nexport const ApplySubaccountPolicyInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n policyId: v.pipe(\n v.nullable(v.pipe(v.string(), v.trim())),\n v.transform((value) => (value ? idToBigInt(value, \"policyId\") : undefined)),\n ),\n});\n\nexport type SubaccountPolicyApplyInput = v.InferInput<typeof ApplySubaccountPolicyInputSchema>;\n\nconst DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT = Date.now();\n\nexport const DEFAULT_SUBACCOUNT_POLICY: SubaccountPolicy = {\n id: \"\",\n name: \"Subaccount Policy\",\n description: \"Subaccount Policy description\",\n spotMarkets: [],\n spotMarketScope: \"all\",\n actions: [\"read-balances\", \"read-internal-transfers\", \"read-address-book\", \"read-spot\"],\n maxOrderSize: \"0\",\n maxOpenOrders: 0,\n tradingHalted: false,\n createdAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,\n updatedAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,\n updatedAtNs: (BigInt(DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT) * 1_000_000n).toString(),\n isTemplate: false,\n sourceTemplateId: undefined,\n locked: false,\n reviewAt: undefined,\n expiresAt: undefined,\n revision: \"0\",\n};\n"],"mappings":";;;;;;;;;;;;;AA0CA,MAAa,oCAAoC,EAAE,KAC/C,EAAE,aAAa,wBAAwB,GACvC,EAAE,WAAW,EAAE,eAAe,EAC1B,cAAc,2BAA2B,OAAO,EACpD,EAA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a,mCAAmC,EAAE,aAAa;CAC3D,cAAc,cAAc,cAAc;CAC1C,UAAU,EAAE,KACR,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,CAAC,GACvC,EAAE,WAAW,UAAW,QAAQ,WAAW,OAAO,UAAU,IAAI,KAAA,CAAU,CAC9E;AACJ,CAAC;AAID,MAAM,uCAAuC,KAAK,IAAI;AAEtD,MAAa,4BAA8C;CACvD,IAAI;CACJ,MAAM;CACN,aAAa;CACb,aAAa,CAAC;CACd,iBAAiB;CACjB,SAAS;EAAC;EAAiB;EAA2B;EAAqB;CAAW;CACtF,cAAc;CACd,eAAe;CACf,eAAe;CACf,WAAW;CACX,WAAW;CACX,cAAc,OAAO,oCAAoC,IAAI,SAAA,CAAY,SAAS;CAClF,YAAY;CACZ,kBAAkB,KAAA;CAClB,QAAQ;CACR,UAAU,KAAA;CACV,WAAW,KAAA;CACX,UAAU;AACd"}
|
|
1
|
+
{"version":3,"file":"subaccount-policies.schemas.js","names":[],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport {\n PolicyMarketScopeEnumSchema,\n ProtoPolicyActionEnumSchema,\n ProtoPolicyMarketScopeEnumSchema,\n SpotMarketRuleSchema,\n SubaccountPolicyActionEnumSchema,\n} from \"../shared.js\";\nimport {\n PolicyMarketScopeCodec,\n PolicyActionCodec,\n policyMarketScopeLabelFor,\n policyActionLabelFor,\n} from \"../shared.codecs.js\";\nimport { idToBigInt } from \"../../../utils/base58-id.js\";\nimport {\n OptionalNumberToIntOrZeroSchema,\n OptionalPublicIdSchema,\n OptionalTimestampMsSchema,\n BigIntStringSchema,\n PublicIdSchema,\n TimestampSchema,\n TimestampMsSchema,\n idInputSchema,\n optionalSubaccountIdInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../../shared/schemas.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../../utils/time.js\";\nimport { msToTimestamp } from \"../../../utils/timestamp.js\";\nimport {\n QUOTE_NOTIONAL_SCALE,\n decimalInputToScaled,\n scaledToDecimalOutput,\n} from \"../../../shared/decimal-surface.js\";\nimport { PROTOBUF_UINT32_MAX } from \"../../../shared/wire-bounds.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../../shared/account-scope.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../../utils/proto-patch.js\";\n\nexport const ListSubaccountPoliciesInputSchema = v.pipe(\n v.strictObject(AccountScopeInputEntries),\n v.transform(({ account }) => ({\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type ListSubaccountPoliciesInput = v.InferInput<typeof ListSubaccountPoliciesInputSchema>;\n\nexport const GetSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n policyId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n ...AccountScopeInputEntries,\n }),\n v.transform(({ policyId, account }) => ({\n policyId: idToBigInt(policyId, \"policyId\"),\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type GetSubaccountPolicyInput = v.InferInput<typeof GetSubaccountPolicyInputSchema>;\n\n/**\n * From the backend format to a usable frontend/UI format, so big ints to numbers, etc.\n */\nexport const SubaccountPolicySchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n name: v.string(),\n description: v.string(),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n ProtoPolicyMarketScopeEnumSchema,\n v.transform((v) => policyMarketScopeLabelFor(v)),\n ),\n actions: v.pipe(\n v.optional(v.array(ProtoPolicyActionEnumSchema), []),\n v.transform((v) => v.map((action) => policyActionLabelFor(action))),\n ),\n isTemplate: v.optional(v.boolean(), false),\n sourceTemplateId: OptionalPublicIdSchema,\n maxOrderNotional: v.pipe(\n v.bigint(),\n v.transform((value) => scaledToDecimalOutput(value, QUOTE_NOTIONAL_SCALE)),\n ),\n maxOpenOrders: v.number(),\n tradingHalted: v.boolean(),\n locked: v.boolean(),\n reviewAt: OptionalTimestampMsSchema,\n expiresAt: OptionalTimestampMsSchema,\n createdAt: TimestampMsSchema,\n updatedAt: TimestampSchema,\n revision: BigIntStringSchema,\n }),\n v.transform(({ maxOrderNotional, updatedAt, ...rest }) => ({\n maxOrderSize: maxOrderNotional,\n ...rest,\n updatedAt: tsObjToMs(updatedAt),\n updatedAtNs: tsObjToNsString(updatedAt),\n })),\n);\n\nexport type SubaccountPolicy = v.InferOutput<typeof SubaccountPolicySchema>;\n\n/**\n * Max spot order notional as a decimal USDT string (e.g. `\"100000.5\"`). The wire\n * field is canonical quote microunits, so `\"100000\"` caps orders at 100,000 USDT.\n * `\"0\"` means no cap.\n */\nconst MaxOrderSizeInputSchema = v.pipe(\n v.string(),\n v.transform((value) => decimalInputToScaled(\"maxOrderSize\", value, QUOTE_NOTIONAL_SCALE)),\n);\n\nconst OptionalMaxOrderSizeInputSchema = v.pipe(\n v.optional(v.nullable(MaxOrderSizeInputSchema), null),\n v.transform((value) => value ?? 0n),\n);\n\nconst SubaccountPolicyInputBaseSchema = v.strictObject({\n name: v.string(),\n description: v.optional(v.string(), \"\"),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema), []),\n spotMarketScope: v.pipe(\n PolicyMarketScopeEnumSchema,\n v.transform((v) => PolicyMarketScopeCodec.inputToProto[v]),\n ),\n actions: v.pipe(\n v.optional(v.array(SubaccountPolicyActionEnumSchema), []),\n v.transform((v) => (v ?? []).map((action) => PolicyActionCodec.inputToProto[action])),\n ),\n maxOrderSize: OptionalMaxOrderSizeInputSchema,\n maxOpenOrders: OptionalNumberToIntOrZeroSchema,\n tradingHalted: v.optional(v.boolean(), false),\n policyLocked: v.optional(v.boolean(), false),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n subaccountId: optionalSubaccountIdInputSchema(),\n});\n\nfunction timestampFromMs(value: number | null | undefined) {\n if (value == null) return undefined;\n return msToTimestamp(value);\n}\n\nfunction createSubaccountPolicyBaseTransform(\n input: v.InferOutput<typeof SubaccountPolicyInputBaseSchema>,\n) {\n const {\n subaccountId: _subaccountId,\n reviewAt,\n expiresAt,\n maxOrderSize,\n policyLocked,\n ...rest\n } = input;\n return {\n ...rest,\n maxOrderNotional: maxOrderSize,\n locked: policyLocked,\n reviewAt: timestampFromMs(reviewAt),\n expiresAt: timestampFromMs(expiresAt),\n };\n}\n\nexport const CreateSubaccountPolicyInputSchema = v.pipe(\n SubaccountPolicyInputBaseSchema,\n v.transform((input) => ({\n policy: createSubaccountPolicyBaseTransform(input),\n subaccountId: input.subaccountId,\n })),\n);\nexport type SubaccountPolicyCreateInput = v.InferInput<typeof CreateSubaccountPolicyInputSchema>;\n\nconst SubaccountPolicyPatchSchema = v.strictObject({\n name: v.optional(v.string()),\n description: v.optional(v.string()),\n spotMarkets: v.optional(v.array(SpotMarketRuleSchema)),\n spotMarketScope: v.optional(PolicyMarketScopeEnumSchema),\n actions: v.optional(v.array(SubaccountPolicyActionEnumSchema)),\n maxOrderSize: v.optional(v.nullable(MaxOrderSizeInputSchema)),\n maxOpenOrders: v.optional(\n v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(PROTOBUF_UINT32_MAX))),\n ),\n tradingHalted: v.optional(v.boolean()),\n policyLocked: v.optional(v.boolean()),\n reviewAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n expiresAt: v.optional(v.nullable(v.pipe(v.number(), v.integer(), v.minValue(0)))),\n});\n\ntype SubaccountPolicyPatch = v.InferOutput<typeof SubaccountPolicyPatchSchema>;\n\nconst SUBACCOUNT_POLICY_PATCH_FIELDS = defineProtoPatchFields<SubaccountPolicyPatch>()({\n name: { path: \"name\", encode: (name) => ({ name }) },\n description: { path: \"description\", encode: (description) => ({ description }) },\n spotMarkets: { path: \"spot_markets\", encode: (spotMarkets) => ({ spotMarkets }) },\n spotMarketScope: {\n path: \"spot_market_scope\",\n encode: (scope) => ({ spotMarketScope: PolicyMarketScopeCodec.inputToProto[scope] }),\n },\n actions: {\n path: \"actions\",\n encode: (actions) => ({\n actions: actions.map((action) => PolicyActionCodec.inputToProto[action]),\n }),\n },\n maxOrderSize: {\n path: \"max_order_notional\",\n encode: (value) => ({ maxOrderNotional: value ?? 0n }),\n },\n maxOpenOrders: {\n path: \"max_open_orders\",\n encode: (value) => ({ maxOpenOrders: value ?? 0 }),\n },\n tradingHalted: {\n path: \"trading_halted\",\n encode: (tradingHalted) => ({ tradingHalted }),\n },\n policyLocked: { path: \"locked\", encode: (locked) => ({ locked }) },\n reviewAt: {\n path: \"review_at\",\n encode: (reviewAt) => {\n const timestamp = timestampFromMs(reviewAt);\n return timestamp === undefined ? {} : { reviewAt: timestamp };\n },\n },\n expiresAt: {\n path: \"expires_at\",\n encode: (expiresAt) => {\n const timestamp = timestampFromMs(expiresAt);\n return timestamp === undefined ? {} : { expiresAt: timestamp };\n },\n },\n});\n\nexport const UpdateSubaccountPolicyInputSchema = v.pipe(\n v.strictObject({\n ...SubaccountPolicyPatchSchema.entries,\n policyId: v.pipe(\n v.string(),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n ),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n }),\n v.check(\n ({ policyId: _policyId, expectedRevision: _expectedRevision, ...patch }) =>\n Object.values(patch).some((value) => value !== undefined),\n \"At least one subaccount policy field must be provided\",\n ),\n v.transform(({ policyId, expectedRevision, ...patch }) => {\n const { patch: policy, updateMask } = buildProtoPatch(\n patch,\n SUBACCOUNT_POLICY_PATCH_FIELDS,\n );\n return {\n policyId,\n policy,\n updateMask,\n expectedRevision,\n };\n }),\n);\nexport type SubaccountPolicyUpdateInput = v.InferInput<typeof UpdateSubaccountPolicyInputSchema>;\n\nexport const PolicyIdSchema = v.pipe(\n v.string(),\n v.trim(),\n v.minLength(1),\n v.transform((v) => idToBigInt(v, \"policyId\")),\n);\n\nexport const ApplySubaccountPolicyInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n policyId: v.pipe(\n v.nullable(v.pipe(v.string(), v.trim())),\n v.transform((value) => (value ? idToBigInt(value, \"policyId\") : undefined)),\n ),\n});\n\nexport type SubaccountPolicyApplyInput = v.InferInput<typeof ApplySubaccountPolicyInputSchema>;\n\nconst DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT = Date.now();\n\nexport const DEFAULT_SUBACCOUNT_POLICY: SubaccountPolicy = {\n id: \"\",\n name: \"Subaccount Policy\",\n description: \"Subaccount Policy description\",\n spotMarkets: [],\n spotMarketScope: \"all\",\n actions: [\"read-balances\", \"read-internal-transfers\", \"read-address-book\", \"read-spot\"],\n maxOrderSize: \"0\",\n maxOpenOrders: 0,\n tradingHalted: false,\n createdAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,\n updatedAt: DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT,\n updatedAtNs: (BigInt(DEFAULT_SUBACCOUNT_POLICY_UPDATED_AT) * 1_000_000n).toString(),\n isTemplate: false,\n sourceTemplateId: undefined,\n locked: false,\n reviewAt: undefined,\n expiresAt: undefined,\n revision: \"0\",\n};\n"],"mappings":";;;;;;;;;;;;AAyCA,MAAa,oCAAoC,EAAE,KAC/C,EAAE,aAAa,wBAAwB,GACvC,EAAE,WAAW,EAAE,eAAe,EAC1B,cAAc,2BAA2B,OAAO,EACpD,EAAE,CACN;AAIA,MAAa,iCAAiC,EAAE,KAC5C,EAAE,aAAa;CACX,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;CACrD,GAAG;AACP,CAAC,GACD,EAAE,WAAW,EAAE,UAAU,eAAe;CACpC,UAAU,WAAW,UAAU,UAAU;CACzC,cAAc,2BAA2B,OAAO;AACpD,EAAE,CACN;;;;AAOA,MAAa,yBAAyB,EAAE,KACpC,EAAE,OAAO;CACL,IAAI;CACJ,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AAM;CACN,aAAa;CACb,aAAa,CAAC;CACd,iBAAiB;CACjB,SAAS;EAAC;EAAiB;EAA2B;EAAqB;CAAW;CACtF,cAAc;CACd,eAAe;CACf,eAAe;CACf,WAAW;CACX,WAAW;CACX,cAAc,OAAO,oCAAoC,IAAI,SAAA,CAAY,SAAS;CAClF,YAAY;CACZ,kBAAkB,KAAA;CAClB,QAAQ;CACR,UAAU,KAAA;CACV,WAAW,KAAA;CACX,UAAU;AACd"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { PriceAlertService } from "../../gen/alerts/v1/price_alerts_pb.js";
|
|
1
2
|
import { parse } from "../../shared/validation.js";
|
|
2
3
|
import { removeUndefined } from "../../utils/remove-undefined.js";
|
|
3
4
|
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
4
|
-
import { PriceAlertService } from "../../gen/alerts/v1/price_alerts_pb.js";
|
|
5
5
|
import { CancelPriceAlertInputSchema, CreatePriceAlertInputSchema, ListPriceAlertsInputSchema, ListPriceAlertsResultSchema, PriceAlertSchema, UpdatePriceAlertInputSchema, UpdatePriceAlertResultSchema } from "./price-alerts.schemas.js";
|
|
6
6
|
import { createClient } from "@connectrpc/connect";
|
|
7
7
|
//#region src/services/price-alerts/price-alerts.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { RateLimitService as RateLimitService$1 } from "../../gen/ratelimit/v1/ratelimit_pb.js";
|
|
1
2
|
import { parse } from "../../shared/validation.js";
|
|
2
3
|
import { removeUndefined } from "../../utils/remove-undefined.js";
|
|
3
4
|
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
4
5
|
import { resolveAccountScopedInput } from "../subaccount-resolver.js";
|
|
5
|
-
import { RateLimitService as RateLimitService$1 } from "../../gen/ratelimit/v1/ratelimit_pb.js";
|
|
6
6
|
import { GetTradingRateLimitsInputSchema, RateLimitConfigSchema, TradingRateLimitsSchema } from "./rate-limits.schemas.js";
|
|
7
7
|
import { createClient } from "@connectrpc/connect";
|
|
8
8
|
//#region src/services/rate-limits/rate-limits.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { RewardCampaignService } from "../../gen/rewards/v1/rewards_pb.js";
|
|
1
2
|
import { parse } from "../../shared/validation.js";
|
|
2
3
|
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
3
|
-
import { RewardCampaignService } from "../../gen/rewards/v1/rewards_pb.js";
|
|
4
4
|
import { AcknowledgeRewardAwardInputSchema, AcknowledgeRewardAwardResultSchema, ListRewardAwardsInputSchema, ListRewardAwardsResultSchema, SetRewardDestinationInputSchema, SetRewardDestinationResultSchema } from "./rewards.schemas.js";
|
|
5
5
|
import { createClient } from "@connectrpc/connect";
|
|
6
6
|
//#region src/services/rewards/rewards.ts
|
|
@@ -29,7 +29,7 @@ declare const RewardAwardSchema: v.ObjectSchema<{
|
|
|
29
29
|
readonly assetId: v.NumberSchema<undefined>;
|
|
30
30
|
readonly amountBaseUnits: v.StringSchema<undefined>;
|
|
31
31
|
readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
|
|
32
|
-
readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "
|
|
32
|
+
readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "awaiting_destination" | "ready_for_payout" | "paid" | "canceled">]>;
|
|
33
33
|
readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
34
34
|
readonly seconds: v.BigintSchema<undefined>;
|
|
35
35
|
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
@@ -67,7 +67,7 @@ declare const ListRewardAwardsResultSchema: v.ObjectSchema<{
|
|
|
67
67
|
readonly assetId: v.NumberSchema<undefined>;
|
|
68
68
|
readonly amountBaseUnits: v.StringSchema<undefined>;
|
|
69
69
|
readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
|
|
70
|
-
readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "
|
|
70
|
+
readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "awaiting_destination" | "ready_for_payout" | "paid" | "canceled">]>;
|
|
71
71
|
readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
72
72
|
readonly seconds: v.BigintSchema<undefined>;
|
|
73
73
|
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
@@ -114,7 +114,7 @@ declare const SetRewardDestinationResultSchema: v.ObjectSchema<{
|
|
|
114
114
|
readonly assetId: v.NumberSchema<undefined>;
|
|
115
115
|
readonly amountBaseUnits: v.StringSchema<undefined>;
|
|
116
116
|
readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
|
|
117
|
-
readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "
|
|
117
|
+
readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "awaiting_destination" | "ready_for_payout" | "paid" | "canceled">]>;
|
|
118
118
|
readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
119
119
|
readonly seconds: v.BigintSchema<undefined>;
|
|
120
120
|
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
@@ -153,7 +153,7 @@ declare const AcknowledgeRewardAwardResultSchema: v.ObjectSchema<{
|
|
|
153
153
|
readonly assetId: v.NumberSchema<undefined>;
|
|
154
154
|
readonly amountBaseUnits: v.StringSchema<undefined>;
|
|
155
155
|
readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
|
|
156
|
-
readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "
|
|
156
|
+
readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "awaiting_destination" | "ready_for_payout" | "paid" | "canceled">]>;
|
|
157
157
|
readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
158
158
|
readonly seconds: v.BigintSchema<undefined>;
|
|
159
159
|
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { SocialVerificationService as SocialVerificationService$1 } from "../../gen/auth/v1/social_verification_pb.js";
|
|
1
2
|
import { parse } from "../../shared/validation.js";
|
|
2
3
|
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
3
|
-
import { SocialVerificationService as SocialVerificationService$1 } from "../../gen/auth/v1/social_verification_pb.js";
|
|
4
4
|
import { ConfirmVerificationInputSchema, GetVerificationResponseSchema, SocialProviderInputSchema, StartVerificationInputSchema, StartVerificationResponseSchema, UnlinkSocialAccountInputSchema, VerificationReadyResponseSchema } from "./social-verification.schemas.js";
|
|
5
5
|
import { createClient } from "@connectrpc/connect";
|
|
6
6
|
//#region src/services/social-verification/social-verification.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import "../../gen/auth/v1/social_verification_pb.js";
|
|
1
2
|
import { TimestampSchema } from "../../shared/schemas.js";
|
|
2
3
|
import { enumLabel } from "../../shared/proto-enum-codec.js";
|
|
3
|
-
import "../../gen/auth/v1/social_verification_pb.js";
|
|
4
4
|
import { SOCIAL_PROVIDER_VALUES, SOCIAL_VERIFICATION_ERROR_CODE_VALUES, SOCIAL_VERIFICATION_METHOD_VALUES, SOCIAL_VERIFICATION_STATUS_VALUES, SocialProviderCodec, SocialVerificationErrorCodeCodec, SocialVerificationMethodCodec, SocialVerificationStatusCodec } from "./social-verification.codecs.js";
|
|
5
5
|
import * as v from "valibot";
|
|
6
6
|
//#region src/services/social-verification/social-verification.schemas.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { StatementExportService } from "../../gen/ledger/read/v1/statement_export_pb.js";
|
|
1
2
|
import { parse } from "../../shared/validation.js";
|
|
2
3
|
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
3
4
|
import { resolveAccountScopedInput } from "../subaccount-resolver.js";
|
|
4
|
-
import { StatementExportService } from "../../gen/ledger/read/v1/statement_export_pb.js";
|
|
5
5
|
import { CreateStatementExportInputSchema, GetStatementExportInputSchema, ListStatementExportsInputSchema, ListStatementExportsResultSchema, StatementExportSchema } from "./statement-exports.schemas.js";
|
|
6
6
|
import { createClient } from "@connectrpc/connect";
|
|
7
7
|
//#region src/services/statement-exports/statement-exports.ts
|
|
@@ -87,7 +87,7 @@ declare const StatementExportSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
87
87
|
}, number>]>;
|
|
88
88
|
readonly assetId: v.NumberSchema<undefined>;
|
|
89
89
|
readonly idempotencyKey: v.StringSchema<undefined>;
|
|
90
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "ready" | "
|
|
90
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "ready" | "processing" | "failed" | "queued" | "expired">]>;
|
|
91
91
|
readonly completeThrough: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
92
92
|
readonly seconds: v.BigintSchema<undefined>;
|
|
93
93
|
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
@@ -118,7 +118,7 @@ declare const StatementExportSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
118
118
|
seconds: bigint;
|
|
119
119
|
nanos: number;
|
|
120
120
|
} | undefined, number | undefined>]>;
|
|
121
|
-
readonly failureReason: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
121
|
+
readonly failureReason: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "unavailable" | "too_large">]>;
|
|
122
122
|
}, undefined>, v.TransformAction<{
|
|
123
123
|
exportId: string;
|
|
124
124
|
subaccountId?: string | undefined;
|
|
@@ -126,14 +126,14 @@ declare const StatementExportSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
126
126
|
endTime: number;
|
|
127
127
|
assetId: number;
|
|
128
128
|
idempotencyKey: string;
|
|
129
|
-
status: "unspecified" | "ready" | "
|
|
129
|
+
status: "unspecified" | "ready" | "processing" | "failed" | "queued" | "expired";
|
|
130
130
|
completeThrough: number;
|
|
131
131
|
movements: string;
|
|
132
132
|
bytes: string;
|
|
133
133
|
createdAt: number;
|
|
134
134
|
readyAt?: number | undefined;
|
|
135
135
|
expiresAt?: number | undefined;
|
|
136
|
-
failureReason: "unspecified" | "
|
|
136
|
+
failureReason: "unspecified" | "unavailable" | "too_large";
|
|
137
137
|
}, {
|
|
138
138
|
exportId: string;
|
|
139
139
|
/** Public subaccount ID the statement covers; null for the root account. */
|
|
@@ -145,7 +145,7 @@ declare const StatementExportSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
145
145
|
/** Ledger asset ID the statement is limited to; 0 for every asset. */
|
|
146
146
|
assetId: number;
|
|
147
147
|
idempotencyKey: string;
|
|
148
|
-
status: "unspecified" | "ready" | "
|
|
148
|
+
status: "unspecified" | "ready" | "processing" | "failed" | "queued" | "expired";
|
|
149
149
|
/**
|
|
150
150
|
* End of what the file covers, exclusive: the earlier of `endTime` and when the export
|
|
151
151
|
* was created. Every movement recorded before both is in the file.
|
|
@@ -161,7 +161,7 @@ declare const StatementExportSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
161
161
|
/** When a ready file expires, 7 days after `readyAt`; null before ready. */
|
|
162
162
|
expiresAt: number | null;
|
|
163
163
|
/** Why the export failed; `unspecified` unless `status` is `failed`. */
|
|
164
|
-
failureReason: "unspecified" | "
|
|
164
|
+
failureReason: "unspecified" | "unavailable" | "too_large";
|
|
165
165
|
}>]>;
|
|
166
166
|
type StatementExport = v.InferOutput<typeof StatementExportSchema>;
|
|
167
167
|
declare const ListStatementExportsResultSchema: v.ObjectSchema<{
|
|
@@ -184,7 +184,7 @@ declare const ListStatementExportsResultSchema: v.ObjectSchema<{
|
|
|
184
184
|
}, number>]>;
|
|
185
185
|
readonly assetId: v.NumberSchema<undefined>;
|
|
186
186
|
readonly idempotencyKey: v.StringSchema<undefined>;
|
|
187
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "ready" | "
|
|
187
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "ready" | "processing" | "failed" | "queued" | "expired">]>;
|
|
188
188
|
readonly completeThrough: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
189
189
|
readonly seconds: v.BigintSchema<undefined>;
|
|
190
190
|
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
@@ -215,7 +215,7 @@ declare const ListStatementExportsResultSchema: v.ObjectSchema<{
|
|
|
215
215
|
seconds: bigint;
|
|
216
216
|
nanos: number;
|
|
217
217
|
} | undefined, number | undefined>]>;
|
|
218
|
-
readonly failureReason: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
218
|
+
readonly failureReason: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "unavailable" | "too_large">]>;
|
|
219
219
|
}, undefined>, v.TransformAction<{
|
|
220
220
|
exportId: string;
|
|
221
221
|
subaccountId?: string | undefined;
|
|
@@ -223,14 +223,14 @@ declare const ListStatementExportsResultSchema: v.ObjectSchema<{
|
|
|
223
223
|
endTime: number;
|
|
224
224
|
assetId: number;
|
|
225
225
|
idempotencyKey: string;
|
|
226
|
-
status: "unspecified" | "ready" | "
|
|
226
|
+
status: "unspecified" | "ready" | "processing" | "failed" | "queued" | "expired";
|
|
227
227
|
completeThrough: number;
|
|
228
228
|
movements: string;
|
|
229
229
|
bytes: string;
|
|
230
230
|
createdAt: number;
|
|
231
231
|
readyAt?: number | undefined;
|
|
232
232
|
expiresAt?: number | undefined;
|
|
233
|
-
failureReason: "unspecified" | "
|
|
233
|
+
failureReason: "unspecified" | "unavailable" | "too_large";
|
|
234
234
|
}, {
|
|
235
235
|
exportId: string;
|
|
236
236
|
/** Public subaccount ID the statement covers; null for the root account. */
|
|
@@ -242,7 +242,7 @@ declare const ListStatementExportsResultSchema: v.ObjectSchema<{
|
|
|
242
242
|
/** Ledger asset ID the statement is limited to; 0 for every asset. */
|
|
243
243
|
assetId: number;
|
|
244
244
|
idempotencyKey: string;
|
|
245
|
-
status: "unspecified" | "ready" | "
|
|
245
|
+
status: "unspecified" | "ready" | "processing" | "failed" | "queued" | "expired";
|
|
246
246
|
/**
|
|
247
247
|
* End of what the file covers, exclusive: the earlier of `endTime` and when the export
|
|
248
248
|
* was created. Every movement recorded before both is in the file.
|
|
@@ -258,7 +258,7 @@ declare const ListStatementExportsResultSchema: v.ObjectSchema<{
|
|
|
258
258
|
/** When a ready file expires, 7 days after `readyAt`; null before ready. */
|
|
259
259
|
expiresAt: number | null;
|
|
260
260
|
/** Why the export failed; `unspecified` unless `status` is `failed`. */
|
|
261
|
-
failureReason: "unspecified" | "
|
|
261
|
+
failureReason: "unspecified" | "unavailable" | "too_large";
|
|
262
262
|
}>]>, undefined>;
|
|
263
263
|
readonly nextPageToken: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
264
264
|
}, undefined>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { ApiKeySchema } from "../../gen/auth/v1/api_keys_pb.js";
|
|
2
|
+
import { SubaccountRoleService, SubaccountSchema, SubaccountService, SubaccountViewService } from "../../gen/auth/v1/subaccounts_pb.js";
|
|
1
3
|
import { parse } from "../../shared/validation.js";
|
|
2
4
|
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
3
5
|
import { formatId } from "../../utils/base58-id.js";
|
|
4
|
-
import { ApiKeySchema } from "../../gen/auth/v1/api_keys_pb.js";
|
|
5
|
-
import { SubaccountRoleService, SubaccountSchema, SubaccountService, SubaccountViewService } from "../../gen/auth/v1/subaccounts_pb.js";
|
|
6
6
|
import { ApiKeySchema as ApiKeySchema$1 } from "../api-keys/api-keys.schemas.js";
|
|
7
7
|
import { createLedgerBalanceSchema } from "../balances/balances.schemas.js";
|
|
8
8
|
import { DEFAULT_SUBACCOUNT_POLICY, SubaccountPolicySchema } from "../policies/subaccount-policies/subaccount-policies.schemas.js";
|
|
9
9
|
import { SubaccountPoliciesService } from "../policies/subaccount-policies/subaccount-policies.js";
|
|
10
10
|
import { CreateSubaccountChallengeInputSchema, CreateSubaccountInputSchema, CreateSubaccountResultSchema, EffectiveSubaccountPermissionsSchema, GetSubaccountInputSchema, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInputSchema, SubaccountActivityEventSchema, SubaccountActivityInputSchema, SubaccountChallengeSchema, SubaccountIdInputSchema, SubaccountInviteSchema, SubaccountMemberSchema, SubaccountMutationResultSchema, SubaccountRoleCatalogSchema, SubaccountSchema as SubaccountSchema$1, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInputSchema } from "./subaccounts.schemas.js";
|
|
11
|
-
import { createClient } from "@connectrpc/connect";
|
|
12
11
|
import * as v from "valibot";
|
|
12
|
+
import { createClient } from "@connectrpc/connect";
|
|
13
13
|
//#region src/services/subaccounts/subaccounts.ts
|
|
14
14
|
/**
|
|
15
15
|
* Reads the public role catalog and creates, manages, shares, audits, and subscribes to subaccounts visible to the authenticated caller.
|
|
@@ -13,7 +13,7 @@ declare const SubaccountPermissionDefinitionSchema: v.ObjectSchema<{
|
|
|
13
13
|
}, undefined>;
|
|
14
14
|
type SubaccountPermissionDefinition = v.InferOutput<typeof SubaccountPermissionDefinitionSchema>;
|
|
15
15
|
declare const SubaccountRoleDefinitionSchema: v.ObjectSchema<{
|
|
16
|
-
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "
|
|
16
|
+
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer" | "unspecified">]>;
|
|
17
17
|
readonly displayName: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
18
18
|
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
19
19
|
readonly assignable: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
@@ -28,7 +28,7 @@ declare const SubaccountRoleCatalogSchema: v.ObjectSchema<{
|
|
|
28
28
|
readonly policyAction: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "swap" | "trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book" | "read-auto-withdraw" | "manage-auto-withdraw" | "read-api-keys" | "read-api-policies" | "read-subaccount-policies" | "read-subaccount-permissions" | "read-vip-status" | "read-social-verification" | "read-profile" | "read-account-directory" | "read-withdraw-validation" | "read-daily-claims" | "claim-daily-reward" | "read-checkpoints" | "read-rewards" | "create-deposit-address" | "read-deposit-addresses" | "read-subaccounts" | "read-subaccount-activity" | "read-subaccount-members" | "read-subaccount-invites" | "read-guard-signer-status" | "read-price-alerts" | "manage-price-alerts" | "read-statements" | "convert-dust" | "read-funding-flows">]>;
|
|
29
29
|
}, undefined>, undefined>, readonly []>;
|
|
30
30
|
readonly roles: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
|
|
31
|
-
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "
|
|
31
|
+
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer" | "unspecified">]>;
|
|
32
32
|
readonly displayName: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
33
33
|
readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
34
34
|
readonly assignable: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
@@ -37,7 +37,7 @@ declare const SubaccountRoleCatalogSchema: v.ObjectSchema<{
|
|
|
37
37
|
}, undefined>;
|
|
38
38
|
type SubaccountRoleCatalog = v.InferOutput<typeof SubaccountRoleCatalogSchema>;
|
|
39
39
|
declare const EffectiveSubaccountPermissionsSchema: v.ObjectSchema<{
|
|
40
|
-
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "
|
|
40
|
+
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer" | "unspecified">]>;
|
|
41
41
|
readonly permissions: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "internal_transfer" | "swap" | "read_subaccount" | "update_subaccount" | "read_balances" | "read_spot" | "trade_spot" | "read_internal_transfers" | "external_withdraw" | "read_address_book" | "manage_address_book" | "read_members" | "manage_members" | "read_invites" | "manage_invites" | "read_api_keys" | "manage_api_keys" | "read_subaccount_policy" | "manage_subaccount_policy" | "read_activity" | "read_activity_security_details" | "manage_member_mfa_requirement" | "create_deposit_address" | "read_deposit_addresses" | "read_guard_signer_status" | "manage_guard_signer" | "read_auto_withdraw" | "manage_auto_withdraw" | "read_statements" | "convert_dust" | "read_funding_flows">]>, undefined>, readonly []>;
|
|
42
42
|
readonly subaccountPolicyId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
43
43
|
}, undefined>;
|
|
@@ -163,7 +163,7 @@ declare const ProtoSubaccountStatusSchema: v.SchemaWithPipe<readonly [v.NumberSc
|
|
|
163
163
|
type SubaccountStatus = v.InferOutput<typeof ProtoSubaccountStatusSchema>;
|
|
164
164
|
declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
165
165
|
readonly id: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
166
|
-
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "
|
|
166
|
+
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer" | "unspecified">]>;
|
|
167
167
|
readonly label: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
168
168
|
readonly icon: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
169
169
|
readonly color: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
@@ -189,7 +189,7 @@ declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
189
189
|
readonly removed: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
190
190
|
}, undefined>, v.TransformAction<{
|
|
191
191
|
id: string;
|
|
192
|
-
role: "
|
|
192
|
+
role: "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer" | "unspecified";
|
|
193
193
|
label: string;
|
|
194
194
|
icon: string;
|
|
195
195
|
color: string;
|
|
@@ -211,7 +211,7 @@ declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
211
211
|
updatedAt: number | undefined;
|
|
212
212
|
updatedAtNs: string | undefined;
|
|
213
213
|
id: string;
|
|
214
|
-
role: "
|
|
214
|
+
role: "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer" | "unspecified";
|
|
215
215
|
label: string;
|
|
216
216
|
icon: string;
|
|
217
217
|
color: string;
|
|
@@ -229,7 +229,7 @@ declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
229
229
|
type Subaccount = v.InferOutput<typeof SubaccountSchema>;
|
|
230
230
|
declare const SubaccountMemberSchema: v.ObjectSchema<{
|
|
231
231
|
readonly accountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
232
|
-
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "
|
|
232
|
+
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer" | "unspecified">]>;
|
|
233
233
|
readonly username: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
234
234
|
readonly smartAccountAddress: v.StringSchema<undefined>;
|
|
235
235
|
readonly avatarUrl: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
@@ -241,8 +241,8 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
241
241
|
readonly subaccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
242
242
|
readonly granteeAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
243
243
|
readonly inviterAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
244
|
-
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "
|
|
245
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
244
|
+
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer" | "unspecified">]>;
|
|
245
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "pending" | "canceled" | "accepted" | "declined">]>;
|
|
246
246
|
readonly createdAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
247
247
|
readonly seconds: v.BigintSchema<undefined>;
|
|
248
248
|
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
@@ -268,8 +268,8 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
268
268
|
subaccountId: string;
|
|
269
269
|
granteeAccountId: string;
|
|
270
270
|
inviterAccountId: string;
|
|
271
|
-
role: "
|
|
272
|
-
status: "unspecified" | "
|
|
271
|
+
role: "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer" | "unspecified";
|
|
272
|
+
status: "unspecified" | "pending" | "canceled" | "accepted" | "declined";
|
|
273
273
|
createdAt?: number | undefined;
|
|
274
274
|
respondedAt?: number | undefined;
|
|
275
275
|
granteeUsername: string;
|
|
@@ -286,8 +286,8 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
286
286
|
id: string;
|
|
287
287
|
granteeAccountId: string;
|
|
288
288
|
inviterAccountId: string;
|
|
289
|
-
role: "
|
|
290
|
-
status: "unspecified" | "
|
|
289
|
+
role: "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer" | "unspecified";
|
|
290
|
+
status: "unspecified" | "pending" | "canceled" | "accepted" | "declined";
|
|
291
291
|
createdAt?: number | undefined;
|
|
292
292
|
respondedAt?: number | undefined;
|
|
293
293
|
granteeUsername: string;
|
|
@@ -309,8 +309,8 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
|
|
|
309
309
|
seconds: bigint;
|
|
310
310
|
nanos: number;
|
|
311
311
|
} | undefined, number | undefined>]>;
|
|
312
|
-
readonly entityKind: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "subaccount" | "api_key" | "account" | "
|
|
313
|
-
readonly eventAction: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "disabled" | "
|
|
312
|
+
readonly entityKind: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "subaccount" | "api_key" | "account" | "destination" | "security" | "policy" | "session" | "member" | "invite">]>;
|
|
313
|
+
readonly eventAction: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "disabled" | "removed" | "revoked" | "enabled" | "failed" | "applied" | "created" | "updated" | "deleted" | "role_set" | "received" | "replied" | "blocked" | "hold_placed" | "hold_released" | "requested">]>;
|
|
314
314
|
readonly source: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "api" | "web" | "mobile">]>;
|
|
315
315
|
readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
316
316
|
readonly userAgent: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { SystemService as SystemService$1 } from "../../gen/system/v1/system_pb.js";
|
|
1
2
|
import { parse } from "../../shared/validation.js";
|
|
2
3
|
import { removeUndefined } from "../../utils/remove-undefined.js";
|
|
3
4
|
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
4
|
-
import { SystemService as SystemService$1 } from "../../gen/system/v1/system_pb.js";
|
|
5
5
|
import { ListStatusEventsInputSchema, ListStatusEventsResultSchema } from "./system.schemas.js";
|
|
6
6
|
import { createClient } from "@connectrpc/connect";
|
|
7
7
|
//#region src/services/system/system.ts
|
|
@@ -11,7 +11,7 @@ declare const ListStatusEventsInputSchema: v.SchemaWithPipe<readonly [v.StrictOb
|
|
|
11
11
|
/** Previous `nextPageToken`; resend the same `states` and `kinds` with it. */
|
|
12
12
|
readonly pageToken: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>;
|
|
13
13
|
}, undefined>, v.TransformAction<{
|
|
14
|
-
states?: ("
|
|
14
|
+
states?: ("completed" | "canceled" | "scheduled" | "in_progress")[] | undefined;
|
|
15
15
|
kinds?: ("maintenance" | "incident")[] | undefined;
|
|
16
16
|
limit?: number | undefined;
|
|
17
17
|
pageToken?: string | undefined;
|
|
@@ -26,7 +26,7 @@ type ListStatusEventsInput = v.InferInput<typeof ListStatusEventsInputSchema>;
|
|
|
26
26
|
declare const StatusEventSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
27
27
|
readonly id: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
28
28
|
readonly kind: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "maintenance" | "incident">]>;
|
|
29
|
-
readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
29
|
+
readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "completed" | "canceled" | "scheduled" | "in_progress">]>;
|
|
30
30
|
readonly title: v.StringSchema<undefined>;
|
|
31
31
|
readonly message: v.StringSchema<undefined>;
|
|
32
32
|
readonly startTime: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
@@ -77,7 +77,7 @@ declare const StatusEventSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
77
77
|
}, undefined>, v.TransformAction<{
|
|
78
78
|
id: string;
|
|
79
79
|
kind: "unspecified" | "maintenance" | "incident";
|
|
80
|
-
state: "unspecified" | "
|
|
80
|
+
state: "unspecified" | "completed" | "canceled" | "scheduled" | "in_progress";
|
|
81
81
|
title: string;
|
|
82
82
|
message: string;
|
|
83
83
|
startTime?: number | undefined;
|
|
@@ -98,7 +98,7 @@ declare const StatusEventSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
98
98
|
/** Stable across updates; match events across pages by it. */
|
|
99
99
|
id: string;
|
|
100
100
|
kind: "unspecified" | "maintenance" | "incident";
|
|
101
|
-
state: "unspecified" | "
|
|
101
|
+
state: "unspecified" | "completed" | "canceled" | "scheduled" | "in_progress";
|
|
102
102
|
title: string;
|
|
103
103
|
message: string;
|
|
104
104
|
startTime: number | null;
|
|
@@ -128,7 +128,7 @@ declare const ListStatusEventsResultSchema: v.ObjectSchema<{
|
|
|
128
128
|
readonly events: v.ArraySchema<v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
129
129
|
readonly id: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
130
130
|
readonly kind: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "maintenance" | "incident">]>;
|
|
131
|
-
readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
131
|
+
readonly state: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "completed" | "canceled" | "scheduled" | "in_progress">]>;
|
|
132
132
|
readonly title: v.StringSchema<undefined>;
|
|
133
133
|
readonly message: v.StringSchema<undefined>;
|
|
134
134
|
readonly startTime: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
@@ -179,7 +179,7 @@ declare const ListStatusEventsResultSchema: v.ObjectSchema<{
|
|
|
179
179
|
}, undefined>, v.TransformAction<{
|
|
180
180
|
id: string;
|
|
181
181
|
kind: "unspecified" | "maintenance" | "incident";
|
|
182
|
-
state: "unspecified" | "
|
|
182
|
+
state: "unspecified" | "completed" | "canceled" | "scheduled" | "in_progress";
|
|
183
183
|
title: string;
|
|
184
184
|
message: string;
|
|
185
185
|
startTime?: number | undefined;
|
|
@@ -200,7 +200,7 @@ declare const ListStatusEventsResultSchema: v.ObjectSchema<{
|
|
|
200
200
|
/** Stable across updates; match events across pages by it. */
|
|
201
201
|
id: string;
|
|
202
202
|
kind: "unspecified" | "maintenance" | "incident";
|
|
203
|
-
state: "unspecified" | "
|
|
203
|
+
state: "unspecified" | "completed" | "canceled" | "scheduled" | "in_progress";
|
|
204
204
|
title: string;
|
|
205
205
|
message: string;
|
|
206
206
|
startTime: number | null;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { OrdersReadService, UserTradeBatchSchema } from "../../gen/orders/v1/orders_read_pb.js";
|
|
1
2
|
import { parse } from "../../shared/validation.js";
|
|
2
3
|
import { removeUndefined } from "../../utils/remove-undefined.js";
|
|
3
4
|
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
4
5
|
import { deliverBatch } from "../../shared/subscription-errors.js";
|
|
5
6
|
import { resolveAccountScopedInput } from "../subaccount-resolver.js";
|
|
6
|
-
import { OrdersReadService, UserTradeBatchSchema } from "../../gen/orders/v1/orders_read_pb.js";
|
|
7
7
|
import { GetUserTradesInputSchema, formatUserTrade } from "./trades.schemas.js";
|
|
8
8
|
import { createOrderTransferSchema } from "../orders/orders-output.schemas.js";
|
|
9
9
|
import { connectReadyGatedProtoChannel } from "../../realtime/ready-gated-subscription.js";
|
|
10
|
-
import { createClient } from "@connectrpc/connect";
|
|
11
10
|
import * as v from "valibot";
|
|
11
|
+
import { createClient } from "@connectrpc/connect";
|
|
12
12
|
//#region src/services/trades/trades.ts
|
|
13
13
|
/**
|
|
14
14
|
* Reads and streams authenticated user trade fills.
|