@polyester/sdk 0.32.2-devnet-20261103030350 → 0.32.2-devnet-20261103214026
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 +13 -1
- package/dist/core-client.d.ts +1 -1
- package/dist/gen/auth/v1/address_book_pb.d.ts +6 -3
- package/dist/gen/auth/v1/address_book_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/address_book_pb.js.map +1 -1
- package/dist/gen/auth/v1/auth_pb.d.ts +48 -1
- package/dist/gen/auth/v1/auth_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/auth_pb.js +48 -1
- package/dist/gen/auth/v1/auth_pb.js.map +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.d.ts +21 -2
- package/dist/gen/auth/v1/subaccounts_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.js +3 -1
- package/dist/gen/auth/v1/subaccounts_pb.js.map +1 -1
- package/dist/gen/chain/guard/v1/guard_signer_pb.d.ts +1 -1
- package/dist/gen/chain/guard/v1/guard_signer_pb.js.map +1 -1
- package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.d.ts +16 -1
- package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.d.ts.map +1 -1
- package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.js +4 -1
- package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.js.map +1 -1
- package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts +3 -1
- package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts.map +1 -1
- package/dist/gen/chain/withdraw/v1/withdraw_pb.js.map +1 -1
- package/dist/gen/changelog/v1/changelog_pb.d.ts +29 -3
- package/dist/gen/changelog/v1/changelog_pb.d.ts.map +1 -1
- package/dist/gen/changelog/v1/changelog_pb.js +22 -3
- package/dist/gen/changelog/v1/changelog_pb.js.map +1 -1
- package/dist/gen/index.js +3 -3
- package/dist/gen/ledger/read/v1/ledger_read_pb.js +1 -1
- package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts +5 -0
- package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts.map +1 -1
- package/dist/gen/marketoverview/v1/marketoverview_pb.js.map +1 -1
- package/dist/gen/orders/v1/orders_pb.d.ts +75 -6
- package/dist/gen/orders/v1/orders_pb.d.ts.map +1 -1
- package/dist/gen/orders/v1/orders_pb.js +12 -1
- package/dist/gen/orders/v1/orders_pb.js.map +1 -1
- package/dist/gen/orders/v1/orders_read_pb.d.ts +107 -8
- package/dist/gen/orders/v1/orders_read_pb.d.ts.map +1 -1
- package/dist/gen/orders/v1/orders_read_pb.js +45 -22
- package/dist/gen/orders/v1/orders_read_pb.js.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts +11 -9
- package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_pb.js.map +1 -1
- package/dist/gen/triggers/v1/triggers_pb.d.ts +71 -11
- package/dist/gen/triggers/v1/triggers_pb.d.ts.map +1 -1
- package/dist/gen/triggers/v1/triggers_pb.js +56 -10
- package/dist/gen/triggers/v1/triggers_pb.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/services/address-book/address-book.schemas.d.ts +2 -2
- package/dist/services/balances/balances.js +1 -1
- package/dist/services/balances/balances.schemas.d.ts +1 -1
- package/dist/services/changelog/changelog.codecs.d.ts +1 -1
- package/dist/services/changelog/changelog.codecs.d.ts.map +1 -1
- package/dist/services/changelog/changelog.codecs.js +12 -3
- package/dist/services/changelog/changelog.codecs.js.map +1 -1
- package/dist/services/changelog/changelog.schemas.d.ts +20 -15
- package/dist/services/changelog/changelog.schemas.d.ts.map +1 -1
- package/dist/services/changelog/changelog.schemas.js +2 -0
- package/dist/services/changelog/changelog.schemas.js.map +1 -1
- package/dist/services/checkpoints/checkpoints.schemas.d.ts +2 -2
- package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +1 -1
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +40 -40
- package/dist/services/orderbook/orderbook.schemas.d.ts +1 -1
- package/dist/services/orders/order-errors.schemas.d.ts +1 -1
- package/dist/services/orders/orders-batch.schemas.d.ts +32 -32
- package/dist/services/orders/orders-input.schemas.d.ts +3 -3
- package/dist/services/orders/orders-output.schemas.d.ts +95 -19
- package/dist/services/orders/orders-output.schemas.d.ts.map +1 -1
- package/dist/services/orders/orders-output.schemas.js +15 -2
- package/dist/services/orders/orders-output.schemas.js.map +1 -1
- package/dist/services/orders/orders.codecs.js +1 -0
- package/dist/services/orders/orders.codecs.js.map +1 -1
- package/dist/services/rewards/rewards.schemas.d.ts +3 -3
- package/dist/services/subaccounts/index.d.ts +2 -2
- package/dist/services/subaccounts/subaccounts.d.ts +11 -3
- package/dist/services/subaccounts/subaccounts.d.ts.map +1 -1
- package/dist/services/subaccounts/subaccounts.js +14 -4
- package/dist/services/subaccounts/subaccounts.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +21 -16
- package/dist/services/subaccounts/subaccounts.schemas.d.ts.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.js +5 -1
- package/dist/services/subaccounts/subaccounts.schemas.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.types.d.ts +2 -2
- package/dist/services/trades/trades.schemas.d.ts +2 -2
- package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts +1 -1
- package/dist/services/transfers/transfers.js +1 -1
- package/dist/services/triggers/trigger-input.schemas.d.ts +4 -4
- package/dist/services/triggers/triggers-output.schemas.d.ts +40 -32
- package/dist/services/triggers/triggers-output.schemas.d.ts.map +1 -1
- package/dist/services/triggers/triggers-output.schemas.js +5 -2
- package/dist/services/triggers/triggers-output.schemas.js.map +1 -1
- package/dist/services/triggers/triggers.codecs.js +8 -3
- package/dist/services/triggers/triggers.codecs.js.map +1 -1
- package/dist/shared/connect-error-mapping.d.ts.map +1 -1
- package/dist/shared/connect-error-mapping.js +1 -1
- package/dist/shared/connect-error-mapping.js.map +1 -1
- package/dist/wired-services.js +1 -1
- package/package.json +1 -1
|
@@ -19,7 +19,7 @@ declare const RewardAwardSchema: v.ObjectSchema<{
|
|
|
19
19
|
readonly assetId: v.NumberSchema<undefined>;
|
|
20
20
|
readonly amountBaseUnits: v.StringSchema<undefined>;
|
|
21
21
|
readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
|
|
22
|
-
readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
22
|
+
readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "awaiting_destination" | "ready_for_payout" | "paid" | "failed" | "canceled">]>;
|
|
23
23
|
readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
24
24
|
readonly seconds: v.BigintSchema<undefined>;
|
|
25
25
|
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
@@ -41,7 +41,7 @@ declare const ListRewardAwardsResultSchema: v.ObjectSchema<{
|
|
|
41
41
|
readonly assetId: v.NumberSchema<undefined>;
|
|
42
42
|
readonly amountBaseUnits: v.StringSchema<undefined>;
|
|
43
43
|
readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
|
|
44
|
-
readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
44
|
+
readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "awaiting_destination" | "ready_for_payout" | "paid" | "failed" | "canceled">]>;
|
|
45
45
|
readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
46
46
|
readonly seconds: v.BigintSchema<undefined>;
|
|
47
47
|
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
@@ -65,7 +65,7 @@ declare const SetRewardDestinationResultSchema: v.ObjectSchema<{
|
|
|
65
65
|
readonly assetId: v.NumberSchema<undefined>;
|
|
66
66
|
readonly amountBaseUnits: v.StringSchema<undefined>;
|
|
67
67
|
readonly fulfillmentMethod: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "external_testnet" | "internal_trading">]>;
|
|
68
|
-
readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
68
|
+
readonly fulfillmentState: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "awaiting_destination" | "ready_for_payout" | "paid" | "failed" | "canceled">]>;
|
|
69
69
|
readonly publishedAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
70
70
|
readonly seconds: v.BigintSchema<undefined>;
|
|
71
71
|
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { CreateSubaccountChallengeInput, CreateSubaccountChallengeInputSchema, CreateSubaccountInput, CreateSubaccountInputSchema, CreateSubaccountResult, CreateSubaccountResultSchema, EffectiveSubaccountPermissions, EffectiveSubaccountPermissionsSchema, InviteSubaccountMemberInput, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInput, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInput, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInput, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInput, SetSubaccountMemberMfaRequirementInputSchema, Subaccount, SubaccountActivityEventSchema, SubaccountActivityInput, SubaccountActivityInputSchema, SubaccountChallenge, SubaccountChallengeSchema, SubaccountEvent, SubaccountIdInput, SubaccountIdInputSchema, SubaccountInvite, SubaccountInviteSchema, SubaccountInviteStatus, SubaccountMember, SubaccountMemberSchema, SubaccountMutationResult, SubaccountMutationResultSchema, SubaccountPermission, SubaccountPermissionDefinition, SubaccountPermissionDefinitionSchema, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleCatalogSchema, SubaccountRoleDefinition, SubaccountRoleDefinitionSchema, SubaccountRoleSchema, SubaccountSchema, SubaccountStatus, UpdateSubaccountInput, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInput, UpdateSubaccountMemberRoleInputSchema } from "./subaccounts.schemas.js";
|
|
1
|
+
import { CreateSubaccountChallengeInput, CreateSubaccountChallengeInputSchema, CreateSubaccountInput, CreateSubaccountInputSchema, CreateSubaccountResult, CreateSubaccountResultSchema, EffectiveSubaccountPermissions, EffectiveSubaccountPermissionsSchema, GetSubaccountInput, GetSubaccountInputSchema, InviteSubaccountMemberInput, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInput, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInput, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInput, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInput, SetSubaccountMemberMfaRequirementInputSchema, Subaccount, SubaccountActivityEventSchema, SubaccountActivityInput, SubaccountActivityInputSchema, SubaccountChallenge, SubaccountChallengeSchema, SubaccountEvent, SubaccountIdInput, SubaccountIdInputSchema, SubaccountInvite, SubaccountInviteSchema, SubaccountInviteStatus, SubaccountMember, SubaccountMemberSchema, SubaccountMutationResult, SubaccountMutationResultSchema, SubaccountPermission, SubaccountPermissionDefinition, SubaccountPermissionDefinitionSchema, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleCatalogSchema, SubaccountRoleDefinition, SubaccountRoleDefinitionSchema, SubaccountRoleSchema, SubaccountSchema, SubaccountStatus, UpdateSubaccountInput, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInput, UpdateSubaccountMemberRoleInputSchema } from "./subaccounts.schemas.js";
|
|
2
2
|
import { SubaccountsService } from "./subaccounts.js";
|
|
3
|
-
export { CreateSubaccountChallengeInput, CreateSubaccountChallengeInputSchema, CreateSubaccountInput, CreateSubaccountInputSchema, CreateSubaccountResult, CreateSubaccountResultSchema, EffectiveSubaccountPermissions, EffectiveSubaccountPermissionsSchema, InviteSubaccountMemberInput, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInput, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInput, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInput, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInput, SetSubaccountMemberMfaRequirementInputSchema, Subaccount, SubaccountActivityEventSchema, SubaccountActivityInput, SubaccountActivityInputSchema, SubaccountChallenge, SubaccountChallengeSchema, SubaccountEvent, SubaccountIdInput, SubaccountIdInputSchema, SubaccountInvite, SubaccountInviteSchema, SubaccountInviteStatus, SubaccountMember, SubaccountMemberSchema, SubaccountMutationResult, SubaccountMutationResultSchema, SubaccountPermission, SubaccountPermissionDefinition, SubaccountPermissionDefinitionSchema, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleCatalogSchema, SubaccountRoleDefinition, SubaccountRoleDefinitionSchema, SubaccountRoleSchema, SubaccountSchema, SubaccountStatus, SubaccountsService, UpdateSubaccountInput, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInput, UpdateSubaccountMemberRoleInputSchema };
|
|
3
|
+
export { CreateSubaccountChallengeInput, CreateSubaccountChallengeInputSchema, CreateSubaccountInput, CreateSubaccountInputSchema, CreateSubaccountResult, CreateSubaccountResultSchema, EffectiveSubaccountPermissions, EffectiveSubaccountPermissionsSchema, GetSubaccountInput, GetSubaccountInputSchema, InviteSubaccountMemberInput, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInput, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInput, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInput, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInput, SetSubaccountMemberMfaRequirementInputSchema, Subaccount, SubaccountActivityEventSchema, SubaccountActivityInput, SubaccountActivityInputSchema, SubaccountChallenge, SubaccountChallengeSchema, SubaccountEvent, SubaccountIdInput, SubaccountIdInputSchema, SubaccountInvite, SubaccountInviteSchema, SubaccountInviteStatus, SubaccountMember, SubaccountMemberSchema, SubaccountMutationResult, SubaccountMutationResultSchema, SubaccountPermission, SubaccountPermissionDefinition, SubaccountPermissionDefinitionSchema, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleCatalogSchema, SubaccountRoleDefinition, SubaccountRoleDefinitionSchema, SubaccountRoleSchema, SubaccountSchema, SubaccountStatus, SubaccountsService, UpdateSubaccountInput, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInput, UpdateSubaccountMemberRoleInputSchema };
|
|
@@ -9,7 +9,8 @@ import "../api-keys/index.js";
|
|
|
9
9
|
import { SubaccountPolicy } from "../policies/subaccount-policies/subaccount-policies.schemas.js";
|
|
10
10
|
import { SubaccountPoliciesService } from "../policies/subaccount-policies/subaccount-policies.js";
|
|
11
11
|
import "../policies/subaccount-policies/index.js";
|
|
12
|
-
import {
|
|
12
|
+
import { LedgerBalance } from "../balances/balances.schemas.js";
|
|
13
|
+
import { CreateSubaccountChallengeInputSchema, CreateSubaccountInputSchema, CreateSubaccountResult, EffectiveSubaccountPermissions, GetSubaccountInputSchema, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInputSchema, Subaccount, SubaccountActivityInputSchema, SubaccountChallenge, SubaccountEvent, SubaccountIdInputSchema, SubaccountInvite, SubaccountMember, SubaccountMutationResult, SubaccountRoleCatalog, SubaccountSchema, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInputSchema } from "./subaccounts.schemas.js";
|
|
13
14
|
import * as v from "valibot";
|
|
14
15
|
//#region src/services/subaccounts/subaccounts.d.ts
|
|
15
16
|
interface SubscribeSubaccountsInput extends BaseSubscribeInput<Subaccount> {
|
|
@@ -34,12 +35,19 @@ declare class SubaccountsService {
|
|
|
34
35
|
}>;
|
|
35
36
|
/**
|
|
36
37
|
* Fetches an aggregated subaccount dashboard view with subaccount details, policy, API keys, members, and outgoing invites; throws if the subaccount is missing.
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
*
|
|
39
|
+
* `includeBalances: true` also returns the sub-account's current `balances`, in the shape of
|
|
40
|
+
* `balances.list`. It needs the READ_BALANCES action on the sub-account (its role, any attached
|
|
41
|
+
* policy and, for an API key, the key's policy), or the call fails with PermissionDenied. When
|
|
42
|
+
* balances cannot be read right now the call fails with the retryable
|
|
43
|
+
* `AUTH_TEMPORARILY_UNAVAILABLE`; retry the same call.
|
|
44
|
+
*/
|
|
45
|
+
get(input: v.InferInput<typeof GetSubaccountInputSchema>, options?: PolyesterRequestOptions): Promise<Subaccount & {
|
|
39
46
|
apiKeys: ApiKey[];
|
|
40
47
|
policy: SubaccountPolicy;
|
|
41
48
|
members: SubaccountMember[];
|
|
42
49
|
invites: SubaccountInvite[];
|
|
50
|
+
balances?: LedgerBalance[];
|
|
43
51
|
}>;
|
|
44
52
|
/**
|
|
45
53
|
* Requests the canonical next smart account and a short-lived EIP-191 authorization message
|
|
@@ -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":";;;;;;;;;;;;;;;UAwDU,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;IACT,QAAQ;IACR,SAAS;IACT,SAAS;IACT,WAAW;;;;;;;EAyCb,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"}
|
|
@@ -4,9 +4,10 @@ import { formatId } from "../../utils/base58-id.js";
|
|
|
4
4
|
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
|
+
import { createLedgerBalanceSchema } from "../balances/balances.schemas.js";
|
|
7
8
|
import { DEFAULT_SUBACCOUNT_POLICY, SubaccountPolicySchema } from "../policies/subaccount-policies/subaccount-policies.schemas.js";
|
|
8
9
|
import { SubaccountPoliciesService } from "../policies/subaccount-policies/subaccount-policies.js";
|
|
9
|
-
import { CreateSubaccountChallengeInputSchema, CreateSubaccountInputSchema, CreateSubaccountResultSchema, EffectiveSubaccountPermissionsSchema, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInputSchema, SubaccountActivityEventSchema, SubaccountActivityInputSchema, SubaccountChallengeSchema, SubaccountIdInputSchema, SubaccountInviteSchema, SubaccountMemberSchema, SubaccountMutationResultSchema, SubaccountRoleCatalogSchema, SubaccountSchema as SubaccountSchema$1, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInputSchema } from "./subaccounts.schemas.js";
|
|
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";
|
|
10
11
|
import { createClient } from "@connectrpc/connect";
|
|
11
12
|
import * as v from "valibot";
|
|
12
13
|
//#region src/services/subaccounts/subaccounts.ts
|
|
@@ -40,17 +41,25 @@ var SubaccountsService = class {
|
|
|
40
41
|
}
|
|
41
42
|
/**
|
|
42
43
|
* Fetches an aggregated subaccount dashboard view with subaccount details, policy, API keys, members, and outgoing invites; throws if the subaccount is missing.
|
|
44
|
+
*
|
|
45
|
+
* `includeBalances: true` also returns the sub-account's current `balances`, in the shape of
|
|
46
|
+
* `balances.list`. It needs the READ_BALANCES action on the sub-account (its role, any attached
|
|
47
|
+
* policy and, for an API key, the key's policy), or the call fails with PermissionDenied. When
|
|
48
|
+
* balances cannot be read right now the call fails with the retryable
|
|
49
|
+
* `AUTH_TEMPORARILY_UNAVAILABLE`; retry the same call.
|
|
43
50
|
*/
|
|
44
51
|
async get(input, options) {
|
|
45
|
-
const validatedInput = parse(
|
|
52
|
+
const validatedInput = parse(GetSubaccountInputSchema, input);
|
|
46
53
|
const subaccountId = formatId(validatedInput.subaccountId);
|
|
54
|
+
const includeBalances = validatedInput.includeBalances === true;
|
|
47
55
|
const res = await this.#viewClient.getSubaccount({
|
|
48
56
|
subaccountId: validatedInput.subaccountId,
|
|
49
57
|
includeApiKeys: true,
|
|
50
58
|
includeMembers: true,
|
|
51
59
|
includeInvites: true,
|
|
52
60
|
includePolicy: true,
|
|
53
|
-
invitesDirection: 2
|
|
61
|
+
invitesDirection: 2,
|
|
62
|
+
...includeBalances && { includeBalances }
|
|
54
63
|
}, toConnectCallOptions(options));
|
|
55
64
|
if (!res.subaccount) throw new Error(`Subaccount not found: ${subaccountId}`);
|
|
56
65
|
return {
|
|
@@ -58,7 +67,8 @@ var SubaccountsService = class {
|
|
|
58
67
|
policy: res.policy ? parse(SubaccountPolicySchema, res.policy) : DEFAULT_SUBACCOUNT_POLICY,
|
|
59
68
|
apiKeys: parse(v.optional(v.array(ApiKeySchema$1), []), res.apiKeys),
|
|
60
69
|
members: parse(v.optional(v.array(SubaccountMemberSchema), []), res.members),
|
|
61
|
-
invites: v.parse(v.optional(v.array(SubaccountInviteSchema), []), res.invites).filter((invite) => invite.subaccountId === subaccountId)
|
|
70
|
+
invites: v.parse(v.optional(v.array(SubaccountInviteSchema), []), res.invites).filter((invite) => invite.subaccountId === subaccountId),
|
|
71
|
+
...includeBalances && { balances: parse(v.array(createLedgerBalanceSchema()), res.balances?.balances ?? []) }
|
|
62
72
|
};
|
|
63
73
|
}
|
|
64
74
|
/**
|
|
@@ -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 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 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.\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.\n */\n async get(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<\n Subaccount & {\n apiKeys: ApiKey[];\n policy: SubaccountPolicy;\n members: SubaccountMember[];\n invites: SubaccountInvite[];\n }\n > {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const subaccountId = formatId(validatedInput.subaccountId);\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 },\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 };\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.\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.\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.\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.\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.\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":";;;;;;;;;;;;;;;AAiEA,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;;;;CAKA,MAAM,IACF,OACA,SAQF;EACE,MAAM,iBAAiB,MAAM,yBAAyB,KAAK;EAC3D,MAAM,eAAe,SAAS,eAAe,YAAY;EACzD,MAAM,MAAM,MAAM,KAAKN,YAAY,cAC/B;GACI,cAAc,eAAe;GAC7B,gBAAgB;GAChB,gBAAgB;GAChB,gBAAgB;GAChB,eAAe;GACf,kBAAA;EACJ,GACA,qBAAqB,OAAO,CAChC;EACA,IAAI,CAAC,IAAI,YAAY,MAAM,IAAI,MAAM,yBAAyB,cAAc;EAE5E,OAAO;GACH,GAAG,MAAMM,oBAAkB,IAAI,UAAU;GACzC,QAAQ,IAAI,SACN,MAAM,wBAAwB,IAAI,MAAM,IACxC;GACN,SAAS,MAAM,EAAE,SAAS,EA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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 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.\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.\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.\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.\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.\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.\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.\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":";;;;;;;;;;;;;;;;AAmEA,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,SASF;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,gBAAgB;GAChB,gBAAgB;GAChB,gBAAgB;GAChB,eAAe;GACf,kBAAA;GACA,GAAI,mBAAmB,EAAE,gBAAgB;EAC7C,GACA,qBAAqB,OAAO,CAChC;EACA,IAAI,CAAC,IAAI,YAAY,MAAM,IAAI,MAAM,yBAAyB,cAAc;EAE5E,OAAO;GACH,G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"}
|
|
@@ -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, "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer"
|
|
16
|
+
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
|
|
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">]>;
|
|
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, "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer"
|
|
31
|
+
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
|
|
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, "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer"
|
|
40
|
+
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
|
|
41
41
|
readonly permissions: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "internal_transfer" | "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" | "swap">]>, undefined>, readonly []>;
|
|
42
42
|
readonly subaccountPolicyId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
43
43
|
}, undefined>;
|
|
@@ -74,6 +74,11 @@ declare const SubaccountIdInputSchema: v.StrictObjectSchema<{
|
|
|
74
74
|
readonly subaccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
|
|
75
75
|
}, undefined>;
|
|
76
76
|
type SubaccountIdInput = v.InferInput<typeof SubaccountIdInputSchema>;
|
|
77
|
+
declare const GetSubaccountInputSchema: v.StrictObjectSchema<{
|
|
78
|
+
readonly subaccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
|
|
79
|
+
readonly includeBalances: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
|
|
80
|
+
}, undefined>;
|
|
81
|
+
type GetSubaccountInput = v.InferInput<typeof GetSubaccountInputSchema>;
|
|
77
82
|
declare const CreateSubaccountResultSchema: v.ObjectSchema<{
|
|
78
83
|
readonly subaccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
79
84
|
readonly totalCreated: v.NumberSchema<undefined>;
|
|
@@ -158,7 +163,7 @@ declare const ProtoSubaccountStatusSchema: v.SchemaWithPipe<readonly [v.NumberSc
|
|
|
158
163
|
type SubaccountStatus = v.InferOutput<typeof ProtoSubaccountStatusSchema>;
|
|
159
164
|
declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
160
165
|
readonly id: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
161
|
-
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer"
|
|
166
|
+
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
|
|
162
167
|
readonly label: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
163
168
|
readonly icon: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
164
169
|
readonly color: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
@@ -177,7 +182,7 @@ declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
177
182
|
readonly revision: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
178
183
|
}, undefined>, v.TransformAction<{
|
|
179
184
|
id: string;
|
|
180
|
-
role: "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer"
|
|
185
|
+
role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
181
186
|
label: string;
|
|
182
187
|
icon: string;
|
|
183
188
|
color: string;
|
|
@@ -198,7 +203,7 @@ declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
198
203
|
updatedAt: number | undefined;
|
|
199
204
|
updatedAtNs: string | undefined;
|
|
200
205
|
id: string;
|
|
201
|
-
role: "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer"
|
|
206
|
+
role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
202
207
|
label: string;
|
|
203
208
|
icon: string;
|
|
204
209
|
color: string;
|
|
@@ -215,7 +220,7 @@ declare const SubaccountSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
|
|
|
215
220
|
type Subaccount = v.InferOutput<typeof SubaccountSchema>;
|
|
216
221
|
declare const SubaccountMemberSchema: v.ObjectSchema<{
|
|
217
222
|
readonly accountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
218
|
-
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer"
|
|
223
|
+
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
|
|
219
224
|
readonly username: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
220
225
|
readonly smartAccountAddress: v.StringSchema<undefined>;
|
|
221
226
|
readonly avatarUrl: v.OptionalSchema<v.StringSchema<undefined>, "">;
|
|
@@ -227,8 +232,8 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
227
232
|
readonly subaccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
228
233
|
readonly granteeAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
229
234
|
readonly inviterAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
|
|
230
|
-
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer"
|
|
231
|
-
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "
|
|
235
|
+
readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
|
|
236
|
+
readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "pending" | "cancelled" | "accepted" | "declined">]>;
|
|
232
237
|
readonly createdAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
|
|
233
238
|
readonly seconds: v.BigintSchema<undefined>;
|
|
234
239
|
readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
|
|
@@ -254,8 +259,8 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
254
259
|
subaccountId: string;
|
|
255
260
|
granteeAccountId: string;
|
|
256
261
|
inviterAccountId: string;
|
|
257
|
-
role: "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer"
|
|
258
|
-
status: "unspecified" | "
|
|
262
|
+
role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
263
|
+
status: "unspecified" | "pending" | "cancelled" | "accepted" | "declined";
|
|
259
264
|
createdAt?: number | undefined;
|
|
260
265
|
respondedAt?: number | undefined;
|
|
261
266
|
granteeUsername: string;
|
|
@@ -272,8 +277,8 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
|
|
|
272
277
|
id: string;
|
|
273
278
|
granteeAccountId: string;
|
|
274
279
|
inviterAccountId: string;
|
|
275
|
-
role: "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer"
|
|
276
|
-
status: "unspecified" | "
|
|
280
|
+
role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
|
|
281
|
+
status: "unspecified" | "pending" | "cancelled" | "accepted" | "declined";
|
|
277
282
|
createdAt?: number | undefined;
|
|
278
283
|
respondedAt?: number | undefined;
|
|
279
284
|
granteeUsername: string;
|
|
@@ -295,8 +300,8 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
|
|
|
295
300
|
seconds: bigint;
|
|
296
301
|
nanos: number;
|
|
297
302
|
} | undefined, number | undefined>]>;
|
|
298
|
-
readonly entityKind: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "subaccount" | "api_key" | "account" | "
|
|
299
|
-
readonly eventAction: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "disabled" | "
|
|
303
|
+
readonly entityKind: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "subaccount" | "api_key" | "account" | "destination" | "session" | "member" | "policy" | "invite" | "security">]>;
|
|
304
|
+
readonly eventAction: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "disabled" | "revoked" | "removed" | "failed" | "enabled" | "created" | "updated" | "deleted" | "role_set" | "received" | "replied" | "blocked" | "hold_placed" | "hold_released">]>;
|
|
300
305
|
readonly source: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "api" | "web" | "mobile">]>;
|
|
301
306
|
readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
302
307
|
readonly userAgent: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -305,5 +310,5 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
|
|
|
305
310
|
}, undefined>;
|
|
306
311
|
type SubaccountEvent = v.InferOutput<typeof SubaccountActivityEventSchema>;
|
|
307
312
|
//#endregion
|
|
308
|
-
export { CreateSubaccountChallengeInput, CreateSubaccountChallengeInputSchema, CreateSubaccountInput, CreateSubaccountInputSchema, CreateSubaccountResult, CreateSubaccountResultSchema, EffectiveSubaccountPermissions, EffectiveSubaccountPermissionsSchema, InviteSubaccountMemberInput, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInput, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInput, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInput, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInput, SetSubaccountMemberMfaRequirementInputSchema, Subaccount, SubaccountActivityEventSchema, SubaccountActivityInput, SubaccountActivityInputSchema, SubaccountChallenge, SubaccountChallengeSchema, SubaccountEvent, SubaccountIdInput, SubaccountIdInputSchema, SubaccountInvite, SubaccountInviteSchema, SubaccountInviteStatus, SubaccountMember, SubaccountMemberSchema, SubaccountMutationResult, SubaccountMutationResultSchema, SubaccountPermission, SubaccountPermissionDefinition, SubaccountPermissionDefinitionSchema, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleCatalogSchema, SubaccountRoleDefinition, SubaccountRoleDefinitionSchema, SubaccountRoleSchema, SubaccountSchema, SubaccountStatus, UpdateSubaccountInput, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInput, UpdateSubaccountMemberRoleInputSchema };
|
|
313
|
+
export { CreateSubaccountChallengeInput, CreateSubaccountChallengeInputSchema, CreateSubaccountInput, CreateSubaccountInputSchema, CreateSubaccountResult, CreateSubaccountResultSchema, EffectiveSubaccountPermissions, EffectiveSubaccountPermissionsSchema, GetSubaccountInput, GetSubaccountInputSchema, InviteSubaccountMemberInput, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInput, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInput, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInput, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInput, SetSubaccountMemberMfaRequirementInputSchema, Subaccount, SubaccountActivityEventSchema, SubaccountActivityInput, SubaccountActivityInputSchema, SubaccountChallenge, SubaccountChallengeSchema, SubaccountEvent, SubaccountIdInput, SubaccountIdInputSchema, SubaccountInvite, SubaccountInviteSchema, SubaccountInviteStatus, SubaccountMember, SubaccountMemberSchema, SubaccountMutationResult, SubaccountMutationResultSchema, SubaccountPermission, SubaccountPermissionDefinition, SubaccountPermissionDefinitionSchema, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleCatalogSchema, SubaccountRoleDefinition, SubaccountRoleDefinitionSchema, SubaccountRoleSchema, SubaccountSchema, SubaccountStatus, UpdateSubaccountInput, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInput, UpdateSubaccountMemberRoleInputSchema };
|
|
309
314
|
//# sourceMappingURL=subaccounts.schemas.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccounts.schemas.d.ts","names":[],"sources":["../../../src/services/subaccounts/subaccounts.schemas.ts"],"mappings":";;;cA2Ca,sBAAoB,EAAA;KAErB,iBAAiB,EAAE,mBAAmB;cAI5C,iCAA+B,EAAA,yBAAA,EAAA,yBAAA,EAAA;KAEzB,uBAAuB,EAAE,mBAAmB;cAE3C,sCAAoC,EAAA;;;;;;KAOrC,iCAAiC,EAAE,mBACpC;cAGE,gCAA8B,EAAA;;;;;;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B5B,wBAAwB,EAAE,kBAAkB;cAE3C,mCAAiC,EAAA;;;;;KASlC,8BAA8B,EAAE,kBAAkB;cAEjD,mCAAiC,EAAA;;;;KAKlC,8BAA8B,EAAE,kBAAkB;cAEjD,uCAAqC,EAAA;;;;;KAEtC,kCAAkC,EAAE,kBACrC;cAGE,8CAA4C,EAAA;;;;KAK7C,yCAAyC,EAAE,kBAC5C;cAGE,kCAAgC,EAAA;;;KAOjC,6BAA6B,EAAE,kBAAkB;cAIvD,oBAAkB,EAAA;KAEZ,yBAAyB,EAAE,mBAAmB;cAI7C,oCAAkC,EAAA;;;;KAQnC,+BAA+B,EAAE,kBAAkB;cAEzD,6BAA2B,EAAA,yBAAA,EAAA,yBAAA,EAAA;KAErB,mBAAmB,EAAE,mBAAmB;cAEvC,kBAAgB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyBjB,aAAa,EAAE,mBAAmB;cAEjC,wBAAsB,EAAA;;;;;;;;KASvB,mBAAmB,EAAE,mBAAmB;cAEvC,wBAAsB,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqCvB,mBAAmB,EAAE,mBAAmB;cAEvC,+BAA6B,EAAA;;;;;KAM9B,0BAA0B,EAAE,kBAAkB;cAE7C,+BAA6B,EAAA;;;;;;;;;;;;;;;;KAc9B,kBAAkB,EAAE,mBAAmB"}
|
|
@@ -58,6 +58,10 @@ const CreateSubaccountInputSchema = v.strictObject({
|
|
|
58
58
|
signature: WalletSignatureSchema
|
|
59
59
|
});
|
|
60
60
|
const SubaccountIdInputSchema = v.strictObject({ subaccountId: idInputSchema("subaccountId") });
|
|
61
|
+
const GetSubaccountInputSchema = v.strictObject({
|
|
62
|
+
subaccountId: idInputSchema("subaccountId"),
|
|
63
|
+
includeBalances: v.optional(v.boolean())
|
|
64
|
+
});
|
|
61
65
|
const CreateSubaccountResultSchema = v.object({
|
|
62
66
|
subaccountId: PublicIdSchema,
|
|
63
67
|
totalCreated: v.number(),
|
|
@@ -198,6 +202,6 @@ const SubaccountActivityEventSchema = v.object({
|
|
|
198
202
|
payloadJson: v.pipe(v.string(), v.transform((v) => JSON.parse(v)))
|
|
199
203
|
});
|
|
200
204
|
//#endregion
|
|
201
|
-
export { CreateSubaccountChallengeInputSchema, CreateSubaccountInputSchema, CreateSubaccountResultSchema, EffectiveSubaccountPermissionsSchema, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInputSchema, SubaccountActivityEventSchema, SubaccountActivityInputSchema, SubaccountChallengeSchema, SubaccountIdInputSchema, SubaccountInviteSchema, SubaccountMemberSchema, SubaccountMutationResultSchema, SubaccountPermissionDefinitionSchema, SubaccountRoleCatalogSchema, SubaccountRoleDefinitionSchema, SubaccountRoleSchema, SubaccountSchema, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInputSchema };
|
|
205
|
+
export { CreateSubaccountChallengeInputSchema, CreateSubaccountInputSchema, CreateSubaccountResultSchema, EffectiveSubaccountPermissionsSchema, GetSubaccountInputSchema, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInputSchema, SubaccountActivityEventSchema, SubaccountActivityInputSchema, SubaccountChallengeSchema, SubaccountIdInputSchema, SubaccountInviteSchema, SubaccountMemberSchema, SubaccountMutationResultSchema, SubaccountPermissionDefinitionSchema, SubaccountRoleCatalogSchema, SubaccountRoleDefinitionSchema, SubaccountRoleSchema, SubaccountSchema, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInputSchema };
|
|
202
206
|
|
|
203
207
|
//# sourceMappingURL=subaccounts.schemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccounts.schemas.js","names":[],"sources":["../../../src/services/subaccounts/subaccounts.schemas.ts"],"sourcesContent":["import {\n WalletAddressSchema,\n WalletChallengeMessageSchema,\n WalletChallengeUriSchema,\n WalletSignatureSchema,\n} from \"../auth/wallet-challenge.schemas.js\";\nimport * as v from \"valibot\";\nimport {\n BigIntStringSchema,\n OptionalTimestampMsSchema,\n PublicIdOrEmptySchema,\n PublicIdSchema,\n TimestampSchema,\n idInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../shared/schemas.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../utils/time.js\";\nimport { enumLabel, enumLabelSchema } from \"../../shared/proto-enum-codec.js\";\nimport {\n SubaccountRoleCodec,\n SubaccountPermissionCodec,\n InviteActionCodec,\n InviteStatusCodec,\n SubaccountInviteDirectionCodec,\n SUBACCOUNT_INVITE_DIRECTION_VALUES,\n SubaccountStatusCodec,\n SUBACCOUNT_STATUS_VALUES,\n ActivityEntityKindCodec,\n ActivityEventActionCodec,\n ActivityEventSourceCodec,\n} from \"./subaccounts.codecs.js\";\nimport { PolicyActionCodec } from \"../policies/shared.codecs.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../utils/proto-patch.js\";\n\nconst SUBACCOUNT_ROLE_VALUES = [\n \"owner\",\n \"admin\",\n \"treasury\",\n \"leveraged_trader\",\n \"trader\",\n \"viewer\",\n] as const;\n\nexport const SubaccountRoleSchema = v.picklist(SUBACCOUNT_ROLE_VALUES);\n\nexport type SubaccountRole = v.InferOutput<typeof SubaccountRoleSchema>;\n\nconst ProtoSubaccountRoleSchema = enumLabelSchema(SubaccountRoleCodec.protoToOutput);\n\nconst ProtoSubaccountPermissionSchema = enumLabelSchema(SubaccountPermissionCodec.protoToOutput);\n\nexport type SubaccountPermission = v.InferOutput<typeof ProtoSubaccountPermissionSchema>;\n\nexport const SubaccountPermissionDefinitionSchema = v.object({\n permission: ProtoSubaccountPermissionSchema,\n displayName: v.optional(v.string(), \"\"),\n description: v.optional(v.string(), \"\"),\n policyAction: enumLabelSchema(PolicyActionCodec.protoToOutput),\n});\n\nexport type SubaccountPermissionDefinition = v.InferOutput<\n typeof SubaccountPermissionDefinitionSchema\n>;\n\nexport const SubaccountRoleDefinitionSchema = v.object({\n role: ProtoSubaccountRoleSchema,\n displayName: v.optional(v.string(), \"\"),\n description: v.optional(v.string(), \"\"),\n assignable: v.optional(v.boolean(), false),\n permissions: v.optional(v.array(ProtoSubaccountPermissionSchema), []),\n});\n\nexport type SubaccountRoleDefinition = v.InferOutput<typeof SubaccountRoleDefinitionSchema>;\n\nexport const SubaccountRoleCatalogSchema = v.object({\n permissions: v.optional(v.array(SubaccountPermissionDefinitionSchema), []),\n roles: v.optional(v.array(SubaccountRoleDefinitionSchema), []),\n});\n\nexport type SubaccountRoleCatalog = v.InferOutput<typeof SubaccountRoleCatalogSchema>;\n\nexport const EffectiveSubaccountPermissionsSchema = v.object({\n role: ProtoSubaccountRoleSchema,\n permissions: v.optional(v.array(ProtoSubaccountPermissionSchema), []),\n subaccountPolicyId: PublicIdOrEmptySchema,\n});\n\nexport type EffectiveSubaccountPermissions = v.InferOutput<\n typeof EffectiveSubaccountPermissionsSchema\n>;\n\nexport const CreateSubaccountChallengeInputSchema = v.strictObject({\n ownerAddress: WalletAddressSchema,\n uri: WalletChallengeUriSchema,\n});\n\nexport type CreateSubaccountChallengeInput = v.InferInput<\n typeof CreateSubaccountChallengeInputSchema\n>;\n\nexport const SubaccountChallengeSchema = v.object({\n message: WalletChallengeMessageSchema,\n smartAccountAddress: WalletAddressSchema,\n smartAccountSaltNonce: v.number(),\n expiresAt: OptionalTimestampMsSchema,\n polyesterChainId: v.pipe(v.bigint(), v.transform(Number)),\n});\n\nexport type SubaccountChallenge = v.InferOutput<typeof SubaccountChallengeSchema>;\n\nexport const CreateSubaccountInputSchema = v.strictObject({\n label: v.optional(v.string(), \"\"),\n icon: v.optional(v.string(), \"\"),\n color: v.optional(v.string(), \"\"),\n smartAccountAddress: WalletAddressSchema,\n message: WalletChallengeMessageSchema,\n signature: WalletSignatureSchema,\n});\n\nexport type CreateSubaccountInput = v.InferInput<typeof CreateSubaccountInputSchema>;\n\nexport const SubaccountIdInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n});\n\nexport type SubaccountIdInput = v.InferInput<typeof SubaccountIdInputSchema>;\n\nexport const CreateSubaccountResultSchema = v.object({\n subaccountId: PublicIdSchema,\n totalCreated: v.number(),\n smartAccountSaltNonce: v.number(),\n revision: BigIntStringSchema,\n});\n\nexport type CreateSubaccountResult = v.InferOutput<typeof CreateSubaccountResultSchema>;\n\nexport const SubaccountMutationResultSchema = v.object({});\n\nexport type SubaccountMutationResult = v.InferOutput<typeof SubaccountMutationResultSchema>;\n\ntype SubaccountPatch = {\n label?: string;\n icon?: string;\n color?: string;\n status?: (typeof SUBACCOUNT_STATUS_VALUES)[number];\n};\n\nconst SUBACCOUNT_PATCH_FIELDS = defineProtoPatchFields<SubaccountPatch>()({\n label: { path: \"label\", encode: (label) => ({ label }) },\n icon: { path: \"icon\", encode: (icon) => ({ icon }) },\n color: { path: \"color\", encode: (color) => ({ color }) },\n status: {\n path: \"status\",\n encode: (status) => ({ status: SubaccountStatusCodec.inputToProto[status] }),\n },\n});\n\nexport const UpdateSubaccountInputSchema = v.pipe(\n v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n label: v.optional(v.string()),\n icon: v.optional(v.string()),\n color: v.optional(v.string()),\n status: v.optional(v.picklist(SUBACCOUNT_STATUS_VALUES)),\n }),\n v.check(\n ({ label, icon, color, status }) =>\n label !== undefined ||\n icon !== undefined ||\n color !== undefined ||\n status !== undefined,\n \"At least one subaccount field must be provided\",\n ),\n v.transform(({ subaccountId, expectedRevision, ...input }) => {\n const { patch: subaccount, updateMask } = buildProtoPatch(input, SUBACCOUNT_PATCH_FIELDS);\n return {\n subaccountId,\n subaccount,\n updateMask,\n expectedRevision,\n };\n }),\n);\n\nexport type UpdateSubaccountInput = v.InferInput<typeof UpdateSubaccountInputSchema>;\n\nexport const InviteSubaccountMemberInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n granteeAccountId: idInputSchema(\"granteeAccountId\"),\n role: v.pipe(\n SubaccountRoleSchema,\n v.transform((role) => SubaccountRoleCodec.inputToProto[role]),\n ),\n});\n\nexport type InviteSubaccountMemberInput = v.InferInput<typeof InviteSubaccountMemberInputSchema>;\n\nexport const RemoveSubaccountMemberInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n granteeAccountId: idInputSchema(\"granteeAccountId\"),\n});\n\nexport type RemoveSubaccountMemberInput = v.InferInput<typeof RemoveSubaccountMemberInputSchema>;\n\nexport const UpdateSubaccountMemberRoleInputSchema = InviteSubaccountMemberInputSchema;\n\nexport type UpdateSubaccountMemberRoleInput = v.InferInput<\n typeof UpdateSubaccountMemberRoleInputSchema\n>;\n\nexport const SetSubaccountMemberMfaRequirementInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n requireMemberMfa: v.boolean(),\n});\n\nexport type SetSubaccountMemberMfaRequirementInput = v.InferInput<\n typeof SetSubaccountMemberMfaRequirementInputSchema\n>;\n\nexport const ListSubaccountInvitesInputSchema = v.strictObject({\n direction: v.pipe(\n v.optional(v.picklist(SUBACCOUNT_INVITE_DIRECTION_VALUES), \"\"),\n v.transform((direction) => SubaccountInviteDirectionCodec.inputToProto[direction]),\n ),\n});\n\nexport type ListSubaccountInvitesInput = v.InferInput<typeof ListSubaccountInvitesInputSchema>;\n\nconst InviteActionSchema = v.picklist([\"accept\", \"decline\", \"cancel\"]);\n\nconst InviteStatusSchema = v.picklist([\"pending\", \"accepted\", \"declined\", \"cancelled\"]);\n\nexport type SubaccountInviteStatus = v.InferOutput<typeof InviteStatusSchema>;\n\nconst ProtoInviteStatusSchema = v.number();\n\nexport const RespondSubaccountInviteInputSchema = v.strictObject({\n inviteId: idInputSchema(\"inviteId\"),\n action: v.pipe(\n InviteActionSchema,\n v.transform((v) => InviteActionCodec.inputToProto[v]),\n ),\n});\n\nexport type RespondSubaccountInviteInput = v.InferInput<typeof RespondSubaccountInviteInputSchema>;\n\nconst ProtoSubaccountStatusSchema = enumLabelSchema(SubaccountStatusCodec.protoToOutput);\n\nexport type SubaccountStatus = v.InferOutput<typeof ProtoSubaccountStatusSchema>;\n\nexport const SubaccountSchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n role: ProtoSubaccountRoleSchema,\n label: v.optional(v.string(), \"\"),\n icon: v.optional(v.string(), \"\"),\n color: v.optional(v.string(), \"\"),\n status: ProtoSubaccountStatusSchema,\n smartAccountAddress: v.string(),\n smartAccountSaltNonce: v.optional(v.number()),\n ownerUsername: v.optional(v.string(), \"\"),\n ownerAvatarUrl: v.optional(v.string(), \"\"),\n ownerRootSmartAccountAddress: v.string(),\n subaccountPolicyId: PublicIdOrEmptySchema,\n requireMemberMfa: v.optional(v.boolean(), false),\n updatedAt: v.optional(TimestampSchema),\n revision: BigIntStringSchema,\n }),\n v.transform(({ updatedAt, ...subaccount }) => ({\n ...subaccount,\n updatedAt: tsObjToMs(updatedAt),\n updatedAtNs: tsObjToNsString(updatedAt),\n })),\n);\n\nexport type Subaccount = v.InferOutput<typeof SubaccountSchema>;\n\nexport const SubaccountMemberSchema = v.object({\n accountId: PublicIdSchema,\n role: ProtoSubaccountRoleSchema,\n username: v.optional(v.string(), \"\"),\n smartAccountAddress: v.string(),\n avatarUrl: v.optional(v.string(), \"\"),\n mfaEnrolled: v.optional(v.boolean(), false),\n});\n\nexport type SubaccountMember = v.InferOutput<typeof SubaccountMemberSchema>;\n\nexport const SubaccountInviteSchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n subaccountId: PublicIdSchema,\n granteeAccountId: PublicIdSchema,\n inviterAccountId: PublicIdSchema,\n role: ProtoSubaccountRoleSchema,\n status: v.pipe(\n ProtoInviteStatusSchema,\n v.transform((v) => enumLabel(InviteStatusCodec.protoToOutput, v)),\n ),\n createdAt: OptionalTimestampMsSchema,\n respondedAt: OptionalTimestampMsSchema,\n granteeUsername: v.optional(v.string(), \"\"),\n inviterUsername: v.optional(v.string(), \"\"),\n subaccountLabel: v.optional(v.string(), \"\"),\n inviterRootSmartAccountAddress: v.string(),\n granteeRootSmartAccountAddress: v.string(),\n requireMemberMfa: v.boolean(),\n }),\n v.transform(\n ({\n subaccountLabel,\n subaccountId,\n inviterRootSmartAccountAddress,\n granteeRootSmartAccountAddress,\n ...rest\n }) => ({\n ...rest,\n subaccountId,\n subaccountLabel,\n inviterSmartAccountAddress: inviterRootSmartAccountAddress,\n granteeSmartAccountAddress: granteeRootSmartAccountAddress,\n }),\n ),\n);\n\nexport type SubaccountInvite = v.InferOutput<typeof SubaccountInviteSchema>;\n\nexport const SubaccountActivityInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(200)), 50),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n});\n\nexport type SubaccountActivityInput = v.InferInput<typeof SubaccountActivityInputSchema>;\n\nexport const SubaccountActivityEventSchema = v.object({\n createdAt: OptionalTimestampMsSchema,\n entityKind: enumLabelSchema(ActivityEntityKindCodec.protoToOutput),\n eventAction: enumLabelSchema(ActivityEventActionCodec.protoToOutput),\n source: enumLabelSchema(ActivityEventSourceCodec.protoToOutput),\n ip: v.optional(v.string()),\n userAgent: v.optional(v.string()),\n actorAccountId: PublicIdSchema,\n payloadJson: v.pipe(\n v.string(),\n v.transform((v) => JSON.parse(v)),\n ),\n});\n\nexport type SubaccountEvent = v.InferOutput<typeof SubaccountActivityEventSchema>;\n"],"mappings":";;;;;;;;AA2CA,MAAa,uBAAuB,EAAE,SAAS;CAR3C;CACA;CACA;CACA;CACA;CACA;AAG2C,CAAsB;AAIrE,MAAM,4BAA4B,gBAAgB,oBAAoB,aAAa;AAEnF,MAAM,kCAAkC,gBAA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AC,GAAG,EAAE;CACrF,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE;AAC1D,CAAC;AAID,MAAa,gCAAgC,EAAE,OAAO;CAClD,WAAW;CACX,YAAY,gBAAgB,wBAAwB,aAAa;CACjE,aAAa,gBAAgB,yBAAyB,aAAa;CACnE,QAAQ,gBAAgB,yBAAyB,aAAa;CAC9D,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC;CACzB,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC;CAChC,gBAAgB;CAChB,aAAa,EAAE,KACX,EAAE,OAAO,GACT,EAAE,WAAW,MAAM,KAAK,MAAM,CAAC,CAAC,CACpC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"subaccounts.schemas.js","names":[],"sources":["../../../src/services/subaccounts/subaccounts.schemas.ts"],"sourcesContent":["import {\n WalletAddressSchema,\n WalletChallengeMessageSchema,\n WalletChallengeUriSchema,\n WalletSignatureSchema,\n} from \"../auth/wallet-challenge.schemas.js\";\nimport * as v from \"valibot\";\nimport {\n BigIntStringSchema,\n OptionalTimestampMsSchema,\n PublicIdOrEmptySchema,\n PublicIdSchema,\n TimestampSchema,\n idInputSchema,\n positiveBigintStringInputSchema,\n} from \"../../shared/schemas.js\";\nimport { tsObjToMs, tsObjToNsString } from \"../../utils/time.js\";\nimport { enumLabel, enumLabelSchema } from \"../../shared/proto-enum-codec.js\";\nimport {\n SubaccountRoleCodec,\n SubaccountPermissionCodec,\n InviteActionCodec,\n InviteStatusCodec,\n SubaccountInviteDirectionCodec,\n SUBACCOUNT_INVITE_DIRECTION_VALUES,\n SubaccountStatusCodec,\n SUBACCOUNT_STATUS_VALUES,\n ActivityEntityKindCodec,\n ActivityEventActionCodec,\n ActivityEventSourceCodec,\n} from \"./subaccounts.codecs.js\";\nimport { PolicyActionCodec } from \"../policies/shared.codecs.js\";\nimport { buildProtoPatch, defineProtoPatchFields } from \"../../utils/proto-patch.js\";\n\nconst SUBACCOUNT_ROLE_VALUES = [\n \"owner\",\n \"admin\",\n \"treasury\",\n \"leveraged_trader\",\n \"trader\",\n \"viewer\",\n] as const;\n\nexport const SubaccountRoleSchema = v.picklist(SUBACCOUNT_ROLE_VALUES);\n\nexport type SubaccountRole = v.InferOutput<typeof SubaccountRoleSchema>;\n\nconst ProtoSubaccountRoleSchema = enumLabelSchema(SubaccountRoleCodec.protoToOutput);\n\nconst ProtoSubaccountPermissionSchema = enumLabelSchema(SubaccountPermissionCodec.protoToOutput);\n\nexport type SubaccountPermission = v.InferOutput<typeof ProtoSubaccountPermissionSchema>;\n\nexport const SubaccountPermissionDefinitionSchema = v.object({\n permission: ProtoSubaccountPermissionSchema,\n displayName: v.optional(v.string(), \"\"),\n description: v.optional(v.string(), \"\"),\n policyAction: enumLabelSchema(PolicyActionCodec.protoToOutput),\n});\n\nexport type SubaccountPermissionDefinition = v.InferOutput<\n typeof SubaccountPermissionDefinitionSchema\n>;\n\nexport const SubaccountRoleDefinitionSchema = v.object({\n role: ProtoSubaccountRoleSchema,\n displayName: v.optional(v.string(), \"\"),\n description: v.optional(v.string(), \"\"),\n assignable: v.optional(v.boolean(), false),\n permissions: v.optional(v.array(ProtoSubaccountPermissionSchema), []),\n});\n\nexport type SubaccountRoleDefinition = v.InferOutput<typeof SubaccountRoleDefinitionSchema>;\n\nexport const SubaccountRoleCatalogSchema = v.object({\n permissions: v.optional(v.array(SubaccountPermissionDefinitionSchema), []),\n roles: v.optional(v.array(SubaccountRoleDefinitionSchema), []),\n});\n\nexport type SubaccountRoleCatalog = v.InferOutput<typeof SubaccountRoleCatalogSchema>;\n\nexport const EffectiveSubaccountPermissionsSchema = v.object({\n role: ProtoSubaccountRoleSchema,\n permissions: v.optional(v.array(ProtoSubaccountPermissionSchema), []),\n subaccountPolicyId: PublicIdOrEmptySchema,\n});\n\nexport type EffectiveSubaccountPermissions = v.InferOutput<\n typeof EffectiveSubaccountPermissionsSchema\n>;\n\nexport const CreateSubaccountChallengeInputSchema = v.strictObject({\n ownerAddress: WalletAddressSchema,\n uri: WalletChallengeUriSchema,\n});\n\nexport type CreateSubaccountChallengeInput = v.InferInput<\n typeof CreateSubaccountChallengeInputSchema\n>;\n\nexport const SubaccountChallengeSchema = v.object({\n message: WalletChallengeMessageSchema,\n smartAccountAddress: WalletAddressSchema,\n smartAccountSaltNonce: v.number(),\n expiresAt: OptionalTimestampMsSchema,\n polyesterChainId: v.pipe(v.bigint(), v.transform(Number)),\n});\n\nexport type SubaccountChallenge = v.InferOutput<typeof SubaccountChallengeSchema>;\n\nexport const CreateSubaccountInputSchema = v.strictObject({\n label: v.optional(v.string(), \"\"),\n icon: v.optional(v.string(), \"\"),\n color: v.optional(v.string(), \"\"),\n smartAccountAddress: WalletAddressSchema,\n message: WalletChallengeMessageSchema,\n signature: WalletSignatureSchema,\n});\n\nexport type CreateSubaccountInput = v.InferInput<typeof CreateSubaccountInputSchema>;\n\nexport const SubaccountIdInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n});\n\nexport type SubaccountIdInput = v.InferInput<typeof SubaccountIdInputSchema>;\n\nexport const GetSubaccountInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n includeBalances: v.optional(v.boolean()),\n});\n\nexport type GetSubaccountInput = v.InferInput<typeof GetSubaccountInputSchema>;\n\nexport const CreateSubaccountResultSchema = v.object({\n subaccountId: PublicIdSchema,\n totalCreated: v.number(),\n smartAccountSaltNonce: v.number(),\n revision: BigIntStringSchema,\n});\n\nexport type CreateSubaccountResult = v.InferOutput<typeof CreateSubaccountResultSchema>;\n\nexport const SubaccountMutationResultSchema = v.object({});\n\nexport type SubaccountMutationResult = v.InferOutput<typeof SubaccountMutationResultSchema>;\n\ntype SubaccountPatch = {\n label?: string;\n icon?: string;\n color?: string;\n status?: (typeof SUBACCOUNT_STATUS_VALUES)[number];\n};\n\nconst SUBACCOUNT_PATCH_FIELDS = defineProtoPatchFields<SubaccountPatch>()({\n label: { path: \"label\", encode: (label) => ({ label }) },\n icon: { path: \"icon\", encode: (icon) => ({ icon }) },\n color: { path: \"color\", encode: (color) => ({ color }) },\n status: {\n path: \"status\",\n encode: (status) => ({ status: SubaccountStatusCodec.inputToProto[status] }),\n },\n});\n\nexport const UpdateSubaccountInputSchema = v.pipe(\n v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n expectedRevision: positiveBigintStringInputSchema(\"expectedRevision\"),\n label: v.optional(v.string()),\n icon: v.optional(v.string()),\n color: v.optional(v.string()),\n status: v.optional(v.picklist(SUBACCOUNT_STATUS_VALUES)),\n }),\n v.check(\n ({ label, icon, color, status }) =>\n label !== undefined ||\n icon !== undefined ||\n color !== undefined ||\n status !== undefined,\n \"At least one subaccount field must be provided\",\n ),\n v.transform(({ subaccountId, expectedRevision, ...input }) => {\n const { patch: subaccount, updateMask } = buildProtoPatch(input, SUBACCOUNT_PATCH_FIELDS);\n return {\n subaccountId,\n subaccount,\n updateMask,\n expectedRevision,\n };\n }),\n);\n\nexport type UpdateSubaccountInput = v.InferInput<typeof UpdateSubaccountInputSchema>;\n\nexport const InviteSubaccountMemberInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n granteeAccountId: idInputSchema(\"granteeAccountId\"),\n role: v.pipe(\n SubaccountRoleSchema,\n v.transform((role) => SubaccountRoleCodec.inputToProto[role]),\n ),\n});\n\nexport type InviteSubaccountMemberInput = v.InferInput<typeof InviteSubaccountMemberInputSchema>;\n\nexport const RemoveSubaccountMemberInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n granteeAccountId: idInputSchema(\"granteeAccountId\"),\n});\n\nexport type RemoveSubaccountMemberInput = v.InferInput<typeof RemoveSubaccountMemberInputSchema>;\n\nexport const UpdateSubaccountMemberRoleInputSchema = InviteSubaccountMemberInputSchema;\n\nexport type UpdateSubaccountMemberRoleInput = v.InferInput<\n typeof UpdateSubaccountMemberRoleInputSchema\n>;\n\nexport const SetSubaccountMemberMfaRequirementInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n requireMemberMfa: v.boolean(),\n});\n\nexport type SetSubaccountMemberMfaRequirementInput = v.InferInput<\n typeof SetSubaccountMemberMfaRequirementInputSchema\n>;\n\nexport const ListSubaccountInvitesInputSchema = v.strictObject({\n direction: v.pipe(\n v.optional(v.picklist(SUBACCOUNT_INVITE_DIRECTION_VALUES), \"\"),\n v.transform((direction) => SubaccountInviteDirectionCodec.inputToProto[direction]),\n ),\n});\n\nexport type ListSubaccountInvitesInput = v.InferInput<typeof ListSubaccountInvitesInputSchema>;\n\nconst InviteActionSchema = v.picklist([\"accept\", \"decline\", \"cancel\"]);\n\nconst InviteStatusSchema = v.picklist([\"pending\", \"accepted\", \"declined\", \"cancelled\"]);\n\nexport type SubaccountInviteStatus = v.InferOutput<typeof InviteStatusSchema>;\n\nconst ProtoInviteStatusSchema = v.number();\n\nexport const RespondSubaccountInviteInputSchema = v.strictObject({\n inviteId: idInputSchema(\"inviteId\"),\n action: v.pipe(\n InviteActionSchema,\n v.transform((v) => InviteActionCodec.inputToProto[v]),\n ),\n});\n\nexport type RespondSubaccountInviteInput = v.InferInput<typeof RespondSubaccountInviteInputSchema>;\n\nconst ProtoSubaccountStatusSchema = enumLabelSchema(SubaccountStatusCodec.protoToOutput);\n\nexport type SubaccountStatus = v.InferOutput<typeof ProtoSubaccountStatusSchema>;\n\nexport const SubaccountSchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n role: ProtoSubaccountRoleSchema,\n label: v.optional(v.string(), \"\"),\n icon: v.optional(v.string(), \"\"),\n color: v.optional(v.string(), \"\"),\n status: ProtoSubaccountStatusSchema,\n smartAccountAddress: v.string(),\n smartAccountSaltNonce: v.optional(v.number()),\n ownerUsername: v.optional(v.string(), \"\"),\n ownerAvatarUrl: v.optional(v.string(), \"\"),\n ownerRootSmartAccountAddress: v.string(),\n subaccountPolicyId: PublicIdOrEmptySchema,\n requireMemberMfa: v.optional(v.boolean(), false),\n updatedAt: v.optional(TimestampSchema),\n revision: BigIntStringSchema,\n }),\n v.transform(({ updatedAt, ...subaccount }) => ({\n ...subaccount,\n updatedAt: tsObjToMs(updatedAt),\n updatedAtNs: tsObjToNsString(updatedAt),\n })),\n);\n\nexport type Subaccount = v.InferOutput<typeof SubaccountSchema>;\n\nexport const SubaccountMemberSchema = v.object({\n accountId: PublicIdSchema,\n role: ProtoSubaccountRoleSchema,\n username: v.optional(v.string(), \"\"),\n smartAccountAddress: v.string(),\n avatarUrl: v.optional(v.string(), \"\"),\n mfaEnrolled: v.optional(v.boolean(), false),\n});\n\nexport type SubaccountMember = v.InferOutput<typeof SubaccountMemberSchema>;\n\nexport const SubaccountInviteSchema = v.pipe(\n v.object({\n id: PublicIdSchema,\n subaccountId: PublicIdSchema,\n granteeAccountId: PublicIdSchema,\n inviterAccountId: PublicIdSchema,\n role: ProtoSubaccountRoleSchema,\n status: v.pipe(\n ProtoInviteStatusSchema,\n v.transform((v) => enumLabel(InviteStatusCodec.protoToOutput, v)),\n ),\n createdAt: OptionalTimestampMsSchema,\n respondedAt: OptionalTimestampMsSchema,\n granteeUsername: v.optional(v.string(), \"\"),\n inviterUsername: v.optional(v.string(), \"\"),\n subaccountLabel: v.optional(v.string(), \"\"),\n inviterRootSmartAccountAddress: v.string(),\n granteeRootSmartAccountAddress: v.string(),\n requireMemberMfa: v.boolean(),\n }),\n v.transform(\n ({\n subaccountLabel,\n subaccountId,\n inviterRootSmartAccountAddress,\n granteeRootSmartAccountAddress,\n ...rest\n }) => ({\n ...rest,\n subaccountId,\n subaccountLabel,\n inviterSmartAccountAddress: inviterRootSmartAccountAddress,\n granteeSmartAccountAddress: granteeRootSmartAccountAddress,\n }),\n ),\n);\n\nexport type SubaccountInvite = v.InferOutput<typeof SubaccountInviteSchema>;\n\nexport const SubaccountActivityInputSchema = v.strictObject({\n subaccountId: idInputSchema(\"subaccountId\"),\n limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(200)), 50),\n pageToken: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n});\n\nexport type SubaccountActivityInput = v.InferInput<typeof SubaccountActivityInputSchema>;\n\nexport const SubaccountActivityEventSchema = v.object({\n createdAt: OptionalTimestampMsSchema,\n entityKind: enumLabelSchema(ActivityEntityKindCodec.protoToOutput),\n eventAction: enumLabelSchema(ActivityEventActionCodec.protoToOutput),\n source: enumLabelSchema(ActivityEventSourceCodec.protoToOutput),\n ip: v.optional(v.string()),\n userAgent: v.optional(v.string()),\n actorAccountId: PublicIdSchema,\n payloadJson: v.pipe(\n v.string(),\n v.transform((v) => JSON.parse(v)),\n ),\n});\n\nexport type SubaccountEvent = v.InferOutput<typeof SubaccountActivityEventSchema>;\n"],"mappings":";;;;;;;;AA2CA,MAAa,uBAAuB,EAAE,SAAS;CAR3C;CACA;CACA;CACA;CACA;CACA;AAG2C,CAAsB;AAIrE,MAAM,4BAA4B,gBAAgB,oBAAoB,aAAa;AAEnF,MAAM,kCAAkC,gBAAgB,0BAA0B,aAAa;AAI/F,MAAa,uCAAuC,EAAE,OAAO;CACzD,YAAY;CACZ,aAAa,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACtC,aAAa,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACtC,cAAc,gBAAgB,kBAAkB,aAAa;AACjE,CAAC;AAMD,MAAa,iCAAiC,EAAE,OAAO;CACnD,MAAM;CACN,aAAa,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACtC,aAAa,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACtC,YAAY,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK;CACzC,aAAa,EAAE,SAAS,EAAE,MAAM,+BAA+B,GAAG,CAAC,CAAC;AACxE,CAAC;AAID,MAAa,8BAA8B,EAAE,OAAO;CAChD,aAAa,EAAE,SAAS,EAAE,MAAM,oCAAoC,GAAG,CAAC,CAAC;CACzE,OAAO,EAAE,SAAS,EAAE,MAAM,8B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|
|
|
1
|
-
import { CreateSubaccountChallengeInput, CreateSubaccountInput, CreateSubaccountResult, EffectiveSubaccountPermissions, InviteSubaccountMemberInput, ListSubaccountInvitesInput, RemoveSubaccountMemberInput, RespondSubaccountInviteInput, SetSubaccountMemberMfaRequirementInput, Subaccount, SubaccountActivityInput, SubaccountChallenge, SubaccountEvent, SubaccountIdInput, SubaccountInvite, SubaccountInviteStatus, SubaccountMember, SubaccountPermission, SubaccountPermissionDefinition, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleDefinition, SubaccountStatus, UpdateSubaccountInput, UpdateSubaccountMemberRoleInput } from "./subaccounts.schemas.js";
|
|
2
|
-
export type { CreateSubaccountChallengeInput, CreateSubaccountInput, CreateSubaccountResult, CreateSubaccountResult as CreateSubaccountServiceResult, EffectiveSubaccountPermissions, InviteSubaccountMemberInput, ListSubaccountInvitesInput, RemoveSubaccountMemberInput, RespondSubaccountInviteInput, SetSubaccountMemberMfaRequirementInput, Subaccount, SubaccountActivityInput, SubaccountChallenge, SubaccountEvent, SubaccountIdInput, SubaccountInvite, SubaccountInviteStatus, SubaccountMember, SubaccountPermission, SubaccountPermissionDefinition, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleDefinition, SubaccountStatus, UpdateSubaccountInput, UpdateSubaccountMemberRoleInput };
|
|
1
|
+
import { CreateSubaccountChallengeInput, CreateSubaccountInput, CreateSubaccountResult, EffectiveSubaccountPermissions, GetSubaccountInput, InviteSubaccountMemberInput, ListSubaccountInvitesInput, RemoveSubaccountMemberInput, RespondSubaccountInviteInput, SetSubaccountMemberMfaRequirementInput, Subaccount, SubaccountActivityInput, SubaccountChallenge, SubaccountEvent, SubaccountIdInput, SubaccountInvite, SubaccountInviteStatus, SubaccountMember, SubaccountPermission, SubaccountPermissionDefinition, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleDefinition, SubaccountStatus, UpdateSubaccountInput, UpdateSubaccountMemberRoleInput } from "./subaccounts.schemas.js";
|
|
2
|
+
export type { CreateSubaccountChallengeInput, CreateSubaccountInput, CreateSubaccountResult, CreateSubaccountResult as CreateSubaccountServiceResult, EffectiveSubaccountPermissions, GetSubaccountInput, InviteSubaccountMemberInput, ListSubaccountInvitesInput, RemoveSubaccountMemberInput, RespondSubaccountInviteInput, SetSubaccountMemberMfaRequirementInput, Subaccount, SubaccountActivityInput, SubaccountChallenge, SubaccountEvent, SubaccountIdInput, SubaccountInvite, SubaccountInviteStatus, SubaccountMember, SubaccountPermission, SubaccountPermissionDefinition, SubaccountRole, SubaccountRoleCatalog, SubaccountRoleDefinition, SubaccountStatus, UpdateSubaccountInput, UpdateSubaccountMemberRoleInput };
|
|
@@ -62,7 +62,7 @@ declare function createUserTradeSchema(scales: SdkScales): v.SchemaWithPipe<read
|
|
|
62
62
|
referralShare?: string | undefined;
|
|
63
63
|
orderId: string;
|
|
64
64
|
symbolId: number;
|
|
65
|
-
sideLabel: "
|
|
65
|
+
sideLabel: "buy" | "sell" | "unspecified";
|
|
66
66
|
liquidityLabel: "maker" | "taker";
|
|
67
67
|
feeAsset: "unspecified" | "quote" | "base";
|
|
68
68
|
qty: string;
|
|
@@ -168,7 +168,7 @@ declare const GetUserTradesInputSchema: v.SchemaWithPipe<readonly [v.UnionSchema
|
|
|
168
168
|
readonly orderId: v.OptionalSchema<v.NeverSchema<undefined>, undefined>;
|
|
169
169
|
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`>]>;
|
|
170
170
|
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>;
|
|
171
|
-
}, undefined>], undefined>], ({ input }: v.UnionIssue<v.NumberIssue | v.
|
|
171
|
+
}, undefined>], undefined>], ({ input }: v.UnionIssue<v.NumberIssue | v.BooleanIssue | v.IntegerIssue<number> | v.MinValueIssue<number, 1> | v.MaxValueIssue<number, 4294967295> | v.StringIssue | v.MinLengthIssue<string, 1> | v.CheckIssue<bigint> | v.StrictObjectIssue | v.PicklistIssue | v.UnionIssue<v.StringIssue | v.MinLengthIssue<string, 1> | v.StrictObjectIssue | v.PicklistIssue> | v.NeverIssue | v.MaxValueIssue<number, 1000> | v.UnionIssue<v.NumberIssue | v.BooleanIssue | v.IntegerIssue<number> | v.MinValueIssue<number, 1> | v.MaxValueIssue<number, 4294967295> | v.StringIssue | v.MinLengthIssue<string, 1> | v.CheckIssue<bigint> | v.StrictObjectIssue | v.PicklistIssue | v.UnionIssue<v.StringIssue | v.MinLengthIssue<string, 1> | v.StrictObjectIssue | v.PicklistIssue> | v.NeverIssue | v.MaxValueIssue<number, 1000>> | v.CheckIssue<number> | v.UnionIssue<v.NumberIssue | v.BooleanIssue | v.IntegerIssue<number> | v.MinValueIssue<number, 1> | v.MaxValueIssue<number, 4294967295> | v.StringIssue | v.MinLengthIssue<string, 1> | v.CheckIssue<bigint> | v.StrictObjectIssue | v.PicklistIssue | v.UnionIssue<v.StringIssue | v.MinLengthIssue<string, 1> | v.StrictObjectIssue | v.PicklistIssue> | v.NeverIssue | v.MaxValueIssue<number, 1000> | v.CheckIssue<number>>>) => "symbolId is required when afterMatchId is set" | "Provide at most one of orderId or lineageId" | "throughGeneration requires lineageId">, v.TransformAction<{
|
|
172
172
|
symbolId?: number | undefined;
|
|
173
173
|
afterMatchId?: undefined;
|
|
174
174
|
side?: Side.BUY | Side.SELL | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TradingWithdrawAction, WithdrawDestinationValidationCode } from "../../gen/chain/withdraw/v1/withdraw_pb.js";
|
|
2
|
-
import { SdkScales } from "../../shared/decimal-surface.js";
|
|
3
2
|
import { U128Value } from "../../utils/u128.js";
|
|
3
|
+
import { SdkScales } from "../../shared/decimal-surface.js";
|
|
4
4
|
import * as v from "valibot";
|
|
5
5
|
//#region src/services/trading-withdraws/trading-withdraws.schemas.d.ts
|
|
6
6
|
type TradingWithdrawIntentPayloadRequest = {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { parse } from "../../shared/validation.js";
|
|
2
2
|
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
3
3
|
import { deliverBatch } from "../../shared/subscription-errors.js";
|
|
4
|
-
import { resolveAccountScopedInput } from "../subaccount-resolver.js";
|
|
5
4
|
import { LedgerReadService, TransferRowBatchSchema } from "../../gen/ledger/read/v1/ledger_read_pb.js";
|
|
5
|
+
import { resolveAccountScopedInput } from "../subaccount-resolver.js";
|
|
6
6
|
import { LedgerTransferSchema, ListTransfersInputSchema } from "./transfers.schemas.js";
|
|
7
7
|
import { createClient } from "@connectrpc/connect";
|
|
8
8
|
import * as v from "valibot";
|