@polyester/sdk 0.35.0-devnet-20261111031027 → 0.35.0-devnet-20261111161451
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 +35 -1
- package/dist/catalogs/snapshot-validation.js +2 -1
- package/dist/catalogs/snapshot-validation.js.map +1 -1
- package/dist/client.d.ts +6 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +6 -0
- package/dist/client.js.map +1 -1
- package/dist/gen/ai/v1/assistant_pb.d.ts +4164 -0
- package/dist/gen/ai/v1/assistant_pb.d.ts.map +1 -0
- package/dist/gen/ai/v1/assistant_pb.js +1174 -0
- package/dist/gen/ai/v1/assistant_pb.js.map +1 -0
- package/dist/gen/alerts/v1/price_alerts_pb.d.ts +776 -0
- package/dist/gen/alerts/v1/price_alerts_pb.d.ts.map +1 -0
- package/dist/gen/alerts/v1/price_alerts_pb.js +378 -0
- package/dist/gen/alerts/v1/price_alerts_pb.js.map +1 -0
- package/dist/gen/auth/v1/address_book_pb.d.ts +6 -0
- package/dist/gen/auth/v1/address_book_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/address_book_pb.js +6 -0
- package/dist/gen/auth/v1/address_book_pb.js.map +1 -1
- package/dist/gen/auth/v1/api_keys_pb.d.ts +242 -2
- package/dist/gen/auth/v1/api_keys_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/api_keys_pb.js +81 -2
- package/dist/gen/auth/v1/api_keys_pb.js.map +1 -1
- package/dist/gen/auth/v1/auth_pb.d.ts +48 -6
- package/dist/gen/auth/v1/auth_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/auth_pb.js +48 -6
- package/dist/gen/auth/v1/auth_pb.js.map +1 -1
- package/dist/gen/auth/v1/policies_pb.d.ts +83 -19
- package/dist/gen/auth/v1/policies_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/policies_pb.js +74 -16
- package/dist/gen/auth/v1/policies_pb.js.map +1 -1
- package/dist/gen/auth/v1/social_verification_pb.d.ts +167 -11
- package/dist/gen/auth/v1/social_verification_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/social_verification_pb.js +41 -3
- package/dist/gen/auth/v1/social_verification_pb.js.map +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.d.ts +17 -6
- package/dist/gen/auth/v1/subaccounts_pb.d.ts.map +1 -1
- package/dist/gen/auth/v1/subaccounts_pb.js.map +1 -1
- package/dist/gen/chain/deposit/v1/deposit_pb.d.ts +4 -2
- package/dist/gen/chain/deposit/v1/deposit_pb.d.ts.map +1 -1
- package/dist/gen/chain/deposit/v1/deposit_pb.js.map +1 -1
- package/dist/gen/chain/guard/v1/guard_signer_pb.d.ts +5 -0
- package/dist/gen/chain/guard/v1/guard_signer_pb.d.ts.map +1 -1
- package/dist/gen/chain/guard/v1/guard_signer_pb.js.map +1 -1
- package/dist/gen/chain/lifecycle/v1/lifecycle_read_pb.d.ts +10 -0
- package/dist/gen/chain/lifecycle/v1/lifecycle_read_pb.d.ts.map +1 -1
- package/dist/gen/chain/lifecycle/v1/lifecycle_read_pb.js +1 -1
- package/dist/gen/chain/lifecycle/v1/lifecycle_read_pb.js.map +1 -1
- package/dist/gen/chain/lifecycle/v1/types_pb.d.ts +32 -4
- package/dist/gen/chain/lifecycle/v1/types_pb.d.ts.map +1 -1
- package/dist/gen/chain/lifecycle/v1/types_pb.js +32 -4
- package/dist/gen/chain/lifecycle/v1/types_pb.js.map +1 -1
- package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.d.ts +391 -42
- package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.d.ts.map +1 -1
- package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.js +103 -17
- package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.js.map +1 -1
- package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts +170 -3
- package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts.map +1 -1
- package/dist/gen/chain/withdraw/v1/withdraw_pb.js +63 -2
- package/dist/gen/chain/withdraw/v1/withdraw_pb.js.map +1 -1
- package/dist/gen/claims/v1/claims_pb.d.ts +1 -1
- package/dist/gen/claims/v1/claims_pb.js +1 -1
- package/dist/gen/claims/v1/claims_pb.js.map +1 -1
- package/dist/gen/index.d.ts +14 -10
- package/dist/gen/index.js +11 -7
- package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts +1 -1
- package/dist/gen/ledger/v1/catalog_pb.d.ts +9 -1
- package/dist/gen/ledger/v1/catalog_pb.d.ts.map +1 -1
- package/dist/gen/ledger/v1/catalog_pb.js +9 -1
- package/dist/gen/ledger/v1/catalog_pb.js.map +1 -1
- package/dist/gen/marketdata/v1/marketdata_pb.d.ts +8 -0
- package/dist/gen/marketdata/v1/marketdata_pb.d.ts.map +1 -1
- package/dist/gen/marketdata/v1/marketdata_pb.js +1 -1
- package/dist/gen/marketdata/v1/marketdata_pb.js.map +1 -1
- package/dist/gen/orders/v1/orders_pb.d.ts +4 -4
- package/dist/gen/orders/v1/orders_pb.js.map +1 -1
- package/dist/gen/orders/v1/orders_read_pb.d.ts +1 -1
- package/dist/gen/polyester/ratelimit/v1/types_pb.d.ts +20 -1
- package/dist/gen/polyester/ratelimit/v1/types_pb.d.ts.map +1 -1
- package/dist/gen/polyester/ratelimit/v1/types_pb.js +20 -1
- package/dist/gen/polyester/ratelimit/v1/types_pb.js.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts +1186 -127
- package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.js +282 -5
- package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.js.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts +253 -38
- package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_pb.js +180 -36
- package/dist/gen/swap/quickswap/v1/quickswap_pb.js.map +1 -1
- package/dist/gen/swap/quickswap/v1/quickswap_referral_pb.d.ts +933 -0
- package/dist/gen/swap/quickswap/v1/quickswap_referral_pb.d.ts.map +1 -0
- package/dist/gen/swap/quickswap/v1/quickswap_referral_pb.js +292 -0
- package/dist/gen/swap/quickswap/v1/quickswap_referral_pb.js.map +1 -0
- package/dist/gen/system/v1/system_pb.d.ts +77 -0
- package/dist/gen/system/v1/system_pb.d.ts.map +1 -0
- package/dist/gen/system/v1/system_pb.js +34 -0
- package/dist/gen/system/v1/system_pb.js.map +1 -0
- package/dist/gen/tradews/v1/trade_ws_pb.d.ts +2 -2
- package/dist/gen/tradews/v1/trade_ws_pb.js.map +1 -1
- package/dist/index.d.ts +14 -6
- package/dist/services/api-keys/api-keys.codecs.js +10 -1
- package/dist/services/api-keys/api-keys.codecs.js.map +1 -1
- package/dist/services/api-keys/api-keys.d.ts +16 -1
- package/dist/services/api-keys/api-keys.d.ts.map +1 -1
- package/dist/services/api-keys/api-keys.js +25 -1
- package/dist/services/api-keys/api-keys.js.map +1 -1
- package/dist/services/api-keys/api-keys.schemas.d.ts +116 -1
- package/dist/services/api-keys/api-keys.schemas.d.ts.map +1 -1
- package/dist/services/api-keys/api-keys.schemas.js +29 -3
- package/dist/services/api-keys/api-keys.schemas.js.map +1 -1
- package/dist/services/api-keys/api-keys.types.d.ts +2 -2
- package/dist/services/api-keys/index.d.ts +2 -2
- package/dist/services/assistant/assistant-events.schemas.d.ts +4618 -0
- package/dist/services/assistant/assistant-events.schemas.d.ts.map +1 -0
- package/dist/services/assistant/assistant-events.schemas.js +485 -0
- package/dist/services/assistant/assistant-events.schemas.js.map +1 -0
- package/dist/services/assistant/assistant.codecs.d.ts +24 -0
- package/dist/services/assistant/assistant.codecs.d.ts.map +1 -0
- package/dist/services/assistant/assistant.codecs.js +88 -0
- package/dist/services/assistant/assistant.codecs.js.map +1 -0
- package/dist/services/assistant/assistant.d.ts +76 -0
- package/dist/services/assistant/assistant.d.ts.map +1 -0
- package/dist/services/assistant/assistant.js +133 -0
- package/dist/services/assistant/assistant.js.map +1 -0
- package/dist/services/assistant/assistant.schemas.d.ts +184 -0
- package/dist/services/assistant/assistant.schemas.d.ts.map +1 -0
- package/dist/services/assistant/assistant.schemas.js +135 -0
- package/dist/services/assistant/assistant.schemas.js.map +1 -0
- package/dist/services/assistant/assistant.types.d.ts +4 -0
- package/dist/services/assistant/service.d.ts +8 -0
- package/dist/services/assistant/service.d.ts.map +1 -0
- package/dist/services/assistant/service.js +9 -0
- package/dist/services/assistant/service.js.map +1 -0
- package/dist/services/auto-withdraw/auto-withdraw.codecs.d.ts +9 -2
- package/dist/services/auto-withdraw/auto-withdraw.codecs.d.ts.map +1 -1
- package/dist/services/auto-withdraw/auto-withdraw.codecs.js +9 -1
- package/dist/services/auto-withdraw/auto-withdraw.codecs.js.map +1 -1
- package/dist/services/auto-withdraw/auto-withdraw.d.ts +15 -4
- package/dist/services/auto-withdraw/auto-withdraw.d.ts.map +1 -1
- package/dist/services/auto-withdraw/auto-withdraw.js +24 -8
- package/dist/services/auto-withdraw/auto-withdraw.js.map +1 -1
- package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts +394 -26
- package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts.map +1 -1
- package/dist/services/auto-withdraw/auto-withdraw.schemas.js +67 -12
- package/dist/services/auto-withdraw/auto-withdraw.schemas.js.map +1 -1
- package/dist/services/auto-withdraw/auto-withdraw.types.d.ts +3 -3
- package/dist/services/balances/balances.js +1 -1
- package/dist/services/balances/balances.schemas.d.ts +3 -3
- package/dist/services/candles/candles.js +1 -1
- package/dist/services/candles/candles.schemas.d.ts +10 -10
- package/dist/services/candles/candles.schemas.js +5 -2
- package/dist/services/candles/candles.schemas.js.map +1 -1
- package/dist/services/changelog/changelog.schemas.d.ts +17 -17
- package/dist/services/checkpoints/checkpoints.schemas.d.ts +1 -1
- package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
- package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +3 -3
- package/dist/services/lifecycle/lifecycle.codecs.d.ts +2 -2
- package/dist/services/lifecycle/lifecycle.codecs.d.ts.map +1 -1
- package/dist/services/lifecycle/lifecycle.codecs.js +3 -1
- package/dist/services/lifecycle/lifecycle.codecs.js.map +1 -1
- package/dist/services/lifecycle/lifecycle.schemas.d.ts +210 -186
- package/dist/services/lifecycle/lifecycle.schemas.d.ts.map +1 -1
- package/dist/services/lifecycle/lifecycle.schemas.js +7 -1
- package/dist/services/lifecycle/lifecycle.schemas.js.map +1 -1
- package/dist/services/market-data/market-data.js +1 -1
- package/dist/services/market-data/market-data.schemas.js +7 -2
- package/dist/services/market-data/market-data.schemas.js.map +1 -1
- package/dist/services/market-overview/market-overview.schemas.d.ts +1 -1
- package/dist/services/orderbook/orderbook.schemas.d.ts +1 -1
- package/dist/services/orders/order-errors.schemas.d.ts +2 -2
- package/dist/services/orders/orders-batch.schemas.d.ts +54 -54
- package/dist/services/orders/orders-input.schemas.d.ts +6 -6
- package/dist/services/orders/orders-input.schemas.js +1 -1
- package/dist/services/orders/orders-modify.schemas.js +1 -1
- package/dist/services/orders/orders-output.schemas.d.ts +16 -16
- package/dist/services/orders/orders-output.schemas.js +3 -3
- package/dist/services/orders/orders-risk.schemas.js +1 -1
- package/dist/services/orders/orders.codecs.js +1 -1
- package/dist/services/orders/orders.js +3 -3
- package/dist/services/policies/api-key-policies/api-key-policies.schemas.d.ts +15 -15
- package/dist/services/policies/shared.codecs.js +24 -3
- package/dist/services/policies/shared.codecs.js.map +1 -1
- package/dist/services/policies/shared.d.ts +1 -1
- package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts +3 -3
- package/dist/services/price-alerts/price-alerts.codecs.d.ts +20 -0
- package/dist/services/price-alerts/price-alerts.codecs.d.ts.map +1 -0
- package/dist/services/price-alerts/price-alerts.codecs.js +66 -0
- package/dist/services/price-alerts/price-alerts.codecs.js.map +1 -0
- package/dist/services/price-alerts/price-alerts.d.ts +38 -0
- package/dist/services/price-alerts/price-alerts.d.ts.map +1 -0
- package/dist/services/price-alerts/price-alerts.js +60 -0
- package/dist/services/price-alerts/price-alerts.js.map +1 -0
- package/dist/services/price-alerts/price-alerts.schemas.d.ts +309 -0
- package/dist/services/price-alerts/price-alerts.schemas.d.ts.map +1 -0
- package/dist/services/price-alerts/price-alerts.schemas.js +130 -0
- package/dist/services/price-alerts/price-alerts.schemas.js.map +1 -0
- package/dist/services/price-alerts/price-alerts.types.d.ts +3 -0
- package/dist/services/price-alerts/service.d.ts +8 -0
- package/dist/services/price-alerts/service.d.ts.map +1 -0
- package/dist/services/price-alerts/service.js +9 -0
- package/dist/services/price-alerts/service.js.map +1 -0
- package/dist/services/social-verification/social-verification.codecs.js +13 -5
- package/dist/services/social-verification/social-verification.codecs.js.map +1 -1
- package/dist/services/social-verification/social-verification.d.ts +18 -3
- package/dist/services/social-verification/social-verification.d.ts.map +1 -1
- package/dist/services/social-verification/social-verification.js +26 -3
- package/dist/services/social-verification/social-verification.js.map +1 -1
- package/dist/services/social-verification/social-verification.schemas.d.ts +33 -7
- package/dist/services/social-verification/social-verification.schemas.d.ts.map +1 -1
- package/dist/services/social-verification/social-verification.schemas.js +35 -10
- package/dist/services/social-verification/social-verification.schemas.js.map +1 -1
- package/dist/services/social-verification/social-verification.types.d.ts +2 -2
- package/dist/services/subaccounts/subaccounts.schemas.d.ts +8 -8
- package/dist/services/system/service.d.ts +8 -0
- package/dist/services/system/service.d.ts.map +1 -0
- package/dist/services/system/service.js +9 -0
- package/dist/services/system/service.js.map +1 -0
- package/dist/services/system/system.d.ts +25 -0
- package/dist/services/system/system.d.ts.map +1 -0
- package/dist/services/system/system.js +24 -0
- package/dist/services/system/system.js.map +1 -0
- package/dist/services/trades/trades.js +1 -1
- package/dist/services/trades/trades.schemas.d.ts +1 -1
- package/dist/services/trades/trades.schemas.js +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.d.ts +7 -1
- package/dist/services/trading-withdraws/trading-withdraws.d.ts.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.js +11 -1
- package/dist/services/trading-withdraws/trading-withdraws.js.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts +42 -1
- package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.schemas.js +19 -3
- package/dist/services/trading-withdraws/trading-withdraws.schemas.js.map +1 -1
- package/dist/services/trading-withdraws/trading-withdraws.types.d.ts +2 -2
- package/dist/services/transfers/transfers.schemas.d.ts +5 -5
- package/dist/services/triggers/trigger-child-order.schemas.js +1 -1
- package/dist/services/triggers/trigger-input.schemas.d.ts +2 -2
- package/dist/services/triggers/trigger-input.schemas.js +1 -1
- package/dist/services/triggers/triggers-output.schemas.d.ts +49 -49
- package/dist/services/triggers/triggers.codecs.js +1 -1
- package/dist/services/triggers/triggers.js +2 -2
- package/dist/shared/catalog-config.d.ts +5 -0
- package/dist/shared/catalog-config.d.ts.map +1 -1
- package/dist/shared/catalog-config.js.map +1 -1
- package/dist/shared/connect-error-mapping.d.ts.map +1 -1
- package/dist/shared/connect-error-mapping.js +1 -0
- package/dist/shared/connect-error-mapping.js.map +1 -1
- package/dist/shared/error-detail.d.ts +24 -10
- package/dist/shared/error-detail.d.ts.map +1 -1
- package/dist/shared/error-detail.js +2 -0
- package/dist/shared/error-detail.js.map +1 -1
- package/dist/shared/error-details/alerts.js +15 -0
- package/dist/shared/error-details/alerts.js.map +1 -0
- package/dist/shared/error-details/assistant.js +15 -0
- package/dist/shared/error-details/assistant.js.map +1 -0
- package/dist/shared/error-details/withdraw.js +11 -2
- package/dist/shared/error-details/withdraw.js.map +1 -1
- package/dist/shared/ledger-codes.d.ts +4 -2
- package/dist/shared/ledger-codes.d.ts.map +1 -1
- package/dist/shared/ledger-codes.js +6 -3
- package/dist/shared/ledger-codes.js.map +1 -1
- package/dist/shared/rate-limit.schemas.d.ts +3 -3
- package/dist/shared/rate-limit.schemas.d.ts.map +1 -1
- package/dist/shared/rate-limit.schemas.js +4 -1
- package/dist/shared/rate-limit.schemas.js.map +1 -1
- package/dist/shared/transports.d.ts +2 -1
- package/dist/shared/transports.d.ts.map +1 -1
- package/dist/shared/transports.js.map +1 -1
- package/dist/wired-services.d.ts.map +1 -1
- package/dist/wired-services.js +11 -5
- package/dist/wired-services.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { formatId } from "../../utils/base58-id.js";
|
|
2
|
+
import { tsObjToMs } from "../../utils/time.js";
|
|
3
|
+
import { idInputSchema, optionalSubaccountIdInputSchema } from "../../shared/schemas.js";
|
|
4
|
+
import { enumLabel } from "../../shared/proto-enum-codec.js";
|
|
5
|
+
import { ASSISTANT_APPROVAL_DECISION_VALUES, ApprovalDecisionCodec, AssistantKeyStateCodec, MemoryKindCodec, MessageRoleCodec } from "./assistant.codecs.js";
|
|
6
|
+
import { bytesToHex } from "@noble/hashes/utils.js";
|
|
7
|
+
import * as v from "valibot";
|
|
8
|
+
//#region src/services/assistant/assistant.schemas.ts
|
|
9
|
+
const IdempotencyKeySchema = v.pipe(v.string(), v.trim(), v.minLength(1));
|
|
10
|
+
function pageInputEntries(maxLimit) {
|
|
11
|
+
return {
|
|
12
|
+
/** Page size; omit for the server default. */
|
|
13
|
+
limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(maxLimit))),
|
|
14
|
+
/** The previous page's `nextPageToken`. */
|
|
15
|
+
pageToken: v.optional(v.pipe(v.string(), v.trim()))
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const DestinationInputSchema = v.strictObject({
|
|
19
|
+
/** The client's id for the place, e.g. `"page-subaccounts"`: lowercase letters, digits and hyphens. */
|
|
20
|
+
id: v.pipe(v.string(), v.regex(/^[a-z0-9-]{1,64}$/, "destination id must be 1-64 of a-z, 0-9, -")),
|
|
21
|
+
/** Its name as the client shows it, 1 to 80 characters. */
|
|
22
|
+
title: v.pipe(v.string(), v.minLength(1), v.maxLength(80)),
|
|
23
|
+
/** What the user does there, at most 200 characters. */
|
|
24
|
+
description: v.optional(v.pipe(v.string(), v.maxLength(200)), "")
|
|
25
|
+
});
|
|
26
|
+
const SendAssistantMessageInputSchema = v.pipe(v.strictObject({
|
|
27
|
+
/** Conversation to continue; omit to start a new one. */
|
|
28
|
+
conversationId: v.optional(idInputSchema("conversationId")),
|
|
29
|
+
/** Message text, plain text or Markdown, 1 to 16000 characters. */
|
|
30
|
+
text: v.pipe(v.string(), v.minLength(1), v.maxLength(16e3)),
|
|
31
|
+
/** Client-chosen key, unique per caller. Repeat the request unchanged to resolve an unknown outcome. */
|
|
32
|
+
idempotencyKey: IdempotencyKeySchema,
|
|
33
|
+
/**
|
|
34
|
+
* Trading account the run reads and acts on. Omit to answer without account data: the
|
|
35
|
+
* run then has no account tools.
|
|
36
|
+
*/
|
|
37
|
+
subaccountId: optionalSubaccountIdInputSchema(),
|
|
38
|
+
/** Places in the client the run may suggest, at most 100, each id once. */
|
|
39
|
+
destinations: v.optional(v.pipe(v.array(DestinationInputSchema), v.maxLength(100, "At most 100 destinations are allowed."), v.check((items) => new Set(items.map((d) => d.id)).size === items.length, "Destination ids must be distinct.")))
|
|
40
|
+
}));
|
|
41
|
+
const AssistantRunIdInputSchema = v.strictObject({ runId: idInputSchema("runId") });
|
|
42
|
+
const WatchAssistantRunInputSchema = v.pipe(v.strictObject({
|
|
43
|
+
runId: idInputSchema("runId"),
|
|
44
|
+
/** Return events after this seq. 0 (default) replays the run; pass the last seq received to resume. */
|
|
45
|
+
afterSeq: v.optional(v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(Number.MAX_SAFE_INTEGER)), 0)
|
|
46
|
+
}), v.transform(({ runId, afterSeq }) => ({
|
|
47
|
+
runId,
|
|
48
|
+
afterSeq: BigInt(afterSeq)
|
|
49
|
+
})));
|
|
50
|
+
const DecideAssistantApprovalInputSchema = v.pipe(v.strictObject({
|
|
51
|
+
approvalId: idInputSchema("approvalId"),
|
|
52
|
+
decision: v.picklist(ASSISTANT_APPROVAL_DECISION_VALUES)
|
|
53
|
+
}), v.transform(({ approvalId, decision }) => ({
|
|
54
|
+
approvalId,
|
|
55
|
+
decision: ApprovalDecisionCodec.inputToProto[decision]
|
|
56
|
+
})));
|
|
57
|
+
const ListAssistantConversationsInputSchema = v.strictObject(pageInputEntries(100));
|
|
58
|
+
const ListAssistantMessagesInputSchema = v.strictObject({
|
|
59
|
+
conversationId: idInputSchema("conversationId"),
|
|
60
|
+
...pageInputEntries(200)
|
|
61
|
+
});
|
|
62
|
+
const ListAssistantMemoriesInputSchema = v.strictObject(pageInputEntries(200));
|
|
63
|
+
const DeleteAssistantMemoryInputSchema = v.strictObject({ memoryId: idInputSchema("memoryId") });
|
|
64
|
+
const PrepareAssistantKeysInputSchema = v.pipe(v.strictObject({
|
|
65
|
+
/** 1 to 64 accounts, each once. An entry without `subaccountId` is the main account. */
|
|
66
|
+
accounts: v.pipe(v.array(v.strictObject({ subaccountId: optionalSubaccountIdInputSchema() })), v.minLength(1, "At least one account is required."), v.maxLength(64, "At most 64 accounts are allowed.")) }), v.check(({ accounts }) => new Set(accounts.map((a) => a.subaccountId ?? 0n)).size === accounts.length, "Each account may be named only once."));
|
|
67
|
+
const CompleteAssistantKeysInputSchema = v.strictObject({ setupId: idInputSchema("setupId") });
|
|
68
|
+
function optionalId(id) {
|
|
69
|
+
return id ? formatId(id) : void 0;
|
|
70
|
+
}
|
|
71
|
+
function formatConversation(c) {
|
|
72
|
+
return {
|
|
73
|
+
conversationId: formatId(c.conversationId),
|
|
74
|
+
/** Empty until a title is available. */
|
|
75
|
+
title: c.title,
|
|
76
|
+
createdAt: tsObjToMs(c.createdAt),
|
|
77
|
+
updatedAt: tsObjToMs(c.updatedAt)
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
function formatMessage(m) {
|
|
81
|
+
return {
|
|
82
|
+
messageId: formatId(m.messageId),
|
|
83
|
+
role: enumLabel(MessageRoleCodec.protoToOutput, m.role),
|
|
84
|
+
/** Markdown. For an assistant message, its run's final text. */
|
|
85
|
+
text: m.text,
|
|
86
|
+
createdAt: tsObjToMs(m.createdAt),
|
|
87
|
+
/** Replay this run with `watchRun` from `afterSeq: 0` to show its tool activity and views. */
|
|
88
|
+
runId: formatId(m.runId)
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
function formatMemory(m) {
|
|
92
|
+
return {
|
|
93
|
+
memoryId: formatId(m.memoryId),
|
|
94
|
+
text: m.text,
|
|
95
|
+
createdAt: tsObjToMs(m.createdAt),
|
|
96
|
+
/** Omitted when the conversation it was learned in is unknown. */
|
|
97
|
+
conversationId: optionalId(m.conversationId),
|
|
98
|
+
kind: enumLabel(MemoryKindCodec.protoToOutput, m.kind)
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
function formatAssistantKey(k) {
|
|
102
|
+
return {
|
|
103
|
+
/** Omitted for the main account. */
|
|
104
|
+
subaccountId: optionalId(k.subaccountId),
|
|
105
|
+
keyId: k.keyId,
|
|
106
|
+
publicKeyEd25519: k.publicKeyEd25519,
|
|
107
|
+
publicKeyHex: bytesToHex(k.publicKeyEd25519),
|
|
108
|
+
state: enumLabel(AssistantKeyStateCodec.protoToOutput, k.state)
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
function formatPreparedAssistantKey(k) {
|
|
112
|
+
return {
|
|
113
|
+
/** Omitted for the main account. */
|
|
114
|
+
subaccountId: optionalId(k.subaccountId),
|
|
115
|
+
publicKeyEd25519: k.publicKeyEd25519,
|
|
116
|
+
publicKeyHex: bytesToHex(k.publicKeyEd25519),
|
|
117
|
+
/** Pass unchanged to `apiKeys.setAssistantKeys`. */
|
|
118
|
+
registrationProof: k.registrationProof,
|
|
119
|
+
/** Epoch ms; pass unchanged to `apiKeys.setAssistantKeys`. */
|
|
120
|
+
registrationDeadline: tsObjToMs(k.registrationDeadline)
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function formatPrepareAssistantKeysResult(r) {
|
|
124
|
+
return {
|
|
125
|
+
setupId: formatId(r.setupId),
|
|
126
|
+
/** One key per requested account, in request order. */
|
|
127
|
+
keys: r.keys.map(formatPreparedAssistantKey),
|
|
128
|
+
/** Epoch ms after which the keys can no longer be registered. */
|
|
129
|
+
expiresAt: tsObjToMs(r.expiresAt)
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
//#endregion
|
|
133
|
+
export { AssistantRunIdInputSchema, CompleteAssistantKeysInputSchema, DecideAssistantApprovalInputSchema, DeleteAssistantMemoryInputSchema, ListAssistantConversationsInputSchema, ListAssistantMemoriesInputSchema, ListAssistantMessagesInputSchema, PrepareAssistantKeysInputSchema, SendAssistantMessageInputSchema, WatchAssistantRunInputSchema, formatAssistantKey, formatConversation, formatMemory, formatMessage, formatPrepareAssistantKeysResult, formatPreparedAssistantKey };
|
|
134
|
+
|
|
135
|
+
//# sourceMappingURL=assistant.schemas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assistant.schemas.js","names":[],"sources":["../../../src/services/assistant/assistant.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { bytesToHex } from \"@noble/hashes/utils.js\";\nimport type * as Proto from \"../../gen/ai/v1/assistant_pb.js\";\nimport { enumLabel } from \"../../shared/proto-enum-codec.js\";\nimport { idInputSchema, optionalSubaccountIdInputSchema } from \"../../shared/schemas.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport { tsObjToMs } from \"../../utils/time.js\";\nimport {\n ASSISTANT_APPROVAL_DECISION_VALUES,\n ApprovalDecisionCodec,\n AssistantKeyStateCodec,\n MemoryKindCodec,\n MessageRoleCodec,\n} from \"./assistant.codecs.js\";\n\nconst IdempotencyKeySchema = v.pipe(v.string(), v.trim(), v.minLength(1));\n\nfunction pageInputEntries(maxLimit: number) {\n return {\n /** Page size; omit for the server default. */\n limit: v.optional(v.pipe(v.number(), v.integer(), v.minValue(1), v.maxValue(maxLimit))),\n /** The previous page's `nextPageToken`. */\n pageToken: v.optional(v.pipe(v.string(), v.trim())),\n };\n}\n\nconst DestinationInputSchema = v.strictObject({\n /** The client's id for the place, e.g. `\"page-subaccounts\"`: lowercase letters, digits and hyphens. */\n id: v.pipe(\n v.string(),\n v.regex(/^[a-z0-9-]{1,64}$/, \"destination id must be 1-64 of a-z, 0-9, -\"),\n ),\n /** Its name as the client shows it, 1 to 80 characters. */\n title: v.pipe(v.string(), v.minLength(1), v.maxLength(80)),\n /** What the user does there, at most 200 characters. */\n description: v.optional(v.pipe(v.string(), v.maxLength(200)), \"\"),\n});\n\nexport const SendAssistantMessageInputSchema = v.pipe(\n v.strictObject({\n /** Conversation to continue; omit to start a new one. */\n conversationId: v.optional(idInputSchema(\"conversationId\")),\n /** Message text, plain text or Markdown, 1 to 16000 characters. */\n text: v.pipe(v.string(), v.minLength(1), v.maxLength(16_000)),\n /** Client-chosen key, unique per caller. Repeat the request unchanged to resolve an unknown outcome. */\n idempotencyKey: IdempotencyKeySchema,\n /**\n * Trading account the run reads and acts on. Omit to answer without account data: the\n * run then has no account tools.\n */\n subaccountId: optionalSubaccountIdInputSchema(),\n /** Places in the client the run may suggest, at most 100, each id once. */\n destinations: v.optional(\n v.pipe(\n v.array(DestinationInputSchema),\n v.maxLength(100, \"At most 100 destinations are allowed.\"),\n v.check(\n (items) => new Set(items.map((d) => d.id)).size === items.length,\n \"Destination ids must be distinct.\",\n ),\n ),\n ),\n }),\n);\n\nexport type SendAssistantMessageInput = v.InferInput<typeof SendAssistantMessageInputSchema>;\n\nexport const AssistantRunIdInputSchema = v.strictObject({ runId: idInputSchema(\"runId\") });\n\nexport type AssistantRunIdInput = v.InferInput<typeof AssistantRunIdInputSchema>;\n\nexport const WatchAssistantRunInputSchema = v.pipe(\n v.strictObject({\n runId: idInputSchema(\"runId\"),\n /** Return events after this seq. 0 (default) replays the run; pass the last seq received to resume. */\n afterSeq: v.optional(\n v.pipe(v.number(), v.integer(), v.minValue(0), v.maxValue(Number.MAX_SAFE_INTEGER)),\n 0,\n ),\n }),\n v.transform(({ runId, afterSeq }) => ({ runId, afterSeq: BigInt(afterSeq) })),\n);\n\nexport type WatchAssistantRunInput = v.InferInput<typeof WatchAssistantRunInputSchema>;\n\nexport const DecideAssistantApprovalInputSchema = v.pipe(\n v.strictObject({\n approvalId: idInputSchema(\"approvalId\"),\n decision: v.picklist(ASSISTANT_APPROVAL_DECISION_VALUES),\n }),\n v.transform(({ approvalId, decision }) => ({\n approvalId,\n decision: ApprovalDecisionCodec.inputToProto[decision],\n })),\n);\n\nexport type DecideAssistantApprovalInput = v.InferInput<typeof DecideAssistantApprovalInputSchema>;\n\nexport const ListAssistantConversationsInputSchema = v.strictObject(pageInputEntries(100));\n\nexport type ListAssistantConversationsInput = v.InferInput<\n typeof ListAssistantConversationsInputSchema\n>;\n\nexport const ListAssistantMessagesInputSchema = v.strictObject({\n conversationId: idInputSchema(\"conversationId\"),\n ...pageInputEntries(200),\n});\n\nexport type ListAssistantMessagesInput = v.InferInput<typeof ListAssistantMessagesInputSchema>;\n\nexport const ListAssistantMemoriesInputSchema = v.strictObject(pageInputEntries(200));\n\nexport type ListAssistantMemoriesInput = v.InferInput<typeof ListAssistantMemoriesInputSchema>;\n\nexport const DeleteAssistantMemoryInputSchema = v.strictObject({\n memoryId: idInputSchema(\"memoryId\"),\n});\n\nexport type DeleteAssistantMemoryInput = v.InferInput<typeof DeleteAssistantMemoryInputSchema>;\n\nexport const PrepareAssistantKeysInputSchema = v.pipe(\n v.strictObject({\n /** 1 to 64 accounts, each once. An entry without `subaccountId` is the main account. */\n accounts: v.pipe(\n v.array(v.strictObject({ subaccountId: optionalSubaccountIdInputSchema() })),\n v.minLength(1, \"At least one account is required.\"),\n v.maxLength(64, \"At most 64 accounts are allowed.\"),\n ),\n }),\n v.check(\n ({ accounts }) =>\n new Set(accounts.map((a) => a.subaccountId ?? 0n)).size === accounts.length,\n \"Each account may be named only once.\",\n ),\n);\n\nexport type PrepareAssistantKeysInput = v.InferInput<typeof PrepareAssistantKeysInputSchema>;\n\nexport const CompleteAssistantKeysInputSchema = v.strictObject({\n setupId: idInputSchema(\"setupId\"),\n});\n\nexport type CompleteAssistantKeysInput = v.InferInput<typeof CompleteAssistantKeysInputSchema>;\n\n/* ---------- outputs ---------- */\n\nfunction optionalId(id: bigint | undefined): string | undefined {\n return id ? formatId(id) : undefined;\n}\n\nexport function formatConversation(c: Proto.Conversation) {\n return {\n conversationId: formatId(c.conversationId),\n /** Empty until a title is available. */\n title: c.title,\n createdAt: tsObjToMs(c.createdAt),\n updatedAt: tsObjToMs(c.updatedAt),\n };\n}\n\nexport type AssistantConversation = ReturnType<typeof formatConversation>;\n\nexport function formatMessage(m: Proto.Message) {\n return {\n messageId: formatId(m.messageId),\n role: enumLabel(MessageRoleCodec.protoToOutput, m.role),\n /** Markdown. For an assistant message, its run's final text. */\n text: m.text,\n createdAt: tsObjToMs(m.createdAt),\n /** Replay this run with `watchRun` from `afterSeq: 0` to show its tool activity and views. */\n runId: formatId(m.runId),\n };\n}\n\nexport type AssistantMessage = ReturnType<typeof formatMessage>;\n\nexport function formatMemory(m: Proto.Memory) {\n return {\n memoryId: formatId(m.memoryId),\n text: m.text,\n createdAt: tsObjToMs(m.createdAt),\n /** Omitted when the conversation it was learned in is unknown. */\n conversationId: optionalId(m.conversationId),\n kind: enumLabel(MemoryKindCodec.protoToOutput, m.kind),\n };\n}\n\nexport type AssistantMemory = ReturnType<typeof formatMemory>;\n\nexport function formatAssistantKey(k: Proto.AssistantKey) {\n return {\n /** Omitted for the main account. */\n subaccountId: optionalId(k.subaccountId),\n keyId: k.keyId,\n publicKeyEd25519: k.publicKeyEd25519,\n publicKeyHex: bytesToHex(k.publicKeyEd25519),\n state: enumLabel(AssistantKeyStateCodec.protoToOutput, k.state),\n };\n}\n\nexport type AssistantKey = ReturnType<typeof formatAssistantKey>;\n\nexport function formatPreparedAssistantKey(k: Proto.PreparedAssistantKey) {\n return {\n /** Omitted for the main account. */\n subaccountId: optionalId(k.subaccountId),\n publicKeyEd25519: k.publicKeyEd25519,\n publicKeyHex: bytesToHex(k.publicKeyEd25519),\n /** Pass unchanged to `apiKeys.setAssistantKeys`. */\n registrationProof: k.registrationProof,\n /** Epoch ms; pass unchanged to `apiKeys.setAssistantKeys`. */\n registrationDeadline: tsObjToMs(k.registrationDeadline),\n };\n}\n\nexport type PreparedAssistantKey = ReturnType<typeof formatPreparedAssistantKey>;\n\nexport function formatPrepareAssistantKeysResult(r: Proto.PrepareAssistantKeysResponse) {\n return {\n setupId: formatId(r.setupId),\n /** One key per requested account, in request order. */\n keys: r.keys.map(formatPreparedAssistantKey),\n /** Epoch ms after which the keys can no longer be registered. */\n expiresAt: tsObjToMs(r.expiresAt),\n };\n}\n\nexport type PrepareAssistantKeysResult = ReturnType<typeof formatPrepareAssistantKeysResult>;\n\n/** `nextPageToken` is empty when no more results exist. */\nexport type ListAssistantConversationsResult = {\n conversations: AssistantConversation[];\n nextPageToken: string;\n};\nexport type ListAssistantMessagesResult = { messages: AssistantMessage[]; nextPageToken: string };\nexport type ListAssistantMemoriesResult = { memories: AssistantMemory[]; nextPageToken: string };\n"],"mappings":"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"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { AssistantApprovalPreview, AssistantOrderPreview, AssistantRunEvent, AssistantView } from "./assistant-events.schemas.js";
|
|
2
|
+
import { AssistantApprovalDecision, AssistantApprovalStatus, AssistantFailureCategory, AssistantKeyState, AssistantMemoryKind, AssistantMessageRole, AssistantOrderPriceField, AssistantPriceOffsetDirection, AssistantPriceRounding, AssistantReferencePriceSource, AssistantTriggerChangeAction, AssistantTriggerDirection, AssistantUnfilledSlicePolicy } from "./assistant.codecs.js";
|
|
3
|
+
import { AssistantConversation, AssistantKey, AssistantMemory, AssistantMessage, AssistantRunIdInput, CompleteAssistantKeysInput, DecideAssistantApprovalInput, DeleteAssistantMemoryInput, ListAssistantConversationsInput, ListAssistantConversationsResult, ListAssistantMemoriesInput, ListAssistantMemoriesResult, ListAssistantMessagesInput, ListAssistantMessagesResult, PrepareAssistantKeysInput, PrepareAssistantKeysResult, PreparedAssistantKey, SendAssistantMessageInput, WatchAssistantRunInput } from "./assistant.schemas.js";
|
|
4
|
+
export type { AssistantApprovalDecision, AssistantApprovalPreview, AssistantApprovalStatus, AssistantConversation, AssistantFailureCategory, AssistantKey, AssistantKeyState, AssistantMemory, AssistantMemoryKind, AssistantMessage, AssistantMessageRole, AssistantOrderPreview, AssistantOrderPriceField, AssistantPriceOffsetDirection, AssistantPriceRounding, AssistantReferencePriceSource, AssistantRunEvent, AssistantRunIdInput, AssistantTriggerChangeAction, AssistantTriggerDirection, AssistantUnfilledSlicePolicy, AssistantView, CompleteAssistantKeysInput, DecideAssistantApprovalInput, DeleteAssistantMemoryInput, ListAssistantConversationsInput, ListAssistantConversationsResult, ListAssistantMemoriesInput, ListAssistantMemoriesResult, ListAssistantMessagesInput, ListAssistantMessagesResult, PrepareAssistantKeysInput, PrepareAssistantKeysResult, PreparedAssistantKey, SendAssistantMessageInput, WatchAssistantRunInput };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AssistantService } from "./assistant.js";
|
|
2
|
+
import { PolyesterCore } from "../../core-client.js";
|
|
3
|
+
//#region src/services/assistant/service.d.ts
|
|
4
|
+
/** Returns the client's AssistantService, creating it on first use. */
|
|
5
|
+
declare const assistantService: (client: PolyesterCore) => AssistantService;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { assistantService };
|
|
8
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","names":[],"sources":["../../../src/services/assistant/service.ts"],"mappings":";;;;cAIa,mBAAgB,QAAhB,kBAAgB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { defineService } from "../../core-client.js";
|
|
2
|
+
import { AssistantService } from "./assistant.js";
|
|
3
|
+
//#region src/services/assistant/service.ts
|
|
4
|
+
/** Returns the client's AssistantService, creating it on first use. */
|
|
5
|
+
const assistantService = defineService((context) => new AssistantService(context.transports, context.scales));
|
|
6
|
+
//#endregion
|
|
7
|
+
export { assistantService };
|
|
8
|
+
|
|
9
|
+
//# sourceMappingURL=service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.js","names":[],"sources":["../../../src/services/assistant/service.ts"],"sourcesContent":["import { defineService } from \"../../core-client.js\";\nimport { AssistantService } from \"./assistant.js\";\n\n/** Returns the client's AssistantService, creating it on first use. */\nexport const assistantService = defineService(\n (context) => new AssistantService(context.transports, context.scales),\n);\n"],"mappings":";;;;AAIA,MAAa,mBAAmB,eAC3B,YAAY,IAAI,iBAAiB,QAAQ,YAAY,QAAQ,MAAM,CACxE"}
|
|
@@ -8,12 +8,19 @@ declare const AUTO_WITHDRAW_RUN_STATE_VALUES: readonly ["planned", "paying", "co
|
|
|
8
8
|
type AutoWithdrawRunState = (typeof AUTO_WITHDRAW_RUN_STATE_VALUES)[number];
|
|
9
9
|
declare const AUTO_WITHDRAW_STEP_STATE_VALUES: readonly ["pending", "submitting", "submitted", "completed", "failed", "skipped"];
|
|
10
10
|
type AutoWithdrawStepState = (typeof AUTO_WITHDRAW_STEP_STATE_VALUES)[number];
|
|
11
|
+
declare const AUTO_WITHDRAW_PREVIEW_STATUS_VALUES: readonly ["will_pay", "rolls_over", "no_destination", "paused", "no_rule"];
|
|
12
|
+
type AutoWithdrawPreviewStatus = (typeof AUTO_WITHDRAW_PREVIEW_STATUS_VALUES)[number];
|
|
11
13
|
/** Why a rule paused itself. Unknown future reasons pass through as strings. */
|
|
12
14
|
type AutoWithdrawPauseReason = "destination_not_whitelisted" | "destination_invalid" | "authority_revoked" | (string & {});
|
|
13
15
|
/** Why a run was skipped. Unknown future reasons pass through as strings. */
|
|
14
16
|
type AutoWithdrawRunReason = "nothing_to_pay" | "price_unavailable" | "rule_superseded" | (string & {});
|
|
15
17
|
/** Why a step was skipped or failed. Unknown future reasons pass through as strings. */
|
|
16
|
-
type AutoWithdrawStepReason = "below_minimum" | "price_unavailable" | "rule_superseded" | "destination_not_whitelisted" | "authority_revoked" | "gateway_capacity_insufficient" | "withdrawal_released" | "withdrawal_failed" | (string & {});
|
|
18
|
+
type AutoWithdrawStepReason = "below_minimum" | "price_unavailable" | "rule_superseded" | "destination_not_whitelisted" | "destination_cooling_down" | "authority_revoked" | "gateway_capacity_insufficient" | "withdrawal_released" | "withdrawal_failed" | (string & {});
|
|
19
|
+
/**
|
|
20
|
+
* Why part or all of an asset's balance would stay on the account in a previewed run. Unknown
|
|
21
|
+
* future reasons pass through as strings.
|
|
22
|
+
*/
|
|
23
|
+
type AutoWithdrawHoldReason = "below_minimum" | "price_unavailable" | "no_destination" | "destination_cooling_down" | "above_max" | "dust" | (string & {});
|
|
17
24
|
//#endregion
|
|
18
|
-
export { AUTO_WITHDRAW_CADENCE_VALUES, AUTO_WITHDRAW_RUN_STATE_VALUES, AUTO_WITHDRAW_STEP_STATE_VALUES, AUTO_WITHDRAW_WEEKDAY_VALUES, AutoWithdrawCadence, AutoWithdrawPauseReason, AutoWithdrawRunReason, AutoWithdrawRunState, AutoWithdrawStepReason, AutoWithdrawStepState, AutoWithdrawWeekday };
|
|
25
|
+
export { AUTO_WITHDRAW_CADENCE_VALUES, AUTO_WITHDRAW_PREVIEW_STATUS_VALUES, AUTO_WITHDRAW_RUN_STATE_VALUES, AUTO_WITHDRAW_STEP_STATE_VALUES, AUTO_WITHDRAW_WEEKDAY_VALUES, AutoWithdrawCadence, AutoWithdrawHoldReason, AutoWithdrawPauseReason, AutoWithdrawPreviewStatus, AutoWithdrawRunReason, AutoWithdrawRunState, AutoWithdrawStepReason, AutoWithdrawStepState, AutoWithdrawWeekday };
|
|
19
26
|
//# sourceMappingURL=auto-withdraw.codecs.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-withdraw.codecs.d.ts","names":[],"sources":["../../../src/services/auto-withdraw/auto-withdraw.codecs.ts"],"mappings":";;cAGa;KAOD,8BAA8B;cAE7B;KASD,8BAA8B;cAE7B;KAQD,+BAA+B;cAE9B;KAQD,gCAAgC;;
|
|
1
|
+
{"version":3,"file":"auto-withdraw.codecs.d.ts","names":[],"sources":["../../../src/services/auto-withdraw/auto-withdraw.codecs.ts"],"mappings":";;cAGa;KAOD,8BAA8B;cAE7B;KASD,8BAA8B;cAE7B;KAQD,+BAA+B;cAE9B;KAQD,gCAAgC;cAE/B;KAOD,oCAAoC;;KAsEpC;;KAOA;;KAOA;;;;;KAgBA"}
|
|
@@ -55,7 +55,15 @@ const AutoWithdrawStepStateCodec = { protoToOutput: {
|
|
|
55
55
|
[5]: "failed",
|
|
56
56
|
[6]: "skipped"
|
|
57
57
|
} };
|
|
58
|
+
const AutoWithdrawPreviewStatusCodec = { protoToOutput: {
|
|
59
|
+
[0]: "unspecified",
|
|
60
|
+
[1]: "will_pay",
|
|
61
|
+
[2]: "rolls_over",
|
|
62
|
+
[3]: "no_destination",
|
|
63
|
+
[4]: "paused",
|
|
64
|
+
[5]: "no_rule"
|
|
65
|
+
} };
|
|
58
66
|
//#endregion
|
|
59
|
-
export { AUTO_WITHDRAW_WEEKDAY_VALUES, AutoWithdrawCadenceCodec, AutoWithdrawRunStateCodec, AutoWithdrawStepStateCodec, AutoWithdrawWeekdayCodec };
|
|
67
|
+
export { AUTO_WITHDRAW_WEEKDAY_VALUES, AutoWithdrawCadenceCodec, AutoWithdrawPreviewStatusCodec, AutoWithdrawRunStateCodec, AutoWithdrawStepStateCodec, AutoWithdrawWeekdayCodec };
|
|
60
68
|
|
|
61
69
|
//# sourceMappingURL=auto-withdraw.codecs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-withdraw.codecs.js","names":[],"sources":["../../../src/services/auto-withdraw/auto-withdraw.codecs.ts"],"sourcesContent":["import * as Proto from \"../../gen/chain/withdraw/v1/auto_withdraw_pb.js\";\nimport type { InputToProto, ProtoToOutput } from \"../../utils/types.js\";\n\nexport const AUTO_WITHDRAW_CADENCE_VALUES = [\n \"hourly\",\n \"daily\",\n \"weekly\",\n \"biweekly\",\n \"monthly\",\n] as const;\nexport type AutoWithdrawCadence = (typeof AUTO_WITHDRAW_CADENCE_VALUES)[number];\n\nexport const AUTO_WITHDRAW_WEEKDAY_VALUES = [\n \"monday\",\n \"tuesday\",\n \"wednesday\",\n \"thursday\",\n \"friday\",\n \"saturday\",\n \"sunday\",\n] as const;\nexport type AutoWithdrawWeekday = (typeof AUTO_WITHDRAW_WEEKDAY_VALUES)[number];\n\nexport const AUTO_WITHDRAW_RUN_STATE_VALUES = [\n \"planned\",\n \"paying\",\n \"completed\",\n \"partially_failed\",\n \"failed\",\n \"skipped\",\n] as const;\nexport type AutoWithdrawRunState = (typeof AUTO_WITHDRAW_RUN_STATE_VALUES)[number];\n\nexport const AUTO_WITHDRAW_STEP_STATE_VALUES = [\n \"pending\",\n \"submitting\",\n \"submitted\",\n \"completed\",\n \"failed\",\n \"skipped\",\n] as const;\nexport type AutoWithdrawStepState = (typeof AUTO_WITHDRAW_STEP_STATE_VALUES)[number];\n\nexport const AutoWithdrawCadenceCodec = {\n inputToProto: {\n hourly: Proto.AutoWithdrawCadence.HOURLY,\n daily: Proto.AutoWithdrawCadence.DAILY,\n weekly: Proto.AutoWithdrawCadence.WEEKLY,\n biweekly: Proto.AutoWithdrawCadence.BIWEEKLY,\n monthly: Proto.AutoWithdrawCadence.MONTHLY,\n } satisfies InputToProto<AutoWithdrawCadence, Proto.AutoWithdrawCadence>,\n} as const;\n\nexport const AutoWithdrawWeekdayCodec = {\n inputToProto: {\n monday: Proto.AutoWithdrawWeekday.MONDAY,\n tuesday: Proto.AutoWithdrawWeekday.TUESDAY,\n wednesday: Proto.AutoWithdrawWeekday.WEDNESDAY,\n thursday: Proto.AutoWithdrawWeekday.THURSDAY,\n friday: Proto.AutoWithdrawWeekday.FRIDAY,\n saturday: Proto.AutoWithdrawWeekday.SATURDAY,\n sunday: Proto.AutoWithdrawWeekday.SUNDAY,\n } satisfies InputToProto<AutoWithdrawWeekday, Proto.AutoWithdrawWeekday>,\n protoToOutput: {\n [Proto.AutoWithdrawWeekday.WEEKDAY_UNSPECIFIED]: \"unspecified\",\n [Proto.AutoWithdrawWeekday.MONDAY]: \"monday\",\n [Proto.AutoWithdrawWeekday.TUESDAY]: \"tuesday\",\n [Proto.AutoWithdrawWeekday.WEDNESDAY]: \"wednesday\",\n [Proto.AutoWithdrawWeekday.THURSDAY]: \"thursday\",\n [Proto.AutoWithdrawWeekday.FRIDAY]: \"friday\",\n [Proto.AutoWithdrawWeekday.SATURDAY]: \"saturday\",\n [Proto.AutoWithdrawWeekday.SUNDAY]: \"sunday\",\n } satisfies ProtoToOutput<Proto.AutoWithdrawWeekday, AutoWithdrawWeekday>,\n} as const;\n\nexport const AutoWithdrawRunStateCodec = {\n protoToOutput: {\n [Proto.AutoWithdrawRunState.RUN_STATE_UNSPECIFIED]: \"unspecified\",\n [Proto.AutoWithdrawRunState.RUN_PLANNED]: \"planned\",\n [Proto.AutoWithdrawRunState.RUN_PAYING]: \"paying\",\n [Proto.AutoWithdrawRunState.RUN_COMPLETED]: \"completed\",\n [Proto.AutoWithdrawRunState.RUN_PARTIALLY_FAILED]: \"partially_failed\",\n [Proto.AutoWithdrawRunState.RUN_FAILED]: \"failed\",\n [Proto.AutoWithdrawRunState.RUN_SKIPPED]: \"skipped\",\n } satisfies ProtoToOutput<Proto.AutoWithdrawRunState, AutoWithdrawRunState>,\n} as const;\n\nexport const AutoWithdrawStepStateCodec = {\n protoToOutput: {\n [Proto.AutoWithdrawStepState.STEP_STATE_UNSPECIFIED]: \"unspecified\",\n [Proto.AutoWithdrawStepState.STEP_PENDING]: \"pending\",\n [Proto.AutoWithdrawStepState.STEP_SUBMITTING]: \"submitting\",\n [Proto.AutoWithdrawStepState.STEP_SUBMITTED]: \"submitted\",\n [Proto.AutoWithdrawStepState.STEP_COMPLETED]: \"completed\",\n [Proto.AutoWithdrawStepState.STEP_FAILED]: \"failed\",\n [Proto.AutoWithdrawStepState.STEP_SKIPPED]: \"skipped\",\n } satisfies ProtoToOutput<Proto.AutoWithdrawStepState, AutoWithdrawStepState>,\n} as const;\n\n/** Why a rule paused itself. Unknown future reasons pass through as strings. */\nexport type AutoWithdrawPauseReason =\n | \"destination_not_whitelisted\"\n | \"destination_invalid\"\n | \"authority_revoked\"\n | (string & {});\n\n/** Why a run was skipped. Unknown future reasons pass through as strings. */\nexport type AutoWithdrawRunReason =\n | \"nothing_to_pay\"\n | \"price_unavailable\"\n | \"rule_superseded\"\n | (string & {});\n\n/** Why a step was skipped or failed. Unknown future reasons pass through as strings. */\nexport type AutoWithdrawStepReason =\n | \"below_minimum\"\n | \"price_unavailable\"\n | \"rule_superseded\"\n | \"destination_not_whitelisted\"\n | \"authority_revoked\"\n | \"gateway_capacity_insufficient\"\n | \"withdrawal_released\"\n | \"withdrawal_failed\"\n | (string & {});\n"],"mappings":";;AAYA,MAAa,+BAA+B;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;AACJ;
|
|
1
|
+
{"version":3,"file":"auto-withdraw.codecs.js","names":[],"sources":["../../../src/services/auto-withdraw/auto-withdraw.codecs.ts"],"sourcesContent":["import * as Proto from \"../../gen/chain/withdraw/v1/auto_withdraw_pb.js\";\nimport type { InputToProto, ProtoToOutput } from \"../../utils/types.js\";\n\nexport const AUTO_WITHDRAW_CADENCE_VALUES = [\n \"hourly\",\n \"daily\",\n \"weekly\",\n \"biweekly\",\n \"monthly\",\n] as const;\nexport type AutoWithdrawCadence = (typeof AUTO_WITHDRAW_CADENCE_VALUES)[number];\n\nexport const AUTO_WITHDRAW_WEEKDAY_VALUES = [\n \"monday\",\n \"tuesday\",\n \"wednesday\",\n \"thursday\",\n \"friday\",\n \"saturday\",\n \"sunday\",\n] as const;\nexport type AutoWithdrawWeekday = (typeof AUTO_WITHDRAW_WEEKDAY_VALUES)[number];\n\nexport const AUTO_WITHDRAW_RUN_STATE_VALUES = [\n \"planned\",\n \"paying\",\n \"completed\",\n \"partially_failed\",\n \"failed\",\n \"skipped\",\n] as const;\nexport type AutoWithdrawRunState = (typeof AUTO_WITHDRAW_RUN_STATE_VALUES)[number];\n\nexport const AUTO_WITHDRAW_STEP_STATE_VALUES = [\n \"pending\",\n \"submitting\",\n \"submitted\",\n \"completed\",\n \"failed\",\n \"skipped\",\n] as const;\nexport type AutoWithdrawStepState = (typeof AUTO_WITHDRAW_STEP_STATE_VALUES)[number];\n\nexport const AUTO_WITHDRAW_PREVIEW_STATUS_VALUES = [\n \"will_pay\",\n \"rolls_over\",\n \"no_destination\",\n \"paused\",\n \"no_rule\",\n] as const;\nexport type AutoWithdrawPreviewStatus = (typeof AUTO_WITHDRAW_PREVIEW_STATUS_VALUES)[number];\n\nexport const AutoWithdrawCadenceCodec = {\n inputToProto: {\n hourly: Proto.AutoWithdrawCadence.HOURLY,\n daily: Proto.AutoWithdrawCadence.DAILY,\n weekly: Proto.AutoWithdrawCadence.WEEKLY,\n biweekly: Proto.AutoWithdrawCadence.BIWEEKLY,\n monthly: Proto.AutoWithdrawCadence.MONTHLY,\n } satisfies InputToProto<AutoWithdrawCadence, Proto.AutoWithdrawCadence>,\n} as const;\n\nexport const AutoWithdrawWeekdayCodec = {\n inputToProto: {\n monday: Proto.AutoWithdrawWeekday.MONDAY,\n tuesday: Proto.AutoWithdrawWeekday.TUESDAY,\n wednesday: Proto.AutoWithdrawWeekday.WEDNESDAY,\n thursday: Proto.AutoWithdrawWeekday.THURSDAY,\n friday: Proto.AutoWithdrawWeekday.FRIDAY,\n saturday: Proto.AutoWithdrawWeekday.SATURDAY,\n sunday: Proto.AutoWithdrawWeekday.SUNDAY,\n } satisfies InputToProto<AutoWithdrawWeekday, Proto.AutoWithdrawWeekday>,\n protoToOutput: {\n [Proto.AutoWithdrawWeekday.WEEKDAY_UNSPECIFIED]: \"unspecified\",\n [Proto.AutoWithdrawWeekday.MONDAY]: \"monday\",\n [Proto.AutoWithdrawWeekday.TUESDAY]: \"tuesday\",\n [Proto.AutoWithdrawWeekday.WEDNESDAY]: \"wednesday\",\n [Proto.AutoWithdrawWeekday.THURSDAY]: \"thursday\",\n [Proto.AutoWithdrawWeekday.FRIDAY]: \"friday\",\n [Proto.AutoWithdrawWeekday.SATURDAY]: \"saturday\",\n [Proto.AutoWithdrawWeekday.SUNDAY]: \"sunday\",\n } satisfies ProtoToOutput<Proto.AutoWithdrawWeekday, AutoWithdrawWeekday>,\n} as const;\n\nexport const AutoWithdrawRunStateCodec = {\n protoToOutput: {\n [Proto.AutoWithdrawRunState.RUN_STATE_UNSPECIFIED]: \"unspecified\",\n [Proto.AutoWithdrawRunState.RUN_PLANNED]: \"planned\",\n [Proto.AutoWithdrawRunState.RUN_PAYING]: \"paying\",\n [Proto.AutoWithdrawRunState.RUN_COMPLETED]: \"completed\",\n [Proto.AutoWithdrawRunState.RUN_PARTIALLY_FAILED]: \"partially_failed\",\n [Proto.AutoWithdrawRunState.RUN_FAILED]: \"failed\",\n [Proto.AutoWithdrawRunState.RUN_SKIPPED]: \"skipped\",\n } satisfies ProtoToOutput<Proto.AutoWithdrawRunState, AutoWithdrawRunState>,\n} as const;\n\nexport const AutoWithdrawStepStateCodec = {\n protoToOutput: {\n [Proto.AutoWithdrawStepState.STEP_STATE_UNSPECIFIED]: \"unspecified\",\n [Proto.AutoWithdrawStepState.STEP_PENDING]: \"pending\",\n [Proto.AutoWithdrawStepState.STEP_SUBMITTING]: \"submitting\",\n [Proto.AutoWithdrawStepState.STEP_SUBMITTED]: \"submitted\",\n [Proto.AutoWithdrawStepState.STEP_COMPLETED]: \"completed\",\n [Proto.AutoWithdrawStepState.STEP_FAILED]: \"failed\",\n [Proto.AutoWithdrawStepState.STEP_SKIPPED]: \"skipped\",\n } satisfies ProtoToOutput<Proto.AutoWithdrawStepState, AutoWithdrawStepState>,\n} as const;\n\nexport const AutoWithdrawPreviewStatusCodec = {\n protoToOutput: {\n [Proto.AutoWithdrawPreviewStatus.PREVIEW_STATUS_UNSPECIFIED]: \"unspecified\",\n [Proto.AutoWithdrawPreviewStatus.WILL_PAY]: \"will_pay\",\n [Proto.AutoWithdrawPreviewStatus.ROLLS_OVER]: \"rolls_over\",\n [Proto.AutoWithdrawPreviewStatus.NO_DESTINATION]: \"no_destination\",\n [Proto.AutoWithdrawPreviewStatus.PAUSED]: \"paused\",\n [Proto.AutoWithdrawPreviewStatus.NO_RULE]: \"no_rule\",\n } satisfies ProtoToOutput<Proto.AutoWithdrawPreviewStatus, AutoWithdrawPreviewStatus>,\n} as const;\n\n/** Why a rule paused itself. Unknown future reasons pass through as strings. */\nexport type AutoWithdrawPauseReason =\n | \"destination_not_whitelisted\"\n | \"destination_invalid\"\n | \"authority_revoked\"\n | (string & {});\n\n/** Why a run was skipped. Unknown future reasons pass through as strings. */\nexport type AutoWithdrawRunReason =\n | \"nothing_to_pay\"\n | \"price_unavailable\"\n | \"rule_superseded\"\n | (string & {});\n\n/** Why a step was skipped or failed. Unknown future reasons pass through as strings. */\nexport type AutoWithdrawStepReason =\n | \"below_minimum\"\n | \"price_unavailable\"\n | \"rule_superseded\"\n | \"destination_not_whitelisted\"\n | \"destination_cooling_down\"\n | \"authority_revoked\"\n | \"gateway_capacity_insufficient\"\n | \"withdrawal_released\"\n | \"withdrawal_failed\"\n | (string & {});\n\n/**\n * Why part or all of an asset's balance would stay on the account in a previewed run. Unknown\n * future reasons pass through as strings.\n */\nexport type AutoWithdrawHoldReason =\n | \"below_minimum\"\n | \"price_unavailable\"\n | \"no_destination\"\n | \"destination_cooling_down\"\n | \"above_max\"\n | \"dust\"\n | (string & {});\n"],"mappings":";;AAYA,MAAa,+BAA+B;CACxC;CACA;CACA;CACA;CACA;CACA;CACA;AACJ;AAgCA,MAAa,2BAA2B,EACpC,cAAc;CACV,QAAA;CACA,OAAA;CACA,QAAA;CACA,UAAA;CACA,SAAA;AACJ,EACJ;AAEA,MAAa,2BAA2B;CACpC,cAAc;EACV,QAAA;EACA,SAAA;EACA,WAAA;EACA,UAAA;EACA,QAAA;EACA,UAAA;EACA,QAAA;CACJ;CACA,eAAe;GACsC,IAAA;GACb,IAAA;GACC,IAAA;GACE,IAAA;GACD,IAAA;GACF,IAAA;GACE,IAAA;GACF,IAAA;CACxC;AACJ;AAEA,MAAa,4BAA4B,EACrC,eAAe;EACyC,IAAA;EACV,IAAA;EACD,IAAA;EACG,IAAA;EACO,IAAA;EACV,IAAA;EACC,IAAA;AAC9C,EACJ;AAEA,MAAa,6BAA6B,EACtC,eAAe;EAC2C,IAAA;EACV,IAAA;EACG,IAAA;EACD,IAAA;EACA,IAAA;EACH,IAAA;EACC,IAAA;AAChD,EACJ;AAEA,MAAa,iCAAiC,EAC1C,eAAe;EACmD,IAAA;EAClB,IAAA;EACE,IAAA;EACI,IAAA;EACR,IAAA;EACC,IAAA;AAC/C,EACJ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AuthApiTransports } from "../../shared/transports.js";
|
|
2
2
|
import { PolyesterMutationOptions, PolyesterRequestOptions } from "../../shared/request-options.js";
|
|
3
3
|
import { SubaccountResolver } from "../subaccount-resolver.js";
|
|
4
|
-
import { AutoWithdrawRule, AutoWithdrawScopedInput,
|
|
4
|
+
import { AutoWithdrawPreview, AutoWithdrawRule, AutoWithdrawScopedInput, ListAutoWithdrawRunsInput, ListAutoWithdrawRunsResult, SetAutoWithdrawRuleEnabledInput, SetAutoWithdrawRuleInput } from "./auto-withdraw.schemas.js";
|
|
5
5
|
//#region src/services/auto-withdraw/auto-withdraw.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Manages the scheduled auto-withdraw rule of the root account or a subaccount: each asset's
|
|
@@ -24,10 +24,21 @@ declare class AutoWithdrawService {
|
|
|
24
24
|
*/
|
|
25
25
|
setRule(input: SetAutoWithdrawRuleInput, options?: PolyesterMutationOptions): Promise<AutoWithdrawRule>;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
27
|
+
* Pauses (`enabled: false`) or resumes (`enabled: true`) the account's rule, keeping its
|
|
28
|
+
* schedule and destinations, and returns the latest version: a new one, or the current one
|
|
29
|
+
* unchanged when the rule is already in that state. Each change creates a version, so pass
|
|
30
|
+
* the latest `version` as `expectedVersion`; a stale one throws `RevisionConflictError`.
|
|
31
|
+
* Pausing needs no step-up. Resuming needs a fresh `stepUpToken`, checks every destination
|
|
32
|
+
* again like `setRule`, and clears a pause the rule set itself; a refused destination
|
|
33
|
+
* leaves the rule paused.
|
|
29
34
|
*/
|
|
30
|
-
|
|
35
|
+
setRuleEnabled(input: SetAutoWithdrawRuleEnabledInput, options?: PolyesterMutationOptions): Promise<AutoWithdrawRule>;
|
|
36
|
+
/**
|
|
37
|
+
* Previews what the account's next run would pay, using the same planning as the run and
|
|
38
|
+
* the balances, prices and fees now. Readable by API keys with `read-auto-withdraw`. With a
|
|
39
|
+
* USD minimum, a failed price read throws a retryable error.
|
|
40
|
+
*/
|
|
41
|
+
previewRun(input?: AutoWithdrawScopedInput, options?: PolyesterRequestOptions): Promise<AutoWithdrawPreview>;
|
|
31
42
|
/**
|
|
32
43
|
* Lists the account's runs with their payouts, newest first. Pass the previous
|
|
33
44
|
* `nextPageToken` as `pageToken` to continue; an empty `nextPageToken` means no more runs.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-withdraw.d.ts","names":[],"sources":["../../../src/services/auto-withdraw/auto-withdraw.ts"],"mappings":";;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"auto-withdraw.d.ts","names":[],"sources":["../../../src/services/auto-withdraw/auto-withdraw.ts"],"mappings":";;;;;;;;;;;;;;cAiEa;;EAIG,YAAA,YAAY,mBAAmB,WAAW;;EAMhD,QACF,QAAO,yBACP,UAAU,0BACX,QAAQ;;;;;;EAcL,QACF,OAAO,0BACP,UAAU,2BACX,QAAQ;;;;;;;;;;EAiBL,eACF,OAAO,iCACP,UAAU,2BACX,QAAQ;;;;;;EAaL,WACF,QAAO,yBACP,UAAU,0BACX,QAAQ;;;;;EAaL,SACF,QAAO,2BACP,UAAU,0BACX,QAAQ;UASH"}
|
|
@@ -5,17 +5,18 @@ import { removeUndefined } from "../../utils/remove-undefined.js";
|
|
|
5
5
|
import { toConnectCallOptions } from "../../shared/request-options.js";
|
|
6
6
|
import { resolveAccountScopedInput } from "../subaccount-resolver.js";
|
|
7
7
|
import { AutoWithdrawService as AutoWithdrawService$1 } from "../../gen/chain/withdraw/v1/auto_withdraw_pb.js";
|
|
8
|
-
import { AutoWithdrawRuleSchema, AutoWithdrawScopedInputSchema,
|
|
8
|
+
import { AutoWithdrawPreviewSchema, AutoWithdrawRuleSchema, AutoWithdrawScopedInputSchema, ListAutoWithdrawRunsInputSchema, ListAutoWithdrawRunsResultSchema, SetAutoWithdrawRuleEnabledInputSchema, SetAutoWithdrawRuleInputSchema } from "./auto-withdraw.schemas.js";
|
|
9
9
|
import { Code, ConnectError, createClient } from "@connectrpc/connect";
|
|
10
10
|
//#region src/services/auto-withdraw/auto-withdraw.ts
|
|
11
11
|
/**
|
|
12
|
-
* A stale `expectedVersion` comes back as the withdraw `
|
|
12
|
+
* A stale `expectedVersion` comes back as the withdraw `VERSION_CONFLICT` detail (older
|
|
13
|
+
* servers send `CONFLICT`), or as a bare
|
|
13
14
|
* `Aborted`, which the transport would otherwise surface as a retryable `TransientError`.
|
|
14
15
|
* Either one becomes a `RevisionConflictError`: refetch the rule, don't retry blindly.
|
|
15
16
|
*/
|
|
16
17
|
function rethrowVersionConflict(err) {
|
|
17
18
|
const mapped = toPolyesterError(err);
|
|
18
|
-
if (mapped instanceof PolyesterError && !(mapped instanceof RevisionConflictError) && (mapped.detail?.service === "withdraw" && mapped.detail.code === "CONFLICT" || mapped.cause instanceof ConnectError && mapped.cause.code === Code.Aborted && mapped.cause.details.length === 0)) throw new RevisionConflictError(mapped.message || "Auto-withdraw rule changed since it was last read.", {
|
|
19
|
+
if (mapped instanceof PolyesterError && !(mapped instanceof RevisionConflictError) && (mapped.detail?.service === "withdraw" && (mapped.detail.code === "VERSION_CONFLICT" || mapped.detail.code === "CONFLICT") || mapped.cause instanceof ConnectError && mapped.cause.code === Code.Aborted && mapped.cause.details.length === 0)) throw new RevisionConflictError(mapped.message || "Auto-withdraw rule changed since it was last read.", {
|
|
19
20
|
cause: mapped.cause,
|
|
20
21
|
detail: mapped.detail,
|
|
21
22
|
status: mapped.status
|
|
@@ -55,15 +56,30 @@ var AutoWithdrawService = class {
|
|
|
55
56
|
return parse(AutoWithdrawRuleSchema, response.rule);
|
|
56
57
|
}
|
|
57
58
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
59
|
+
* Pauses (`enabled: false`) or resumes (`enabled: true`) the account's rule, keeping its
|
|
60
|
+
* schedule and destinations, and returns the latest version: a new one, or the current one
|
|
61
|
+
* unchanged when the rule is already in that state. Each change creates a version, so pass
|
|
62
|
+
* the latest `version` as `expectedVersion`; a stale one throws `RevisionConflictError`.
|
|
63
|
+
* Pausing needs no step-up. Resuming needs a fresh `stepUpToken`, checks every destination
|
|
64
|
+
* again like `setRule`, and clears a pause the rule set itself; a refused destination
|
|
65
|
+
* leaves the rule paused.
|
|
60
66
|
*/
|
|
61
|
-
async
|
|
62
|
-
const request = parse(
|
|
63
|
-
const response = await this.#client.
|
|
67
|
+
async setRuleEnabled(input, options) {
|
|
68
|
+
const request = parse(SetAutoWithdrawRuleEnabledInputSchema, this.resolveInput(input));
|
|
69
|
+
const response = await this.#client.setAutoWithdrawRuleEnabled(removeUndefined(request), toConnectCallOptions(options)).catch(rethrowVersionConflict);
|
|
64
70
|
return parse(AutoWithdrawRuleSchema, response.rule);
|
|
65
71
|
}
|
|
66
72
|
/**
|
|
73
|
+
* Previews what the account's next run would pay, using the same planning as the run and
|
|
74
|
+
* the balances, prices and fees now. Readable by API keys with `read-auto-withdraw`. With a
|
|
75
|
+
* USD minimum, a failed price read throws a retryable error.
|
|
76
|
+
*/
|
|
77
|
+
async previewRun(input = {}, options) {
|
|
78
|
+
const request = parse(AutoWithdrawScopedInputSchema, this.resolveInput(input));
|
|
79
|
+
const response = await this.#client.previewAutoWithdrawRun(removeUndefined(request), toConnectCallOptions(options));
|
|
80
|
+
return parse(AutoWithdrawPreviewSchema, response);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
67
83
|
* Lists the account's runs with their payouts, newest first. Pass the previous
|
|
68
84
|
* `nextPageToken` as `pageToken` to continue; an empty `nextPageToken` means no more runs.
|
|
69
85
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto-withdraw.js","names":["#client","Proto.AutoWithdrawService","#resolver"],"sources":["../../../src/services/auto-withdraw/auto-withdraw.ts"],"sourcesContent":["import { Code, ConnectError, createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/chain/withdraw/v1/auto_withdraw_pb.js\";\nimport type { AccountScopedInput } from \"../../shared/account-scope.js\";\nimport { toPolyesterError } from \"../../shared/connect-error-mapping.js\";\nimport { PolyesterError, RevisionConflictError } from \"../../shared/errors.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { AuthApiTransports } 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
|
|
1
|
+
{"version":3,"file":"auto-withdraw.js","names":["#client","Proto.AutoWithdrawService","#resolver"],"sources":["../../../src/services/auto-withdraw/auto-withdraw.ts"],"sourcesContent":["import { Code, ConnectError, createClient, type Client } from \"@connectrpc/connect\";\nimport * as Proto from \"../../gen/chain/withdraw/v1/auto_withdraw_pb.js\";\nimport type { AccountScopedInput } from \"../../shared/account-scope.js\";\nimport { toPolyesterError } from \"../../shared/connect-error-mapping.js\";\nimport { PolyesterError, RevisionConflictError } from \"../../shared/errors.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport type { AuthApiTransports } 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 AutoWithdrawPreviewSchema,\n AutoWithdrawRuleSchema,\n AutoWithdrawScopedInputSchema,\n ListAutoWithdrawRunsInputSchema,\n ListAutoWithdrawRunsResultSchema,\n SetAutoWithdrawRuleEnabledInputSchema,\n SetAutoWithdrawRuleInputSchema,\n type AutoWithdrawPreview,\n type AutoWithdrawRule,\n type AutoWithdrawScopedInput,\n type ListAutoWithdrawRunsInput,\n type ListAutoWithdrawRunsResult,\n type SetAutoWithdrawRuleEnabledInput,\n type SetAutoWithdrawRuleInput,\n} from \"./auto-withdraw.schemas.js\";\n\n/**\n * A stale `expectedVersion` comes back as the withdraw `VERSION_CONFLICT` detail (older\n * servers send `CONFLICT`), or as a bare\n * `Aborted`, which the transport would otherwise surface as a retryable `TransientError`.\n * Either one becomes a `RevisionConflictError`: refetch the rule, don't retry blindly.\n */\nfunction rethrowVersionConflict(err: unknown): never {\n const mapped = toPolyesterError(err);\n if (\n mapped instanceof PolyesterError &&\n !(mapped instanceof RevisionConflictError) &&\n ((mapped.detail?.service === \"withdraw\" &&\n (mapped.detail.code === \"VERSION_CONFLICT\" || mapped.detail.code === \"CONFLICT\")) ||\n (mapped.cause instanceof ConnectError &&\n mapped.cause.code === Code.Aborted &&\n mapped.cause.details.length === 0))\n ) {\n throw new RevisionConflictError(\n mapped.message || \"Auto-withdraw rule changed since it was last read.\",\n { cause: mapped.cause, detail: mapped.detail, status: mapped.status },\n );\n }\n throw mapped;\n}\n\n/**\n * Manages the scheduled auto-withdraw rule of the root account or a subaccount: each asset's\n * balance is paid in kind on an hourly, daily, weekly, biweekly or monthly UTC slot to\n * destinations on the account's external withdraw whitelist. API keys can read rules and runs;\n * changing a rule needs a session login with withdraw rights and a fresh single-use step-up\n * token (`stepUpToken`). A missing step-up throws `StepUpRequiredError` or\n * `SessionElevationRequiredError`; check `isFreshStepUpRequiredError` before retrying with a new\n * token.\n */\nexport class AutoWithdrawService {\n #client: Client<typeof Proto.AutoWithdrawService>;\n #resolver?: SubaccountResolver;\n\n constructor(transports: AuthApiTransports, resolver?: SubaccountResolver) {\n this.#client = createClient(Proto.AutoWithdrawService, transports.authApi);\n this.#resolver = resolver;\n }\n\n /** Returns the account's latest rule version, or null when the account never had a rule. */\n async getRule(\n input: AutoWithdrawScopedInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<AutoWithdrawRule | null> {\n const request = parse(AutoWithdrawScopedInputSchema, this.resolveInput(input));\n const response = await this.#client.getAutoWithdrawRule(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return response.rule ? parse(AutoWithdrawRuleSchema, response.rule) : null;\n }\n\n /**\n * Creates the account's rule, or replaces its latest version, and returns the new version.\n * `expectedVersion` is 0 when the account has no rule yet, otherwise its latest version; a\n * stale version throws `RevisionConflictError`. Requires a fresh `stepUpToken`.\n */\n async setRule(\n input: SetAutoWithdrawRuleInput,\n options?: PolyesterMutationOptions,\n ): Promise<AutoWithdrawRule> {\n const request = parse(SetAutoWithdrawRuleInputSchema, this.resolveInput(input));\n const response = await this.#client\n .setAutoWithdrawRule(removeUndefined(request), toConnectCallOptions(options))\n .catch(rethrowVersionConflict);\n return parse(AutoWithdrawRuleSchema, response.rule);\n }\n\n /**\n * Pauses (`enabled: false`) or resumes (`enabled: true`) the account's rule, keeping its\n * schedule and destinations, and returns the latest version: a new one, or the current one\n * unchanged when the rule is already in that state. Each change creates a version, so pass\n * the latest `version` as `expectedVersion`; a stale one throws `RevisionConflictError`.\n * Pausing needs no step-up. Resuming needs a fresh `stepUpToken`, checks every destination\n * again like `setRule`, and clears a pause the rule set itself; a refused destination\n * leaves the rule paused.\n */\n async setRuleEnabled(\n input: SetAutoWithdrawRuleEnabledInput,\n options?: PolyesterMutationOptions,\n ): Promise<AutoWithdrawRule> {\n const request = parse(SetAutoWithdrawRuleEnabledInputSchema, this.resolveInput(input));\n const response = await this.#client\n .setAutoWithdrawRuleEnabled(removeUndefined(request), toConnectCallOptions(options))\n .catch(rethrowVersionConflict);\n return parse(AutoWithdrawRuleSchema, response.rule);\n }\n\n /**\n * Previews what the account's next run would pay, using the same planning as the run and\n * the balances, prices and fees now. Readable by API keys with `read-auto-withdraw`. With a\n * USD minimum, a failed price read throws a retryable error.\n */\n async previewRun(\n input: AutoWithdrawScopedInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<AutoWithdrawPreview> {\n const request = parse(AutoWithdrawScopedInputSchema, this.resolveInput(input));\n const response = await this.#client.previewAutoWithdrawRun(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(AutoWithdrawPreviewSchema, response);\n }\n\n /**\n * Lists the account's runs with their payouts, newest first. Pass the previous\n * `nextPageToken` as `pageToken` to continue; an empty `nextPageToken` means no more runs.\n */\n async listRuns(\n input: ListAutoWithdrawRunsInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<ListAutoWithdrawRunsResult> {\n const request = parse(ListAutoWithdrawRunsInputSchema, this.resolveInput(input));\n const response = await this.#client.listAutoWithdrawRuns(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(ListAutoWithdrawRunsResultSchema, response);\n }\n\n private resolveInput<TInput extends AccountScopedInput>(input: TInput): TInput {\n return resolveAccountScopedInput(input, this.#resolver);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAqCA,SAAS,uBAAuB,KAAqB;CACjD,MAAM,SAAS,iBAAiB,GAAG;CACnC,IACI,kBAAkB,kBAClB,EAAE,kBAAkB,2BAClB,OAAO,QAAQ,YAAY,eACxB,OAAO,OAAO,SAAS,sBAAsB,OAAO,OAAO,SAAS,eACpE,OAAO,iBAAiB,gBACrB,OAAO,MAAM,SAAS,KAAK,WAC3B,OAAO,MAAM,QAAQ,WAAW,IAExC,MAAM,IAAI,sBACN,OAAO,WAAW,sDAClB;EAAE,OAAO,OAAO;EAAO,QAAQ,OAAO;EAAQ,QAAQ,OAAO;CAAO,CACxE;CAEJ,MAAM;AACV;;;;;;;;;;AAWA,IAAa,sBAAb,MAAiC;CAC7B;CACA;CAEA,YAAY,YAA+B,UAA+B;EACtE,KAAKA,UAAU,aAAaC,uBAA2B,WAAW,OAAO;EACzE,KAAKC,YAAY;CACrB;;CAGA,MAAM,QACF,QAAiC,CAAC,GAClC,SACgC;EAChC,MAAM,UAAU,MAAM,+BAA+B,KAAK,aAAa,KAAK,CAAC;EAC7E,MAAM,WAAW,MAAM,KAAKF,QAAQ,oBAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO,SAAS,OAAO,MAAM,wBAAwB,SAAS,IAAI,IAAI;CAC1E;;;;;;CAOA,MAAM,QACF,OACA,SACyB;EACzB,MAAM,UAAU,MAAM,gCAAgC,KAAK,aAAa,KAAK,CAAC;EAC9E,MAAM,WAAW,MAAM,KAAKA,QACvB,oBAAoB,gBAAgB,OAAO,GAAG,qBAAqB,OAAO,CAAC,CAAC,CAC5E,MAAM,sBAAsB;EACjC,OAAO,MAAM,wBAAwB,SAAS,IAAI;CACtD;;;;;;;;;;CAWA,MAAM,eACF,OACA,SACyB;EACzB,MAAM,UAAU,MAAM,uCAAuC,KAAK,aAAa,KAAK,CAAC;EACrF,MAAM,WAAW,MAAM,KAAKA,QACvB,2BAA2B,gBAAgB,OAAO,GAAG,qBAAqB,OAAO,CAAC,CAAC,CACnF,MAAM,sBAAsB;EACjC,OAAO,MAAM,wBAAwB,SAAS,IAAI;CACtD;;;;;;CAOA,MAAM,WACF,QAAiC,CAAC,GAClC,SAC4B;EAC5B,MAAM,UAAU,MAAM,+BAA+B,KAAK,aAAa,KAAK,CAAC;EAC7E,MAAM,WAAW,MAAM,KAAKA,QAAQ,uBAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,2BAA2B,QAAQ;CACpD;;;;;CAMA,MAAM,SACF,QAAmC,CAAC,GACpC,SACmC;EACnC,MAAM,UAAU,MAAM,iCAAiC,KAAK,aAAa,KAAK,CAAC;EAC/E,MAAM,WAAW,MAAM,KAAKA,QAAQ,qBAChC,gBAAgB,OAAO,GACvB,qBAAqB,OAAO,CAChC;EACA,OAAO,MAAM,kCAAkC,QAAQ;CAC3D;CAEA,aAAwD,OAAuB;EAC3E,OAAO,0BAA0B,OAAO,KAAKE,SAAS;CAC1D;AACJ"}
|