@polyester/sdk 0.35.0-devnet-20261111161451 → 0.35.0

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/dist/services/accounts/accounts.d.ts +1 -1
  3. package/dist/services/accounts/accounts.js +1 -1
  4. package/dist/services/accounts/accounts.js.map +1 -1
  5. package/dist/services/api-keys/api-keys.d.ts +2 -2
  6. package/dist/services/api-keys/api-keys.js +2 -2
  7. package/dist/services/api-keys/api-keys.js.map +1 -1
  8. package/dist/services/assistant/assistant-events.schemas.d.ts +129 -101
  9. package/dist/services/assistant/assistant-events.schemas.d.ts.map +1 -1
  10. package/dist/services/auth/profile/profile.d.ts +2 -2
  11. package/dist/services/auth/profile/profile.js +2 -2
  12. package/dist/services/auth/profile/profile.js.map +1 -1
  13. package/dist/services/balances/balances.schemas.d.ts +3 -3
  14. package/dist/services/candles/candles.schemas.d.ts +10 -10
  15. package/dist/services/changelog/changelog.schemas.d.ts +17 -17
  16. package/dist/services/checkpoints/checkpoints.d.ts +2 -2
  17. package/dist/services/checkpoints/checkpoints.js +2 -2
  18. package/dist/services/checkpoints/checkpoints.js.map +1 -1
  19. package/dist/services/checkpoints/checkpoints.schemas.d.ts +1 -1
  20. package/dist/services/deposit/deposit.d.ts +2 -2
  21. package/dist/services/deposit/deposit.js +2 -2
  22. package/dist/services/deposit/deposit.js.map +1 -1
  23. package/dist/services/guard-signer/guard-signer.d.ts +1 -1
  24. package/dist/services/guard-signer/guard-signer.js +1 -1
  25. package/dist/services/guard-signer/guard-signer.js.map +1 -1
  26. package/dist/services/heatmap/heatmap.schemas.d.ts +13 -13
  27. package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +3 -3
  28. package/dist/services/lifecycle/lifecycle.schemas.d.ts +148 -148
  29. package/dist/services/market-overview/market-overview.schemas.d.ts +3 -3
  30. package/dist/services/orderbook/orderbook.schemas.d.ts +1 -1
  31. package/dist/services/orders/orders-batch.schemas.d.ts +19 -19
  32. package/dist/services/orders/orders-input.schemas.d.ts +1 -1
  33. package/dist/services/orders/orders-output.schemas.d.ts +22 -22
  34. package/dist/services/policies/api-key-policies/api-key-policies.d.ts +2 -2
  35. package/dist/services/policies/api-key-policies/api-key-policies.js +2 -2
  36. package/dist/services/policies/api-key-policies/api-key-policies.js.map +1 -1
  37. package/dist/services/policies/subaccount-policies/subaccount-policies.d.ts +2 -2
  38. package/dist/services/policies/subaccount-policies/subaccount-policies.js +2 -2
  39. package/dist/services/policies/subaccount-policies/subaccount-policies.js.map +1 -1
  40. package/dist/services/rewards/rewards.schemas.d.ts +4 -4
  41. package/dist/services/social-verification/social-verification.d.ts +1 -1
  42. package/dist/services/social-verification/social-verification.js +1 -1
  43. package/dist/services/social-verification/social-verification.js.map +1 -1
  44. package/dist/services/subaccounts/subaccounts.d.ts +6 -6
  45. package/dist/services/subaccounts/subaccounts.js +6 -6
  46. package/dist/services/subaccounts/subaccounts.js.map +1 -1
  47. package/dist/services/subaccounts/subaccounts.schemas.d.ts +12 -12
  48. package/dist/services/trades/trades.schemas.d.ts +1 -1
  49. package/dist/services/trading-withdraws/trading-withdraws.d.ts +1 -1
  50. package/dist/services/trading-withdraws/trading-withdraws.js +1 -1
  51. package/dist/services/trading-withdraws/trading-withdraws.js.map +1 -1
  52. package/dist/services/transfers/transfers.schemas.d.ts +1 -1
  53. package/dist/services/triggers/trigger-input.schemas.d.ts +2 -2
  54. package/dist/services/triggers/triggers-output.schemas.d.ts +37 -37
  55. package/dist/services/vip/vip.d.ts +1 -1
  56. package/dist/services/vip/vip.js +1 -1
  57. package/dist/services/vip/vip.js.map +1 -1
  58. package/dist/services/vip/vip.schemas.d.ts +3 -3
  59. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"social-verification.js","names":["#client","Proto.SocialVerificationService"],"sources":["../../../src/services/social-verification/social-verification.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/auth/v1/social_verification_pb.js\";\nimport type * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport {\n ConfirmVerificationInputSchema,\n UnlinkSocialAccountInputSchema,\n StartVerificationInputSchema,\n StartVerificationResponseSchema,\n VerificationReadyResponseSchema,\n GetVerificationResponseSchema,\n SocialProviderInputSchema,\n type ConfirmVerificationInput,\n type UnlinkSocialAccountInput,\n type StartVerificationInput,\n type StartVerificationResponse,\n type VerificationReadyResponse,\n type GetVerificationResponse,\n} from \"./social-verification.schemas.js\";\n\n/**\n * Verifies ownership of external social accounts for the authenticated caller.\n */\nexport class SocialVerificationService {\n #client: Client<typeof Proto.SocialVerificationService>;\n\n constructor(transports: AuthApiTransports) {\n this.#client = createClient(Proto.SocialVerificationService, transports.authApi);\n }\n\n /**\n * Starts or restarts provider verification. Twitter requires a handle and strips a leading @; Discord and Telegram get their identity from the provider bot. An omitted method uses the provider default (Twitter profile, Discord channel, Telegram dm). Discord and Telegram return an empty challengeCode when no new challenge is issued. For Telegram, open `actionUrl` to send the code to the Polyester bot, poll `get` until `awaiting_confirmation`, then `confirm`; while a Telegram account is linked, starting again throws until it is unlinked.\n */\n async start(\n input: StartVerificationInput,\n options?: PolyesterMutationOptions,\n ): Promise<StartVerificationResponse> {\n const validated = parse(StartVerificationInputSchema, input);\n const res = await this.#client.startSocialVerification(\n validated,\n toConnectCallOptions(options),\n );\n return parse(StartVerificationResponseSchema, res);\n }\n\n /**\n * Queues a provider check after the caller has placed the challenge code according to the selected verification method. Not used for Telegram, which links through `confirm`.\n */\n async markReady(\n input: v.InferInput<typeof SocialProviderInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<VerificationReadyResponse> {\n const validated = parse(SocialProviderInputSchema, input);\n const res = await this.#client.socialVerificationReady(\n validated,\n toConnectCallOptions(options),\n );\n return parse(VerificationReadyResponseSchema, res);\n }\n\n /**\n * Returns the caller's current verification state for a provider, including status, challenge metadata, attempts, last error, and verified timestamp.\n */\n async get(\n input: v.InferInput<typeof SocialProviderInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<GetVerificationResponse> {\n const validated = parse(SocialProviderInputSchema, input);\n const res = await this.#client.getSocialVerification(\n validated,\n toConnectCallOptions(options),\n );\n return parse(GetVerificationResponseSchema, res);\n }\n\n /**\n * Links the Telegram account that sent the challenge code. Pass the `providerUserId` shown\n * while the verification is `awaiting_confirmation`, so the user links exactly the account\n * they were shown. Requires enrolled MFA and a fresh `stepUpToken`; a retried confirmation of\n * an existing link needs no new token. A mismatched ID or no account awaiting confirmation\n * fails with `social_verification_invalid_state`; a Telegram account linked elsewhere fails\n * the verification with `social_account_already_linked`.\n */\n async confirm(\n input: ConfirmVerificationInput,\n options?: PolyesterMutationOptions,\n ): Promise<GetVerificationResponse> {\n const validated = parse(ConfirmVerificationInputSchema, input);\n const res = await this.#client.confirmSocialVerification(\n validated,\n toConnectCallOptions(options),\n );\n return parse(GetVerificationResponseSchema, res);\n }\n\n /**\n * Unlinks the Telegram account, or cancels a link in progress, and returns the `canceled`\n * verification (absent if none was ever started). Repeating it changes nothing; start a new\n * verification to link again.\n */\n async unlink(\n input: UnlinkSocialAccountInput,\n options?: PolyesterMutationOptions,\n ): Promise<GetVerificationResponse> {\n const validated = parse(UnlinkSocialAccountInputSchema, input);\n const res = await this.#client.unlinkSocialAccount(\n validated,\n toConnectCallOptions(options),\n );\n return parse(GetVerificationResponseSchema, res);\n }\n}\n"],"mappings":";;;;;;;;;AA6BA,IAAa,4BAAb,MAAuC;CACnC;CAEA,YAAY,YAA+B;EACvC,KAAKA,UAAU,aAAaC,6BAAiC,WAAW,OAAO;CACnF;;;;CAKA,MAAM,MACF,OACA,SACkC;EAClC,MAAM,YAAY,MAAM,8BAA8B,KAAK;EAC3D,MAAM,MAAM,MAAM,KAAKD,QAAQ,wBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,iCAAiC,GAAG;CACrD;;;;CAKA,MAAM,UACF,OACA,SACkC;EAClC,MAAM,YAAY,MAAM,2BAA2B,KAAK;EACxD,MAAM,MAAM,MAAM,KAAKA,QAAQ,wBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,iCAAiC,GAAG;CACrD;;;;CAKA,MAAM,IACF,OACA,SACgC;EAChC,MAAM,YAAY,MAAM,2BAA2B,KAAK;EACxD,MAAM,MAAM,MAAM,KAAKA,QAAQ,sBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;;;;;;;;;CAUA,MAAM,QACF,OACA,SACgC;EAChC,MAAM,YAAY,MAAM,gCAAgC,KAAK;EAC7D,MAAM,MAAM,MAAM,KAAKA,QAAQ,0BAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;;;;;;CAOA,MAAM,OACF,OACA,SACgC;EAChC,MAAM,YAAY,MAAM,gCAAgC,KAAK;EAC7D,MAAM,MAAM,MAAM,KAAKA,QAAQ,oBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;AACJ"}
1
+ {"version":3,"file":"social-verification.js","names":["#client","Proto.SocialVerificationService"],"sources":["../../../src/services/social-verification/social-verification.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/auth/v1/social_verification_pb.js\";\nimport type * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport {\n ConfirmVerificationInputSchema,\n UnlinkSocialAccountInputSchema,\n StartVerificationInputSchema,\n StartVerificationResponseSchema,\n VerificationReadyResponseSchema,\n GetVerificationResponseSchema,\n SocialProviderInputSchema,\n type ConfirmVerificationInput,\n type UnlinkSocialAccountInput,\n type StartVerificationInput,\n type StartVerificationResponse,\n type VerificationReadyResponse,\n type GetVerificationResponse,\n} from \"./social-verification.schemas.js\";\n\n/**\n * Verifies ownership of external social accounts for the authenticated caller.\n */\nexport class SocialVerificationService {\n #client: Client<typeof Proto.SocialVerificationService>;\n\n constructor(transports: AuthApiTransports) {\n this.#client = createClient(Proto.SocialVerificationService, transports.authApi);\n }\n\n /**\n * Starts or restarts provider verification. Twitter requires a handle and strips a leading @; Discord and Telegram get their identity from the provider bot. An omitted method uses the provider default (Twitter profile, Discord channel, Telegram dm). Discord and Telegram return an empty challengeCode when no new challenge is issued. For Telegram, open `actionUrl` to send the code to the Polyester bot, poll `get` until `awaiting_confirmation`, then `confirm`; while a Telegram account is linked, starting again throws until it is unlinked.\n */\n async start(\n input: StartVerificationInput,\n options?: PolyesterMutationOptions,\n ): Promise<StartVerificationResponse> {\n const validated = parse(StartVerificationInputSchema, input);\n const res = await this.#client.startSocialVerification(\n validated,\n toConnectCallOptions(options),\n );\n return parse(StartVerificationResponseSchema, res);\n }\n\n /**\n * Queues a provider check after the caller has placed the challenge code according to the selected verification method. Not used for Telegram, which links through `confirm`.\n */\n async markReady(\n input: v.InferInput<typeof SocialProviderInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<VerificationReadyResponse> {\n const validated = parse(SocialProviderInputSchema, input);\n const res = await this.#client.socialVerificationReady(\n validated,\n toConnectCallOptions(options),\n );\n return parse(VerificationReadyResponseSchema, res);\n }\n\n /**\n * Returns the caller's current verification state for a provider, including status, challenge metadata, attempts, last error, and verified timestamp. API keys need `read-social-verification` and must be scoped to the main account.\n */\n async get(\n input: v.InferInput<typeof SocialProviderInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<GetVerificationResponse> {\n const validated = parse(SocialProviderInputSchema, input);\n const res = await this.#client.getSocialVerification(\n validated,\n toConnectCallOptions(options),\n );\n return parse(GetVerificationResponseSchema, res);\n }\n\n /**\n * Links the Telegram account that sent the challenge code. Pass the `providerUserId` shown\n * while the verification is `awaiting_confirmation`, so the user links exactly the account\n * they were shown. Requires enrolled MFA and a fresh `stepUpToken`; a retried confirmation of\n * an existing link needs no new token. A mismatched ID or no account awaiting confirmation\n * fails with `social_verification_invalid_state`; a Telegram account linked elsewhere fails\n * the verification with `social_account_already_linked`.\n */\n async confirm(\n input: ConfirmVerificationInput,\n options?: PolyesterMutationOptions,\n ): Promise<GetVerificationResponse> {\n const validated = parse(ConfirmVerificationInputSchema, input);\n const res = await this.#client.confirmSocialVerification(\n validated,\n toConnectCallOptions(options),\n );\n return parse(GetVerificationResponseSchema, res);\n }\n\n /**\n * Unlinks the Telegram account, or cancels a link in progress, and returns the `canceled`\n * verification (absent if none was ever started). Repeating it changes nothing; start a new\n * verification to link again.\n */\n async unlink(\n input: UnlinkSocialAccountInput,\n options?: PolyesterMutationOptions,\n ): Promise<GetVerificationResponse> {\n const validated = parse(UnlinkSocialAccountInputSchema, input);\n const res = await this.#client.unlinkSocialAccount(\n validated,\n toConnectCallOptions(options),\n );\n return parse(GetVerificationResponseSchema, res);\n }\n}\n"],"mappings":";;;;;;;;;AA6BA,IAAa,4BAAb,MAAuC;CACnC;CAEA,YAAY,YAA+B;EACvC,KAAKA,UAAU,aAAaC,6BAAiC,WAAW,OAAO;CACnF;;;;CAKA,MAAM,MACF,OACA,SACkC;EAClC,MAAM,YAAY,MAAM,8BAA8B,KAAK;EAC3D,MAAM,MAAM,MAAM,KAAKD,QAAQ,wBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,iCAAiC,GAAG;CACrD;;;;CAKA,MAAM,UACF,OACA,SACkC;EAClC,MAAM,YAAY,MAAM,2BAA2B,KAAK;EACxD,MAAM,MAAM,MAAM,KAAKA,QAAQ,wBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,iCAAiC,GAAG;CACrD;;;;CAKA,MAAM,IACF,OACA,SACgC;EAChC,MAAM,YAAY,MAAM,2BAA2B,KAAK;EACxD,MAAM,MAAM,MAAM,KAAKA,QAAQ,sBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;;;;;;;;;CAUA,MAAM,QACF,OACA,SACgC;EAChC,MAAM,YAAY,MAAM,gCAAgC,KAAK;EAC7D,MAAM,MAAM,MAAM,KAAKA,QAAQ,0BAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;;;;;;CAOA,MAAM,OACF,OACA,SACgC;EAChC,MAAM,YAAY,MAAM,gCAAgC,KAAK;EAC7D,MAAM,MAAM,MAAM,KAAKA,QAAQ,oBAC3B,WACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,+BAA+B,GAAG;CACnD;AACJ"}
@@ -27,14 +27,14 @@ declare class SubaccountsService {
27
27
  readonly policies: SubaccountPoliciesService;
28
28
  constructor(transports: AuthAndPublicApiTransports, realtime: PolyesterRealtime, resolver?: SubaccountResolver);
29
29
  /**
30
- * 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.
30
+ * Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted ones. Use `createChallenge` for the canonical next smart-account address and salt. API keys need `read-subaccounts` and see only the subaccounts within their scope.
31
31
  */
32
32
  list(options?: PolyesterRequestOptions): Promise<{
33
33
  totalCreated: number;
34
34
  subaccounts: v.InferOutput<typeof SubaccountSchema>[];
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
+ * Fetches an aggregated subaccount dashboard view with subaccount details, policy, API keys, members, and outgoing invites; throws if the subaccount is missing. API keys need `read-subaccounts`.
38
38
  *
39
39
  * `includeBalances: true` also returns the sub-account's current `balances`, in the shape of
40
40
  * `balances.list`. It needs the READ_BALANCES action on the sub-account (its role, any attached
@@ -81,7 +81,7 @@ declare class SubaccountsService {
81
81
  setMemberMfaRequirement(input: v.InferInput<typeof SetSubaccountMemberMfaRequirementInputSchema>, options?: PolyesterMutationOptions): Promise<SubaccountMutationResult>;
82
82
  /**
83
83
  * Returns the caller's subaccount invitations, newest first. Omit `direction` to include both
84
- * incoming and outgoing invitations, or pass `"incoming"` or `"outgoing"` to filter.
84
+ * incoming and outgoing invitations, or pass `"incoming"` or `"outgoing"` to filter. API keys need `read-subaccount-invites` and see only outgoing invitations.
85
85
  */
86
86
  listInvites(input: v.InferInput<typeof ListSubaccountInvitesInputSchema>, options?: PolyesterRequestOptions): Promise<SubaccountInvite[]>;
87
87
  /**
@@ -89,11 +89,11 @@ declare class SubaccountsService {
89
89
  */
90
90
  listRoles(options?: PolyesterRequestOptions): Promise<SubaccountRoleCatalog>;
91
91
  /**
92
- * Returns the caller's current role, effective role-granted permissions, and attached policy ID for a subaccount.
92
+ * Returns the caller's current role, effective role-granted permissions, and attached policy ID for a subaccount. API keys need `read-subaccount-permissions` and get what the key itself may do.
93
93
  */
94
94
  getEffectivePermissions(input: v.InferInput<typeof SubaccountIdInputSchema>, options?: PolyesterRequestOptions): Promise<EffectiveSubaccountPermissions>;
95
95
  /**
96
- * Returns the owner and delegated members for a subaccount, including role and MFA enrollment status.
96
+ * Returns the owner and delegated members for a subaccount, including role and MFA enrollment status. API keys need `read-subaccount-members`.
97
97
  */
98
98
  listMembers(input: v.InferInput<typeof SubaccountIdInputSchema>, options?: PolyesterRequestOptions): Promise<SubaccountMember[]>;
99
99
  /**
@@ -101,7 +101,7 @@ declare class SubaccountsService {
101
101
  */
102
102
  respondInvite(input: v.InferInput<typeof RespondSubaccountInviteInputSchema>, options?: PolyesterMutationOptions): Promise<SubaccountInvite>;
103
103
  /**
104
- * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination.
104
+ * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination. API keys need `read-subaccount-activity`.
105
105
  */
106
106
  listEvents(input: v.InferInput<typeof SubaccountActivityInputSchema>, options?: PolyesterRequestOptions): Promise<{
107
107
  events: SubaccountEvent[];
@@ -30,7 +30,7 @@ var SubaccountsService = class {
30
30
  this.#realtime = realtime;
31
31
  }
32
32
  /**
33
- * 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.
33
+ * Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted ones. Use `createChallenge` for the canonical next smart-account address and salt. API keys need `read-subaccounts` and see only the subaccounts within their scope.
34
34
  */
35
35
  async list(options) {
36
36
  const res = await this.#client.listSubaccounts({}, toConnectCallOptions(options));
@@ -40,7 +40,7 @@ var SubaccountsService = class {
40
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.
43
+ * Fetches an aggregated subaccount dashboard view with subaccount details, policy, API keys, members, and outgoing invites; throws if the subaccount is missing. API keys need `read-subaccounts`.
44
44
  *
45
45
  * `includeBalances: true` also returns the sub-account's current `balances`, in the shape of
46
46
  * `balances.list`. It needs the READ_BALANCES action on the sub-account (its role, any attached
@@ -132,7 +132,7 @@ var SubaccountsService = class {
132
132
  }
133
133
  /**
134
134
  * Returns the caller's subaccount invitations, newest first. Omit `direction` to include both
135
- * incoming and outgoing invitations, or pass `"incoming"` or `"outgoing"` to filter.
135
+ * incoming and outgoing invitations, or pass `"incoming"` or `"outgoing"` to filter. API keys need `read-subaccount-invites` and see only outgoing invitations.
136
136
  */
137
137
  async listInvites(input, options) {
138
138
  const validatedInput = parse(ListSubaccountInvitesInputSchema, input);
@@ -147,7 +147,7 @@ var SubaccountsService = class {
147
147
  return parse(SubaccountRoleCatalogSchema, res);
148
148
  }
149
149
  /**
150
- * Returns the caller's current role, effective role-granted permissions, and attached policy ID for a subaccount.
150
+ * Returns the caller's current role, effective role-granted permissions, and attached policy ID for a subaccount. API keys need `read-subaccount-permissions` and get what the key itself may do.
151
151
  */
152
152
  async getEffectivePermissions(input, options) {
153
153
  const validatedInput = parse(SubaccountIdInputSchema, input);
@@ -155,7 +155,7 @@ var SubaccountsService = class {
155
155
  return parse(EffectiveSubaccountPermissionsSchema, res);
156
156
  }
157
157
  /**
158
- * Returns the owner and delegated members for a subaccount, including role and MFA enrollment status.
158
+ * Returns the owner and delegated members for a subaccount, including role and MFA enrollment status. API keys need `read-subaccount-members`.
159
159
  */
160
160
  async listMembers(input, options) {
161
161
  const validatedInput = parse(SubaccountIdInputSchema, input);
@@ -171,7 +171,7 @@ var SubaccountsService = class {
171
171
  return parse(SubaccountInviteSchema, res.invite);
172
172
  }
173
173
  /**
174
- * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination.
174
+ * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination. API keys need `read-subaccount-activity`.
175
175
  */
176
176
  async listEvents(input, options) {
177
177
  const validatedInput = parse(SubaccountActivityInputSchema, input);
@@ -1 +1 @@
1
- {"version":3,"file":"subaccounts.js","names":["#client","Proto.SubaccountService","#viewClient","Proto.SubaccountViewService","#publicRoleClient","Proto.SubaccountRoleService","#authRoleClient","#realtime","SubaccountSchema","ApiKeySchema","Proto.SubaccountSchema","ProtoApiKeys.ApiKeySchema"],"sources":["../../../src/services/subaccounts/subaccounts.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport * as ProtoApiKeys from \"../../gen/auth/v1/api_keys_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { type ApiKey, ApiKeySchema } from \"../api-keys/index.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport {\n DEFAULT_SUBACCOUNT_POLICY,\n SubaccountPoliciesService,\n type SubaccountPolicy,\n SubaccountPolicySchema,\n} from \"../policies/subaccount-policies/index.js\";\nimport { createLedgerBalanceSchema, type LedgerBalance } from \"../balances/balances.schemas.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport type { SubaccountResolver } from \"../subaccount-resolver.js\";\nimport {\n CreateSubaccountChallengeInputSchema,\n CreateSubaccountInputSchema,\n CreateSubaccountResultSchema,\n SubaccountChallengeSchema,\n UpdateSubaccountInputSchema,\n InviteSubaccountMemberInputSchema,\n RemoveSubaccountMemberInputSchema,\n UpdateSubaccountMemberRoleInputSchema,\n ListSubaccountInvitesInputSchema,\n RespondSubaccountInviteInputSchema,\n SubaccountActivityInputSchema,\n SubaccountSchema,\n SubaccountMemberSchema,\n SubaccountInviteSchema,\n SubaccountActivityEventSchema,\n SetSubaccountMemberMfaRequirementInputSchema,\n SubaccountIdInputSchema,\n GetSubaccountInputSchema,\n SubaccountMutationResultSchema,\n SubaccountRoleCatalogSchema,\n EffectiveSubaccountPermissionsSchema,\n type CreateSubaccountResult,\n type SubaccountChallenge,\n type Subaccount,\n type SubaccountMember,\n type SubaccountInvite,\n type SubaccountEvent,\n type SubaccountMutationResult,\n type SubaccountRoleCatalog,\n type EffectiveSubaccountPermissions,\n} from \"./subaccounts.schemas.js\";\n\ninterface SubscribeSubaccountsInput extends BaseSubscribeInput<Subaccount> {\n accountId: string;\n}\n\ninterface SubscribeApiKeysInput extends BaseSubscribeInput<ApiKey> {\n accountId: string;\n}\n\n/**\n * Reads the public role catalog and creates, manages, shares, audits, and subscribes to subaccounts visible to the authenticated caller.\n */\nexport class SubaccountsService {\n readonly policies: SubaccountPoliciesService;\n\n #client: Client<typeof Proto.SubaccountService>;\n #viewClient: Client<typeof Proto.SubaccountViewService>;\n #publicRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #authRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #realtime: PolyesterRealtime;\n\n constructor(\n transports: AuthAndPublicApiTransports,\n realtime: PolyesterRealtime,\n resolver?: SubaccountResolver,\n ) {\n this.policies = new SubaccountPoliciesService(transports, realtime, resolver);\n this.#client = createClient(Proto.SubaccountService, transports.authApi);\n this.#viewClient = createClient(Proto.SubaccountViewService, transports.authApi);\n this.#publicRoleClient = createClient(Proto.SubaccountRoleService, transports.publicApi);\n this.#authRoleClient = createClient(Proto.SubaccountRoleService, transports.authApi);\n this.#realtime = realtime;\n }\n\n /**\n * Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted ones. Use `createChallenge` for the canonical next smart-account address and salt.\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. A record with `removed: true` means the caller lost access to that subaccount; remove it locally. Losing access also ends the caller's subscriptions to that subaccount's channels.\n */\n subscribe(input: SubscribeSubaccountsInput) {\n const channel = `private:auth:subaccounts:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: Proto.SubaccountSchema,\n onPublication: (data) => {\n const subaccount = parse(SubaccountSchema, data);\n input.onEvent(subaccount);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n\n /**\n * Subscribes to private API key updates for an account through the subaccount realtime channel helper.\n */\n subscribeApiKeys(input: SubscribeApiKeysInput) {\n const channel = `private:auth:api-keys:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: ProtoApiKeys.ApiKeySchema,\n onPublication: (data) => {\n const apiKey = parse(ApiKeySchema, data);\n input.onEvent(apiKey);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });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B;EACzB,MAAM,iBAAiB,MAAM,oCAAoC,KAAK;EACtE,MAAM,MAAM,MAAM,KAAKA,QAAQ,wBAC3B,gBACA,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,wBAAwB,IAAI,MAAM;CACnD;;;;CAKA,MAAM,WACF,OACA,SAC6D;EAC7D,MAAM,iBAAiB,MAAM,+BAA+B,KAAK;EACjE,MAAM,MAAM,MAAM,KAAKE,YAAY,uBAC/B,gBACA,qBAAqB,OAAO,CAChC;EACA,OAAO;GACH,QAAQ,MAAM,EAAE,SAAS,EAAE,MAAM,6BAA6B,GAAG,CAAC,CAAC,GAAG,IAAI,MAAM;GAChF,eAAe,IAAI;EACvB;CACJ;;;;CAKA,UAAU,OAAkC;EACxC,MAAM,UAAU,4BAA4B,MAAM,UAAU;EAE5D,OAAO,KAAKK,UAAU,oBAAoB;GACtC;GACA,QAAQG;GACR,gBAAgB,SAAS;IACrB,MAAM,aAAa,MAAMF,oBAAkB,IAAI;IAC/C,MAAM,QAAQ,UAAU;GAC5B;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;;;;CAKA,iBAAiB,OAA8B;EAC3C,MAAM,UAAU,yBAAyB,MAAM,UAAU;EAEzD,OAAO,KAAKD,UAAU,oBAAoB;GACtC;GACA,QAAQI;GACR,gBAAgB,SAAS;IACrB,MAAM,SAAS,MAAMF,gBAAc,IAAI;IACvC,MAAM,QAAQ,MAAM;GACxB;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
1
+ {"version":3,"file":"subaccounts.js","names":["#client","Proto.SubaccountService","#viewClient","Proto.SubaccountViewService","#publicRoleClient","Proto.SubaccountRoleService","#authRoleClient","#realtime","SubaccountSchema","ApiKeySchema","Proto.SubaccountSchema","ProtoApiKeys.ApiKeySchema"],"sources":["../../../src/services/subaccounts/subaccounts.ts"],"sourcesContent":["import * as Proto from \"../../gen/auth/v1/subaccounts_pb.js\";\nimport * as ProtoApiKeys from \"../../gen/auth/v1/api_keys_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { type ApiKey, ApiKeySchema } from \"../api-keys/index.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport {\n DEFAULT_SUBACCOUNT_POLICY,\n SubaccountPoliciesService,\n type SubaccountPolicy,\n SubaccountPolicySchema,\n} from \"../policies/subaccount-policies/index.js\";\nimport { createLedgerBalanceSchema, type LedgerBalance } from \"../balances/balances.schemas.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport type { SubaccountResolver } from \"../subaccount-resolver.js\";\nimport {\n CreateSubaccountChallengeInputSchema,\n CreateSubaccountInputSchema,\n CreateSubaccountResultSchema,\n SubaccountChallengeSchema,\n UpdateSubaccountInputSchema,\n InviteSubaccountMemberInputSchema,\n RemoveSubaccountMemberInputSchema,\n UpdateSubaccountMemberRoleInputSchema,\n ListSubaccountInvitesInputSchema,\n RespondSubaccountInviteInputSchema,\n SubaccountActivityInputSchema,\n SubaccountSchema,\n SubaccountMemberSchema,\n SubaccountInviteSchema,\n SubaccountActivityEventSchema,\n SetSubaccountMemberMfaRequirementInputSchema,\n SubaccountIdInputSchema,\n GetSubaccountInputSchema,\n SubaccountMutationResultSchema,\n SubaccountRoleCatalogSchema,\n EffectiveSubaccountPermissionsSchema,\n type CreateSubaccountResult,\n type SubaccountChallenge,\n type Subaccount,\n type SubaccountMember,\n type SubaccountInvite,\n type SubaccountEvent,\n type SubaccountMutationResult,\n type SubaccountRoleCatalog,\n type EffectiveSubaccountPermissions,\n} from \"./subaccounts.schemas.js\";\n\ninterface SubscribeSubaccountsInput extends BaseSubscribeInput<Subaccount> {\n accountId: string;\n}\n\ninterface SubscribeApiKeysInput extends BaseSubscribeInput<ApiKey> {\n accountId: string;\n}\n\n/**\n * Reads the public role catalog and creates, manages, shares, audits, and subscribes to subaccounts visible to the authenticated caller.\n */\nexport class SubaccountsService {\n readonly policies: SubaccountPoliciesService;\n\n #client: Client<typeof Proto.SubaccountService>;\n #viewClient: Client<typeof Proto.SubaccountViewService>;\n #publicRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #authRoleClient: Client<typeof Proto.SubaccountRoleService>;\n #realtime: PolyesterRealtime;\n\n constructor(\n transports: AuthAndPublicApiTransports,\n realtime: PolyesterRealtime,\n resolver?: SubaccountResolver,\n ) {\n this.policies = new SubaccountPoliciesService(transports, realtime, resolver);\n this.#client = createClient(Proto.SubaccountService, transports.authApi);\n this.#viewClient = createClient(Proto.SubaccountViewService, transports.authApi);\n this.#publicRoleClient = createClient(Proto.SubaccountRoleService, transports.publicApi);\n this.#authRoleClient = createClient(Proto.SubaccountRoleService, transports.authApi);\n this.#realtime = realtime;\n }\n\n /**\n * Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted ones. Use `createChallenge` for the canonical next smart-account address and salt. API keys need `read-subaccounts` and see only the subaccounts within their scope.\n */\n async list(options?: PolyesterRequestOptions): Promise<{\n totalCreated: number;\n subaccounts: v.InferOutput<typeof SubaccountSchema>[];\n }> {\n const res = await this.#client.listSubaccounts({}, toConnectCallOptions(options));\n return {\n totalCreated: res.totalCreated,\n subaccounts: parse(v.array(SubaccountSchema), res.subaccounts),\n };\n }\n\n /**\n * Fetches an aggregated subaccount dashboard view with subaccount details, policy, API keys, members, and outgoing invites; throws if the subaccount is missing. API keys need `read-subaccounts`.\n *\n * `includeBalances: true` also returns the sub-account's current `balances`, in the shape of\n * `balances.list`. It needs the READ_BALANCES action on the sub-account (its role, any attached\n * policy and, for an API key, the key's policy), or the call fails with PermissionDenied. When\n * balances cannot be read right now the call fails with the retryable\n * `AUTH_TEMPORARILY_UNAVAILABLE`; retry the same call.\n */\n async get(\n input: v.InferInput<typeof GetSubaccountInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<\n Subaccount & {\n apiKeys: ApiKey[];\n policy: SubaccountPolicy;\n members: SubaccountMember[];\n invites: SubaccountInvite[];\n balances?: LedgerBalance[];\n }\n > {\n const validatedInput = parse(GetSubaccountInputSchema, input);\n const subaccountId = formatId(validatedInput.subaccountId);\n const includeBalances = validatedInput.includeBalances === true;\n const res = await this.#viewClient.getSubaccount(\n {\n subaccountId: validatedInput.subaccountId,\n includeApiKeys: true,\n includeMembers: true,\n includeInvites: true,\n includePolicy: true,\n invitesDirection: Proto.SubaccountInviteDirection.OUTGOING,\n ...(includeBalances && { includeBalances }),\n },\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(`Subaccount not found: ${subaccountId}`);\n\n return {\n ...parse(SubaccountSchema, res.subaccount),\n policy: res.policy\n ? parse(SubaccountPolicySchema, res.policy)\n : DEFAULT_SUBACCOUNT_POLICY,\n apiKeys: parse(v.optional(v.array(ApiKeySchema), []), res.apiKeys),\n members: parse(v.optional(v.array(SubaccountMemberSchema), []), res.members),\n invites: v\n .parse(v.optional(v.array(SubaccountInviteSchema), []), res.invites)\n .filter((invite) => invite.subaccountId === subaccountId),\n ...(includeBalances && {\n balances: parse(v.array(createLedgerBalanceSchema()), res.balances?.balances ?? []),\n }),\n };\n }\n\n /**\n * Requests the canonical next smart account and a short-lived EIP-191 authorization message\n * bound to the authenticated root and the selected owner EOA. Sign the exact message through\n * the returned smart account, then pass it to `create`. A new challenge replaces the previous one.\n */\n async createChallenge(\n input: v.InferInput<typeof CreateSubaccountChallengeInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountChallenge> {\n const validatedInput = parse(CreateSubaccountChallengeInputSchema, input);\n const res = await this.#client.createSubaccountChallenge(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountChallengeSchema, res);\n }\n\n /**\n * Creates a new subaccount under the caller's root account using the smart-account address, message, and smart-account signature from `createChallenge`.\n */\n async create(\n input: v.InferInput<typeof CreateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<CreateSubaccountResult> {\n const validatedInput = parse(CreateSubaccountInputSchema, input);\n const res = await this.#client.createSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(CreateSubaccountResultSchema, res);\n }\n\n /**\n * Updates mutable subaccount display/status fields such as label and active/disabled status.\n */\n async update(\n input: v.InferInput<typeof UpdateSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<Subaccount> {\n const validatedInput = parse(UpdateSubaccountInputSchema, input);\n const res = await this.#client.updateSubaccount(\n validatedInput,\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(\"Failed to update subaccount\");\n return parse(SubaccountSchema, res.subaccount);\n }\n\n /**\n * Creates or refreshes a pending invitation granting a role on a subaccount to another root account.\n */\n async inviteMember(\n input: v.InferInput<typeof InviteSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(InviteSubaccountMemberInputSchema, input);\n const res = await this.#client.inviteSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Removes delegated access for a subaccount member by grantee account ID.\n */\n async removeMember(\n input: v.InferInput<typeof RemoveSubaccountMemberInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(RemoveSubaccountMemberInputSchema, input);\n const res = await this.#client.removeSubaccountMember(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Changes an existing delegated member's role without sending a new invitation.\n */\n async updateMemberRole(\n input: v.InferInput<typeof UpdateSubaccountMemberRoleInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(UpdateSubaccountMemberRoleInputSchema, input);\n const res = await this.#client.updateSubaccountMemberRole(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Enables or disables the owner-controlled MFA requirement for delegated interactive member actions on a subaccount.\n */\n async setMemberMfaRequirement(\n input: v.InferInput<typeof SetSubaccountMemberMfaRequirementInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountMutationResult> {\n const validatedInput = parse(SetSubaccountMemberMfaRequirementInputSchema, input);\n const res = await this.#client.setSubaccountMemberMFARequirement(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountMutationResultSchema, res);\n }\n\n /**\n * Returns the caller's subaccount invitations, newest first. Omit `direction` to include both\n * incoming and outgoing invitations, or pass `\"incoming\"` or `\"outgoing\"` to filter. API keys need `read-subaccount-invites` and see only outgoing invitations.\n */\n async listInvites(\n input: v.InferInput<typeof ListSubaccountInvitesInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountInvite[]> {\n const validatedInput = parse(ListSubaccountInvitesInputSchema, input);\n const res = await this.#client.listSubaccountInvites(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountInviteSchema), res.invites);\n }\n\n /**\n * Returns the public built-in role and permission catalog with display metadata and per-role permission sets.\n */\n async listRoles(options?: PolyesterRequestOptions): Promise<SubaccountRoleCatalog> {\n const res = await this.#publicRoleClient.listSubaccountRoles(\n {},\n toConnectCallOptions(options),\n );\n return parse(SubaccountRoleCatalogSchema, res);\n }\n\n /**\n * Returns the caller's current role, effective role-granted permissions, and attached policy ID for a subaccount. API keys need `read-subaccount-permissions` and get what the key itself may do.\n */\n async getEffectivePermissions(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<EffectiveSubaccountPermissions> {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const res = await this.#authRoleClient.getEffectiveSubaccountPermissions(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(EffectiveSubaccountPermissionsSchema, res);\n }\n\n /**\n * Returns the owner and delegated members for a subaccount, including role and MFA enrollment status. API keys need `read-subaccount-members`.\n */\n async listMembers(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountMember[]> {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const res = await this.#client.listSubaccountMembers(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountMemberSchema), res.members);\n }\n\n /**\n * Accepts or rejects an incoming invite, or cancels an outgoing invite, returning the updated invitation.\n */\n async respondInvite(\n input: v.InferInput<typeof RespondSubaccountInviteInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountInvite> {\n const validatedInput = parse(RespondSubaccountInviteInputSchema, input);\n const res = await this.#client.respondSubaccountInvite(\n validatedInput,\n toConnectCallOptions(options),\n );\n return parse(SubaccountInviteSchema, res.invite);\n }\n\n /**\n * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination. API keys need `read-subaccount-activity`.\n */\n async listEvents(\n input: v.InferInput<typeof SubaccountActivityInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<{ events: SubaccountEvent[]; nextPageToken: string }> {\n const validatedInput = parse(SubaccountActivityInputSchema, input);\n const res = await this.#viewClient.listSubaccountActivity(\n validatedInput,\n toConnectCallOptions(options),\n );\n return {\n events: parse(v.optional(v.array(SubaccountActivityEventSchema), []), res.events),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Subscribes to private subaccount updates for an account and emits normalized subaccount records. A record with `removed: true` means the caller lost access to that subaccount; remove it locally. Losing access also ends the caller's subscriptions to that subaccount's channels.\n */\n subscribe(input: SubscribeSubaccountsInput) {\n const channel = `private:auth:subaccounts:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: Proto.SubaccountSchema,\n onPublication: (data) => {\n const subaccount = parse(SubaccountSchema, data);\n input.onEvent(subaccount);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n\n /**\n * Subscribes to private API key updates for an account through the subaccount realtime channel helper.\n */\n subscribeApiKeys(input: SubscribeApiKeysInput) {\n const channel = `private:auth:api-keys:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: ProtoApiKeys.ApiKeySchema,\n onPublication: (data) => {\n const apiKey = parse(ApiKeySchema, data);\n input.onEvent(apiKey);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\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;G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EzD,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"}
@@ -3,10 +3,10 @@ import * as v from "valibot";
3
3
  //#region src/services/subaccounts/subaccounts.schemas.d.ts
4
4
  declare const SubaccountRoleSchema: v.PicklistSchema<readonly ["owner", "admin", "treasury", "leveraged_trader", "trader", "viewer"], undefined>;
5
5
  type SubaccountRole = v.InferOutput<typeof SubaccountRoleSchema>;
6
- declare const ProtoSubaccountPermissionSchema: 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">]>;
6
+ declare const ProtoSubaccountPermissionSchema: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "internal_transfer" | "swap" | "read_subaccount" | "update_subaccount" | "read_balances" | "read_spot" | "trade_spot" | "read_internal_transfers" | "external_withdraw" | "read_address_book" | "manage_address_book" | "read_members" | "manage_members" | "read_invites" | "manage_invites" | "read_api_keys" | "manage_api_keys" | "read_subaccount_policy" | "manage_subaccount_policy" | "read_activity" | "read_activity_security_details" | "manage_member_mfa_requirement" | "create_deposit_address" | "read_deposit_addresses" | "read_guard_signer_status" | "manage_guard_signer" | "read_auto_withdraw" | "manage_auto_withdraw">]>;
7
7
  type SubaccountPermission = v.InferOutput<typeof ProtoSubaccountPermissionSchema>;
8
8
  declare const SubaccountPermissionDefinitionSchema: v.ObjectSchema<{
9
- readonly permission: 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">]>;
9
+ readonly permission: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "internal_transfer" | "swap" | "read_subaccount" | "update_subaccount" | "read_balances" | "read_spot" | "trade_spot" | "read_internal_transfers" | "external_withdraw" | "read_address_book" | "manage_address_book" | "read_members" | "manage_members" | "read_invites" | "manage_invites" | "read_api_keys" | "manage_api_keys" | "read_subaccount_policy" | "manage_subaccount_policy" | "read_activity" | "read_activity_security_details" | "manage_member_mfa_requirement" | "create_deposit_address" | "read_deposit_addresses" | "read_guard_signer_status" | "manage_guard_signer" | "read_auto_withdraw" | "manage_auto_withdraw">]>;
10
10
  readonly displayName: v.OptionalSchema<v.StringSchema<undefined>, "">;
11
11
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
12
12
  readonly policyAction: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "swap" | "trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book" | "read-auto-withdraw" | "manage-auto-withdraw" | "read-api-keys" | "read-api-policies" | "read-subaccount-policies" | "read-subaccount-permissions" | "read-vip-status" | "read-social-verification" | "read-profile" | "read-account-directory" | "read-withdraw-validation" | "read-daily-claims" | "claim-daily-reward" | "read-checkpoints" | "read-rewards" | "create-deposit-address" | "read-deposit-addresses" | "read-subaccounts" | "read-subaccount-activity" | "read-subaccount-members" | "read-subaccount-invites" | "read-guard-signer-status">]>;
@@ -17,12 +17,12 @@ declare const SubaccountRoleDefinitionSchema: v.ObjectSchema<{
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>;
20
- 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 []>;
20
+ readonly permissions: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "internal_transfer" | "swap" | "read_subaccount" | "update_subaccount" | "read_balances" | "read_spot" | "trade_spot" | "read_internal_transfers" | "external_withdraw" | "read_address_book" | "manage_address_book" | "read_members" | "manage_members" | "read_invites" | "manage_invites" | "read_api_keys" | "manage_api_keys" | "read_subaccount_policy" | "manage_subaccount_policy" | "read_activity" | "read_activity_security_details" | "manage_member_mfa_requirement" | "create_deposit_address" | "read_deposit_addresses" | "read_guard_signer_status" | "manage_guard_signer" | "read_auto_withdraw" | "manage_auto_withdraw">]>, undefined>, readonly []>;
21
21
  }, undefined>;
22
22
  type SubaccountRoleDefinition = v.InferOutput<typeof SubaccountRoleDefinitionSchema>;
23
23
  declare const SubaccountRoleCatalogSchema: v.ObjectSchema<{
24
24
  readonly permissions: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
25
- readonly permission: 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">]>;
25
+ readonly permission: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "internal_transfer" | "swap" | "read_subaccount" | "update_subaccount" | "read_balances" | "read_spot" | "trade_spot" | "read_internal_transfers" | "external_withdraw" | "read_address_book" | "manage_address_book" | "read_members" | "manage_members" | "read_invites" | "manage_invites" | "read_api_keys" | "manage_api_keys" | "read_subaccount_policy" | "manage_subaccount_policy" | "read_activity" | "read_activity_security_details" | "manage_member_mfa_requirement" | "create_deposit_address" | "read_deposit_addresses" | "read_guard_signer_status" | "manage_guard_signer" | "read_auto_withdraw" | "manage_auto_withdraw">]>;
26
26
  readonly displayName: v.OptionalSchema<v.StringSchema<undefined>, "">;
27
27
  readonly description: v.OptionalSchema<v.StringSchema<undefined>, "">;
28
28
  readonly policyAction: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "swap" | "trade-spot" | "internal-transfer" | "external-withdraw" | "read-balances" | "read-spot" | "read-internal-transfers" | "read-address-book" | "manage-address-book" | "read-auto-withdraw" | "manage-auto-withdraw" | "read-api-keys" | "read-api-policies" | "read-subaccount-policies" | "read-subaccount-permissions" | "read-vip-status" | "read-social-verification" | "read-profile" | "read-account-directory" | "read-withdraw-validation" | "read-daily-claims" | "claim-daily-reward" | "read-checkpoints" | "read-rewards" | "create-deposit-address" | "read-deposit-addresses" | "read-subaccounts" | "read-subaccount-activity" | "read-subaccount-members" | "read-subaccount-invites" | "read-guard-signer-status">]>;
@@ -32,13 +32,13 @@ declare const SubaccountRoleCatalogSchema: v.ObjectSchema<{
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>;
35
- 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 []>;
35
+ readonly permissions: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "internal_transfer" | "swap" | "read_subaccount" | "update_subaccount" | "read_balances" | "read_spot" | "trade_spot" | "read_internal_transfers" | "external_withdraw" | "read_address_book" | "manage_address_book" | "read_members" | "manage_members" | "read_invites" | "manage_invites" | "read_api_keys" | "manage_api_keys" | "read_subaccount_policy" | "manage_subaccount_policy" | "read_activity" | "read_activity_security_details" | "manage_member_mfa_requirement" | "create_deposit_address" | "read_deposit_addresses" | "read_guard_signer_status" | "manage_guard_signer" | "read_auto_withdraw" | "manage_auto_withdraw">]>, undefined>, readonly []>;
36
36
  }, undefined>, undefined>, readonly []>;
37
37
  }, undefined>;
38
38
  type SubaccountRoleCatalog = v.InferOutput<typeof SubaccountRoleCatalogSchema>;
39
39
  declare const EffectiveSubaccountPermissionsSchema: v.ObjectSchema<{
40
40
  readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
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 []>;
41
+ readonly permissions: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "internal_transfer" | "swap" | "read_subaccount" | "update_subaccount" | "read_balances" | "read_spot" | "trade_spot" | "read_internal_transfers" | "external_withdraw" | "read_address_book" | "manage_address_book" | "read_members" | "manage_members" | "read_invites" | "manage_invites" | "read_api_keys" | "manage_api_keys" | "read_subaccount_policy" | "manage_subaccount_policy" | "read_activity" | "read_activity_security_details" | "manage_member_mfa_requirement" | "create_deposit_address" | "read_deposit_addresses" | "read_guard_signer_status" | "manage_guard_signer" | "read_auto_withdraw" | "manage_auto_withdraw">]>, undefined>, readonly []>;
42
42
  readonly subaccountPolicyId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
43
43
  }, undefined>;
44
44
  type EffectiveSubaccountPermissions = v.InferOutput<typeof EffectiveSubaccountPermissionsSchema>;
@@ -242,7 +242,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
242
242
  readonly granteeAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
243
243
  readonly inviterAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
244
244
  readonly role: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer">]>;
245
- readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "accepted" | "canceled" | "pending" | "declined">]>;
245
+ readonly status: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "canceled" | "pending" | "accepted" | "declined">]>;
246
246
  readonly createdAt: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ObjectSchema<{
247
247
  readonly seconds: v.BigintSchema<undefined>;
248
248
  readonly nanos: v.OptionalSchema<v.NumberSchema<undefined>, 0>;
@@ -269,7 +269,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
269
269
  granteeAccountId: string;
270
270
  inviterAccountId: string;
271
271
  role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
272
- status: "unspecified" | "accepted" | "canceled" | "pending" | "declined";
272
+ status: "unspecified" | "canceled" | "pending" | "accepted" | "declined";
273
273
  createdAt?: number | undefined;
274
274
  respondedAt?: number | undefined;
275
275
  granteeUsername: string;
@@ -287,7 +287,7 @@ declare const SubaccountInviteSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<
287
287
  granteeAccountId: string;
288
288
  inviterAccountId: string;
289
289
  role: "unspecified" | "owner" | "admin" | "treasury" | "leveraged_trader" | "trader" | "viewer";
290
- status: "unspecified" | "accepted" | "canceled" | "pending" | "declined";
290
+ status: "unspecified" | "canceled" | "pending" | "accepted" | "declined";
291
291
  createdAt?: number | undefined;
292
292
  respondedAt?: number | undefined;
293
293
  granteeUsername: string;
@@ -309,9 +309,9 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
309
309
  seconds: bigint;
310
310
  nanos: number;
311
311
  } | undefined, number | undefined>]>;
312
- readonly entityKind: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "member" | "policy" | "invite" | "security">]>;
313
- readonly eventAction: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "disabled" | "removed" | "revoked" | "failed" | "created" | "updated" | "deleted" | "enabled" | "role_set" | "received" | "replied" | "blocked" | "hold_placed" | "hold_released">]>;
314
- readonly source: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "web" | "mobile" | "api">]>;
312
+ readonly entityKind: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "api_key" | "account" | "subaccount" | "session" | "policy" | "destination" | "member" | "invite" | "security">]>;
313
+ readonly eventAction: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "disabled" | "revoked" | "removed" | "failed" | "created" | "enabled" | "updated" | "deleted" | "role_set" | "received" | "replied" | "blocked" | "hold_placed" | "hold_released">]>;
314
+ readonly source: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "api" | "web" | "mobile">]>;
315
315
  readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
316
316
  readonly userAgent: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
317
317
  readonly actorAccountId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
@@ -169,7 +169,7 @@ declare const GetUserTradesInputSchema: v.SchemaWithPipe<readonly [v.UnionSchema
169
169
  readonly orderId: v.OptionalSchema<v.NeverSchema<undefined>, undefined>;
170
170
  readonly lineageId: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>, v.CheckAction<bigint, `${string} must be greater than zero`>]>;
171
171
  readonly throughGeneration: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 1, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>;
172
- }, undefined>], undefined>], ({ input }: v.UnionIssue<v.NumberIssue | v.StringIssue | v.BooleanIssue | v.IntegerIssue<number> | v.MinValueIssue<number, 1> | v.MaxValueIssue<number, 4294967295> | v.MinLengthIssue<string, 1> | v.StrictObjectIssue | v.PicklistIssue | v.UnionIssue<v.StringIssue | v.MinLengthIssue<string, 1> | v.StrictObjectIssue | v.PicklistIssue> | v.GtValueIssue<number, 0> | v.CheckIssue<bigint> | v.NeverIssue | v.MaxValueIssue<number, 1000> | v.UnionIssue<v.NumberIssue | v.StringIssue | v.BooleanIssue | v.IntegerIssue<number> | v.MinValueIssue<number, 1> | v.MaxValueIssue<number, 4294967295> | v.MinLengthIssue<string, 1> | v.StrictObjectIssue | v.PicklistIssue | v.UnionIssue<v.StringIssue | v.MinLengthIssue<string, 1> | v.StrictObjectIssue | v.PicklistIssue> | v.GtValueIssue<number, 0> | v.CheckIssue<bigint> | v.NeverIssue | v.MaxValueIssue<number, 1000>>>) => "Provide at most one of orderId or lineageId" | "throughGeneration requires lineageId" | "symbolId is required when afterMatchId is set" | "Invalid trade filters">, v.TransformAction<{
172
+ }, undefined>], undefined>], ({ input }: v.UnionIssue<v.StringIssue | v.NumberIssue | v.BooleanIssue | v.IntegerIssue<number> | v.MinValueIssue<number, 1> | v.MaxValueIssue<number, 4294967295> | v.StrictObjectIssue | v.PicklistIssue | v.MinLengthIssue<string, 1> | v.UnionIssue<v.StringIssue | v.StrictObjectIssue | v.PicklistIssue | v.MinLengthIssue<string, 1>> | v.GtValueIssue<number, 0> | v.CheckIssue<bigint> | v.MaxValueIssue<number, 1000> | v.NeverIssue | v.UnionIssue<v.StringIssue | v.NumberIssue | v.BooleanIssue | v.IntegerIssue<number> | v.MinValueIssue<number, 1> | v.MaxValueIssue<number, 4294967295> | v.StrictObjectIssue | v.PicklistIssue | v.MinLengthIssue<string, 1> | v.UnionIssue<v.StringIssue | v.StrictObjectIssue | v.PicklistIssue | v.MinLengthIssue<string, 1>> | v.GtValueIssue<number, 0> | v.CheckIssue<bigint> | v.MaxValueIssue<number, 1000> | v.NeverIssue>>) => "Provide at most one of orderId or lineageId" | "throughGeneration requires lineageId" | "symbolId is required when afterMatchId is set" | "Invalid trade filters">, v.TransformAction<{
173
173
  symbolId?: number | undefined;
174
174
  afterMatchId?: undefined;
175
175
  side?: Side.BUY | Side.SELL | undefined;
@@ -56,7 +56,7 @@ declare class TradingWithdrawsService {
56
56
  */
57
57
  getWalletBalances(input?: GetWalletBalancesInput, options?: PolyesterRequestOptions): Promise<GetWalletBalancesResult>;
58
58
  /**
59
- * Checks whether an external-chain destination can receive a withdrawal without creating, signing, or reserving one.
59
+ * Checks whether an external-chain destination can receive a withdrawal without creating, signing, or reserving one. API keys need `read-withdraw-validation`.
60
60
  */
61
61
  validateDestination(input: ValidateWithdrawDestinationInput, options?: PolyesterRequestOptions): Promise<ValidateWithdrawDestinationResult>;
62
62
  /**
@@ -94,7 +94,7 @@ var TradingWithdrawsService = class {
94
94
  return parse(GetWalletBalancesResultSchema, response);
95
95
  }
96
96
  /**
97
- * Checks whether an external-chain destination can receive a withdrawal without creating, signing, or reserving one.
97
+ * Checks whether an external-chain destination can receive a withdrawal without creating, signing, or reserving one. API keys need `read-withdraw-validation`.
98
98
  */
99
99
  async validateDestination(input, options) {
100
100
  const request = parse(ValidateWithdrawDestinationInputSchema, input);
@@ -1 +1 @@
1
- {"version":3,"file":"trading-withdraws.js","names":["#client","Proto.WithdrawService","#resolver","#signingConfig","#catalog","#scales","#toFundingInputSchema","#toExternalChainInputSchema","#prepareWithdraw"],"sources":["../../../src/services/trading-withdraws/trading-withdraws.ts"],"sourcesContent":["import { ValidationError, WithdrawDeadlineExpiredError } from \"../../shared/errors.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport type { Address, Hex } from \"viem\";\nimport { checksumEvmAddress, evmHexToBytes } from \"../../utils/evm.js\";\nimport type { ClientCatalog } from \"../../catalogs/types.js\";\nimport * as Proto from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { idToBigInt } from \"../../utils/base58-id.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport {\n createCreateTradingWithdrawToExternalChainInputSchema,\n createCreateTradingWithdrawToFundingInputSchema,\n CreateTradingWithdrawResultSchema,\n CreateWalletTradingWithdrawResultSchema,\n GetWalletBalancesInputSchema,\n GetWalletBalancesResultSchema,\n ValidateWithdrawDestinationInputSchema,\n ValidateWithdrawDestinationResultSchema,\n renewTradingWithdrawPayload,\n type CreateTradingWithdrawResult,\n type CreateTradingWithdrawToExternalChainInput,\n type CreateTradingWithdrawToExternalChainRequest,\n type CreateTradingWithdrawToFundingInput,\n type CreateTradingWithdrawToFundingRequest,\n type GetWalletBalancesInput,\n type GetWalletBalancesResult,\n type TradingWithdrawIntentPayloadRequest,\n type ValidateWithdrawDestinationInput,\n type ValidateWithdrawDestinationResult,\n} from \"./trading-withdraws.schemas.js\";\nimport { buildTradingWithdrawWalletMessage } from \"./wallet-message.js\";\n\nexport type TradingWithdrawWalletSigner = {\n signerWallet: string;\n accountId: string;\n /**\n * Signs the UTF-8 message directly using EIP-191 personal_sign, without pre-hashing or switching chains.\n * For a viem account, use `(message) => account.signMessage({ message })`.\n */\n signMessage: (message: string) => Promise<Hex>;\n};\n\nexport type TradingWithdrawSigningConfig = {\n chainId: number;\n tradingGatewayAddress: Address;\n};\n\nexport type CreateTradingWithdrawToFundingServiceInput = CreateTradingWithdrawToFundingInput & {\n walletSigner?: TradingWithdrawWalletSigner;\n};\n\nexport type CreateTradingWithdrawToExternalChainServiceInput =\n CreateTradingWithdrawToExternalChainInput & {\n walletSigner?: TradingWithdrawWalletSigner;\n };\n\nexport type PreparedTradingWithdraw = Readonly<{\n /** When the backend stops accepting the currently signed request. */\n deadline: Date;\n /**\n * True once the deadline is less than a minute away. Wallet-signed\n * withdraws sign again on `submit` from then on, so callers can keep resubmitting the\n * same prepared withdraw, e.g. after a slow MFA step-up. Payload-signed withdraws\n * cannot be signed again: prepare again (same input, same idempotency key) instead.\n */\n isExpired: () => boolean;\n /**\n * Submits the payload and signature produced during preparation. Repeated calls only\n * change transport options such as the step-up token, unless the deadline is near:\n * wallet-signed withdraws then sign a fresh deadline and nonce with the same idempotency\n * key, and payload-signed withdraws throw `WithdrawDeadlineExpiredError` once it passes.\n */\n submit: (options?: PolyesterMutationOptions) => Promise<CreateTradingWithdrawResult>;\n}>;\n\ntype SignedTradingWithdraw = {\n payload: TradingWithdrawIntentPayloadRequest;\n send: (options?: PolyesterMutationOptions) => Promise<CreateTradingWithdrawResult>;\n};\n\n// Leaves room for the request to reach the backend and for modest clock skew.\nconst PREPARED_WITHDRAW_EXPIRY_MARGIN_MS = 60_000;\n\nfunction deadlineMs(payload: TradingWithdrawIntentPayloadRequest): number {\n return Number(payload.deadlineTsSec) * 1000;\n}\n\nfunction preparedWithdraw(\n signed: SignedTradingWithdraw,\n resign?: (payload: TradingWithdrawIntentPayloadRequest) => Promise<SignedTradingWithdraw>,\n): PreparedTradingWithdraw {\n let current = signed;\n const isExpired = () =>\n Date.now() >= deadlineMs(current.payload) - PREPARED_WITHDRAW_EXPIRY_MARGIN_MS;\n return {\n get deadline() {\n return new Date(deadlineMs(current.payload));\n },\n isExpired,\n submit: async (options) => {\n if (resign && isExpired()) {\n current = await resign(renewTradingWithdrawPayload(current.payload));\n } else if (Date.now() >= deadlineMs(current.payload)) {\n throw new WithdrawDeadlineExpiredError(\n \"Withdraw signature deadline has passed. Prepare the withdraw again.\",\n );\n }\n return current.send(options);\n },\n };\n}\n\ntype TradingWithdrawRequest =\n | CreateTradingWithdrawToFundingRequest\n | CreateTradingWithdrawToExternalChainRequest;\n\nfunction resolveTradingWithdrawTargetAccountId(params: {\n subaccountId: bigint | undefined;\n rootAccountId: string;\n}): bigint {\n if (params.subaccountId !== undefined) return params.subaccountId;\n return idToBigInt(params.rootAccountId, \"targetAccountId\");\n}\n\nasync function resolveTradingWithdrawSigningConfig(params: {\n fallback: TradingWithdrawSigningConfig;\n catalog?: ClientCatalog;\n}): Promise<TradingWithdrawSigningConfig> {\n if (!params.catalog) return params.fallback;\n\n try {\n await params.catalog.ensureReady();\n const gateway = params.catalog.zipper.getContractByName(\"tradingGateway\");\n const address = gateway?.address?.trim();\n if (!address?.startsWith(\"0x\")) return params.fallback;\n\n return {\n chainId: params.fallback.chainId,\n tradingGatewayAddress: checksumEvmAddress(address),\n };\n } catch {\n return params.fallback;\n }\n}\n\nasync function resolveWalletSignature(params: {\n signingConfig: TradingWithdrawSigningConfig;\n payload: TradingWithdrawIntentPayloadRequest;\n walletSigner: TradingWithdrawWalletSigner;\n targetAccountId: bigint;\n}): Promise<{ signerWallet: string; payloadSignature: Uint8Array }> {\n const signerWallet = params.walletSigner.signerWallet.trim().toLowerCase();\n const accountId = idToBigInt(params.walletSigner.accountId, \"accountId\");\n const signature = await params.walletSigner.signMessage(\n buildTradingWithdrawWalletMessage({\n signingConfig: params.signingConfig,\n payload: params.payload,\n signerWallet,\n accountId,\n targetAccountId: params.targetAccountId,\n }),\n );\n if (!/^0x[0-9a-fA-F]{128}(?:00|01|1[bBcC])$/.test(signature)) {\n throw new ValidationError(\n \"Trading withdraw wallet signature must be 65 bytes with recovery byte 0, 1, 27, or 28.\",\n );\n }\n return {\n signerWallet,\n payloadSignature: evmHexToBytes(signature),\n };\n}\n\n/**\n * Creates durable Trading withdrawal intents to Funding using API signatures or wallet EIP-191 signatures.\n */\nexport class TradingWithdrawsService {\n #client: Client<typeof Proto.WithdrawService>;\n #resolver?: SubaccountResolver;\n #signingConfig: TradingWithdrawSigningConfig;\n #catalog?: ClientCatalog;\n #scales: SdkScales;\n #toFundingInputSchema: ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>;\n #toExternalChainInputSchema: ReturnType<\n typeof createCreateTradingWithdrawToExternalChainInputSchema\n >;\n\n constructor(\n transports: AuthApiTransports,\n resolver: SubaccountResolver | undefined,\n signingConfig: TradingWithdrawSigningConfig,\n scales: SdkScales,\n catalog?: ClientCatalog,\n ) {\n this.#client = createClient(Proto.WithdrawService, transports.authApi);\n this.#resolver = resolver;\n this.#signingConfig = signingConfig;\n this.#catalog = catalog;\n this.#scales = scales;\n this.#toFundingInputSchema = createCreateTradingWithdrawToFundingInputSchema(scales);\n this.#toExternalChainInputSchema =\n createCreateTradingWithdrawToExternalChainInputSchema(scales);\n }\n\n /**\n * Reads the zTokens the account's smart account wallet holds on Polyester Chain, such as a\n * rejected withdrawal's refund (see the lifecycle step's `refundAddress`), which stays there\n * until moved. API keys need `read-balances`.\n */\n async getWalletBalances(\n input: GetWalletBalancesInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<GetWalletBalancesResult> {\n const request = parse(\n GetWalletBalancesInputSchema,\n resolveAccountScopedInput(input, this.#resolver),\n );\n const response = await this.#client.getWalletBalances(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(GetWalletBalancesResultSchema, response);\n }\n\n /**\n * Checks whether an external-chain destination can receive a withdrawal without creating, signing, or reserving one.\n */\n async validateDestination(\n input: ValidateWithdrawDestinationInput,\n options?: PolyesterRequestOptions,\n ): Promise<ValidateWithdrawDestinationResult> {\n const request = parse(ValidateWithdrawDestinationInputSchema, input);\n const response = await this.#client.validateWithdrawDestination(\n request,\n toConnectCallOptions(options),\n );\n return parse(ValidateWithdrawDestinationResultSchema, response);\n }\n\n /**\n * Builds a Trading-to-Funding withdraw intent payload with asset id, decimal amount, destination address, five-minute deadline, nonce, and idempotency key. If a wallet signer is provided, it signs the canonical EIP-191 message and calls the wallet endpoint; otherwise a payload signature is required for the backend-authorized endpoint.\n */\n async createToFunding(\n input: CreateTradingWithdrawToFundingServiceInput,\n options?: PolyesterMutationOptions,\n ): Promise<CreateTradingWithdrawResult> {\n const prepared = await this.prepareToFunding(input);\n return prepared.submit(options);\n }\n\n /**\n * Builds and signs a Trading-to-Funding withdrawal once so the exact request can be\n * resubmitted after backend-directed authorization such as MFA step-up.\n */\n async prepareToFunding(\n input: CreateTradingWithdrawToFundingServiceInput,\n ): Promise<PreparedTradingWithdraw> {\n await this.#scales.ready();\n const { walletSigner, ...inputForValidation } = input;\n const resolvedInput = resolveAccountScopedInput(inputForValidation, this.#resolver);\n const validated = parse(this.#toFundingInputSchema, resolvedInput);\n return this.#prepareWithdraw(validated, walletSigner);\n }\n\n /**\n * Builds a Trading-to-external-chain withdraw intent payload with asset id, decimal gross amount, destination network, destination address, five-minute deadline, nonce, and idempotency key. If a wallet signer is provided, it signs the canonical EIP-191 message and calls the wallet endpoint; otherwise a payload signature is required for the backend-authorized endpoint.\n */\n async createToExternalChain(\n input: CreateTradingWithdrawToExternalChainServiceInput,\n options?: PolyesterMutationOptions,\n ): Promise<CreateTradingWithdrawResult> {\n const prepared = await this.prepareToExternalChain(input);\n return prepared.submit(options);\n }\n\n /**\n * Builds and signs a Trading-to-external-chain withdrawal once so the exact request can\n * be resubmitted after backend-directed authorization such as MFA step-up.\n */\n async prepareToExternalChain(\n input: CreateTradingWithdrawToExternalChainServiceInput,\n ): Promise<PreparedTradingWithdraw> {\n await this.#scales.ready();\n const { walletSigner, ...inputForValidation } = input;\n const resolvedInput = resolveAccountScopedInput(inputForValidation, this.#resolver);\n const validated = parse(this.#toExternalChainInputSchema, resolvedInput);\n return this.#prepareWithdraw(validated, walletSigner);\n }\n\n async #prepareWithdraw(\n validated: TradingWithdrawRequest,\n walletSigner: TradingWithdrawWalletSigner | undefined,\n ): Promise<PreparedTradingWithdraw> {\n if (walletSigner) {\n const signingConfig = await resolveTradingWithdrawSigningConfig({\n fallback: this.#signingConfig,\n catalog: this.#catalog,\n });\n const targetAccountId = resolveTradingWithdrawTargetAccountId({\n subaccountId: validated.subaccountId,\n rootAccountId: walletSigner.accountId,\n });\n const sign = async (\n payload: TradingWithdrawIntentPayloadRequest,\n ): Promise<SignedTradingWithdraw> => {\n const walletSignature = await resolveWalletSignature({\n signingConfig,\n payload,\n walletSigner,\n targetAccountId,\n });\n const request = removeUndefined({\n payload,\n subaccountId: validated.subaccountId,\n signerWallet: walletSignature.signerWallet,\n payloadSignature: walletSignature.payloadSignature,\n });\n return {\n payload,\n send: async (options) => {\n const response = await this.#client.createWalletTradingWithdraw(\n request,\n toConnectCallOptions(options),\n );\n return parse(CreateWalletTradingWithdrawResultSchema, response);\n },\n };\n };\n return preparedWithdraw(await sign(validated.payload), sign);\n }\n\n if (!validated.payloadSignature) {\n throw new ValidationError(\n \"Trading withdraw requires a wallet signer or payload signature.\",\n );\n }\n\n const request = removeUndefined({\n payload: validated.payload,\n payloadSignature: validated.payloadSignature,\n });\n return preparedWithdraw({\n payload: validated.payload,\n send: async (options) => {\n const response = await this.#client.createTradingWithdraw(\n request,\n toConnectCallOptions(options),\n );\n return parse(CreateTradingWithdrawResultSchema, response);\n },\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;AAyFA,MAAM,qCAAqC;AAE3C,SAAS,W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,QAAQ;GAC5D;EACJ,CAAC;CACL;AACJ"}
1
+ {"version":3,"file":"trading-withdraws.js","names":["#client","Proto.WithdrawService","#resolver","#signingConfig","#catalog","#scales","#toFundingInputSchema","#toExternalChainInputSchema","#prepareWithdraw"],"sources":["../../../src/services/trading-withdraws/trading-withdraws.ts"],"sourcesContent":["import { ValidationError, WithdrawDeadlineExpiredError } from \"../../shared/errors.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport type { Address, Hex } from \"viem\";\nimport { checksumEvmAddress, evmHexToBytes } from \"../../utils/evm.js\";\nimport type { ClientCatalog } from \"../../catalogs/types.js\";\nimport * as Proto from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { idToBigInt } from \"../../utils/base58-id.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport {\n createCreateTradingWithdrawToExternalChainInputSchema,\n createCreateTradingWithdrawToFundingInputSchema,\n CreateTradingWithdrawResultSchema,\n CreateWalletTradingWithdrawResultSchema,\n GetWalletBalancesInputSchema,\n GetWalletBalancesResultSchema,\n ValidateWithdrawDestinationInputSchema,\n ValidateWithdrawDestinationResultSchema,\n renewTradingWithdrawPayload,\n type CreateTradingWithdrawResult,\n type CreateTradingWithdrawToExternalChainInput,\n type CreateTradingWithdrawToExternalChainRequest,\n type CreateTradingWithdrawToFundingInput,\n type CreateTradingWithdrawToFundingRequest,\n type GetWalletBalancesInput,\n type GetWalletBalancesResult,\n type TradingWithdrawIntentPayloadRequest,\n type ValidateWithdrawDestinationInput,\n type ValidateWithdrawDestinationResult,\n} from \"./trading-withdraws.schemas.js\";\nimport { buildTradingWithdrawWalletMessage } from \"./wallet-message.js\";\n\nexport type TradingWithdrawWalletSigner = {\n signerWallet: string;\n accountId: string;\n /**\n * Signs the UTF-8 message directly using EIP-191 personal_sign, without pre-hashing or switching chains.\n * For a viem account, use `(message) => account.signMessage({ message })`.\n */\n signMessage: (message: string) => Promise<Hex>;\n};\n\nexport type TradingWithdrawSigningConfig = {\n chainId: number;\n tradingGatewayAddress: Address;\n};\n\nexport type CreateTradingWithdrawToFundingServiceInput = CreateTradingWithdrawToFundingInput & {\n walletSigner?: TradingWithdrawWalletSigner;\n};\n\nexport type CreateTradingWithdrawToExternalChainServiceInput =\n CreateTradingWithdrawToExternalChainInput & {\n walletSigner?: TradingWithdrawWalletSigner;\n };\n\nexport type PreparedTradingWithdraw = Readonly<{\n /** When the backend stops accepting the currently signed request. */\n deadline: Date;\n /**\n * True once the deadline is less than a minute away. Wallet-signed\n * withdraws sign again on `submit` from then on, so callers can keep resubmitting the\n * same prepared withdraw, e.g. after a slow MFA step-up. Payload-signed withdraws\n * cannot be signed again: prepare again (same input, same idempotency key) instead.\n */\n isExpired: () => boolean;\n /**\n * Submits the payload and signature produced during preparation. Repeated calls only\n * change transport options such as the step-up token, unless the deadline is near:\n * wallet-signed withdraws then sign a fresh deadline and nonce with the same idempotency\n * key, and payload-signed withdraws throw `WithdrawDeadlineExpiredError` once it passes.\n */\n submit: (options?: PolyesterMutationOptions) => Promise<CreateTradingWithdrawResult>;\n}>;\n\ntype SignedTradingWithdraw = {\n payload: TradingWithdrawIntentPayloadRequest;\n send: (options?: PolyesterMutationOptions) => Promise<CreateTradingWithdrawResult>;\n};\n\n// Leaves room for the request to reach the backend and for modest clock skew.\nconst PREPARED_WITHDRAW_EXPIRY_MARGIN_MS = 60_000;\n\nfunction deadlineMs(payload: TradingWithdrawIntentPayloadRequest): number {\n return Number(payload.deadlineTsSec) * 1000;\n}\n\nfunction preparedWithdraw(\n signed: SignedTradingWithdraw,\n resign?: (payload: TradingWithdrawIntentPayloadRequest) => Promise<SignedTradingWithdraw>,\n): PreparedTradingWithdraw {\n let current = signed;\n const isExpired = () =>\n Date.now() >= deadlineMs(current.payload) - PREPARED_WITHDRAW_EXPIRY_MARGIN_MS;\n return {\n get deadline() {\n return new Date(deadlineMs(current.payload));\n },\n isExpired,\n submit: async (options) => {\n if (resign && isExpired()) {\n current = await resign(renewTradingWithdrawPayload(current.payload));\n } else if (Date.now() >= deadlineMs(current.payload)) {\n throw new WithdrawDeadlineExpiredError(\n \"Withdraw signature deadline has passed. Prepare the withdraw again.\",\n );\n }\n return current.send(options);\n },\n };\n}\n\ntype TradingWithdrawRequest =\n | CreateTradingWithdrawToFundingRequest\n | CreateTradingWithdrawToExternalChainRequest;\n\nfunction resolveTradingWithdrawTargetAccountId(params: {\n subaccountId: bigint | undefined;\n rootAccountId: string;\n}): bigint {\n if (params.subaccountId !== undefined) return params.subaccountId;\n return idToBigInt(params.rootAccountId, \"targetAccountId\");\n}\n\nasync function resolveTradingWithdrawSigningConfig(params: {\n fallback: TradingWithdrawSigningConfig;\n catalog?: ClientCatalog;\n}): Promise<TradingWithdrawSigningConfig> {\n if (!params.catalog) return params.fallback;\n\n try {\n await params.catalog.ensureReady();\n const gateway = params.catalog.zipper.getContractByName(\"tradingGateway\");\n const address = gateway?.address?.trim();\n if (!address?.startsWith(\"0x\")) return params.fallback;\n\n return {\n chainId: params.fallback.chainId,\n tradingGatewayAddress: checksumEvmAddress(address),\n };\n } catch {\n return params.fallback;\n }\n}\n\nasync function resolveWalletSignature(params: {\n signingConfig: TradingWithdrawSigningConfig;\n payload: TradingWithdrawIntentPayloadRequest;\n walletSigner: TradingWithdrawWalletSigner;\n targetAccountId: bigint;\n}): Promise<{ signerWallet: string; payloadSignature: Uint8Array }> {\n const signerWallet = params.walletSigner.signerWallet.trim().toLowerCase();\n const accountId = idToBigInt(params.walletSigner.accountId, \"accountId\");\n const signature = await params.walletSigner.signMessage(\n buildTradingWithdrawWalletMessage({\n signingConfig: params.signingConfig,\n payload: params.payload,\n signerWallet,\n accountId,\n targetAccountId: params.targetAccountId,\n }),\n );\n if (!/^0x[0-9a-fA-F]{128}(?:00|01|1[bBcC])$/.test(signature)) {\n throw new ValidationError(\n \"Trading withdraw wallet signature must be 65 bytes with recovery byte 0, 1, 27, or 28.\",\n );\n }\n return {\n signerWallet,\n payloadSignature: evmHexToBytes(signature),\n };\n}\n\n/**\n * Creates durable Trading withdrawal intents to Funding using API signatures or wallet EIP-191 signatures.\n */\nexport class TradingWithdrawsService {\n #client: Client<typeof Proto.WithdrawService>;\n #resolver?: SubaccountResolver;\n #signingConfig: TradingWithdrawSigningConfig;\n #catalog?: ClientCatalog;\n #scales: SdkScales;\n #toFundingInputSchema: ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>;\n #toExternalChainInputSchema: ReturnType<\n typeof createCreateTradingWithdrawToExternalChainInputSchema\n >;\n\n constructor(\n transports: AuthApiTransports,\n resolver: SubaccountResolver | undefined,\n signingConfig: TradingWithdrawSigningConfig,\n scales: SdkScales,\n catalog?: ClientCatalog,\n ) {\n this.#client = createClient(Proto.WithdrawService, transports.authApi);\n this.#resolver = resolver;\n this.#signingConfig = signingConfig;\n this.#catalog = catalog;\n this.#scales = scales;\n this.#toFundingInputSchema = createCreateTradingWithdrawToFundingInputSchema(scales);\n this.#toExternalChainInputSchema =\n createCreateTradingWithdrawToExternalChainInputSchema(scales);\n }\n\n /**\n * Reads the zTokens the account's smart account wallet holds on Polyester Chain, such as a\n * rejected withdrawal's refund (see the lifecycle step's `refundAddress`), which stays there\n * until moved. API keys need `read-balances`.\n */\n async getWalletBalances(\n input: GetWalletBalancesInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<GetWalletBalancesResult> {\n const request = parse(\n GetWalletBalancesInputSchema,\n resolveAccountScopedInput(input, this.#resolver),\n );\n const response = await this.#client.getWalletBalances(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(GetWalletBalancesResultSchema, response);\n }\n\n /**\n * Checks whether an external-chain destination can receive a withdrawal without creating, signing, or reserving one. API keys need `read-withdraw-validation`.\n */\n async validateDestination(\n input: ValidateWithdrawDestinationInput,\n options?: PolyesterRequestOptions,\n ): Promise<ValidateWithdrawDestinationResult> {\n const request = parse(ValidateWithdrawDestinationInputSchema, input);\n const response = await this.#client.validateWithdrawDestination(\n request,\n toConnectCallOptions(options),\n );\n return parse(ValidateWithdrawDestinationResultSchema, response);\n }\n\n /**\n * Builds a Trading-to-Funding withdraw intent payload with asset id, decimal amount, destination address, five-minute deadline, nonce, and idempotency key. If a wallet signer is provided, it signs the canonical EIP-191 message and calls the wallet endpoint; otherwise a payload signature is required for the backend-authorized endpoint.\n */\n async createToFunding(\n input: CreateTradingWithdrawToFundingServiceInput,\n options?: PolyesterMutationOptions,\n ): Promise<CreateTradingWithdrawResult> {\n const prepared = await this.prepareToFunding(input);\n return prepared.submit(options);\n }\n\n /**\n * Builds and signs a Trading-to-Funding withdrawal once so the exact request can be\n * resubmitted after backend-directed authorization such as MFA step-up.\n */\n async prepareToFunding(\n input: CreateTradingWithdrawToFundingServiceInput,\n ): Promise<PreparedTradingWithdraw> {\n await this.#scales.ready();\n const { walletSigner, ...inputForValidation } = input;\n const resolvedInput = resolveAccountScopedInput(inputForValidation, this.#resolver);\n const validated = parse(this.#toFundingInputSchema, resolvedInput);\n return this.#prepareWithdraw(validated, walletSigner);\n }\n\n /**\n * Builds a Trading-to-external-chain withdraw intent payload with asset id, decimal gross amount, destination network, destination address, five-minute deadline, nonce, and idempotency key. If a wallet signer is provided, it signs the canonical EIP-191 message and calls the wallet endpoint; otherwise a payload signature is required for the backend-authorized endpoint.\n */\n async createToExternalChain(\n input: CreateTradingWithdrawToExternalChainServiceInput,\n options?: PolyesterMutationOptions,\n ): Promise<CreateTradingWithdrawResult> {\n const prepared = await this.prepareToExternalChain(input);\n return prepared.submit(options);\n }\n\n /**\n * Builds and signs a Trading-to-external-chain withdrawal once so the exact request can\n * be resubmitted after backend-directed authorization such as MFA step-up.\n */\n async prepareToExternalChain(\n input: CreateTradingWithdrawToExternalChainServiceInput,\n ): Promise<PreparedTradingWithdraw> {\n await this.#scales.ready();\n const { walletSigner, ...inputForValidation } = input;\n const resolvedInput = resolveAccountScopedInput(inputForValidation, this.#resolver);\n const validated = parse(this.#toExternalChainInputSchema, resolvedInput);\n return this.#prepareWithdraw(validated, walletSigner);\n }\n\n async #prepareWithdraw(\n validated: TradingWithdrawRequest,\n walletSigner: TradingWithdrawWalletSigner | undefined,\n ): Promise<PreparedTradingWithdraw> {\n if (walletSigner) {\n const signingConfig = await resolveTradingWithdrawSigningConfig({\n fallback: this.#signingConfig,\n catalog: this.#catalog,\n });\n const targetAccountId = resolveTradingWithdrawTargetAccountId({\n subaccountId: validated.subaccountId,\n rootAccountId: walletSigner.accountId,\n });\n const sign = async (\n payload: TradingWithdrawIntentPayloadRequest,\n ): Promise<SignedTradingWithdraw> => {\n const walletSignature = await resolveWalletSignature({\n signingConfig,\n payload,\n walletSigner,\n targetAccountId,\n });\n const request = removeUndefined({\n payload,\n subaccountId: validated.subaccountId,\n signerWallet: walletSignature.signerWallet,\n payloadSignature: walletSignature.payloadSignature,\n });\n return {\n payload,\n send: async (options) => {\n const response = await this.#client.createWalletTradingWithdraw(\n request,\n toConnectCallOptions(options),\n );\n return parse(CreateWalletTradingWithdrawResultSchema, response);\n },\n };\n };\n return preparedWithdraw(await sign(validated.payload), sign);\n }\n\n if (!validated.payloadSignature) {\n throw new ValidationError(\n \"Trading withdraw requires a wallet signer or payload signature.\",\n );\n }\n\n const request = removeUndefined({\n payload: validated.payload,\n payloadSignature: validated.payloadSignature,\n });\n return preparedWithdraw({\n payload: validated.payload,\n send: async (options) => {\n const response = await this.#client.createTradingWithdraw(\n request,\n toConnectCallOptions(options),\n );\n return parse(CreateTradingWithdrawResultSchema, response);\n },\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;AAyFA,MAAM,qCAAqC;AAE3C,SAAS,WAAW,SAAsD;CACtE,OAAO,OAAO,QAAQ,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"}
@@ -85,7 +85,7 @@ declare const LedgerTransferSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
85
85
  amount: string;
86
86
  balanceAfter: string | undefined;
87
87
  type: "unspecified" | "internal_transfer" | "deposit" | "withdraw" | "maker_fee" | "taker_fee" | "trade_base" | "trade_quote" | "rebate" | "funding_to_trading" | "trading_to_funding" | "trading_withdraw_reserve" | "funding_user_transfer" | "trading_withdraw_request_fee" | "trading_withdraw_fee_leg" | "quickswap_polyester_fee" | "quickswap_broker_fee" | "quickswap_affiliate_fee" | "fee_sweep" | "fee_refill" | "system_adjustment" | "withdraw_failed";
88
- accountCode: "unspecified" | "funding" | "trading";
88
+ accountCode: "unspecified" | "trading" | "funding";
89
89
  timestamp: number;
90
90
  isDebit: boolean;
91
91
  linkId: string | undefined;
@@ -1113,7 +1113,7 @@ type CreateTriggerInput = v.InferInput<ReturnType<typeof createCreateTriggerInpu
1113
1113
  declare const ListTriggersInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
1114
1114
  readonly parentOrderId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
1115
1115
  readonly symbolId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>;
1116
- readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "canceled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("failed" | "armed" | "canceled" | "completed" | "created" | "running" | "paused")[] | undefined, (TriggerStatus.STATUS_CREATED | TriggerStatus.STATUS_ARMED | TriggerStatus.STATUS_RUNNING | TriggerStatus.STATUS_COMPLETED | TriggerStatus.STATUS_CANCELED | TriggerStatus.STATUS_FAILED | TriggerStatus.STATUS_PAUSED)[]>]>;
1116
+ readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "canceled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("armed" | "failed" | "canceled" | "created" | "running" | "completed" | "paused")[] | undefined, (TriggerStatus.STATUS_CREATED | TriggerStatus.STATUS_ARMED | TriggerStatus.STATUS_RUNNING | TriggerStatus.STATUS_COMPLETED | TriggerStatus.STATUS_CANCELED | TriggerStatus.STATUS_FAILED | TriggerStatus.STATUS_PAUSED)[]>]>;
1117
1117
  readonly triggerType: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["stop_loss", "take_profit", "trailing_stop", "twap", "ladder"], undefined>, undefined>, v.TransformAction<"twap" | "ladder" | "stop_loss" | "take_profit" | "trailing_stop" | undefined, TriggerType>]>;
1118
1118
  readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 1000, undefined>]>, 50>;
1119
1119
  readonly pageToken: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
@@ -1334,7 +1334,7 @@ declare const ListTriggerEventsInputSchema: v.SchemaWithPipe<readonly [v.StrictO
1334
1334
  readonly triggerId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>;
1335
1335
  }, undefined>, v.TransformAction<{
1336
1336
  limit?: number | undefined;
1337
- eventType?: "failed" | "armed" | "canceled" | "updated" | "fired" | "activated" | "fire_refused" | undefined;
1337
+ eventType?: "armed" | "failed" | "canceled" | "updated" | "fired" | "activated" | "fire_refused" | undefined;
1338
1338
  pageToken: string;
1339
1339
  account?: "active" | "main" | {
1340
1340
  subaccountId: string;