@polyester/sdk 0.36.0-devnet-20261117035807 → 0.36.0-devnet-20261118123359
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 +11 -1
- package/dist/realtime/client.js +5 -1
- package/dist/realtime/client.js.map +1 -1
- package/dist/realtime/snapshot-then-stream.js +5 -3
- package/dist/realtime/snapshot-then-stream.js.map +1 -1
- package/dist/services/address-book/address-book.schemas.d.ts +2 -2
- package/dist/services/assistant/assistant-events.schemas.d.ts +82 -82
- package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts +22 -22
- package/dist/services/candles/candles.schemas.d.ts +10 -10
- package/dist/services/changelog/changelog.schemas.d.ts +38 -38
- package/dist/services/checkpoints/checkpoints.schemas.d.ts +3 -3
- package/dist/services/claims/claims.schemas.d.ts +2 -2
- package/dist/services/dust-conversion/dust-conversion.schemas.d.ts +11 -11
- package/dist/services/dust-conversion/dust-conversion.schemas.d.ts.map +1 -1
- package/dist/services/dust-conversion/dust-conversion.schemas.js +1 -1
- package/dist/services/dust-conversion/dust-conversion.schemas.js.map +1 -1
- package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +12 -12
- package/dist/services/lifecycle/lifecycle.d.ts +1 -1
- package/dist/services/lifecycle/lifecycle.js +2 -3
- package/dist/services/lifecycle/lifecycle.js.map +1 -1
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +54 -54
- package/dist/services/notifications/notifications.schemas.d.ts +13 -1
- package/dist/services/notifications/notifications.schemas.d.ts.map +1 -1
- package/dist/services/orderbook/orderbook.js +3 -2
- package/dist/services/orderbook/orderbook.js.map +1 -1
- package/dist/services/orders/order-errors.schemas.d.ts +2 -2
- package/dist/services/orders/orders-batch.schemas.d.ts +52 -52
- package/dist/services/orders/orders-input.schemas.d.ts +6 -6
- package/dist/services/orders/orders-output.schemas.d.ts +17 -17
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js +1 -27
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js.map +1 -1
- package/dist/services/rewards/rewards.schemas.d.ts +4 -4
- package/dist/services/statement-exports/statement-exports.schemas.d.ts +7 -7
- package/dist/services/statement-exports/statement-exports.schemas.d.ts.map +1 -1
- package/dist/services/statement-exports/statement-exports.schemas.js +1 -1
- package/dist/services/statement-exports/statement-exports.schemas.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.d.ts +2 -1
- package/dist/services/subaccounts/subaccounts.d.ts.map +1 -1
- package/dist/services/subaccounts/subaccounts.js +2 -2
- package/dist/services/subaccounts/subaccounts.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +15 -15
- package/dist/services/system/system.schemas.d.ts +13 -13
- package/dist/services/trades/trades.schemas.d.ts +2 -2
- package/dist/services/triggers/trigger-child-order.schemas.js +1 -1
- package/dist/services/triggers/trigger-child-order.schemas.js.map +1 -1
- package/dist/services/triggers/trigger-input.schemas.d.ts +9 -9
- package/dist/services/triggers/triggers-output.schemas.d.ts +45 -45
- package/dist/shared/connect-error-mapping.d.ts.map +1 -1
- package/dist/shared/connect-error-mapping.js +24 -3
- package/dist/shared/connect-error-mapping.js.map +1 -1
- package/dist/shared/errors.d.ts +5 -1
- package/dist/shared/errors.d.ts.map +1 -1
- package/dist/shared/errors.js +3 -0
- package/dist/shared/errors.js.map +1 -1
- package/package.json +1 -1
|
@@ -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" | "
|
|
32
|
+
readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "canceled" | "awaiting_destination" | "ready_for_payout" | "paid">]>;
|
|
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" | "
|
|
70
|
+
readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "canceled" | "awaiting_destination" | "ready_for_payout" | "paid">]>;
|
|
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" | "
|
|
117
|
+
readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "canceled" | "awaiting_destination" | "ready_for_payout" | "paid">]>;
|
|
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" | "
|
|
156
|
+
readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "failed" | "canceled" | "awaiting_destination" | "ready_for_payout" | "paid">]>;
|
|
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>;
|
|
@@ -15,7 +15,7 @@ declare const CreateStatementExportInputSchema: v.SchemaWithPipe<readonly [v.Str
|
|
|
15
15
|
* request with the same key returns the same export; the same key with other fields
|
|
16
16
|
* throws `PreconditionFailedError` (`IDEMPOTENCY_KEY_REUSED`).
|
|
17
17
|
*/
|
|
18
|
-
readonly idempotencyKey: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.
|
|
18
|
+
readonly idempotencyKey: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "idempotencyKey must be 1 to 64 letters, digits, '.', '_', ':' or '-'.">]>;
|
|
19
19
|
readonly account: v.OptionalSchema<v.UnionSchema<[v.PicklistSchema<["active", "main"], undefined>, v.StrictObjectSchema<{
|
|
20
20
|
readonly subaccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
|
|
21
21
|
}, undefined>], undefined>, undefined>;
|
|
@@ -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" | "queued" | "failed" | "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>;
|
|
@@ -126,7 +126,7 @@ 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" | "queued" | "failed" | "expired";
|
|
130
130
|
completeThrough: number;
|
|
131
131
|
movements: string;
|
|
132
132
|
bytes: string;
|
|
@@ -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" | "queued" | "failed" | "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.
|
|
@@ -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" | "queued" | "failed" | "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>;
|
|
@@ -223,7 +223,7 @@ 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" | "queued" | "failed" | "expired";
|
|
227
227
|
completeThrough: number;
|
|
228
228
|
movements: string;
|
|
229
229
|
bytes: string;
|
|
@@ -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" | "queued" | "failed" | "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.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statement-exports.schemas.d.ts","names":[],"sources":["../../../src/services/statement-exports/statement-exports.schemas.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"statement-exports.schemas.d.ts","names":[],"sources":["../../../src/services/statement-exports/statement-exports.schemas.ts"],"mappings":";;cAgCa,kCAAgC,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAuCjC,6BAA6B,EAAE,kBAAkB;cAEhD,+BAA6B,EAAA;;;KAI9B,0BAA0B,EAAE,kBAAkB;cAE7C,iCAA+B,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;KAchC,4BAA4B,EAAE,kBAAkB;;cAG/C,uBAAqB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAgDtB,kBAAkB,EAAE,mBAAmB;cAEtC,kCAAgC,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAMjC,6BAA6B,EAAE,mBAAmB"}
|
|
@@ -8,7 +8,7 @@ import * as v from "valibot";
|
|
|
8
8
|
//#region src/services/statement-exports/statement-exports.schemas.ts
|
|
9
9
|
/** Latest period end the server accepts: 2262-04-11T23:47:16Z, the int64-nanosecond limit. */
|
|
10
10
|
const LATEST_END_TIME_MS = Date.UTC(2262, 3, 11, 23, 47, 16);
|
|
11
|
-
const IdempotencyKeySchema = v.pipe(v.string(), v.
|
|
11
|
+
const IdempotencyKeySchema = v.pipe(v.string(), v.regex(/^[A-Za-z0-9._:-]{1,64}$/u, "idempotencyKey must be 1 to 64 letters, digits, '.', '_', ':' or '-'."));
|
|
12
12
|
const CreateStatementExportInputSchema = v.pipe(v.strictObject({
|
|
13
13
|
...AccountScopeInputEntries,
|
|
14
14
|
/** Period start, inclusive, in epoch milliseconds (UTC); after the epoch and not in the future. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statement-exports.schemas.js","names":[],"sources":["../../../src/services/statement-exports/statement-exports.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { enumLabelSchema } from \"../../shared/proto-enum-codec.js\";\nimport {\n BigIntStringSchema,\n OptionalPublicIdSchema,\n OptionalTimestampMsSchema,\n PublicIdSchema,\n TimestampMsSchema,\n idInputSchema,\n} from \"../../shared/schemas.js\";\nimport { PROTOBUF_UINT32_MAX } from \"../../shared/wire-bounds.js\";\nimport { msToTimestamp } from \"../../utils/timestamp.js\";\nimport {\n StatementExportFailureReasonCodec,\n StatementExportStatusCodec,\n} from \"./statement-exports.codecs.js\";\n\n/** Latest period end the server accepts: 2262-04-11T23:47:16Z, the int64-nanosecond limit. */\nconst LATEST_END_TIME_MS = Date.UTC(2262, 3, 11, 23, 47, 16);\n\nconst IdempotencyKeySchema = v.pipe(\n v.string(),\n v.
|
|
1
|
+
{"version":3,"file":"statement-exports.schemas.js","names":[],"sources":["../../../src/services/statement-exports/statement-exports.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { enumLabelSchema } from \"../../shared/proto-enum-codec.js\";\nimport {\n BigIntStringSchema,\n OptionalPublicIdSchema,\n OptionalTimestampMsSchema,\n PublicIdSchema,\n TimestampMsSchema,\n idInputSchema,\n} from \"../../shared/schemas.js\";\nimport { PROTOBUF_UINT32_MAX } from \"../../shared/wire-bounds.js\";\nimport { msToTimestamp } from \"../../utils/timestamp.js\";\nimport {\n StatementExportFailureReasonCodec,\n StatementExportStatusCodec,\n} from \"./statement-exports.codecs.js\";\n\n/** Latest period end the server accepts: 2262-04-11T23:47:16Z, the int64-nanosecond limit. */\nconst LATEST_END_TIME_MS = Date.UTC(2262, 3, 11, 23, 47, 16);\n\nconst IdempotencyKeySchema = v.pipe(\n v.string(),\n v.regex(\n /^[A-Za-z0-9._:-]{1,64}$/u,\n \"idempotencyKey must be 1 to 64 letters, digits, '.', '_', ':' or '-'.\",\n ),\n);\n\nexport const CreateStatementExportInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n /** Period start, inclusive, in epoch milliseconds (UTC); after the epoch and not in the future. */\n startTime: v.pipe(\n v.number(),\n v.integer(),\n v.minValue(1, \"startTime must be after 1970-01-01T00:00:00Z.\"),\n ),\n /**\n * Period end, exclusive, in epoch milliseconds (UTC), by 2262-04-11T23:47:16Z. A period\n * still open when the export is created ends then; see `completeThrough`.\n */\n endTime: v.pipe(\n v.number(),\n v.integer(),\n v.maxValue(LATEST_END_TIME_MS, \"endTime must be by 2262-04-11T23:47:16Z.\"),\n ),\n /** Ledger asset ID to cover only that asset; omit or `0` for every asset. */\n assetId: v.optional(\n v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(PROTOBUF_UINT32_MAX)),\n 0,\n ),\n /**\n * 1 to 64 letters, digits, `.`, `_`, `:` or `-`, unique per root account. Repeating the\n * request with the same key returns the same export; the same key with other fields\n * throws `PreconditionFailedError` (`IDEMPOTENCY_KEY_REUSED`).\n */\n idempotencyKey: IdempotencyKeySchema,\n }),\n v.check(({ startTime, endTime }) => endTime > startTime, \"endTime must be after startTime.\"),\n v.transform(({ account, startTime, endTime, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n startTime: msToTimestamp(startTime),\n endTime: msToTimestamp(endTime),\n })),\n);\n\nexport type CreateStatementExportInput = v.InferInput<typeof CreateStatementExportInputSchema>;\n\nexport const GetStatementExportInputSchema = v.strictObject({\n exportId: idInputSchema(\"exportId\"),\n});\n\nexport type GetStatementExportInput = v.InferInput<typeof GetStatementExportInputSchema>;\n\nexport const ListStatementExportsInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n /** Page size, at most 100; 0 or omitted uses the server default of 20. */\n limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(100)), 0),\n /** Previous `nextPageToken`; reuse only with the same account. */\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\nexport type ListStatementExportsInput = v.InferInput<typeof ListStatementExportsInputSchema>;\n\n/** A whole-period statement file being produced, ready, failed or expired. Times are epoch ms. */\nexport const StatementExportSchema = v.pipe(\n v.object({\n exportId: PublicIdSchema,\n subaccountId: OptionalPublicIdSchema,\n startTime: TimestampMsSchema,\n endTime: TimestampMsSchema,\n assetId: v.number(),\n idempotencyKey: v.string(),\n status: enumLabelSchema(StatementExportStatusCodec.protoToOutput),\n completeThrough: TimestampMsSchema,\n movements: BigIntStringSchema,\n bytes: BigIntStringSchema,\n createdAt: TimestampMsSchema,\n readyAt: OptionalTimestampMsSchema,\n expiresAt: OptionalTimestampMsSchema,\n failureReason: enumLabelSchema(StatementExportFailureReasonCodec.protoToOutput),\n }),\n v.transform((statement) => ({\n exportId: statement.exportId,\n /** Public subaccount ID the statement covers; null for the root account. */\n subaccountId: statement.subaccountId ?? null,\n /** Period start, inclusive. */\n startTime: statement.startTime,\n /** Requested period end, exclusive. */\n endTime: statement.endTime,\n /** Ledger asset ID the statement is limited to; 0 for every asset. */\n assetId: statement.assetId,\n idempotencyKey: statement.idempotencyKey,\n status: statement.status,\n /**\n * End of what the file covers, exclusive: the earlier of `endTime` and when the export\n * was created. Every movement recorded before both is in the file.\n */\n completeThrough: statement.completeThrough,\n /** Ledger movements written so far, as a uint64 decimal string; the total once ready. */\n movements: statement.movements,\n /** Bytes written so far, as a uint64 decimal string; the file size once ready. */\n bytes: statement.bytes,\n createdAt: statement.createdAt,\n /** When the file became ready; null before. */\n readyAt: statement.readyAt ?? null,\n /** When a ready file expires, 7 days after `readyAt`; null before ready. */\n expiresAt: statement.expiresAt ?? null,\n /** Why the export failed; `unspecified` unless `status` is `failed`. */\n failureReason: statement.failureReason,\n })),\n);\n\nexport type StatementExport = v.InferOutput<typeof StatementExportSchema>;\n\nexport const ListStatementExportsResultSchema = v.object({\n exports: v.array(StatementExportSchema),\n nextPageToken: v.optional(v.string(), \"\"),\n});\n\n/** One page of exports, newest first; an empty `nextPageToken` means no more. */\nexport type ListStatementExportsResult = v.InferOutput<typeof ListStatementExportsResultSchema>;\n"],"mappings":";;;;;;;;;AAsBA,MAAM,qBAAqB,KAAK,IAAI,MAAM,GAAG,IAAI,IAAI,IAAI,EAAE;AAE3D,MAAM,uBAAuB,EAAE,KAC3B,EAAE,OAAO,GACT,EAAE,MACE,4BACA,uEACJ,CACJ;AAEA,MAAa,mCAAmC,EAAE,KAC9C,EAAE,aAAa;CACX,GAAG;;CAEH,WAAW,EAAE,KACT,EAAE,OAAO,GACT,EAAE,QAAQ,GACV,EAAE,SAAS,GAAG,+CAA+C,CACjE;;;;;CAKA,SAAS,EAAE,KACP,EAAE,OAAO,GACT,EAAE,QAAQ,GACV,EAAE,SAAS,oBAAoB,0CAA0C,CAC7E;;CAEA,SAAS,EAAE,SACP,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,QAAQ,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,SAAS,mBAAmB,CAAC,GAC9E,CACJ;;;;;;CAMA,gBAAgB;AACpB,CAAC,GACD,EAAE,OAAO,EAAE,WAAW,cAAc,UAAU,WAAW,kCAAkC,GAC3F,EAAE,WAAW,EAAE,SAAS,WAAW,SAAS,GAAG,aAAa;CACxD,GAAG;CACH,cAAc,2BAA2B,OAAO;CAChD,WAAW,cAAc,SAAS;CAClC,SAAS,cAAc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AAC"}
|
|
@@ -44,7 +44,8 @@ declare class SubaccountsService {
|
|
|
44
44
|
*/
|
|
45
45
|
get(input: v.InferInput<typeof GetSubaccountInputSchema>, options?: PolyesterRequestOptions): Promise<Subaccount & {
|
|
46
46
|
apiKeys: ApiKey[];
|
|
47
|
-
policy
|
|
47
|
+
/** Absent when the sub-account has no policy attached. */
|
|
48
|
+
policy?: SubaccountPolicy;
|
|
48
49
|
members: SubaccountMember[];
|
|
49
50
|
invites: SubaccountInvite[];
|
|
50
51
|
balances?: LedgerBalance[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccounts.d.ts","names":[],"sources":["../../../src/services/subaccounts/subaccounts.ts"],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"subaccounts.d.ts","names":[],"sources":["../../../src/services/subaccounts/subaccounts.ts"],"mappings":";;;;;;;;;;;;;;;UAuDU,kCAAkC,mBAAmB;EAC3D;;UAGM,8BAA8B,mBAAmB;EACvD;;;;;cAMS;;WACA,UAAU;EASf,YAAA,YAAY,4BACZ,UAAU,mBACV,WAAW;;;;EAaT,KAAK,UAAU,0BAA0B;IAC3C;IACA,aAAa,EAAE,mBAAmB;;;;;;;;;;;EAkBhC,IACF,OAAO,EAAE,kBAAkB,2BAC3B,UAAU,0BACX,QACC;IACI,SAAS;;IAET,SAAS;IACT,SAAS;IACT,SAAS;IACT,WAAW;;;;;;;EAuCb,gBACF,OAAO,EAAE,kBAAkB,uCAC3B,UAAU,0BACX,QAAQ;;;;EAYL,OACF,OAAO,EAAE,kBAAkB,8BAC3B,UAAU,2BACX,QAAQ;;;;EAYL,OACF,OAAO,EAAE,kBAAkB,8BAC3B,UAAU,2BACX,QAAQ;;;;EAaL,aACF,OAAO,EAAE,kBAAkB,oCAC3B,UAAU,2BACX,QAAQ;;;;EAYL,aACF,OAAO,EAAE,kBAAkB,oCAC3B,UAAU,2BACX,QAAQ;;;;EAYL,iBACF,OAAO,EAAE,kBAAkB,wCAC3B,UAAU,2BACX,QAAQ;;;;EAYL,wBACF,OAAO,EAAE,kBAAkB,+CAC3B,UAAU,2BACX,QAAQ;;;;;EAaL,YACF,OAAO,EAAE,kBAAkB,mCAC3B,UAAU,0BACX,QAAQ;;;;EAYL,UAAU,UAAU,0BAA0B,QAAQ;;;;EAWtD,wBACF,OAAO,EAAE,kBAAkB,0BAC3B,UAAU,0BACX,QAAQ;;;;EAYL,YACF,OAAO,EAAE,kBAAkB,0BAC3B,UAAU,0BACX,QAAQ;;;;EAYL,cACF,OAAO,EAAE,kBAAkB,qCAC3B,UAAU,2BACX,QAAQ;;;;EAYL,WACF,OAAO,EAAE,kBAAkB,gCAC3B,UAAU,0BACX;IAAU,QAAQ;IAAmB;;;;;EAexC,UAAU,OAAO;;;;EAmBjB,iBAAiB,OAAO"}
|
|
@@ -5,7 +5,7 @@ import { ApiKeySchema } from "../../gen/auth/v1/api_keys_pb.js";
|
|
|
5
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
|
-
import {
|
|
8
|
+
import { 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
11
|
import { createClient } from "@connectrpc/connect";
|
|
@@ -64,7 +64,7 @@ var SubaccountsService = class {
|
|
|
64
64
|
if (!res.subaccount) throw new Error(`Subaccount not found: ${subaccountId}`);
|
|
65
65
|
return {
|
|
66
66
|
...parse(SubaccountSchema$1, res.subaccount),
|
|
67
|
-
|
|
67
|
+
...res.policy && { policy: parse(SubaccountPolicySchema, res.policy) },
|
|
68
68
|
apiKeys: parse(v.optional(v.array(ApiKeySchema$1), []), res.apiKeys),
|
|
69
69
|
members: parse(v.optional(v.array(SubaccountMemberSchema), []), res.members),
|
|
70
70
|
invites: v.parse(v.optional(v.array(SubaccountInviteSchema), []), res.invites).filter((invite) => invite.subaccountId === subaccountId),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccounts.js","names":["#client","Proto.SubaccountService","#viewClient","Proto.SubaccountViewService","#publicRoleClient","Proto.SubaccountRoleService","#authRoleClient","#realtime","SubaccountSchema","ApiKeySchema","Proto.SubaccountSchema","ProtoApiKeys.ApiKeySchema"],"sources":["../../../src/services/subaccounts/subaccounts.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport * as ProtoApiKeys from \"../../gen/auth/v1/api_keys_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { type ApiKey, ApiKeySchema } from \"../api-keys/index.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport {\n DEFAULT_SUBACCOUNT_POLICY,\n SubaccountPoliciesService,\n type SubaccountPolicy,\n SubaccountPolicySchema,\n} from \"../policies/subaccount-policies/index.js\";\nimport { createLedgerBalanceSchema, type LedgerBalance } from \"../balances/balances.schemas.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport type { SubaccountResolver } from \"../subaccount-resolver.js\";\nimport {\n CreateSubaccountChallengeInputSchema,\n CreateSubaccountInputSchema,\n CreateSubaccountResultSchema,\n SubaccountChallengeSchema,\n UpdateSubaccountInputSchema,\n InviteSubaccountMemberInputSchema,\n RemoveSubaccountMemberInputSchema,\n UpdateSubaccountMemberRoleInputSchema,\n ListSubaccountInvitesInputSchema,\n RespondSubaccountInviteInputSchema,\n SubaccountActivityInputSchema,\n SubaccountSchema,\n SubaccountMemberSchema,\n SubaccountInviteSchema,\n SubaccountActivityEventSchema,\n SetSubaccountMemberMfaRequirementInputSchema,\n SubaccountIdInputSchema,\n GetSubaccountInputSchema,\n SubaccountMutationResultSchema,\n SubaccountRoleCatalogSchema,\n EffectiveSubaccountPermissionsSchema,\n type CreateSubaccountResult,\n type SubaccountChallenge,\n type Subaccount,\n type SubaccountMember,\n type SubaccountInvite,\n type SubaccountEvent,\n type SubaccountMutationResult,\n type SubaccountRoleCatalog,\n type EffectiveSubaccountPermissions,\n} from \"./subaccounts.schemas.js\";\n\ninterface SubscribeSubaccountsInput extends BaseSubscribeInput<Subaccount> {\n accountId: string;\n}\n\ninterface SubscribeApiKeysInput extends BaseSubscribeInput<ApiKey> {\n accountId: string;\n}\n\n/**\n * Reads the public role catalog and creates, manages, shares, audits, and subscribes to subaccounts visible to the authenticated caller.\n */\nexport class SubaccountsService {\n readonly policies: SubaccountPoliciesService;\n\n #client: Client<typeof Proto.SubaccountService>;\n #viewClient: Client<typeof Proto.SubaccountViewService>;\n #publicRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #authRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #realtime: PolyesterRealtime;\n\n constructor(\n transports: AuthAndPublicApiTransports,\n realtime: PolyesterRealtime,\n resolver?: SubaccountResolver,\n ) {\n this.policies = new SubaccountPoliciesService(transports, realtime, resolver);\n this.#client = createClient(Proto.SubaccountService, transports.authApi);\n this.#viewClient = createClient(Proto.SubaccountViewService, transports.authApi);\n this.#publicRoleClient = createClient(Proto.SubaccountRoleService, transports.publicApi);\n this.#authRoleClient = createClient(Proto.SubaccountRoleService, transports.authApi);\n this.#realtime = realtime;\n }\n\n /**\n * Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted ones. Use `createChallenge` for the canonical next smart-account address and salt. API keys need `read-subaccounts` and see only the subaccounts within their scope.\n */\n async list(options?: PolyesterRequestOptions): Promise<{\n totalCreated: number;\n subaccounts: v.InferOutput<typeof SubaccountSchema>[];\n }> {\n const res = await this.#client.listSubaccounts({}, toConnectCallOptions(options));\n return {\n totalCreated: res.totalCreated,\n subaccounts: parse(v.array(SubaccountSchema), res.subaccounts),\n };\n }\n\n /**\n * Fetches an aggregated subaccount dashboard view with subaccount details, policy, API keys, members, and outgoing invites; throws if the subaccount is missing. API keys need `read-subaccounts`.\n *\n * `includeBalances: true` also returns the sub-account's current `balances`, in the shape of\n * `balances.list`. It needs the READ_BALANCES action on the sub-account (its role, any attached\n * policy and, for an API key, the key's policy), or the call fails with PermissionDenied. When\n * balances cannot be read right now the call fails with the retryable\n * `AUTH_TEMPORARILY_UNAVAILABLE`; retry the same call.\n */\n async get(\n input: v.InferInput<typeof GetSubaccountInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<\n Subaccount & {\n apiKeys: ApiKey[];\n policy: SubaccountPolicy;\n members: SubaccountMember[];\n invites: SubaccountInvite[];\n balances?: LedgerBalance[];\n }\n > {\n const validatedInput = parse(GetSubaccountInputSchema, input);\n const subaccountId = formatId(validatedInput.subaccountId);\n const includeBalances = validatedInput.includeBalances === true;\n const res = await this.#viewClient.getSubaccount(\n {\n subaccountId: validatedInput.subaccountId,\n includeApiKeys: true,\n includeMembers: true,\n includeInvites: true,\n includePolicy: true,\n invitesDirection: Proto.SubaccountInviteDirection.OUTGOING,\n ...(includeBalances && { includeBalances }),\n },\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(`Subaccount not found: ${subaccountId}`);\n\n return {\n ...parse(SubaccountSchema, res.subaccount),\n policy: res.policy\n ? parse(SubaccountPolicySchema, res.policy)\n : DEFAULT_SUBACCOUNT_POLICY,\n apiKeys: parse(v.optional(v.array(ApiKeySchema), []), res.apiKeys),\n members: parse(v.optional(v.array(SubaccountMemberSchema), []), res.members),\n invites: v\n .parse(v.optional(v.array(SubaccountInviteSchema), []), res.invites)\n .filter((invite) => invite.subaccountId === subaccountId),\n ...(includeBalances && {\n balances: parse(v.array(createLedgerBalanceSchema()), res.balances?.balances ?? []),\n }),\n };\n }\n\n /**\n * Requests the canonical next smart account and a short-lived EIP-191 authorization message\n * bound to the authenticated root and the selected owner EOA. Sign the exact message through\n * the returned smart account, then pass it to `create`. A new challenge replaces the previous one.\n */\n async createChallenge(\n input: v.InferInput<typeof CreateSubaccountChallengeInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountChallenge> {\n const validatedInput = parse(CreateSubaccountChallengeInputSchema, input);\n const res = await this.#client.createSubaccountChallenge(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountChallengeSchema, res);\n }\n\n /**\n * Creates a new subaccount under the caller's root account using the smart-account address, message, and smart-account signature from `createChallenge`.\n */\n async create(\n input: v.InferInput<typeof CreateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<CreateSubaccountResult> {\n const validatedInput = parse(CreateSubaccountInputSchema, input);\n const res = await this.#client.createSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(CreateSubaccountResultSchema, res);\n }\n\n /**\n * Updates mutable subaccount display/status fields such as label and active/disabled status.\n */\n async update(\n input: v.InferInput<typeof UpdateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<Subaccount> {\n const validatedInput = parse(UpdateSubaccountInputSchema, input);\n const res = await this.#client.updateSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(\"Failed to update subaccount\");\n return parse(SubaccountSchema, res.subaccount);\n }\n\n /**\n * Creates or refreshes a pending invitation granting a role on a subaccount to another root account.\n */\n async inviteMember(\n input: v.InferInput<typeof InviteSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(InviteSubaccountMemberInputSchema, input);\n const res = await this.#client.inviteSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Removes delegated access for a subaccount member by grantee account ID.\n */\n async removeMember(\n input: v.InferInput<typeof RemoveSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(RemoveSubaccountMemberInputSchema, input);\n const res = await this.#client.removeSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Changes an existing delegated member's role without sending a new invitation.\n */\n async updateMemberRole(\n input: v.InferInput<typeof UpdateSubaccountMemberRoleInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(UpdateSubaccountMemberRoleInputSchema, input);\n const res = await this.#client.updateSubaccountMemberRole(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Enables or disables the owner-controlled MFA requirement for delegated interactive member actions on a subaccount.\n */\n async setMemberMfaRequirement(\n input: v.InferInput<typeof SetSubaccountMemberMfaRequirementInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(SetSubaccountMemberMfaRequirementInputSchema, input);\n const res = await this.#client.setSubaccountMemberMFARequirement(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Returns the caller's subaccount invitations, newest first. Omit `direction` to include both\n * incoming and outgoing invitations, or pass `\"incoming\"` or `\"outgoing\"` to filter. API keys need `read-subaccount-invites` and see only outgoing invitations.\n */\n async listInvites(\n input: v.InferInput<typeof ListSubaccountInvitesInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountInvite[]> {\n const validatedInput = parse(ListSubaccountInvitesInputSchema, input);\n const res = await this.#client.listSubaccountInvites(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountInviteSchema), res.invites);\n }\n\n /**\n * Returns the public built-in role and permission catalog with display metadata and per-role permission sets.\n */\n async listRoles(options?: PolyesterRequestOptions): Promise<SubaccountRoleCatalog> {\n const res = await this.#publicRoleClient.listSubaccountRoles(\n {},\n toConnectCallOptions(options),\n );\n return parse(SubaccountRoleCatalogSchema, res);\n }\n\n /**\n * Returns the caller's current role, effective role-granted permissions, and attached policy ID for a subaccount. API keys need `read-subaccount-permissions` and get what the key itself may do.\n */\n async getEffectivePermissions(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<EffectiveSubaccountPermissions> {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const res = await this.#authRoleClient.getEffectiveSubaccountPermissions(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(EffectiveSubaccountPermissionsSchema, res);\n }\n\n /**\n * Returns the owner and delegated members for a subaccount, including role and MFA enrollment status. API keys need `read-subaccount-members`.\n */\n async listMembers(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountMember[]> {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const res = await this.#client.listSubaccountMembers(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountMemberSchema), res.members);\n }\n\n /**\n * Accepts or rejects an incoming invite, or cancels an outgoing invite, returning the updated invitation.\n */\n async respondInvite(\n input: v.InferInput<typeof RespondSubaccountInviteInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(RespondSubaccountInviteInputSchema, input);\n const res = await this.#client.respondSubaccountInvite(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination. API keys need `read-subaccount-activity`.\n */\n async listEvents(\n input: v.InferInput<typeof SubaccountActivityInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<{ events: SubaccountEvent[]; nextPageToken: string }> {\n const validatedInput = parse(SubaccountActivityInputSchema, input);\n const res = await this.#viewClient.listSubaccountActivity(\n validatedInput,\n toConnectCallOptions(options),\n );\n return {\n events: parse(v.optional(v.array(SubaccountActivityEventSchema), []), res.events),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Subscribes to private subaccount updates for an account and emits normalized subaccount records. A record with `removed: true` means the caller lost access to that subaccount; remove it locally. Losing access also ends the caller's subscriptions to that subaccount's channels.\n */\n subscribe(input: SubscribeSubaccountsInput) {\n const channel = `private:auth:subaccounts:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: Proto.SubaccountSchema,\n onPublication: (data) => {\n const subaccount = parse(SubaccountSchema, data);\n input.onEvent(subaccount);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n\n /**\n * Subscribes to private API key updates for an account through the subaccount realtime channel helper.\n */\n subscribeApiKeys(input: SubscribeApiKeysInput) {\n const channel = `private:auth:api-keys:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: ProtoApiKeys.ApiKeySchema,\n onPublication: (data) => {\n const apiKey = parse(ApiKeySchema, data);\n input.onEvent(apiKey);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n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EACzB,MAAM,iBAAiB,MAAM,oCAAoC,KAAK;EACtE,MAAM,MAAM,MAAM,KAAKA,QAAQ,wBAC3B,gBACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,wBAAwB,IAAI,MAAM;CACnD;;;;CAKA,MAAM,WACF,OACA,SAC6D;EAC7D,MAAM,iBAAiB,MAAM,+BAA+B,KAAK;EACjE,MAAM,MAAM,MAAM,KAAKE,YAAY,uBAC/B,gBACA,qBAAqB,OAAO,CAChC;EACA,OAAO;GACH,QAAQ,MAAM,EAAE,SAAS,EAAE,MAAM,6BAA6B,GAAG,CAAC,CAAC,GAAG,IAAI,MAAM;GAChF,eAAe,IAAI;EACvB;CACJ;;;;CAKA,UAAU,OAAkC;EACxC,MAAM,UAAU,4BAA4B,MAAM,UAAU;EAE5D,OAAO,KAAKK,UAAU,oBAAoB;GACtC;GACA,QAAQG;GACR,gBAAgB,SAAS;IACrB,MAAM,aAAa,MAAMF,oBAAkB,IAAI;IAC/C,MAAM,QAAQ,UAAU;GAC5B;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;;;;CAKA,iBAAiB,OAA8B;EAC3C,MAAM,UAAU,yBAAyB,MAAM,UAAU;EAEzD,OAAO,KAAKD,UAAU,oBAAoB;GACtC;GACA,QAAQI;GACR,gBAAgB,SAAS;IACrB,MAAM,SAAS,MAAMF,gBAAc,IAAI;IACvC,MAAM,QAAQ,MAAM;GACxB;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
|
|
1
|
+
{"version":3,"file":"subaccounts.js","names":["#client","Proto.SubaccountService","#viewClient","Proto.SubaccountViewService","#publicRoleClient","Proto.SubaccountRoleService","#authRoleClient","#realtime","SubaccountSchema","ApiKeySchema","Proto.SubaccountSchema","ProtoApiKeys.ApiKeySchema"],"sources":["../../../src/services/subaccounts/subaccounts.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport * as ProtoApiKeys from \"../../gen/auth/v1/api_keys_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { type ApiKey, ApiKeySchema } from \"../api-keys/index.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport {\n SubaccountPoliciesService,\n type SubaccountPolicy,\n SubaccountPolicySchema,\n} from \"../policies/subaccount-policies/index.js\";\nimport { createLedgerBalanceSchema, type LedgerBalance } from \"../balances/balances.schemas.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport type { SubaccountResolver } from \"../subaccount-resolver.js\";\nimport {\n CreateSubaccountChallengeInputSchema,\n CreateSubaccountInputSchema,\n CreateSubaccountResultSchema,\n SubaccountChallengeSchema,\n UpdateSubaccountInputSchema,\n InviteSubaccountMemberInputSchema,\n RemoveSubaccountMemberInputSchema,\n UpdateSubaccountMemberRoleInputSchema,\n ListSubaccountInvitesInputSchema,\n RespondSubaccountInviteInputSchema,\n SubaccountActivityInputSchema,\n SubaccountSchema,\n SubaccountMemberSchema,\n SubaccountInviteSchema,\n SubaccountActivityEventSchema,\n SetSubaccountMemberMfaRequirementInputSchema,\n SubaccountIdInputSchema,\n GetSubaccountInputSchema,\n SubaccountMutationResultSchema,\n SubaccountRoleCatalogSchema,\n EffectiveSubaccountPermissionsSchema,\n type CreateSubaccountResult,\n type SubaccountChallenge,\n type Subaccount,\n type SubaccountMember,\n type SubaccountInvite,\n type SubaccountEvent,\n type SubaccountMutationResult,\n type SubaccountRoleCatalog,\n type EffectiveSubaccountPermissions,\n} from \"./subaccounts.schemas.js\";\n\ninterface SubscribeSubaccountsInput extends BaseSubscribeInput<Subaccount> {\n accountId: string;\n}\n\ninterface SubscribeApiKeysInput extends BaseSubscribeInput<ApiKey> {\n accountId: string;\n}\n\n/**\n * Reads the public role catalog and creates, manages, shares, audits, and subscribes to subaccounts visible to the authenticated caller.\n */\nexport class SubaccountsService {\n readonly policies: SubaccountPoliciesService;\n\n #client: Client<typeof Proto.SubaccountService>;\n #viewClient: Client<typeof Proto.SubaccountViewService>;\n #publicRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #authRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #realtime: PolyesterRealtime;\n\n constructor(\n transports: AuthAndPublicApiTransports,\n realtime: PolyesterRealtime,\n resolver?: SubaccountResolver,\n ) {\n this.policies = new SubaccountPoliciesService(transports, realtime, resolver);\n this.#client = createClient(Proto.SubaccountService, transports.authApi);\n this.#viewClient = createClient(Proto.SubaccountViewService, transports.authApi);\n this.#publicRoleClient = createClient(Proto.SubaccountRoleService, transports.publicApi);\n this.#authRoleClient = createClient(Proto.SubaccountRoleService, transports.authApi);\n this.#realtime = realtime;\n }\n\n /**\n * Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted ones. Use `createChallenge` for the canonical next smart-account address and salt. API keys need `read-subaccounts` and see only the subaccounts within their scope.\n */\n async list(options?: PolyesterRequestOptions): Promise<{\n totalCreated: number;\n subaccounts: v.InferOutput<typeof SubaccountSchema>[];\n }> {\n const res = await this.#client.listSubaccounts({}, toConnectCallOptions(options));\n return {\n totalCreated: res.totalCreated,\n subaccounts: parse(v.array(SubaccountSchema), res.subaccounts),\n };\n }\n\n /**\n * Fetches an aggregated subaccount dashboard view with subaccount details, policy, API keys, members, and outgoing invites; throws if the subaccount is missing. API keys need `read-subaccounts`.\n *\n * `includeBalances: true` also returns the sub-account's current `balances`, in the shape of\n * `balances.list`. It needs the READ_BALANCES action on the sub-account (its role, any attached\n * policy and, for an API key, the key's policy), or the call fails with PermissionDenied. When\n * balances cannot be read right now the call fails with the retryable\n * `AUTH_TEMPORARILY_UNAVAILABLE`; retry the same call.\n */\n async get(\n input: v.InferInput<typeof GetSubaccountInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<\n Subaccount & {\n apiKeys: ApiKey[];\n /** Absent when the sub-account has no policy attached. */\n policy?: SubaccountPolicy;\n members: SubaccountMember[];\n invites: SubaccountInvite[];\n balances?: LedgerBalance[];\n }\n > {\n const validatedInput = parse(GetSubaccountInputSchema, input);\n const subaccountId = formatId(validatedInput.subaccountId);\n const includeBalances = validatedInput.includeBalances === true;\n const res = await this.#viewClient.getSubaccount(\n {\n subaccountId: validatedInput.subaccountId,\n includeApiKeys: true,\n includeMembers: true,\n includeInvites: true,\n includePolicy: true,\n invitesDirection: Proto.SubaccountInviteDirection.OUTGOING,\n ...(includeBalances && { includeBalances }),\n },\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(`Subaccount not found: ${subaccountId}`);\n\n return {\n ...parse(SubaccountSchema, res.subaccount),\n ...(res.policy && { policy: parse(SubaccountPolicySchema, res.policy) }),\n apiKeys: parse(v.optional(v.array(ApiKeySchema), []), res.apiKeys),\n members: parse(v.optional(v.array(SubaccountMemberSchema), []), res.members),\n invites: v\n .parse(v.optional(v.array(SubaccountInviteSchema), []), res.invites)\n .filter((invite) => invite.subaccountId === subaccountId),\n ...(includeBalances && {\n balances: parse(v.array(createLedgerBalanceSchema()), res.balances?.balances ?? []),\n }),\n };\n }\n\n /**\n * Requests the canonical next smart account and a short-lived EIP-191 authorization message\n * bound to the authenticated root and the selected owner EOA. Sign the exact message through\n * the returned smart account, then pass it to `create`. A new challenge replaces the previous one.\n */\n async createChallenge(\n input: v.InferInput<typeof CreateSubaccountChallengeInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountChallenge> {\n const validatedInput = parse(CreateSubaccountChallengeInputSchema, input);\n const res = await this.#client.createSubaccountChallenge(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountChallengeSchema, res);\n }\n\n /**\n * Creates a new subaccount under the caller's root account using the smart-account address, message, and smart-account signature from `createChallenge`.\n */\n async create(\n input: v.InferInput<typeof CreateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<CreateSubaccountResult> {\n const validatedInput = parse(CreateSubaccountInputSchema, input);\n const res = await this.#client.createSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(CreateSubaccountResultSchema, res);\n }\n\n /**\n * Updates mutable subaccount display/status fields such as label and active/disabled status.\n */\n async update(\n input: v.InferInput<typeof UpdateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<Subaccount> {\n const validatedInput = parse(UpdateSubaccountInputSchema, input);\n const res = await this.#client.updateSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(\"Failed to update subaccount\");\n return parse(SubaccountSchema, res.subaccount);\n }\n\n /**\n * Creates or refreshes a pending invitation granting a role on a subaccount to another root account.\n */\n async inviteMember(\n input: v.InferInput<typeof InviteSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(InviteSubaccountMemberInputSchema, input);\n const res = await this.#client.inviteSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Removes delegated access for a subaccount member by grantee account ID.\n */\n async removeMember(\n input: v.InferInput<typeof RemoveSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(RemoveSubaccountMemberInputSchema, input);\n const res = await this.#client.removeSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Changes an existing delegated member's role without sending a new invitation.\n */\n async updateMemberRole(\n input: v.InferInput<typeof UpdateSubaccountMemberRoleInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(UpdateSubaccountMemberRoleInputSchema, input);\n const res = await this.#client.updateSubaccountMemberRole(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Enables or disables the owner-controlled MFA requirement for delegated interactive member actions on a subaccount.\n */\n async setMemberMfaRequirement(\n input: v.InferInput<typeof SetSubaccountMemberMfaRequirementInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(SetSubaccountMemberMfaRequirementInputSchema, input);\n const res = await this.#client.setSubaccountMemberMFARequirement(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Returns the caller's subaccount invitations, newest first. Omit `direction` to include both\n * incoming and outgoing invitations, or pass `\"incoming\"` or `\"outgoing\"` to filter. API keys need `read-subaccount-invites` and see only outgoing invitations.\n */\n async listInvites(\n input: v.InferInput<typeof ListSubaccountInvitesInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountInvite[]> {\n const validatedInput = parse(ListSubaccountInvitesInputSchema, input);\n const res = await this.#client.listSubaccountInvites(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountInviteSchema), res.invites);\n }\n\n /**\n * Returns the public built-in role and permission catalog with display metadata and per-role permission sets.\n */\n async listRoles(options?: PolyesterRequestOptions): Promise<SubaccountRoleCatalog> {\n const res = await this.#publicRoleClient.listSubaccountRoles(\n {},\n toConnectCallOptions(options),\n );\n return parse(SubaccountRoleCatalogSchema, res);\n }\n\n /**\n * Returns the caller's current role, effective role-granted permissions, and attached policy ID for a subaccount. API keys need `read-subaccount-permissions` and get what the key itself may do.\n */\n async getEffectivePermissions(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<EffectiveSubaccountPermissions> {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const res = await this.#authRoleClient.getEffectiveSubaccountPermissions(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(EffectiveSubaccountPermissionsSchema, res);\n }\n\n /**\n * Returns the owner and delegated members for a subaccount, including role and MFA enrollment status. API keys need `read-subaccount-members`.\n */\n async listMembers(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountMember[]> {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const res = await this.#client.listSubaccountMembers(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountMemberSchema), res.members);\n }\n\n /**\n * Accepts or rejects an incoming invite, or cancels an outgoing invite, returning the updated invitation.\n */\n async respondInvite(\n input: v.InferInput<typeof RespondSubaccountInviteInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(RespondSubaccountInviteInputSchema, input);\n const res = await this.#client.respondSubaccountInvite(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination. API keys need `read-subaccount-activity`.\n */\n async listEvents(\n input: v.InferInput<typeof SubaccountActivityInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<{ events: SubaccountEvent[]; nextPageToken: string }> {\n const validatedInput = parse(SubaccountActivityInputSchema, input);\n const res = await this.#viewClient.listSubaccountActivity(\n validatedInput,\n toConnectCallOptions(options),\n );\n return {\n events: parse(v.optional(v.array(SubaccountActivityEventSchema), []), res.events),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Subscribes to private subaccount updates for an account and emits normalized subaccount records. A record with `removed: true` means the caller lost access to that subaccount; remove it locally. Losing access also ends the caller's subscriptions to that subaccount's channels.\n */\n subscribe(input: SubscribeSubaccountsInput) {\n const channel = `private:auth:subaccounts:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: Proto.SubaccountSchema,\n onPublication: (data) => {\n const subaccount = parse(SubaccountSchema, data);\n input.onEvent(subaccount);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n\n /**\n * Subscribes to private API key updates for an account through the subaccount realtime channel helper.\n */\n subscribeApiKeys(input: SubscribeApiKeysInput) {\n const channel = `private:auth:api-keys:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: ProtoApiKeys.ApiKeySchema,\n onPublication: (data) => {\n const apiKey = parse(ApiKeySchema, data);\n input.onEvent(apiKey);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAkEA,IAAa,qBAAb,MAAgC;CAC5B;CAEA;CACA;CACA;CACA;CACA;CAEA,YACI,YACA,UACA,UACF;EACE,KAAK,WAAW,IAAI,0BAA0B,YAAY,UAAU,QAAQ;EAC5E,KAAKA,UAAU,aAAaC,mBAAyB,WAAW,OAAO;EACvE,KAAKC,cAAc,aAAaC,uBAA6B,WAAW,OAAO;EAC/E,KAAKC,oBAAoB,aAAaC,uBAA6B,WAAW,SAAS;EACvF,KAAKC,kBAAkB,aAAaD,uBAA6B,WAAW,OAAO;EACnF,KAAKE,YAAY;CACrB;;;;CAKA,MAAM,KAAK,SAGR;EACC,MAAM,MAAM,MAAM,KAAKP,QAAQ,gBAAgB,CAAC,GAAG,qBAAqB,OAAO,CAAC;EAChF,OAAO;GACH,cAAc,IAAI;GAClB,aAAa,MAAM,EAAE,MAAMQ,kBAAgB,GAAG,IAAI,WAAW;EACjE;CACJ;;;;;;;;;;CAWA,MAAM,IACF,OACA,SAUF;EACE,MAAM,iBAAiB,MAAM,0BAA0B,KAAK;EAC5D,MAAM,eAAe,SAAS,eAAe,YAAY;EACzD,MAAM,kBAAkB,eAAe,oBAAoB;EAC3D,MAAM,MAAM,MAAM,KAAKN,YAAY,cAC/B;GACI,cAAc,eAAe;GAC7B,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O,KAAKD,UAAU,oBAAoB;GACtC;GACA,QAAQI;GACR,gBAAgB,SAAS;IACrB,MAAM,SAAS,MAAMF,gBAAc,IAAI;IACvC,MAAM,QAAQ,MAAM;GACxB;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
|
|
@@ -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" | "failed" | "enabled" | "created" | "applied" | "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>;
|
|
@@ -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" | "scheduled" | "in_progress" | "canceled")[] | 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" | "scheduled" | "in_progress" | "canceled">]>;
|
|
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<{
|
|
@@ -43,7 +43,7 @@ declare const StatusEventSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
43
43
|
seconds: bigint;
|
|
44
44
|
nanos: number;
|
|
45
45
|
} | undefined, number | undefined>]>;
|
|
46
|
-
readonly services: v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
46
|
+
readonly services: v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "deposits" | "withdrawals" | "transfers" | "trading" | "accounts" | "api" | "market_data" | "quickswap" | "app">]>, undefined>;
|
|
47
47
|
readonly markets: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
48
48
|
readonly updatedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
49
49
|
readonly seconds: v.BigintSchema<undefined>;
|
|
@@ -77,12 +77,12 @@ 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" | "scheduled" | "in_progress" | "canceled";
|
|
81
81
|
title: string;
|
|
82
82
|
message: string;
|
|
83
83
|
startTime?: number | undefined;
|
|
84
84
|
endTime?: number | undefined;
|
|
85
|
-
services: ("unspecified" | "
|
|
85
|
+
services: ("unspecified" | "deposits" | "withdrawals" | "transfers" | "trading" | "accounts" | "api" | "market_data" | "quickswap" | "app")[];
|
|
86
86
|
markets: string[];
|
|
87
87
|
updatedAt?: number | undefined;
|
|
88
88
|
impact: "unspecified" | "degraded" | "partial_outage" | "major_outage";
|
|
@@ -98,13 +98,13 @@ 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" | "scheduled" | "in_progress" | "canceled";
|
|
102
102
|
title: string;
|
|
103
103
|
message: string;
|
|
104
104
|
startTime: number | null;
|
|
105
105
|
/** Always set for maintenance; null for an incident with no expected end yet. */
|
|
106
106
|
endTime: number | null;
|
|
107
|
-
services: ("unspecified" | "
|
|
107
|
+
services: ("unspecified" | "deposits" | "withdrawals" | "transfers" | "trading" | "accounts" | "api" | "market_data" | "quickswap" | "app")[];
|
|
108
108
|
/** Affected market symbols such as `"BTC-USDT"`; empty when not limited to markets. */
|
|
109
109
|
markets: string[];
|
|
110
110
|
/** Affected asset codes such as `"SOL"`; empty when not limited to assets. */
|
|
@@ -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" | "scheduled" | "in_progress" | "canceled">]>;
|
|
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<{
|
|
@@ -145,7 +145,7 @@ declare const ListStatusEventsResultSchema: v.ObjectSchema<{
|
|
|
145
145
|
seconds: bigint;
|
|
146
146
|
nanos: number;
|
|
147
147
|
} | undefined, number | undefined>]>;
|
|
148
|
-
readonly services: v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
148
|
+
readonly services: v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "deposits" | "withdrawals" | "transfers" | "trading" | "accounts" | "api" | "market_data" | "quickswap" | "app">]>, undefined>;
|
|
149
149
|
readonly markets: v.ArraySchema<v.StringSchema<undefined>, undefined>;
|
|
150
150
|
readonly updatedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
151
151
|
readonly seconds: v.BigintSchema<undefined>;
|
|
@@ -179,12 +179,12 @@ 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" | "scheduled" | "in_progress" | "canceled";
|
|
183
183
|
title: string;
|
|
184
184
|
message: string;
|
|
185
185
|
startTime?: number | undefined;
|
|
186
186
|
endTime?: number | undefined;
|
|
187
|
-
services: ("unspecified" | "
|
|
187
|
+
services: ("unspecified" | "deposits" | "withdrawals" | "transfers" | "trading" | "accounts" | "api" | "market_data" | "quickswap" | "app")[];
|
|
188
188
|
markets: string[];
|
|
189
189
|
updatedAt?: number | undefined;
|
|
190
190
|
impact: "unspecified" | "degraded" | "partial_outage" | "major_outage";
|
|
@@ -200,13 +200,13 @@ 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" | "scheduled" | "in_progress" | "canceled";
|
|
204
204
|
title: string;
|
|
205
205
|
message: string;
|
|
206
206
|
startTime: number | null;
|
|
207
207
|
/** Always set for maintenance; null for an incident with no expected end yet. */
|
|
208
208
|
endTime: number | null;
|
|
209
|
-
services: ("unspecified" | "
|
|
209
|
+
services: ("unspecified" | "deposits" | "withdrawals" | "transfers" | "trading" | "accounts" | "api" | "market_data" | "quickswap" | "app")[];
|
|
210
210
|
/** Affected market symbols such as `"BTC-USDT"`; empty when not limited to markets. */
|
|
211
211
|
markets: string[];
|
|
212
212
|
/** Affected asset codes such as `"SOL"`; empty when not limited to assets. */
|
|
@@ -63,7 +63,7 @@ declare function createUserTradeSchema(scales: SdkScales): v.SchemaWithPipe<read
|
|
|
63
63
|
referralShare?: string | undefined;
|
|
64
64
|
orderId: string;
|
|
65
65
|
symbolId: number;
|
|
66
|
-
sideLabel: "
|
|
66
|
+
sideLabel: "unspecified" | "buy" | "sell";
|
|
67
67
|
liquidityLabel: "maker" | "taker";
|
|
68
68
|
feeAsset: "unspecified" | "quote" | "base";
|
|
69
69
|
qty: string;
|
|
@@ -169,7 +169,7 @@ declare const GetUserTradesInputSchema: v.SchemaWithPipe<readonly [v.UnionSchema
|
|
|
169
169
|
readonly orderId: v.OptionalSchema<v.NeverSchema<undefined>, undefined>;
|
|
170
170
|
readonly lineageId: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>, v.CheckAction<bigint, `${string} must be greater than zero`>]>;
|
|
171
171
|
readonly throughGeneration: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>;
|
|
172
|
-
}, undefined>], undefined>], ({ input }: v.UnionIssue<v.NumberIssue | v.BooleanIssue | v.IntegerIssue<number> | v.MinValueIssue<number, 1> | v.MaxValueIssue<number, 4294967295> | v.
|
|
172
|
+
}, undefined>], undefined>], ({ input }: v.UnionIssue<v.NumberIssue | v.StringIssue | v.BooleanIssue | v.IntegerIssue<number> | v.MinValueIssue<number, 1> | v.MaxValueIssue<number, 4294967295> | v.MinLengthIssue<string, 1> | v.StrictObjectIssue | v.PicklistIssue | v.UnionIssue<v.StringIssue | v.MinLengthIssue<string, 1> | v.StrictObjectIssue | v.PicklistIssue> | v.GtValueIssue<number, 0> | v.CheckIssue<bigint> | v.MaxValueIssue<number, 1000> | v.NeverIssue | v.UnionIssue<v.NumberIssue | v.StringIssue | v.BooleanIssue | v.IntegerIssue<number> | v.MinValueIssue<number, 1> | v.MaxValueIssue<number, 4294967295> | v.MinLengthIssue<string, 1> | v.StrictObjectIssue | v.PicklistIssue | v.UnionIssue<v.StringIssue | v.MinLengthIssue<string, 1> | v.StrictObjectIssue | v.PicklistIssue> | v.GtValueIssue<number, 0> | v.CheckIssue<bigint> | v.MaxValueIssue<number, 1000> | v.NeverIssue>>) => "Provide at most one of orderId or lineageId" | "throughGeneration requires lineageId" | "symbolId is required when afterMatchId is set" | "Invalid trade filters">, v.TransformAction<{
|
|
173
173
|
symbolId?: number | undefined;
|
|
174
174
|
afterMatchId?: undefined;
|
|
175
175
|
side?: Side.BUY | Side.SELL | undefined;
|
|
@@ -16,7 +16,7 @@ const DecimalInputStringSchema = v.pipe(v.string(), v.trim(), v.minLength(1));
|
|
|
16
16
|
const BaseTriggerFieldsSchema = v.object({
|
|
17
17
|
...AccountScopeInputEntries,
|
|
18
18
|
symbolId: SymbolIdInputSchema,
|
|
19
|
-
clientTriggerId: v.optional(v.pipe(v.string(), v.
|
|
19
|
+
clientTriggerId: v.optional(v.pipe(v.string(), v.minLength(1)), () => crypto.randomUUID()),
|
|
20
20
|
qty: DecimalInputStringSchema,
|
|
21
21
|
feeAsset: v.pipe(v.optional(FeeAssetSchema, "quote"), v.transform((value) => FeeAssetCodec.inputToProto[value])),
|
|
22
22
|
selfTradePreventionMode: v.pipe(v.optional(SelfTradePreventionModeSchema, "expire_maker"), v.transform((value) => SelfTradePreventionModeCodec.inputToProto[value]))
|