@polyester/sdk 0.12.0 → 0.14.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.
- package/CHANGELOG.md +16 -0
- package/dist/core-client.d.ts +3 -3
- package/dist/core-client.d.ts.map +1 -1
- package/dist/core-client.js +35 -50
- package/dist/core-client.js.map +1 -1
- package/dist/gen/orders/v1/orders_read_pb.d.ts +2 -2
- package/dist/gen/orders/v1/orders_read_pb.js.map +1 -1
- package/dist/services/accounts/accounts.d.ts +2 -2
- package/dist/services/accounts/accounts.d.ts.map +1 -1
- package/dist/services/accounts/accounts.js +2 -2
- package/dist/services/accounts/accounts.js.map +1 -1
- package/dist/services/address-book/address-book.d.ts +2 -2
- package/dist/services/address-book/address-book.d.ts.map +1 -1
- package/dist/services/address-book/address-book.js +2 -2
- package/dist/services/address-book/address-book.js.map +1 -1
- package/dist/services/api-keys/api-keys.d.ts +2 -2
- package/dist/services/api-keys/api-keys.d.ts.map +1 -1
- package/dist/services/api-keys/api-keys.js +3 -3
- package/dist/services/api-keys/api-keys.js.map +1 -1
- package/dist/services/auth/account-signer-auth.d.ts +3 -2
- package/dist/services/auth/account-signer-auth.d.ts.map +1 -1
- package/dist/services/auth/account-signer-auth.js.map +1 -1
- package/dist/services/auth/auth.d.ts +3 -7
- package/dist/services/auth/auth.d.ts.map +1 -1
- package/dist/services/auth/auth.js +1 -1
- package/dist/services/auth/auth.js.map +1 -1
- package/dist/services/auth/profile/profile.d.ts +2 -2
- package/dist/services/auth/profile/profile.d.ts.map +1 -1
- package/dist/services/auth/profile/profile.js +2 -2
- package/dist/services/auth/profile/profile.js.map +1 -1
- package/dist/services/balances/balances.d.ts +2 -2
- package/dist/services/balances/balances.d.ts.map +1 -1
- package/dist/services/balances/balances.js +2 -2
- package/dist/services/balances/balances.js.map +1 -1
- package/dist/services/candles/candles.d.ts +2 -2
- package/dist/services/candles/candles.d.ts.map +1 -1
- package/dist/services/candles/candles.js +2 -2
- package/dist/services/candles/candles.js.map +1 -1
- package/dist/services/chain-analytics/chain-analytics.d.ts +2 -2
- package/dist/services/chain-analytics/chain-analytics.d.ts.map +1 -1
- package/dist/services/chain-analytics/chain-analytics.js +2 -2
- package/dist/services/chain-analytics/chain-analytics.js.map +1 -1
- package/dist/services/deposit/deposit.d.ts +2 -2
- package/dist/services/deposit/deposit.d.ts.map +1 -1
- package/dist/services/deposit/deposit.js +2 -2
- package/dist/services/deposit/deposit.js.map +1 -1
- package/dist/services/fees/fees.d.ts +2 -2
- package/dist/services/fees/fees.d.ts.map +1 -1
- package/dist/services/fees/fees.js +2 -2
- package/dist/services/fees/fees.js.map +1 -1
- package/dist/services/guard-signer/guard-signer.d.ts +2 -2
- package/dist/services/guard-signer/guard-signer.d.ts.map +1 -1
- package/dist/services/guard-signer/guard-signer.js +2 -2
- package/dist/services/guard-signer/guard-signer.js.map +1 -1
- package/dist/services/heatmap/heatmap.d.ts +2 -2
- package/dist/services/heatmap/heatmap.d.ts.map +1 -1
- package/dist/services/heatmap/heatmap.js +2 -2
- package/dist/services/heatmap/heatmap.js.map +1 -1
- package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
- package/dist/services/internal-transfers/internal-transfers.d.ts +2 -2
- package/dist/services/internal-transfers/internal-transfers.d.ts.map +1 -1
- package/dist/services/internal-transfers/internal-transfers.js +2 -2
- package/dist/services/internal-transfers/internal-transfers.js.map +1 -1
- package/dist/services/lifecycle/lifecycle.d.ts +2 -2
- package/dist/services/lifecycle/lifecycle.d.ts.map +1 -1
- package/dist/services/lifecycle/lifecycle.js +2 -2
- package/dist/services/lifecycle/lifecycle.js.map +1 -1
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +42 -42
- package/dist/services/market-data/market-data.d.ts +2 -2
- package/dist/services/market-data/market-data.d.ts.map +1 -1
- package/dist/services/market-data/market-data.js +2 -2
- package/dist/services/market-data/market-data.js.map +1 -1
- package/dist/services/market-overview/market-overview.d.ts +2 -2
- package/dist/services/market-overview/market-overview.d.ts.map +1 -1
- package/dist/services/market-overview/market-overview.js +2 -2
- package/dist/services/market-overview/market-overview.js.map +1 -1
- package/dist/services/mfa/mfa.d.ts +2 -2
- package/dist/services/mfa/mfa.d.ts.map +1 -1
- package/dist/services/mfa/mfa.js +2 -2
- package/dist/services/mfa/mfa.js.map +1 -1
- package/dist/services/orderbook/orderbook.d.ts +2 -2
- package/dist/services/orderbook/orderbook.d.ts.map +1 -1
- package/dist/services/orderbook/orderbook.js +2 -2
- package/dist/services/orderbook/orderbook.js.map +1 -1
- package/dist/services/orderbook/orderbook.schemas.d.ts +1 -1
- package/dist/services/orders/orders-output.schemas.d.ts +8 -8
- package/dist/services/orders/orders-output.schemas.js +1 -1
- package/dist/services/orders/orders-output.schemas.js.map +1 -1
- package/dist/services/orders/orders.d.ts +2 -2
- package/dist/services/orders/orders.d.ts.map +1 -1
- package/dist/services/orders/orders.js +3 -3
- package/dist/services/orders/orders.js.map +1 -1
- package/dist/services/policies/api-key-policies/api-key-policies.d.ts +2 -2
- package/dist/services/policies/api-key-policies/api-key-policies.d.ts.map +1 -1
- package/dist/services/policies/api-key-policies/api-key-policies.js +2 -2
- package/dist/services/policies/api-key-policies/api-key-policies.js.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.d.ts +2 -2
- package/dist/services/policies/subaccount-policies/subaccount-policies.d.ts.map +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.js +2 -2
- package/dist/services/policies/subaccount-policies/subaccount-policies.js.map +1 -1
- package/dist/services/rate-limits/rate-limits.d.ts +2 -2
- package/dist/services/rate-limits/rate-limits.d.ts.map +1 -1
- package/dist/services/rate-limits/rate-limits.js.map +1 -1
- package/dist/services/social-verification/social-verification.d.ts +2 -2
- package/dist/services/social-verification/social-verification.d.ts.map +1 -1
- package/dist/services/social-verification/social-verification.js +2 -2
- package/dist/services/social-verification/social-verification.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.d.ts +3 -3
- package/dist/services/subaccounts/subaccounts.d.ts.map +1 -1
- package/dist/services/subaccounts/subaccounts.js +11 -9
- package/dist/services/subaccounts/subaccounts.js.map +1 -1
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +2 -2
- package/dist/services/trades/trades.d.ts +2 -2
- package/dist/services/trades/trades.d.ts.map +1 -1
- package/dist/services/trades/trades.js +2 -2
- package/dist/services/trades/trades.js.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.d.ts +2 -2
- package/dist/services/trading-withdraws/trading-withdraws.d.ts.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.js +2 -2
- package/dist/services/trading-withdraws/trading-withdraws.js.map +1 -1
- package/dist/services/transfers/transfers.d.ts +2 -2
- package/dist/services/transfers/transfers.d.ts.map +1 -1
- package/dist/services/transfers/transfers.js +2 -2
- package/dist/services/transfers/transfers.js.map +1 -1
- package/dist/services/triggers/trigger-input.schemas.d.ts +2 -2
- package/dist/services/triggers/triggers-output.schemas.d.ts +18 -18
- package/dist/services/triggers/triggers.d.ts +2 -2
- package/dist/services/triggers/triggers.d.ts.map +1 -1
- package/dist/services/triggers/triggers.js +2 -2
- package/dist/services/triggers/triggers.js.map +1 -1
- package/dist/services/vip/vip.d.ts +2 -2
- package/dist/services/vip/vip.js.map +1 -1
- package/dist/services/whiteboard/whiteboard.d.ts +2 -2
- package/dist/services/whiteboard/whiteboard.d.ts.map +1 -1
- package/dist/services/whiteboard/whiteboard.js +2 -2
- package/dist/services/whiteboard/whiteboard.js.map +1 -1
- package/dist/services/zipper/zipper.d.ts +2 -2
- package/dist/services/zipper/zipper.d.ts.map +1 -1
- package/dist/services/zipper/zipper.js +2 -2
- package/dist/services/zipper/zipper.js.map +1 -1
- package/dist/shared/transports.d.ts +7 -1
- package/dist/shared/transports.d.ts.map +1 -1
- package/dist/shared/transports.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccount-policies.d.ts","names":[],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"subaccount-policies.d.ts","names":[],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.ts"],"mappings":";;;;;;;;;UAyBU,+BAA+B,mBAAmB;EACxD;;;;;cAMS;;EAML,YAAA,YAAY,mBACZ,UAAU,mBACV,WAAW;;;;EAUT,KACF,QAAO,EAAE,kBAAkB,oCAC3B,UAAU,0BACX,QAAQ;;;;EAaL,IACF,OAAO,EAAE,kBAAkB,iCAC3B,UAAU,0BACX,QAAQ;;;;EAcL,OACF,OAAO,EAAE,kBAAkB,oCAC3B,UAAU,2BACX,QAAQ;;;;EAaL,OACF,OAAO,EAAE,kBAAkB,oCAC3B,UAAU,2BACX,QAAQ;;;;EAaL,OAAO,kBAAkB,UAAU,2BAA2B;;;;EAW9D,MACF,OAAO,EAAE,kBAAkB,mCAC3B,UAAU,2BACX;;;;EAWH,kBAAkB,OAAO"}
|
|
@@ -14,8 +14,8 @@ var SubaccountPoliciesService = class {
|
|
|
14
14
|
#client;
|
|
15
15
|
#realtime;
|
|
16
16
|
#resolver;
|
|
17
|
-
constructor(
|
|
18
|
-
this.#client = createClient(PolicyService,
|
|
17
|
+
constructor(transports, realtime, resolver) {
|
|
18
|
+
this.#client = createClient(PolicyService, transports.authApi);
|
|
19
19
|
this.#realtime = realtime;
|
|
20
20
|
this.#resolver = resolver;
|
|
21
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccount-policies.js","names":["#client","Proto.PolicyService","#realtime","#resolver","Proto.SubaccountPolicyViewSchema"],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.ts"],"sourcesContent":["import * as Proto from \"../../../gen/auth/v1/policies_pb.js\";\nimport { createClient, type Client
|
|
1
|
+
{"version":3,"file":"subaccount-policies.js","names":["#client","Proto.PolicyService","#realtime","#resolver","Proto.SubaccountPolicyViewSchema"],"sources":["../../../../src/services/policies/subaccount-policies/subaccount-policies.ts"],"sourcesContent":["import * as Proto from \"../../../gen/auth/v1/policies_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../../shared/validation.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 { BaseSubscribeInput } from \"../../../shared/types.js\";\nimport type { PolyesterRealtime } from \"../../../realtime/index.js\";\nimport type { AuthApiTransports } from \"../../../shared/transports.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../../subaccount-resolver.js\";\nimport {\n SubaccountPolicySchema,\n CreateSubaccountPolicyInputSchema,\n UpdateSubaccountPolicyInputSchema,\n PolicyIdSchema,\n ApplySubaccountPolicyInputSchema,\n type SubaccountPolicy,\n ListSubaccountPoliciesInputSchema,\n GetSubaccountPolicyInputSchema,\n} from \"./subaccount-policies.schemas.js\";\n\ninterface SubscribePoliciesInput extends BaseSubscribeInput<SubaccountPolicy> {\n accountId: string;\n}\n\n/**\n * Manages reusable subaccount policy templates, assignments, and realtime policy updates.\n */\nexport class SubaccountPoliciesService {\n #client: Client<typeof Proto.PolicyService>;\n #realtime: PolyesterRealtime;\n #resolver?: SubaccountResolver;\n\n constructor(\n transports: AuthApiTransports,\n realtime: PolyesterRealtime,\n resolver?: SubaccountResolver,\n ) {\n this.#client = createClient(Proto.PolicyService, transports.authApi);\n this.#realtime = realtime;\n this.#resolver = resolver;\n }\n\n /**\n * Returns subaccount policy templates visible to the caller, sorted by ascending policy ID.\n */\n async list(\n input: v.InferInput<typeof ListSubaccountPoliciesInputSchema> = {},\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountPolicy[]> {\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const request = parse(ListSubaccountPoliciesInputSchema, resolved);\n const result = await this.#client.listSubaccountPolicies(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(v.array(SubaccountPolicySchema), result.policies);\n }\n\n /**\n * Fetches one subaccount policy template by base58 policy ID and returns null when no policy is returned.\n */\n async get(\n input: v.InferInput<typeof GetSubaccountPolicyInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<SubaccountPolicy | null> {\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const request = parse(GetSubaccountPolicyInputSchema, resolved);\n const result = await this.#client.getSubaccountPolicy(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n if (!result.policy) return null;\n return parse(SubaccountPolicySchema, result.policy);\n }\n\n /**\n * Creates a subaccount policy template, optionally attaching it to a target subaccount in the same request.\n */\n async create(\n input: v.InferInput<typeof CreateSubaccountPolicyInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountPolicy> {\n const validatedInput = parse(CreateSubaccountPolicyInputSchema, input);\n const result = await this.#client.createSubaccountPolicy(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n if (!result.policy) throw new Error(\"Failed to create subaccount policy\");\n return parse(SubaccountPolicySchema, result.policy);\n }\n\n /**\n * Updates selected subaccount policy fields using optimistic concurrency.\n */\n async update(\n input: v.InferInput<typeof UpdateSubaccountPolicyInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<SubaccountPolicy> {\n const validatedInput = parse(UpdateSubaccountPolicyInputSchema, input);\n const result = await this.#client.updateSubaccountPolicy(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n if (!result.policy) throw new Error(\"Failed to update subaccount policy\");\n return parse(SubaccountPolicySchema, result.policy);\n }\n\n /**\n * Deletes a subaccount policy template when it is not in use.\n */\n async delete(policyId: string, options?: PolyesterMutationOptions): Promise<void> {\n const validatedPolicyId = parse(PolicyIdSchema, policyId);\n await this.#client.deleteSubaccountPolicy(\n { policyId: validatedPolicyId },\n toConnectCallOptions(options),\n );\n }\n\n /**\n * Attaches a policy to a subaccount. Passing a null policyId clears the explicit binding and restores the system read-only policy.\n */\n async apply(\n input: v.InferInput<typeof ApplySubaccountPolicyInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<void> {\n const validatedInput = parse(ApplySubaccountPolicyInputSchema, input);\n await this.#client.setSubaccountPolicy(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n }\n\n /**\n * Subscribes to private subaccount policy updates for an account and emits normalized policy views.\n */\n subscribePolicies(input: SubscribePoliciesInput) {\n const channel = `private:auth:subaccount-policies:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: Proto.SubaccountPolicyViewSchema,\n onPublication: (data) => {\n const policy = parse(SubaccountPolicySchema, data);\n input.onEvent(policy);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;AAgCA,IAAa,4BAAb,MAAuC;CACnC;CACA;CACA;CAEA,YACI,YACA,UACA,UACF;EACE,KAAKA,UAAU,aAAaC,eAAqB,WAAW,OAAO;EACnE,KAAKC,YAAY;EACjB,KAAKC,YAAY;CACrB;;;;CAKA,MAAM,KACF,QAAgE,CAAC,GACjE,SAC2B;EAC3B,MAAM,WAAW,0BAA0B,OAAO,KAAKA,SAAS;EAChE,MAAM,UAAU,MAAM,mCAAmC,QAAQ;EACjE,MAAM,SAAS,MAAM,KAAKH,QAAQ,uBAC9B,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,EAAE,MAAM,sBAAsB,GAAG,OAAO,QAAQ;CACjE;;;;CAKA,MAAM,IACF,OACA,SACgC;EAChC,MAAM,WAAW,0BAA0B,OAAO,KAAKG,SAAS;EAChE,MAAM,UAAU,MAAM,gCAAgC,QAAQ;EAC9D,MAAM,SAAS,MAAM,KAAKH,QAAQ,oBAC9B,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,IAAI,CAAC,OAAO,QAAQ,OAAO;EAC3B,OAAO,MAAM,wBAAwB,OAAO,MAAM;CACtD;;;;CAKA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
|
import { PolyesterRequestOptions } from "../../shared/request-options.js";
|
|
3
3
|
import { AccountScopedInput } from "../../shared/account-scope.js";
|
|
4
4
|
import { SubaccountResolver } from "../subaccount-resolver.js";
|
|
@@ -9,7 +9,7 @@ import { RateLimitConfig, TradingRateLimits } from "./rate-limits.schemas.js";
|
|
|
9
9
|
*/
|
|
10
10
|
declare class RateLimitService {
|
|
11
11
|
#private;
|
|
12
|
-
constructor(transports:
|
|
12
|
+
constructor(transports: AuthAndPublicApiTransports, resolver?: SubaccountResolver);
|
|
13
13
|
/**
|
|
14
14
|
* Returns the complete active placement and cancellation quota catalog for VIP0+.
|
|
15
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limits.d.ts","names":[],"sources":["../../../src/services/rate-limits/rate-limits.ts"],"mappings":";;;;;;;;;cAsBa;;EAKG,YAAA,YAAY,
|
|
1
|
+
{"version":3,"file":"rate-limits.d.ts","names":[],"sources":["../../../src/services/rate-limits/rate-limits.ts"],"mappings":";;;;;;;;;cAsBa;;EAKG,YAAA,YAAY,4BAA4B,WAAW;;;;EASzD,UAAU,UAAU,0BAA0B,QAAQ;;;;EAQtD,iBACF,QAAO,oBACP,UAAU,0BACX,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-limits.js","names":["#publicClient","Proto.RateLimitService","#authClient","#resolver"],"sources":["../../../src/services/rate-limits/rate-limits.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/ratelimit/v1/ratelimit_pb.js\";\nimport type { AccountScopedInput } from \"../../shared/account-scope.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type {
|
|
1
|
+
{"version":3,"file":"rate-limits.js","names":["#publicClient","Proto.RateLimitService","#authClient","#resolver"],"sources":["../../../src/services/rate-limits/rate-limits.ts"],"sourcesContent":["import { createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/ratelimit/v1/ratelimit_pb.js\";\nimport type { AccountScopedInput } from \"../../shared/account-scope.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport {\n GetTradingRateLimitsInputSchema,\n RateLimitConfigSchema,\n TradingRateLimitsSchema,\n type RateLimitConfig,\n type TradingRateLimits,\n} from \"./rate-limits.schemas.js\";\n\n/**\n * Reads public trading quota catalogs and authenticated effective trading limits.\n */\nexport class RateLimitService {\n #publicClient: Client<typeof Proto.RateLimitService>;\n #authClient: Client<typeof Proto.RateLimitService>;\n #resolver?: SubaccountResolver;\n\n constructor(transports: AuthAndPublicApiTransports, resolver?: SubaccountResolver) {\n this.#publicClient = createClient(Proto.RateLimitService, transports.publicApi);\n this.#authClient = createClient(Proto.RateLimitService, transports.authApi);\n this.#resolver = resolver;\n }\n\n /**\n * Returns the complete active placement and cancellation quota catalog for VIP0+.\n */\n async getConfig(options?: PolyesterRequestOptions): Promise<RateLimitConfig> {\n const res = await this.#publicClient.getRateLimitConfig({}, toConnectCallOptions(options));\n return parse(RateLimitConfigSchema, res);\n }\n\n /**\n * Returns the effective placement and cancellation limits for the resolved account target, including API-key-scoped rules when the caller authenticated with an API key.\n */\n async getTradingLimits(\n input: AccountScopedInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<TradingRateLimits> {\n const resolvedInput = resolveAccountScopedInput(input, this.#resolver);\n const res = await this.#authClient.getTradingRateLimits(\n removeUndefined(parse(GetTradingRateLimitsInputSchema, resolvedInput)),\n toConnectCallOptions(options),\n );\n return parse(TradingRateLimitsSchema, res);\n }\n}\n"],"mappings":";;;;;;;;;;;AAsBA,IAAa,mBAAb,MAA8B;CAC1B;CACA;CACA;CAEA,YAAY,YAAwC,UAA+B;EAC/E,KAAKA,gBAAgB,aAAaC,oBAAwB,WAAW,SAAS;EAC9E,KAAKC,cAAc,aAAaD,oBAAwB,WAAW,OAAO;EAC1E,KAAKE,YAAY;CACrB;;;;CAKA,MAAM,UAAU,SAA6D;EACzE,MAAM,MAAM,MAAM,KAAKH,cAAc,mBAAmB,CAAC,GAAG,qBAAqB,OAAO,CAAC;EACzF,OAAO,MAAM,uBAAuB,GAAG;CAC3C;;;;CAKA,MAAM,iBACF,QAA4B,CAAC,GAC7B,SAC0B;EAC1B,MAAM,gBAAgB,0BAA0B,OAAO,KAAKG,SAAS;EACrE,MAAM,MAAM,MAAM,KAAKD,YAAY,qBAC/B,gBAAgB,MAAM,iCAAiC,aAAa,CAAC,GACrE,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,yBAAyB,GAAG;CAC7C;AACJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { AuthApiTransports } from "../../shared/transports.js";
|
|
1
2
|
import { PolyesterMutationOptions, PolyesterRequestOptions } from "../../shared/request-options.js";
|
|
2
3
|
import { GetVerificationResponse, SocialProviderInputSchema, StartVerificationInput, StartVerificationResponse, VerificationReadyResponse } from "./social-verification.schemas.js";
|
|
3
|
-
import { Transport } from "@connectrpc/connect";
|
|
4
4
|
import * as v from "valibot";
|
|
5
5
|
//#region src/services/social-verification/social-verification.d.ts
|
|
6
6
|
/**
|
|
@@ -8,7 +8,7 @@ import * as v from "valibot";
|
|
|
8
8
|
*/
|
|
9
9
|
declare class SocialVerificationService {
|
|
10
10
|
#private;
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(transports: AuthApiTransports);
|
|
12
12
|
/**
|
|
13
13
|
* Starts or restarts provider verification for a handle, normalizing leading @, defaulting to profile verification, and returning a poly_... challenge code that expires after about 15 minutes.
|
|
14
14
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"social-verification.d.ts","names":[],"sources":["../../../src/services/social-verification/social-verification.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"social-verification.d.ts","names":[],"sources":["../../../src/services/social-verification/social-verification.ts"],"mappings":";;;;;;;;cAyBa;;EAGG,YAAA,YAAY;;;;EAOlB,MACF,OAAO,wBACP,UAAU,2BACX,QAAQ;;;;EAYL,UACF,OAAO,EAAE,kBAAkB,4BAC3B,UAAU,2BACX,QAAQ;;;;EAYL,IACF,OAAO,EAAE,kBAAkB,4BAC3B,UAAU,0BACX,QAAQ"}
|
|
@@ -9,8 +9,8 @@ import { createClient } from "@connectrpc/connect";
|
|
|
9
9
|
*/
|
|
10
10
|
var SocialVerificationService = class {
|
|
11
11
|
#client;
|
|
12
|
-
constructor(
|
|
13
|
-
this.#client = createClient(SocialVerificationService$1,
|
|
12
|
+
constructor(transports) {
|
|
13
|
+
this.#client = createClient(SocialVerificationService$1, transports.authApi);
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Starts or restarts provider verification for a handle, normalizing leading @, defaulting to profile verification, and returning a poly_... challenge code that expires after about 15 minutes.
|
|
@@ -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
|
|
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 StartVerificationInputSchema,\n StartVerificationResponseSchema,\n VerificationReadyResponseSchema,\n GetVerificationResponseSchema,\n SocialProviderInputSchema,\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 for a handle, normalizing leading @, defaulting to profile verification, and returning a poly_... challenge code that expires after about 15 minutes.\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.\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"],"mappings":";;;;;;;;;AAyBA,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;AACJ"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AuthAndPublicApiTransports } from "../../shared/transports.js";
|
|
1
2
|
import { PolyesterMutationOptions, PolyesterRequestOptions } from "../../shared/request-options.js";
|
|
2
3
|
import { SubaccountResolver } from "../subaccount-resolver.js";
|
|
3
4
|
import { PolyesterRealtime } from "../../realtime/types.js";
|
|
@@ -9,7 +10,6 @@ import { SubaccountPolicy } from "../policies/subaccount-policies/subaccount-pol
|
|
|
9
10
|
import { SubaccountPoliciesService } from "../policies/subaccount-policies/subaccount-policies.js";
|
|
10
11
|
import "../policies/subaccount-policies/index.js";
|
|
11
12
|
import { CreateSubaccountInputSchema, CreateSubaccountResult, DeleteSubaccountInputSchema, EffectiveSubaccountPermissions, InviteSubaccountMemberInputSchema, ListSubaccountInvitesInputSchema, RemoveSubaccountMemberInputSchema, RespondSubaccountInviteInputSchema, SetSubaccountMemberMfaRequirementInputSchema, Subaccount, SubaccountActivityInputSchema, SubaccountEvent, SubaccountIdInputSchema, SubaccountInvite, SubaccountMember, SubaccountMutationResult, SubaccountRoleCatalog, SubaccountSchema, UpdateSubaccountInputSchema, UpdateSubaccountMemberRoleInputSchema } from "./subaccounts.schemas.js";
|
|
12
|
-
import { Transport } from "@connectrpc/connect";
|
|
13
13
|
import * as v from "valibot";
|
|
14
14
|
//#region src/services/subaccounts/subaccounts.d.ts
|
|
15
15
|
interface SubscribeSubaccountsInput extends BaseSubscribeInput<Subaccount> {
|
|
@@ -19,12 +19,12 @@ interface SubscribeApiKeysInput extends BaseSubscribeInput<ApiKey> {
|
|
|
19
19
|
accountId: string;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Reads the public role catalog and creates, manages, shares, audits, and subscribes to subaccounts visible to the authenticated caller.
|
|
23
23
|
*/
|
|
24
24
|
declare class SubaccountsService {
|
|
25
25
|
#private;
|
|
26
26
|
readonly policies: SubaccountPoliciesService;
|
|
27
|
-
constructor(
|
|
27
|
+
constructor(transports: AuthAndPublicApiTransports, realtime: PolyesterRealtime, resolver?: SubaccountResolver);
|
|
28
28
|
/**
|
|
29
29
|
* Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted count metadata useful for deriving future smart-account salts.
|
|
30
30
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccounts.d.ts","names":[],"sources":["../../../src/services/subaccounts/subaccounts.ts"],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"subaccounts.d.ts","names":[],"sources":["../../../src/services/subaccounts/subaccounts.ts"],"mappings":";;;;;;;;;;;;;;UAoDU,kCAAkC,mBAAmB;EAC3D;;UAGM,8BAA8B,mBAAmB;EACvD;;;;;cAMS;;WACA,UAAU;EASf,YAAA,YAAY,4BACZ,UAAU,mBACV,WAAW;;;;EAaT,KAAK,UAAU,0BAA0B;IAC3C;IACA,aAAa,EAAE,mBAAmB;;;;;EAYhC,IACF,OAAO,EAAE,kBAAkB,0BAC3B,UAAU,0BACX,QACC;IACI,SAAS;IACT,QAAQ;IACR,SAAS;IACT,SAAS;;;;;EAmCX,OACF,OAAO,EAAE,kBAAkB,8BAC3B,UAAU,2BACX,QAAQ;;;;EAYL,OACF,OAAO,EAAE,kBAAkB,8BAC3B,UAAU,2BACX,QAAQ;;;;EAaL,aACF,OAAO,EAAE,kBAAkB,oCAC3B,UAAU,2BACX,QAAQ;;;;EAYL,aACF,OAAO,EAAE,kBAAkB,oCAC3B,UAAU,2BACX,QAAQ;;;;EAYL,iBACF,OAAO,EAAE,kBAAkB,wCAC3B,UAAU,2BACX,QAAQ;;;;EAYL,wBACF,OAAO,EAAE,kBAAkB,+CAC3B,UAAU,2BACX,QAAQ;;;;EAYL,YACF,OAAO,EAAE,kBAAkB,mCAC3B,UAAU,0BACX,QAAQ;;;;EAYL,UAAU,UAAU,0BAA0B,QAAQ;;;;EAWtD,wBACF,OAAO,EAAE,kBAAkB,0BAC3B,UAAU,0BACX,QAAQ;;;;EAYL,YACF,OAAO,EAAE,kBAAkB,0BAC3B,UAAU,0BACX,QAAQ;;;;EAYL,cACF,OAAO,EAAE,kBAAkB,qCAC3B,UAAU,2BACX,QAAQ;;;;EAYL,OACF,OAAO,EAAE,kBAAkB,8BAC3B,UAAU,2BACX,QAAQ;;;;EAkBL,WACF,OAAO,EAAE,kBAAkB,gCAC3B,UAAU,0BACX;IAAU,QAAQ;IAAmB;;;;;EAexC,UAAU,OAAO;;;;EAmBjB,iBAAiB,OAAO"}
|
|
@@ -11,19 +11,21 @@ import { createClient } from "@connectrpc/connect";
|
|
|
11
11
|
import * as v from "valibot";
|
|
12
12
|
//#region src/services/subaccounts/subaccounts.ts
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* Reads the public role catalog and creates, manages, shares, audits, and subscribes to subaccounts visible to the authenticated caller.
|
|
15
15
|
*/
|
|
16
16
|
var SubaccountsService = class {
|
|
17
17
|
policies;
|
|
18
18
|
#client;
|
|
19
19
|
#viewClient;
|
|
20
|
-
#
|
|
20
|
+
#publicRoleClient;
|
|
21
|
+
#authRoleClient;
|
|
21
22
|
#realtime;
|
|
22
|
-
constructor(
|
|
23
|
-
this.policies = new SubaccountPoliciesService(
|
|
24
|
-
this.#client = createClient(SubaccountService,
|
|
25
|
-
this.#viewClient = createClient(SubaccountViewService,
|
|
26
|
-
this.#
|
|
23
|
+
constructor(transports, realtime, resolver) {
|
|
24
|
+
this.policies = new SubaccountPoliciesService(transports, realtime, resolver);
|
|
25
|
+
this.#client = createClient(SubaccountService, transports.authApi);
|
|
26
|
+
this.#viewClient = createClient(SubaccountViewService, transports.authApi);
|
|
27
|
+
this.#publicRoleClient = createClient(SubaccountRoleService, transports.publicApi);
|
|
28
|
+
this.#authRoleClient = createClient(SubaccountRoleService, transports.authApi);
|
|
27
29
|
this.#realtime = realtime;
|
|
28
30
|
}
|
|
29
31
|
/**
|
|
@@ -121,7 +123,7 @@ var SubaccountsService = class {
|
|
|
121
123
|
* Returns the public built-in role and permission catalog with display metadata and per-role permission sets.
|
|
122
124
|
*/
|
|
123
125
|
async listRoles(options) {
|
|
124
|
-
const res = await this.#
|
|
126
|
+
const res = await this.#publicRoleClient.listSubaccountRoles({}, toConnectCallOptions(options));
|
|
125
127
|
return parse(SubaccountRoleCatalogSchema, res);
|
|
126
128
|
}
|
|
127
129
|
/**
|
|
@@ -129,7 +131,7 @@ var SubaccountsService = class {
|
|
|
129
131
|
*/
|
|
130
132
|
async getEffectivePermissions(input, options) {
|
|
131
133
|
const validatedInput = parse(SubaccountIdInputSchema, input);
|
|
132
|
-
const res = await this.#
|
|
134
|
+
const res = await this.#authRoleClient.getEffectiveSubaccountPermissions(validatedInput, toConnectCallOptions(options));
|
|
133
135
|
return parse(EffectiveSubaccountPermissionsSchema, res);
|
|
134
136
|
}
|
|
135
137
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subaccounts.js","names":["#client","Proto.SubaccountService","#viewClient","Proto.SubaccountViewService","#roleClient","Proto.SubaccountRoleService","#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, type Transport } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { type ApiKey, ApiKeySchema } from \"../api-keys/index.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { PolyesterRealtime } from \"../../realtime/index.js\";\nimport {\n DEFAULT_SUBACCOUNT_POLICY,\n SubaccountPoliciesService,\n type SubaccountPolicy,\n SubaccountPolicySchema,\n} from \"../policies/subaccount-policies/index.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport type { SubaccountResolver } from \"../subaccount-resolver.js\";\nimport {\n CreateSubaccountInputSchema,\n CreateSubaccountResultSchema,\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 DeleteSubaccountInputSchema,\n SubaccountMutationResultSchema,\n SubaccountRoleCatalogSchema,\n EffectiveSubaccountPermissionsSchema,\n type CreateSubaccountResult,\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 * 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 #roleClient: Client<typeof Proto.SubaccountRoleService>;\n #realtime: PolyesterRealtime;\n\n constructor(transport: Transport, realtime: PolyesterRealtime, resolver?: SubaccountResolver) {\n this.policies = new SubaccountPoliciesService(transport, realtime, resolver);\n this.#client = createClient(Proto.SubaccountService, transport);\n this.#viewClient = createClient(Proto.SubaccountViewService, transport);\n this.#roleClient = createClient(Proto.SubaccountRoleService, transport);\n this.#realtime = realtime;\n }\n\n /**\n * Returns subaccounts owned by or shared with the caller plus totalCreated, including soft-deleted count metadata useful for deriving future smart-account salts.\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, balances, members, and outgoing invites; throws if the subaccount is missing.\n */\n async get(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<\n Subaccount & {\n apiKeys: ApiKey[];\n policy: SubaccountPolicy;\n members: SubaccountMember[];\n invites: SubaccountInvite[];\n }\n > {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const subaccountId = formatId(validatedInput.subaccountId);\n const res = await this.#viewClient.getSubaccount(\n {\n subaccountId: validatedInput.subaccountId,\n includeApiKeys: true,\n includeBalances: true,\n includeMembers: true,\n includeInvites: true,\n includePolicy: true,\n invitesDirection: \"outgoing\",\n },\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(`Subaccount not found: ${subaccountId}`);\n\n return {\n ...parse(SubaccountSchema, res.subaccount),\n policy: res.policy\n ? parse(SubaccountPolicySchema, res.policy)\n : DEFAULT_SUBACCOUNT_POLICY,\n apiKeys: parse(v.optional(v.array(ApiKeySchema), []), res.apiKeys),\n members: parse(v.optional(v.array(SubaccountMemberSchema), []), res.members),\n invites: v\n .parse(v.optional(v.array(SubaccountInviteSchema), []), res.invites)\n .filter((invite) => invite.subaccountId === subaccountId),\n };\n }\n\n /**\n * Creates a new subaccount under the caller's root account using a smart-account address, nonce, and signature proof.\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/deleted 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 incoming, outgoing, or all subaccount invitations for the caller, newest first.\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.#roleClient.listSubaccountRoles({}, toConnectCallOptions(options));\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.#roleClient.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 * Soft-deletes a subaccount by updating its status to deleted.\n */\n async delete(\n input: v.InferInput<typeof DeleteSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<Subaccount> {\n const validatedInput = parse(DeleteSubaccountInputSchema, input);\n const res = await this.#client.updateSubaccount(\n {\n subaccountId: validatedInput.subaccountId,\n subaccount: { status: \"deleted\" },\n updateMask: { paths: [\"status\"] },\n expectedRevision: validatedInput.expectedRevision,\n },\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(\"Failed to delete subaccount\");\n return parse(SubaccountSchema, res.subaccount);\n }\n\n /**\n * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination.\n */\n async listEvents(\n input: v.InferInput<typeof SubaccountActivityInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<{ events: SubaccountEvent[]; nextPageToken: string }> {\n const validatedInput = parse(SubaccountActivityInputSchema, input);\n const res = await this.#viewClient.listSubaccountActivity(\n validatedInput,\n toConnectCallOptions(options),\n );\n return {\n events: parse(v.optional(v.array(SubaccountActivityEventSchema), []), res.events),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Subscribes to private subaccount updates for an account and emits normalized subaccount records.\n */\n subscribe(input: SubscribeSubaccountsInput) {\n const channel = `private:auth:subaccounts:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: Proto.SubaccountSchema,\n onPublication: (data) => {\n const subaccount = parse(SubaccountSchema, data);\n input.onEvent(subaccount);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n\n /**\n * Subscribes to private API key updates for an account through the subaccount realtime channel helper.\n */\n subscribeApiKeys(input: SubscribeApiKeysInput) {\n const channel = `private:auth:api-keys:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: ProtoApiKeys.ApiKeySchema,\n onPublication: (data) => {\n const apiKey = parse(ApiKeySchema, data);\n input.onEvent(apiKey);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA8DA,IAAa,qBAAb,MAAgC;CAC5B;CAEA;CACA;CACA;CACA;CAEA,YAAY,WAAsB,UAA6B,UAA+B;EAC1F,KAAK,WAAW,IAAI,0BAA0B,WAAW,UAAU,QAAQ;EAC3E,KAAKA,UAAU,aAAaC,mBAAyB,SAAS;EAC9D,KAAKC,cAAc,aAAaC,uBAA6B,SAAS;EACtE,KAAKC,cAAc,aAAaC,uBAA6B,SAAS;EACtE,KAAKC,YAAY;CACrB;;;;CAKA,MAAM,KAAK,SAGR;EACC,MAAM,MAAM,MAAM,KAAKN,QAAQ,gBAAgB,CAAC,GAAG,qBAAqB,OAAO,CAAC;EAChF,OAAO;GACH,cAAc,IAAI;GAClB,aAAa,MAAM,EAAE,MAAMO,kBAAgB,GAAG,IA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,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 type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport type { AuthAndPublicApiTransports } from \"../../shared/transports.js\";\nimport type { SubaccountResolver } from \"../subaccount-resolver.js\";\nimport {\n CreateSubaccountInputSchema,\n CreateSubaccountResultSchema,\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 DeleteSubaccountInputSchema,\n SubaccountMutationResultSchema,\n SubaccountRoleCatalogSchema,\n EffectiveSubaccountPermissionsSchema,\n type CreateSubaccountResult,\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 count metadata useful for deriving future smart-account salts.\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, balances, members, and outgoing invites; throws if the subaccount is missing.\n */\n async get(\n input: v.InferInput<typeof SubaccountIdInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<\n Subaccount & {\n apiKeys: ApiKey[];\n policy: SubaccountPolicy;\n members: SubaccountMember[];\n invites: SubaccountInvite[];\n }\n > {\n const validatedInput = parse(SubaccountIdInputSchema, input);\n const subaccountId = formatId(validatedInput.subaccountId);\n const res = await this.#viewClient.getSubaccount(\n {\n subaccountId: validatedInput.subaccountId,\n includeApiKeys: true,\n includeBalances: true,\n includeMembers: true,\n includeInvites: true,\n includePolicy: true,\n invitesDirection: \"outgoing\",\n },\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(`Subaccount not found: ${subaccountId}`);\n\n return {\n ...parse(SubaccountSchema, res.subaccount),\n policy: res.policy\n ? parse(SubaccountPolicySchema, res.policy)\n : DEFAULT_SUBACCOUNT_POLICY,\n apiKeys: parse(v.optional(v.array(ApiKeySchema), []), res.apiKeys),\n members: parse(v.optional(v.array(SubaccountMemberSchema), []), res.members),\n invites: v\n .parse(v.optional(v.array(SubaccountInviteSchema), []), res.invites)\n .filter((invite) => invite.subaccountId === subaccountId),\n };\n }\n\n /**\n * Creates a new subaccount under the caller's root account using a smart-account address, nonce, and signature proof.\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/deleted 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 incoming, outgoing, or all subaccount invitations for the caller, newest first.\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 * Soft-deletes a subaccount by updating its status to deleted.\n */\n async delete(\n input: v.InferInput<typeof DeleteSubaccountInputSchema>,\n options?: PolyesterMutationOptions,\n ): Promise<Subaccount> {\n const validatedInput = parse(DeleteSubaccountInputSchema, input);\n const res = await this.#client.updateSubaccount(\n {\n subaccountId: validatedInput.subaccountId,\n subaccount: { status: \"deleted\" },\n updateMask: { paths: [\"status\"] },\n expectedRevision: validatedInput.expectedRevision,\n },\n toConnectCallOptions(options),\n );\n if (!res.subaccount) throw new Error(\"Failed to delete subaccount\");\n return parse(SubaccountSchema, res.subaccount);\n }\n\n /**\n * Returns paginated audit/activity events for a subaccount, newest first, with a non-negative integer limit from 0 through 200 and opaque cursor pagination.\n */\n async listEvents(\n input: v.InferInput<typeof SubaccountActivityInputSchema>,\n options?: PolyesterRequestOptions,\n ): Promise<{ events: SubaccountEvent[]; nextPageToken: string }> {\n const validatedInput = parse(SubaccountActivityInputSchema, input);\n const res = await this.#viewClient.listSubaccountActivity(\n validatedInput,\n toConnectCallOptions(options),\n );\n return {\n events: parse(v.optional(v.array(SubaccountActivityEventSchema), []), res.events),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Subscribes to private subaccount updates for an account and emits normalized subaccount records.\n */\n subscribe(input: SubscribeSubaccountsInput) {\n const channel = `private:auth:subaccounts:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: Proto.SubaccountSchema,\n onPublication: (data) => {\n const subaccount = parse(SubaccountSchema, data);\n input.onEvent(subaccount);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n\n /**\n * Subscribes to private API key updates for an account through the subaccount realtime channel helper.\n */\n subscribeApiKeys(input: SubscribeApiKeysInput) {\n const channel = `private:auth:api-keys:${input.accountId}:proto`;\n\n return this.#realtime.connectProtoChannel({\n channel,\n schema: ProtoApiKeys.ApiKeySchema,\n onPublication: (data) => {\n const apiKey = parse(ApiKeySchema, data);\n input.onEvent(apiKey);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AA+DA,IAAa,qBAAb,MAAgC;CAC5B;CAEA;CACA;CACA;CACA;CACA;CAEA,YACI,YACA,UACA,UACF;EACE,KAAK,WAAW,IAAI,0BAA0B,YAAY,UAAU,QAAQ;EAC5E,KAAKA,UAAU,aAAaC,mBAAyB,WAAW,OAAO;EACvE,KAAKC,cAAc,aAAaC,uBAA6B,WAAW,OAAO;EAC/E,KAAKC,oBAAoB,aAAaC,uBAA6B,WAAW,SAAS;EACvF,KAAKC,kBAAkB,aAAaD,uBAA6B,WAAW,OAAO;EACnF,KAAKE,YAAY;CACrB;;;;CAKA,MAAM,KAAK,SAGR;EACC,MAAM,MAAM,MAAM,KAAKP,QAAQ,gBAAgB,CAAC,GAAG,qBAAqB,OAAO,CAAC;EAChF,OAAO;GACH,cAAc,IAAI;GAClB,aAAa,MAAM,EAAE,MAAMQ,kBAAgB,GAAG,IAAI,WAAW;EACjE;CACJ;;;;CAKA,MAAM,IACF,OACA,SAQF;EACE,MAAM,iBAAiB,MAAM,yBAAyB,KAAK;EAC3D,MAAM,eAAe,SAAS,eAAe,YAAY;EACzD,MAAM,MAAM,MAAM,KAAKN,YAAY,cAC/B;GACI,cAAc,eAAe;GAC7B,gBAAgB;GAChB,iBAAiB;GACjB,gBAAgB;GA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KD,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"}
|
|
@@ -283,8 +283,8 @@ declare const SubaccountActivityEventSchema: v.ObjectSchema<{
|
|
|
283
283
|
seconds: bigint;
|
|
284
284
|
nanos: number;
|
|
285
285
|
} | undefined, number | undefined>]>;
|
|
286
|
-
readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "
|
|
287
|
-
readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "
|
|
286
|
+
readonly entityKind: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEntityKind, undefined>, v.TransformAction<ActivityEntityKind, "unspecified" | "api_key" | "account" | "subaccount" | "destination" | "session" | "member" | "policy" | "invite" | "security">]>;
|
|
287
|
+
readonly eventAction: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventAction, undefined>, v.TransformAction<ActivityEventAction, "unspecified" | "enabled" | "disabled" | "deleted" | "created" | "updated" | "removed" | "role_set" | "received" | "replied" | "failed" | "revoked" | "blocked" | "hold_placed" | "hold_released">]>;
|
|
288
288
|
readonly source: v.SchemaWithPipe<readonly [v.EnumSchema<typeof ActivityEventSource, undefined>, v.TransformAction<ActivityEventSource, "unspecified" | "web" | "mobile" | "api">]>;
|
|
289
289
|
readonly ip: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
290
290
|
readonly userAgent: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { AuthApiTransports } from "../../shared/transports.js";
|
|
1
2
|
import { PolyesterRequestOptions } from "../../shared/request-options.js";
|
|
2
3
|
import { SubaccountResolver } from "../subaccount-resolver.js";
|
|
3
4
|
import { PolyesterRealtime } from "../../realtime/types.js";
|
|
4
5
|
import { BaseSubscribeInput } from "../../shared/types.js";
|
|
5
6
|
import { SdkScales } from "../../shared/decimal-surface.js";
|
|
6
7
|
import { GetUserTradesInputSchema, Trade } from "./trades.schemas.js";
|
|
7
|
-
import { Transport } from "@connectrpc/connect";
|
|
8
8
|
import * as v from "valibot";
|
|
9
9
|
//#region src/services/trades/trades.d.ts
|
|
10
10
|
interface SubscribeTradesInput extends BaseSubscribeInput<Trade> {
|
|
@@ -15,7 +15,7 @@ interface SubscribeTradesInput extends BaseSubscribeInput<Trade> {
|
|
|
15
15
|
*/
|
|
16
16
|
declare class TradesService {
|
|
17
17
|
#private;
|
|
18
|
-
constructor(
|
|
18
|
+
constructor(transports: AuthApiTransports, realtime: PolyesterRealtime, resolver: SubaccountResolver | undefined, scales: SdkScales);
|
|
19
19
|
/**
|
|
20
20
|
* Returns user trades for the resolved root account or subaccount, supporting symbol, side, time range, limit, page token, and after-match-ID replay cursor filters. Results include the next page token from GetUserTrades.
|
|
21
21
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trades.d.ts","names":[],"sources":["../../../src/services/trades/trades.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"trades.d.ts","names":[],"sources":["../../../src/services/trades/trades.ts"],"mappings":";;;;;;;;;UAiBU,6BAA6B,mBAAmB;EACtD;;;;;cAMS;;EAQL,YAAA,YAAY,mBACZ,UAAU,mBACV,UAAU,gCACV,QAAQ;;;;EAYN,KACF,QAAO,EAAE,kBAAkB,2BAC3B,UAAU,0BACX;IAAU,QAAQ;IAAS;;;;;EAiB9B,UAAU,OAAO"}
|
|
@@ -17,8 +17,8 @@ var TradesService = class {
|
|
|
17
17
|
#resolver;
|
|
18
18
|
#scales;
|
|
19
19
|
#userTradeSchema;
|
|
20
|
-
constructor(
|
|
21
|
-
this.#client = createClient(OrdersReadService,
|
|
20
|
+
constructor(transports, realtime, resolver, scales) {
|
|
21
|
+
this.#client = createClient(OrdersReadService, transports.authApi);
|
|
22
22
|
this.#realtime = realtime;
|
|
23
23
|
this.#resolver = resolver;
|
|
24
24
|
this.#scales = scales;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trades.js","names":["#client","Proto.OrdersReadService","#realtime","#resolver","#scales","#userTradeSchema","Proto.UserTradeSchema"],"sources":["../../../src/services/trades/trades.ts"],"sourcesContent":["import * as Proto from \"../../gen/orders/v1/orders_read_pb.js\";\nimport { createClient, type Client
|
|
1
|
+
{"version":3,"file":"trades.js","names":["#client","Proto.OrdersReadService","#realtime","#resolver","#scales","#userTradeSchema","Proto.UserTradeSchema"],"sources":["../../../src/services/trades/trades.ts"],"sourcesContent":["import * as Proto from \"../../gen/orders/v1/orders_read_pb.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport * as v from \"valibot\";\nimport { parse } from \"../../shared/validation.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport type { PolyesterRealtime } from \"../../realtime/types.js\";\nimport { connectReadyGatedProtoChannel } from \"../../realtime/ready-gated-subscription.js\";\nimport type { BaseSubscribeInput } from \"../../shared/types.js\";\nimport {\n toConnectCallOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport type { AuthApiTransports } from \"../../shared/transports.js\";\nimport { GetUserTradesInputSchema, createUserTradeSchema, type Trade } from \"./trades.schemas.js\";\n\ninterface SubscribeTradesInput extends BaseSubscribeInput<Trade> {\n accountId: string;\n}\n\n/**\n * Reads and streams authenticated user trade fills.\n */\nexport class TradesService {\n #client: Client<typeof Proto.OrdersReadService>;\n #realtime: PolyesterRealtime;\n #resolver?: SubaccountResolver;\n #scales: SdkScales;\n #userTradeSchema: ReturnType<typeof createUserTradeSchema>;\n\n constructor(\n transports: AuthApiTransports,\n realtime: PolyesterRealtime,\n resolver: SubaccountResolver | undefined,\n scales: SdkScales,\n ) {\n this.#client = createClient(Proto.OrdersReadService, transports.authApi);\n this.#realtime = realtime;\n this.#resolver = resolver;\n this.#scales = scales;\n this.#userTradeSchema = createUserTradeSchema(scales);\n }\n\n /**\n * Returns user trades for the resolved root account or subaccount, supporting symbol, side, time range, limit, page token, and after-match-ID replay cursor filters. Results include the next page token from GetUserTrades.\n */\n async list(\n input: v.InferInput<typeof GetUserTradesInputSchema> = {},\n options?: PolyesterRequestOptions,\n ): Promise<{ trades: Trade[]; nextPageToken: string }> {\n await this.#scales.ready();\n const resolved = resolveAccountScopedInput(input, this.#resolver);\n const validatedInput = parse(GetUserTradesInputSchema, resolved);\n const res = await this.#client.getUserTrades(\n removeUndefined(validatedInput),\n toConnectCallOptions(options),\n );\n return {\n trades: parse(v.array(this.#userTradeSchema), res.trades),\n nextPageToken: res.nextPageToken,\n };\n }\n\n /**\n * Subscribes to private user trade updates on private:spot:trades:{accountId}:proto and emits parsed fills.\n */\n subscribe(input: SubscribeTradesInput) {\n const channel = `private:spot:trades:${input.accountId}:proto`;\n return connectReadyGatedProtoChannel(this.#realtime, {\n channel,\n schema: Proto.UserTradeSchema,\n ready: () => this.#scales.ready(),\n onPublication: (data) => {\n const trade = parse(this.#userTradeSchema, data);\n input.onEvent(trade);\n },\n onConnected: () => input.onOpen?.(),\n onDisconnected: () => input.onClose?.(),\n onError: input.onError,\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAwBA,IAAa,gBAAb,MAA2B;CACvB;CACA;CACA;CACA;CACA;CAEA,YACI,YACA,UACA,UACA,QACF;EACE,KAAKA,UAAU,aAAaC,mBAAyB,WAAW,OAAO;EACvE,KAAKC,YAAY;EACjB,KAAKC,YAAY;EACjB,KAAKC,UAAU;EACf,KAAKC,mBAAmB,sBAAsB,MAAM;CACxD;;;;CAKA,MAAM,KACF,QAAuD,CAAC,GACxD,SACmD;EACnD,MAAM,KAAKD,QAAQ,MAAM;EACzB,MAAM,WAAW,0BAA0B,OAAO,KAAKD,SAAS;EAChE,MAAM,iBAAiB,MAAM,0BAA0B,QAAQ;EAC/D,MAAM,MAAM,MAAM,KAAKH,QAAQ,cAC3B,gBAAgB,cAAc,GAC9B,qBAAqB,OAAO,CAChC;EACA,OAAO;GACH,QAAQ,MAAM,EAAE,MAAM,KAAKK,gBAAgB,GAAG,IAAI,MAAM;GACxD,eAAe,IAAI;EACvB;CACJ;;;;CAKA,UAAU,OAA6B;EACnC,MAAM,UAAU,uBAAuB,MAAM,UAAU;EACvD,OAAO,8BAA8B,KAAKH,WAAW;GACjD;GACA,QAAQI;GACR,aAAa,KAAKF,QAAQ,MAAM;GAChC,gBAAgB,SAAS;IACrB,MAAM,QAAQ,MAAM,KAAKC,kBAAkB,IAAI;IAC/C,MAAM,QAAQ,KAAK;GACvB;GACA,mBAAmB,MAAM,SAAS;GAClC,sBAAsB,MAAM,UAAU;GACtC,SAAS,MAAM;EACnB,CAAC;CACL;AACJ"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ClientCatalog } from "../../catalogs/types.js";
|
|
2
2
|
import { TradingWithdrawAction } from "../../gen/chain/withdraw/v1/withdraw_pb.js";
|
|
3
|
+
import { AuthApiTransports } from "../../shared/transports.js";
|
|
3
4
|
import { PolyesterMutationOptions, PolyesterRequestOptions } from "../../shared/request-options.js";
|
|
4
5
|
import { SubaccountResolver } from "../subaccount-resolver.js";
|
|
5
6
|
import { SdkScales } from "../../shared/decimal-surface.js";
|
|
6
7
|
import { CreateTradingWithdrawResult, CreateTradingWithdrawToExternalChainInput, CreateTradingWithdrawToFundingInput, TradingWithdrawIntentPayloadRequest, ValidateWithdrawDestinationInput, ValidateWithdrawDestinationResult } from "./trading-withdraws.schemas.js";
|
|
7
|
-
import { Transport } from "@connectrpc/connect";
|
|
8
8
|
import { Address, Hex } from "viem";
|
|
9
9
|
//#region src/services/trading-withdraws/trading-withdraws.d.ts
|
|
10
10
|
type TradingWithdrawWalletTypedData = ReturnType<typeof buildTradingWithdrawWalletTypedData>;
|
|
@@ -99,7 +99,7 @@ declare function buildTradingWithdrawWalletTypedData(params: {
|
|
|
99
99
|
*/
|
|
100
100
|
declare class TradingWithdrawsService {
|
|
101
101
|
#private;
|
|
102
|
-
constructor(
|
|
102
|
+
constructor(transports: AuthApiTransports, resolver: SubaccountResolver | undefined, signingConfig: TradingWithdrawSigningConfig, scales: SdkScales, catalog?: ClientCatalog);
|
|
103
103
|
/**
|
|
104
104
|
* Checks whether an external-chain destination can receive a withdrawal without creating, signing, or reserving one.
|
|
105
105
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trading-withdraws.d.ts","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"trading-withdraws.d.ts","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.ts"],"mappings":";;;;;;;;;KAuCY,iCAAiC,kBAAkB;KAEnD;EACR;EACA;EACA,gBAAgB,WAAW,mCAAmC,QAAQ;;KAG9D;EACR;EACA,uBAAuB;;KAGf,6CAA6C;EACrD,eAAe;;KAGP,mDACR;EACI,eAAe;;KAGX,0BAA0B;;;;;EAKlC,SAAS,UAAU,6BAA6B,QAAQ;;iBAyCnD,oCAAoC;EACzC,eAAe;EACf,SAAS;EACT,cAAc;EACd;EACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA0ES;;EAYL,YAAA,YAAY,mBACZ,UAAU,gCACV,eAAe,8BACf,QAAQ,WACR,UAAU;;;;EAeR,oBACF,OAAO,kCACP,UAAU,0BACX,QAAQ;;;;EAYL,gBACF,OAAO,4CACP,UAAU,2BACX,QAAQ;;;;;EASL,iBACF,OAAO,6CACR,QAAQ;;;;EAWL,sBACF,OAAO,kDACP,UAAU,2BACX,QAAQ;;;;;EASL,uBACF,OAAO,mDACR,QAAQ"}
|
|
@@ -131,8 +131,8 @@ var TradingWithdrawsService = class {
|
|
|
131
131
|
#scales;
|
|
132
132
|
#toFundingInputSchema;
|
|
133
133
|
#toExternalChainInputSchema;
|
|
134
|
-
constructor(
|
|
135
|
-
this.#client = createClient(WithdrawService,
|
|
134
|
+
constructor(transports, resolver, signingConfig, scales, catalog) {
|
|
135
|
+
this.#client = createClient(WithdrawService, transports.authApi);
|
|
136
136
|
this.#resolver = resolver;
|
|
137
137
|
this.#signingConfig = signingConfig;
|
|
138
138
|
this.#catalog = catalog;
|
|
@@ -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 } from \"../../shared/errors.js\";\nimport { createClient, type Client, type Transport } from \"@connectrpc/connect\";\nimport type { Address, Hex } from \"viem\";\nimport {\n checksumEvmAddress,\n evmHexToBytes,\n evmUtf8ToBytes,\n keccak256Hex,\n} 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 { parse } from \"../../shared/validation.js\";\nimport {\n createCreateTradingWithdrawToExternalChainInputSchema,\n createCreateTradingWithdrawToFundingInputSchema,\n CreateTradingWithdrawResultSchema,\n CreateWalletTradingWithdrawResultSchema,\n ValidateWithdrawDestinationInputSchema,\n ValidateWithdrawDestinationResultSchema,\n type CreateTradingWithdrawResult,\n type CreateTradingWithdrawToExternalChainInput,\n type CreateTradingWithdrawToExternalChainRequest,\n type CreateTradingWithdrawToFundingInput,\n type CreateTradingWithdrawToFundingRequest,\n type TradingWithdrawIntentPayloadRequest,\n type ValidateWithdrawDestinationInput,\n type ValidateWithdrawDestinationResult,\n} from \"./trading-withdraws.schemas.js\";\n\nexport type TradingWithdrawWalletTypedData = ReturnType<typeof buildTradingWithdrawWalletTypedData>;\n\nexport type TradingWithdrawWalletSigner = {\n signerWallet: string;\n accountId: string;\n signTypedData: (typedData: TradingWithdrawWalletTypedData) => 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 /**\n * Submits the exact payload and signature produced during preparation.\n * Repeated calls only change transport options such as the step-up token.\n */\n submit: (options?: PolyesterMutationOptions) => Promise<CreateTradingWithdrawResult>;\n}>;\n\ntype TradingWithdrawRequest =\n | CreateTradingWithdrawToFundingRequest\n | CreateTradingWithdrawToExternalChainRequest;\n\nfunction fromU128(value: TradingWithdrawIntentPayloadRequest[\"amountE18\"] | undefined): bigint {\n if (!value) return 0n;\n return (value.hi << 64n) + value.lo;\n}\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\nfunction buildTradingWithdrawWalletTypedData(params: {\n signingConfig: TradingWithdrawSigningConfig;\n payload: TradingWithdrawIntentPayloadRequest;\n signerWallet: Address;\n accountId: bigint;\n targetAccountId: bigint;\n}) {\n const payload = params.payload;\n const destinationAddress = (payload.destinationAddress ?? \"\").trim();\n const idempotencyKey = payload.idempotencyKey.trim();\n\n return {\n domain: {\n name: \"Polyester Trading Withdraw\",\n version: \"1\",\n chainId: params.signingConfig.chainId,\n verifyingContract: params.signingConfig.tradingGatewayAddress,\n },\n types: {\n WalletTradingWithdraw: [\n { name: \"signerWallet\", type: \"address\" },\n { name: \"actionType\", type: \"uint8\" },\n { name: \"accountId\", type: \"uint64\" },\n { name: \"targetAccountId\", type: \"uint64\" },\n { name: \"assetId\", type: \"uint32\" },\n { name: \"destinationChainId\", type: \"uint64\" },\n { name: \"amountQ\", type: \"uint128\" },\n { name: \"destinationHash\", type: \"bytes32\" },\n { name: \"deadlineTsSec\", type: \"uint256\" },\n { name: \"nonce\", type: \"uint128\" },\n { name: \"idempotencyKeyHash\", type: \"bytes32\" },\n ],\n },\n primaryType: \"WalletTradingWithdraw\",\n message: {\n signerWallet: params.signerWallet,\n actionType: payload.action,\n accountId: params.accountId,\n targetAccountId: params.targetAccountId,\n assetId: payload.assetId,\n destinationChainId: payload.destinationChainId ?? 0n,\n amountQ: fromU128(payload.amountE18),\n destinationHash: keccak256Hex(evmUtf8ToBytes(destinationAddress)),\n deadlineTsSec: payload.deadlineTsSec,\n nonce: fromU128(payload.nonce),\n idempotencyKeyHash: keccak256Hex(evmUtf8ToBytes(idempotencyKey)),\n },\n } as const;\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();\n if (!signerWallet.startsWith(\"0x\")) {\n throw new ValidationError(\"Trading withdraw signer wallet is required.\");\n }\n const accountId = idToBigInt(params.walletSigner.accountId, \"accountId\");\n const signature = await params.walletSigner.signTypedData(\n buildTradingWithdrawWalletTypedData({\n signingConfig: params.signingConfig,\n payload: params.payload,\n signerWallet: signerWallet as Address,\n accountId,\n targetAccountId: params.targetAccountId,\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-712 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 transport: Transport,\n resolver: SubaccountResolver | undefined,\n signingConfig: TradingWithdrawSigningConfig,\n scales: SdkScales,\n catalog?: ClientCatalog,\n ) {\n this.#client = createClient(Proto.WithdrawService, transport);\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 * 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 EIP-712 typed data 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 EIP-712 typed data 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\n const walletSignature = await resolveWalletSignature({\n signingConfig,\n payload: validated.payload,\n walletSigner,\n targetAccountId,\n });\n const request = removeUndefined({\n payload: validated.payload,\n subaccountId: validated.subaccountId,\n signerWallet: walletSignature.signerWallet,\n payloadSignature: walletSignature.payloadSignature,\n });\n return {\n submit: async (options) => {\n const response = await this.#client.createWalletTradingWithdraw(\n request,\n toConnectCallOptions(options),\n );\n return parse(CreateWalletTradingWithdrawResultSchema, response);\n },\n };\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 {\n submit: 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":";;;;;;;;;;;AAwEA,SAAS,SAAS,OAA6E;CAC3F,IAAI,CAAC,OAAO,OAAO;CACnB,QAAQ,MAAM,MAAM,OAAO,MAAM;AACrC;AAEA,SAAS,sCAAsC,QAGpC;CACP,IAAI,OAAO,iBAAiB,KAAA,GAAW,OAAO,OAAO;CACrD,OAAO,WAAW,OAAO,eAAe,iBAAiB;AAC7D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Q,sBAChC,SACA,qBAAqB,OAAO,CAChC;GACA,OAAO,MAAM,mCAAmC,QAAQ;EAC5D,EACJ;CACJ;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 } from \"../../shared/errors.js\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport type { Address, Hex } from \"viem\";\nimport {\n checksumEvmAddress,\n evmHexToBytes,\n evmUtf8ToBytes,\n keccak256Hex,\n} 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 ValidateWithdrawDestinationInputSchema,\n ValidateWithdrawDestinationResultSchema,\n type CreateTradingWithdrawResult,\n type CreateTradingWithdrawToExternalChainInput,\n type CreateTradingWithdrawToExternalChainRequest,\n type CreateTradingWithdrawToFundingInput,\n type CreateTradingWithdrawToFundingRequest,\n type TradingWithdrawIntentPayloadRequest,\n type ValidateWithdrawDestinationInput,\n type ValidateWithdrawDestinationResult,\n} from \"./trading-withdraws.schemas.js\";\n\nexport type TradingWithdrawWalletTypedData = ReturnType<typeof buildTradingWithdrawWalletTypedData>;\n\nexport type TradingWithdrawWalletSigner = {\n signerWallet: string;\n accountId: string;\n signTypedData: (typedData: TradingWithdrawWalletTypedData) => 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 /**\n * Submits the exact payload and signature produced during preparation.\n * Repeated calls only change transport options such as the step-up token.\n */\n submit: (options?: PolyesterMutationOptions) => Promise<CreateTradingWithdrawResult>;\n}>;\n\ntype TradingWithdrawRequest =\n | CreateTradingWithdrawToFundingRequest\n | CreateTradingWithdrawToExternalChainRequest;\n\nfunction fromU128(value: TradingWithdrawIntentPayloadRequest[\"amountE18\"] | undefined): bigint {\n if (!value) return 0n;\n return (value.hi << 64n) + value.lo;\n}\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\nfunction buildTradingWithdrawWalletTypedData(params: {\n signingConfig: TradingWithdrawSigningConfig;\n payload: TradingWithdrawIntentPayloadRequest;\n signerWallet: Address;\n accountId: bigint;\n targetAccountId: bigint;\n}) {\n const payload = params.payload;\n const destinationAddress = (payload.destinationAddress ?? \"\").trim();\n const idempotencyKey = payload.idempotencyKey.trim();\n\n return {\n domain: {\n name: \"Polyester Trading Withdraw\",\n version: \"1\",\n chainId: params.signingConfig.chainId,\n verifyingContract: params.signingConfig.tradingGatewayAddress,\n },\n types: {\n WalletTradingWithdraw: [\n { name: \"signerWallet\", type: \"address\" },\n { name: \"actionType\", type: \"uint8\" },\n { name: \"accountId\", type: \"uint64\" },\n { name: \"targetAccountId\", type: \"uint64\" },\n { name: \"assetId\", type: \"uint32\" },\n { name: \"destinationChainId\", type: \"uint64\" },\n { name: \"amountQ\", type: \"uint128\" },\n { name: \"destinationHash\", type: \"bytes32\" },\n { name: \"deadlineTsSec\", type: \"uint256\" },\n { name: \"nonce\", type: \"uint128\" },\n { name: \"idempotencyKeyHash\", type: \"bytes32\" },\n ],\n },\n primaryType: \"WalletTradingWithdraw\",\n message: {\n signerWallet: params.signerWallet,\n actionType: payload.action,\n accountId: params.accountId,\n targetAccountId: params.targetAccountId,\n assetId: payload.assetId,\n destinationChainId: payload.destinationChainId ?? 0n,\n amountQ: fromU128(payload.amountE18),\n destinationHash: keccak256Hex(evmUtf8ToBytes(destinationAddress)),\n deadlineTsSec: payload.deadlineTsSec,\n nonce: fromU128(payload.nonce),\n idempotencyKeyHash: keccak256Hex(evmUtf8ToBytes(idempotencyKey)),\n },\n } as const;\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();\n if (!signerWallet.startsWith(\"0x\")) {\n throw new ValidationError(\"Trading withdraw signer wallet is required.\");\n }\n const accountId = idToBigInt(params.walletSigner.accountId, \"accountId\");\n const signature = await params.walletSigner.signTypedData(\n buildTradingWithdrawWalletTypedData({\n signingConfig: params.signingConfig,\n payload: params.payload,\n signerWallet: signerWallet as Address,\n accountId,\n targetAccountId: params.targetAccountId,\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-712 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 * 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 EIP-712 typed data 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 EIP-712 typed data 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\n const walletSignature = await resolveWalletSignature({\n signingConfig,\n payload: validated.payload,\n walletSigner,\n targetAccountId,\n });\n const request = removeUndefined({\n payload: validated.payload,\n subaccountId: validated.subaccountId,\n signerWallet: walletSignature.signerWallet,\n payloadSignature: walletSignature.payloadSignature,\n });\n return {\n submit: async (options) => {\n const response = await this.#client.createWalletTradingWithdraw(\n request,\n toConnectCallOptions(options),\n );\n return parse(CreateWalletTradingWithdrawResultSchema, response);\n },\n };\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 {\n submit: 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":";;;;;;;;;;;AAyEA,SAAS,SAAS,OAA6E;CAC3F,IAAI,CAAC,OAAO,OAAO;CACnB,QAAQ,MAAM,MAAM,OAAO,MAAM;AACrC;AAEA,SAAS,sCAAsC,QAGpC;CACP,IAAI,OAAO,iBAAiB,KAAA,GAAW,OAAO,OAAO;CACrD,OAAO,WAAW,OAAO,eAAe,iBAAiB;AAC7D;AAEA,eAAe,oCAAoC,QAGT;CACtC,IAAI,CAAC,OAAO,SAAS,OAAO,OAAO;CAEnC,IAAI;EACA,MAAM,OAAO,QAAQ,YAAY;EAEjC,MAAM,UADU,OAAO,QAAQ,OAAO,kBAAkB,gBAClC,CAAC,EAAE,SAAS,KAAK;EACvC,IAAI,CAAC,SAAS,WAAW,IAAI,GAAG,OAAO,OAAO;EAE9C,OAAO;GACH,SAAS,OAAO,SAAS;GACzB,uBAAuB,mBAAmB,OAAO;EACrD;CACJ,QAAQ;EACJ,OAAO,OAAO;CA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A0B,oBAAoB,KAAKH,SAAS;EAClF,MAAM,YAAY,MAAM,KAAKK,6BAA6B,aAAa;EACvE,OAAO,KAAKC,iBAAiB,WAAW,YAAY;CACxD;CAEA,MAAMA,iBACF,WACA,cACgC;EAChC,IAAI,cAAc;GACd,MAAM,gBAAgB,MAAM,oCAAoC;IAC5D,UAAU,KAAKL;IACf,SAAS,KAAKC;GAClB,CAAC;GACD,MAAM,kBAAkB,sCAAsC;IAC1D,cAAc,UAAU;IACxB,eAAe,aAAa;GAChC,CAAC;GAED,MAAM,kBAAkB,MAAM,uBAAuB;IACjD;IACA,SAAS,UAAU;IACnB;IACA;GACJ,CAAC;GACD,MAAM,UAAU,gBAAgB;IAC5B,SAAS,UAAU;IACnB,cAAc,UAAU;IACxB,cAAc,gBAAgB;IAC9B,kBAAkB,gBAAgB;GACtC,CAAC;GACD,OAAO,EACH,QAAQ,OAAO,YAAY;IACvB,MAAM,WAAW,MAAM,KAAKJ,QAAQ,4BAChC,SACA,qBAAqB,OAAO,CAChC;IACA,OAAO,MAAM,yCAAyC,QAAQ;GAClE,EACJ;EACJ;EAEA,IAAI,CAAC,UAAU,kBACX,MAAM,IAAI,gBACN,iEACJ;EAGJ,MAAM,UAAU,gBAAgB;GAC5B,SAAS,UAAU;GACnB,kBAAkB,UAAU;EAChC,CAAC;EACD,OAAO,EACH,QAAQ,OAAO,YAAY;GACvB,MAAM,WAAW,MAAM,KAAKA,QAAQ,sBAChC,SACA,qBAAqB,OAAO,CAChC;GACA,OAAO,MAAM,mCAAmC,QAAQ;EAC5D,EACJ;CACJ;AACJ"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { AuthApiTransports } from "../../shared/transports.js";
|
|
1
2
|
import { PolyesterRequestOptions } from "../../shared/request-options.js";
|
|
2
3
|
import { SubaccountResolver } from "../subaccount-resolver.js";
|
|
3
4
|
import { PolyesterRealtime } from "../../realtime/types.js";
|
|
4
5
|
import "../../realtime/index.js";
|
|
5
6
|
import { BaseSubscribeInput } from "../../shared/types.js";
|
|
6
7
|
import { LedgerTransfer, ListTransfersInput } from "./transfers.schemas.js";
|
|
7
|
-
import { Transport } from "@connectrpc/connect";
|
|
8
8
|
//#region src/services/transfers/transfers.d.ts
|
|
9
9
|
interface SubscribeTransfersInput extends BaseSubscribeInput<LedgerTransfer> {
|
|
10
10
|
accountId: string;
|
|
@@ -14,7 +14,7 @@ interface SubscribeTransfersInput extends BaseSubscribeInput<LedgerTransfer> {
|
|
|
14
14
|
*/
|
|
15
15
|
declare class TransfersService {
|
|
16
16
|
#private;
|
|
17
|
-
constructor(
|
|
17
|
+
constructor(transports: AuthApiTransports, realtime: PolyesterRealtime, resolver: SubaccountResolver | undefined);
|
|
18
18
|
/**
|
|
19
19
|
* Returns ledger transfers for the resolved account scope with limit, direction, timestamp, code, ledger, and page-token filters.
|
|
20
20
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfers.d.ts","names":[],"sources":["../../../src/services/transfers/transfers.ts"],"mappings":";;;;;;;;
|
|
1
|
+
{"version":3,"file":"transfers.d.ts","names":[],"sources":["../../../src/services/transfers/transfers.ts"],"mappings":";;;;;;;;UAoBU,gCAAgC,mBAAmB;EACzD;;;;;cAMS;;EAML,YAAA,YAAY,mBACZ,UAAU,mBACV,UAAU;;;;EAUR,KACF,QAAO,oBACP,UAAU,0BACX;IAAU,WAAW;IAAkB;;;;;EAW1C,UAAU,OAAO"}
|