@polyester/sdk 0.21.1 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +5 -0
  3. package/dist/catalogs/snapshot-validation.js +0 -1
  4. package/dist/catalogs/snapshot-validation.js.map +1 -1
  5. package/dist/catalogs/zipper-catalog.d.ts +0 -3
  6. package/dist/catalogs/zipper-catalog.d.ts.map +1 -1
  7. package/dist/catalogs/zipper-catalog.js +0 -1
  8. package/dist/catalogs/zipper-catalog.js.map +1 -1
  9. package/dist/environment.js +43 -1
  10. package/dist/environment.js.map +1 -1
  11. package/dist/gen/chain/zipper/v1/zipper_pb.d.ts +0 -6
  12. package/dist/gen/chain/zipper/v1/zipper_pb.d.ts.map +1 -1
  13. package/dist/gen/chain/zipper/v1/zipper_pb.js +1 -1
  14. package/dist/gen/chain/zipper/v1/zipper_pb.js.map +1 -1
  15. package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts +236 -8
  16. package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts.map +1 -1
  17. package/dist/gen/marketoverview/v1/marketoverview_pb.js +50 -2
  18. package/dist/gen/marketoverview/v1/marketoverview_pb.js.map +1 -1
  19. package/dist/gen/orders/v1/orders_pb.d.ts +9 -6
  20. package/dist/gen/orders/v1/orders_pb.d.ts.map +1 -1
  21. package/dist/gen/orders/v1/orders_pb.js.map +1 -1
  22. package/dist/gen/orders/v1/orders_read_pb.d.ts +2 -1
  23. package/dist/gen/orders/v1/orders_read_pb.d.ts.map +1 -1
  24. package/dist/gen/orders/v1/orders_read_pb.js.map +1 -1
  25. package/dist/index.d.ts +2 -2
  26. package/dist/services/lifecycle/lifecycle.schemas.d.ts +42 -42
  27. package/dist/services/market-overview/index.d.ts +2 -2
  28. package/dist/services/market-overview/market-overview.d.ts +9 -1
  29. package/dist/services/market-overview/market-overview.d.ts.map +1 -1
  30. package/dist/services/market-overview/market-overview.js +15 -1
  31. package/dist/services/market-overview/market-overview.js.map +1 -1
  32. package/dist/services/market-overview/market-overview.schemas.d.ts +160 -1
  33. package/dist/services/market-overview/market-overview.schemas.d.ts.map +1 -1
  34. package/dist/services/market-overview/market-overview.schemas.js +46 -1
  35. package/dist/services/market-overview/market-overview.schemas.js.map +1 -1
  36. package/dist/services/market-overview/market-overview.types.d.ts +2 -2
  37. package/dist/services/orders/orders-output.schemas.d.ts +12 -12
  38. package/dist/services/orders/orders.d.ts +1 -1
  39. package/dist/services/orders/orders.d.ts.map +1 -1
  40. package/dist/services/orders/orders.js +10 -3
  41. package/dist/services/orders/orders.js.map +1 -1
  42. package/dist/services/subaccounts/subaccounts.schemas.d.ts +1 -1
  43. package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts.map +1 -1
  44. package/dist/services/trading-withdraws/trading-withdraws.schemas.js +3 -5
  45. package/dist/services/trading-withdraws/trading-withdraws.schemas.js.map +1 -1
  46. package/dist/services/triggers/trigger-input.schemas.d.ts +2 -2
  47. package/dist/services/triggers/triggers-output.schemas.d.ts +18 -18
  48. package/dist/services/zipper/zipper.schemas.d.ts.map +1 -1
  49. package/dist/services/zipper/zipper.schemas.js +0 -1
  50. package/dist/services/zipper/zipper.schemas.js.map +1 -1
  51. package/dist/shared/catalog-config.d.ts +0 -1
  52. package/dist/shared/catalog-config.d.ts.map +1 -1
  53. package/dist/shared/catalog-config.js.map +1 -1
  54. package/dist/shared/errors.d.ts +3 -2
  55. package/dist/shared/errors.d.ts.map +1 -1
  56. package/dist/shared/errors.js +3 -2
  57. package/dist/shared/errors.js.map +1 -1
  58. package/package.json +2 -2
@@ -1,3 +1,4 @@
1
+ import { ConfigurationError } from "../../shared/errors.js";
1
2
  import "../../gen/chain/withdraw/v1/withdraw_pb.js";
2
3
  import { PositiveUint32InputSchema } from "../shared.js";
3
4
  import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
@@ -9,13 +10,10 @@ import * as v from "valibot";
9
10
  const DEFAULT_DEADLINE_SECONDS = 300;
10
11
  function createNonce() {
11
12
  const random = globalThis.crypto?.getRandomValues?.bind(globalThis.crypto);
12
- if (!random) {
13
- const nonce = BigInt(Date.now());
14
- return nonce === 0n ? 1n : nonce;
15
- }
13
+ if (!random) throw new ConfigurationError("Secure nonce generation requires crypto.getRandomValues.");
16
14
  const bytes = /* @__PURE__ */ new BigUint64Array(1);
17
15
  random(bytes);
18
- const nonce = bytes[0] ?? BigInt(Date.now());
16
+ const nonce = bytes[0];
19
17
  return nonce === 0n ? 1n : nonce;
20
18
  }
21
19
  function createTradingWithdrawPayload(input) {
@@ -1 +1 @@
1
- {"version":3,"file":"trading-withdraws.schemas.js","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { PositiveUint32InputSchema } from \"../shared.js\";\nimport { quantityInputToE18, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport type * as Proto from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { WithdrawDestinationValidationCode } from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { toU128, type U128Value } from \"../../utils/u128.js\";\nimport {\n TradingWithdrawActionCodec,\n WithdrawDestinationValidationCodeCodec,\n} from \"./trading-withdraws.codecs.js\";\n\nconst DEFAULT_DEADLINE_SECONDS = 5 * 60;\n\nexport type TradingWithdrawIntentPayloadRequest = {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n amountE18: U128Value;\n deadlineTsSec: bigint;\n nonce: U128Value;\n destinationAddress: string;\n idempotencyKey: string;\n};\n\ntype CreateTradingWithdrawRequestBase = {\n subaccountId: bigint | undefined;\n payload: TradingWithdrawIntentPayloadRequest;\n payloadSignature?: Uint8Array;\n};\n\nfunction createNonce(): bigint {\n const random = globalThis.crypto?.getRandomValues?.bind(globalThis.crypto);\n if (!random) {\n const nonce = BigInt(Date.now());\n return nonce === 0n ? 1n : nonce;\n }\n\n const bytes = new BigUint64Array(1);\n random(bytes);\n const nonce = bytes[0] ?? BigInt(Date.now());\n return nonce === 0n ? 1n : nonce;\n}\n\nfunction createTradingWithdrawPayload(input: {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n quantityScaled: bigint;\n destinationAddress: string;\n idempotencyKey: string;\n}): TradingWithdrawIntentPayloadRequest {\n return {\n action: input.action,\n assetId: input.assetId,\n destinationChainId: input.destinationChainId,\n amountE18: toU128(input.quantityScaled),\n deadlineTsSec: BigInt(Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE_SECONDS),\n nonce: toU128(createNonce()),\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n };\n}\n\nexport function createCreateTradingWithdrawToFundingInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: PositiveUint32InputSchema,\n quantity: v.string(),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n destinationAddress: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n payloadSignature: v.optional(v.instance(Uint8Array)),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payloadSignature: input.payloadSignature,\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_funding,\n assetId: input.assetId,\n destinationChainId: 0n,\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n }),\n };\n }),\n );\n}\n\nexport function createCreateTradingWithdrawToExternalChainInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: PositiveUint32InputSchema,\n quantity: v.string(),\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n payloadSignature: v.optional(v.instance(Uint8Array)),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payloadSignature: input.payloadSignature,\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_external_chain,\n assetId: input.assetId,\n destinationChainId: BigInt(input.destinationChainId),\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n }),\n };\n }),\n );\n}\n\nexport type CreateTradingWithdrawToFundingInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToFundingRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport const CreateTradingWithdrawResultSchema = v.object({\n intentId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n});\n\nexport type CreateTradingWithdrawResult = v.InferOutput<typeof CreateTradingWithdrawResultSchema>;\n\nexport const CreateWalletTradingWithdrawResultSchema = CreateTradingWithdrawResultSchema;\nexport type CreateWalletTradingWithdrawResult = v.InferOutput<\n typeof CreateWalletTradingWithdrawResultSchema\n>;\n\nexport const ValidateWithdrawDestinationInputSchema = v.pipe(\n v.strictObject({\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((input) => ({\n destinationChainId: BigInt(input.destinationChainId),\n destinationAddress: input.destinationAddress,\n })),\n);\n\nexport type ValidateWithdrawDestinationInput = v.InferInput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\nexport type ValidateWithdrawDestinationRequest = v.InferOutput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\n\nconst ValidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(true),\n code: v.literal(WithdrawDestinationValidationCode.VALID),\n message: v.string(),\n canonicalDestinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((result) => ({\n ...result,\n code: WithdrawDestinationValidationCodeCodec.protoToOutput[result.code],\n })),\n);\n\nconst {\n [WithdrawDestinationValidationCode.VALID]: _validWithdrawDestinationCode,\n ...InvalidWithdrawDestinationCodeCodec\n} = WithdrawDestinationValidationCodeCodec.protoToOutput;\n\nconst InvalidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(false),\n code: v.picklist([\n WithdrawDestinationValidationCode.RESULT_UNSPECIFIED,\n WithdrawDestinationValidationCode.INVALID_ADDRESS,\n WithdrawDestinationValidationCode.UNSUPPORTED_CHAIN,\n WithdrawDestinationValidationCode.POLYESTER_SMART_ACCOUNT,\n WithdrawDestinationValidationCode.TOKEN_CONTRACT,\n WithdrawDestinationValidationCode.DENYLISTED_ADDRESS,\n ]),\n message: v.string(),\n canonicalDestinationAddress: v.string(),\n }),\n v.transform((result) => ({\n ...result,\n code: InvalidWithdrawDestinationCodeCodec[result.code],\n })),\n);\n\nexport const ValidateWithdrawDestinationResultSchema = v.union([\n ValidWithdrawDestinationResultSchema,\n InvalidWithdrawDestinationResultSchema,\n]);\n\nexport type ValidateWithdrawDestinationResult = v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AE,UAAU,CAAC,CAAC,EACzD,CAAC;AAID,MAAa,0CAA0C;AAKvD,MAAa,yCAAyC,EAAE,KACpD,EAAE,aAAa;CACX,oBAAoB,EAAE,KAClB,EAAE,OAAO,GACT,EAAE,QAAQ,GACV,EAAE,QAAQ,CAAC,GACX,EAAE,SAAS,OAAO,gBAAgB,CACtC;CACA,oBAAoB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;AACnE,CAAC,GACD,EAAE,WAAW,WAAW;CACpB,oBAAoB,OAAO,MAAM,kBAAkB;CACnD,oBAAoB,MAAM;AAC9B,EAAE,CACN;AASA,MAAM,uCAAuC,EAAE,KAC3C,EAAE,OAAO;CACL,OAAO,EAAE,QAAQ,IAAI;CACrB,MAAM,EAAE,QAAA,CAA+C;CACvD,SAAS,EAAE,OAAO;CAClB,6BAA6B,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;AAC5E,CAAC,GACD,EAAE,WAAW,YAAY;CACrB,GAAG;CACH,MAAM,uCAAuC,cAAc,OAAO;AACtE,EAAE,CACN;AAEA,MAAM,GAAA,IACyC,+BAC3C,GAAG,wCACH,uCAAuC;AAE3C,MAAM,yCAAyC,EAAE,KAC7C,EAAE,OAAO;CACL,OAAO,EAAE,QAAQ,KAAK;CACtB,MAAM,EAAE,SAAS;;;;;;;CAOjB,CAAC;CACD,SAAS,EAAE,OAAO;CAClB,6BAA6B,EAAE,OAAO;AAC1C,CAAC,GACD,EAAE,WAAW,YAAY;CACrB,GAAG;CACH,MAAM,oCAAoC,OAAO;AACrD,EAAE,CACN;AAEA,MAAa,0CAA0C,EAAE,MAAM,CAC3D,sCACA,sCACJ,CAAC"}
1
+ {"version":3,"file":"trading-withdraws.schemas.js","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { PositiveUint32InputSchema } from \"../shared.js\";\nimport { quantityInputToE18, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport type * as Proto from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { WithdrawDestinationValidationCode } from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { toU128, type U128Value } from \"../../utils/u128.js\";\nimport { ConfigurationError } from \"../../shared/errors.js\";\nimport {\n TradingWithdrawActionCodec,\n WithdrawDestinationValidationCodeCodec,\n} from \"./trading-withdraws.codecs.js\";\n\nconst DEFAULT_DEADLINE_SECONDS = 5 * 60;\n\nexport type TradingWithdrawIntentPayloadRequest = {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n amountE18: U128Value;\n deadlineTsSec: bigint;\n nonce: U128Value;\n destinationAddress: string;\n idempotencyKey: string;\n};\n\ntype CreateTradingWithdrawRequestBase = {\n subaccountId: bigint | undefined;\n payload: TradingWithdrawIntentPayloadRequest;\n payloadSignature?: Uint8Array;\n};\n\nfunction createNonce(): bigint {\n const random = globalThis.crypto?.getRandomValues?.bind(globalThis.crypto);\n if (!random) {\n throw new ConfigurationError(\"Secure nonce generation requires crypto.getRandomValues.\");\n }\n\n const bytes = new BigUint64Array(1);\n random(bytes);\n const nonce = bytes[0]!;\n return nonce === 0n ? 1n : nonce;\n}\n\nfunction createTradingWithdrawPayload(input: {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n quantityScaled: bigint;\n destinationAddress: string;\n idempotencyKey: string;\n}): TradingWithdrawIntentPayloadRequest {\n return {\n action: input.action,\n assetId: input.assetId,\n destinationChainId: input.destinationChainId,\n amountE18: toU128(input.quantityScaled),\n deadlineTsSec: BigInt(Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE_SECONDS),\n nonce: toU128(createNonce()),\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n };\n}\n\nexport function createCreateTradingWithdrawToFundingInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: PositiveUint32InputSchema,\n quantity: v.string(),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n destinationAddress: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n payloadSignature: v.optional(v.instance(Uint8Array)),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payloadSignature: input.payloadSignature,\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_funding,\n assetId: input.assetId,\n destinationChainId: 0n,\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n }),\n };\n }),\n );\n}\n\nexport function createCreateTradingWithdrawToExternalChainInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: PositiveUint32InputSchema,\n quantity: v.string(),\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n payloadSignature: v.optional(v.instance(Uint8Array)),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payloadSignature: input.payloadSignature,\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_external_chain,\n assetId: input.assetId,\n destinationChainId: BigInt(input.destinationChainId),\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n }),\n };\n }),\n );\n}\n\nexport type CreateTradingWithdrawToFundingInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToFundingRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport const CreateTradingWithdrawResultSchema = v.object({\n intentId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n});\n\nexport type CreateTradingWithdrawResult = v.InferOutput<typeof CreateTradingWithdrawResultSchema>;\n\nexport const CreateWalletTradingWithdrawResultSchema = CreateTradingWithdrawResultSchema;\nexport type CreateWalletTradingWithdrawResult = v.InferOutput<\n typeof CreateWalletTradingWithdrawResultSchema\n>;\n\nexport const ValidateWithdrawDestinationInputSchema = v.pipe(\n v.strictObject({\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((input) => ({\n destinationChainId: BigInt(input.destinationChainId),\n destinationAddress: input.destinationAddress,\n })),\n);\n\nexport type ValidateWithdrawDestinationInput = v.InferInput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\nexport type ValidateWithdrawDestinationRequest = v.InferOutput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\n\nconst ValidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(true),\n code: v.literal(WithdrawDestinationValidationCode.VALID),\n message: v.string(),\n canonicalDestinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((result) => ({\n ...result,\n code: WithdrawDestinationValidationCodeCodec.protoToOutput[result.code],\n })),\n);\n\nconst {\n [WithdrawDestinationValidationCode.VALID]: _validWithdrawDestinationCode,\n ...InvalidWithdrawDestinationCodeCodec\n} = WithdrawDestinationValidationCodeCodec.protoToOutput;\n\nconst InvalidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(false),\n code: v.picklist([\n WithdrawDestinationValidationCode.RESULT_UNSPECIFIED,\n WithdrawDestinationValidationCode.INVALID_ADDRESS,\n WithdrawDestinationValidationCode.UNSUPPORTED_CHAIN,\n WithdrawDestinationValidationCode.POLYESTER_SMART_ACCOUNT,\n WithdrawDestinationValidationCode.TOKEN_CONTRACT,\n WithdrawDestinationValidationCode.DENYLISTED_ADDRESS,\n ]),\n message: v.string(),\n canonicalDestinationAddress: v.string(),\n }),\n v.transform((result) => ({\n ...result,\n code: InvalidWithdrawDestinationCodeCodec[result.code],\n })),\n);\n\nexport const ValidateWithdrawDestinationResultSchema = v.union([\n ValidWithdrawDestinationResultSchema,\n InvalidWithdrawDestinationResultSchema,\n]);\n\nexport type ValidateWithdrawDestinationResult = v.InferOutput<\n typeof ValidateWithdrawDestinationResultSchema\n>;\n"],"mappings":";;;;;;;;;AAgBA,MAAM,2BAA2B;AAmBjC,SAAS,cAAsB;CAC3B,MAAM,SAAS,WAAW,QAAQ,iBAAiB,KAAK,WAAW,MAAM;CACzE,IAAI,CAAC,QACD,MAAM,IAAI,mBAAmB,0DAA0D;CAG3F,MAAM,wBAAQ,IAAI,eAAe,CAAC;CAClC,OAAO,KAAK;CACZ,MAAM,QAAQ,MAAM;CACpB,OAAO,UAAU,KAAK,KAAK;AAC/B;AAEA,SAAS,6BAA6B,OAOE;CACpC,OAAO;EACH,QAAQ,MAAM;EACd,SAAS,MAAM;EACf,oBAAoB,MAAM;EAC1B,WAAW,OAAO,MAAM,cAAc;EACtC,eAAe,OAAO,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,IAAI,w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AE,UAAU,CAAC,CAAC;AAC5E,CAAC,GACD,EAAE,WAAW,YAAY;CACrB,GAAG;CACH,MAAM,uCAAuC,cAAc,OAAO;AACtE,EAAE,CACN;AAEA,MAAM,GAAA,IACyC,+BAC3C,GAAG,wCACH,uCAAuC;AAE3C,MAAM,yCAAyC,EAAE,KAC7C,EAAE,OAAO;CACL,OAAO,EAAE,QAAQ,KAAK;CACtB,MAAM,EAAE,SAAS;;;;;;;CAOjB,CAAC;CACD,SAAS,EAAE,OAAO;CAClB,6BAA6B,EAAE,OAAO;AAC1C,CAAC,GACD,EAAE,WAAW,YAAY;CACrB,GAAG;CACH,MAAM,oCAAoC,OAAO;AACrD,EAAE,CACN;AAEA,MAAa,0CAA0C,EAAE,MAAM,CAC3D,sCACA,sCACJ,CAAC"}
@@ -845,8 +845,8 @@ type CreateTriggerInput = v.InferInput<ReturnType<typeof createCreateTriggerInpu
845
845
  declare const ListTriggersInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
846
846
  readonly parentOrderId: v.SchemaWithPipe<readonly [v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, undefined>, v.TransformAction<string | undefined, bigint | undefined>]>;
847
847
  readonly symbolId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>;
848
- readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused")[] | undefined, (TriggerStatus.STATUS_CREATED | TriggerStatus.STATUS_ARMED | TriggerStatus.STATUS_RUNNING | TriggerStatus.STATUS_COMPLETED | TriggerStatus.STATUS_CANCELED | TriggerStatus.STATUS_FAILED | TriggerStatus.STATUS_PAUSED)[]>]>;
849
- readonly triggerType: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["stop_loss", "take_profit", "trailing_stop", "twap", "ladder"], undefined>, undefined>, v.TransformAction<"twap" | "ladder" | "stop_loss" | "take_profit" | "trailing_stop" | undefined, TriggerType>]>;
848
+ readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "cancelled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused")[] | undefined, (TriggerStatus.STATUS_CREATED | TriggerStatus.STATUS_ARMED | TriggerStatus.STATUS_RUNNING | TriggerStatus.STATUS_COMPLETED | TriggerStatus.STATUS_CANCELED | TriggerStatus.STATUS_FAILED | TriggerStatus.STATUS_PAUSED)[]>]>;
849
+ readonly triggerType: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["stop_loss", "take_profit", "trailing_stop", "twap", "ladder"], undefined>, undefined>, v.TransformAction<"stop_loss" | "take_profit" | "trailing_stop" | "twap" | "ladder" | undefined, TriggerType>]>;
850
850
  readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 1000, undefined>]>, 50>;
851
851
  readonly pageToken: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
852
852
  readonly account: v.OptionalSchema<v.UnionSchema<[v.PicklistSchema<["active", "main"], undefined>, v.StrictObjectSchema<{
@@ -31,62 +31,62 @@ declare const CreateTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSche
31
31
  type CreateTriggerResult = v.InferOutput<typeof CreateTriggerResultSchema>;
32
32
  declare const CancelTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
33
33
  readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
34
- readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused">]>;
34
+ readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused">]>;
35
35
  readonly tsNs: v.BigintSchema<undefined>;
36
36
  }, undefined>, v.TransformAction<{
37
37
  triggerId: string;
38
- status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
38
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
39
39
  tsNs: bigint;
40
40
  }, {
41
41
  ts: number;
42
42
  tsNs: string;
43
43
  triggerId: string;
44
- status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
44
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
45
45
  }>]>;
46
46
  type CancelTriggerResult = v.InferOutput<typeof CancelTriggerResultSchema>;
47
47
  declare const ModifyTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
48
48
  readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
49
- readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused">]>;
49
+ readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused">]>;
50
50
  readonly tsNs: v.BigintSchema<undefined>;
51
51
  }, undefined>, v.TransformAction<{
52
52
  triggerId: string;
53
- status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
53
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
54
54
  tsNs: bigint;
55
55
  }, {
56
56
  ts: number;
57
57
  tsNs: string;
58
58
  triggerId: string;
59
- status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
59
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
60
60
  }>]>;
61
61
  type ModifyTriggerResult = v.InferOutput<typeof ModifyTriggerResultSchema>;
62
62
  declare const PauseTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
63
63
  readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
64
- readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused">]>;
64
+ readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused">]>;
65
65
  readonly tsNs: v.BigintSchema<undefined>;
66
66
  }, undefined>, v.TransformAction<{
67
67
  triggerId: string;
68
- status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
68
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
69
69
  tsNs: bigint;
70
70
  }, {
71
71
  ts: number;
72
72
  tsNs: string;
73
73
  triggerId: string;
74
- status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
74
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
75
75
  }>]>;
76
76
  type PauseTriggerResult = v.InferOutput<typeof PauseTriggerResultSchema>;
77
77
  declare const ResumeTriggerResultSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
78
78
  readonly triggerId: v.SchemaWithPipe<readonly [v.BigintSchema<undefined>, v.TransformAction<bigint, string>]>;
79
- readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused">]>;
79
+ readonly status: v.SchemaWithPipe<readonly [v.EnumSchema<typeof TriggerStatus, undefined>, v.TransformAction<TriggerStatus, "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused">]>;
80
80
  readonly tsNs: v.BigintSchema<undefined>;
81
81
  }, undefined>, v.TransformAction<{
82
82
  triggerId: string;
83
- status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
83
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
84
84
  tsNs: bigint;
85
85
  }, {
86
86
  ts: number;
87
87
  tsNs: string;
88
88
  triggerId: string;
89
- status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
89
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
90
90
  }>]>;
91
91
  type ResumeTriggerResult = v.InferOutput<typeof ResumeTriggerResultSchema>;
92
92
  type StopDetailsOutput = {
@@ -558,7 +558,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
558
558
  triggerId: string;
559
559
  subaccountId: string;
560
560
  symbolId: number;
561
- status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
561
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
562
562
  parentOrderId: string | undefined;
563
563
  qty: string;
564
564
  feeAsset: "unspecified" | "quote" | "base";
@@ -714,7 +714,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
714
714
  triggerId: string;
715
715
  subaccountId: string;
716
716
  symbolId: number;
717
- status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
717
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
718
718
  parentOrderId: string | undefined;
719
719
  qty: string;
720
720
  feeAsset: "unspecified" | "quote" | "base";
@@ -870,7 +870,7 @@ declare function createTriggerSchema(scales: SdkScales): v.SchemaWithPipe<readon
870
870
  triggerId: string;
871
871
  subaccountId: string;
872
872
  symbolId: number;
873
- status: "unspecified" | "failed" | "cancelled" | "completed" | "created" | "armed" | "running" | "paused";
873
+ status: "unspecified" | "completed" | "failed" | "cancelled" | "created" | "armed" | "running" | "paused";
874
874
  parentOrderId: string | undefined;
875
875
  qty: string;
876
876
  feeAsset: "unspecified" | "quote" | "base";
@@ -1068,7 +1068,7 @@ declare function createTriggerEventSchema(scales: SdkScales): v.SchemaWithPipe<r
1068
1068
  triggerId: string;
1069
1069
  subaccountId: string;
1070
1070
  symbolId: number;
1071
- triggerType: "unspecified" | "twap" | "ladder" | "stop_loss" | "take_profit" | "trailing_stop";
1071
+ triggerType: "unspecified" | "stop_loss" | "take_profit" | "trailing_stop" | "twap" | "ladder";
1072
1072
  eventType: "unspecified" | "failed" | "updated" | "fired" | "canceled";
1073
1073
  ts: number;
1074
1074
  childSeq: number;
@@ -1080,7 +1080,7 @@ declare function createTriggerEventSchema(scales: SdkScales): v.SchemaWithPipe<r
1080
1080
  triggerId: string;
1081
1081
  subaccountId: string;
1082
1082
  symbolId: number;
1083
- triggerType: "unspecified" | "twap" | "ladder" | "stop_loss" | "take_profit" | "trailing_stop";
1083
+ triggerType: "unspecified" | "stop_loss" | "take_profit" | "trailing_stop" | "twap" | "ladder";
1084
1084
  eventType: "unspecified" | "failed" | "updated" | "fired" | "canceled";
1085
1085
  ts: number;
1086
1086
  childSeq: number;
@@ -1092,7 +1092,7 @@ declare function createTriggerEventSchema(scales: SdkScales): v.SchemaWithPipe<r
1092
1092
  triggerId: string;
1093
1093
  subaccountId: string;
1094
1094
  symbolId: number;
1095
- triggerType: "unspecified" | "twap" | "ladder" | "stop_loss" | "take_profit" | "trailing_stop";
1095
+ triggerType: "unspecified" | "stop_loss" | "take_profit" | "trailing_stop" | "twap" | "ladder";
1096
1096
  eventType: "unspecified" | "failed" | "updated" | "fired" | "canceled";
1097
1097
  ts: number;
1098
1098
  childSeq: number;
@@ -1 +1 @@
1
- {"version":3,"file":"zipper.schemas.d.ts","names":[],"sources":["../../../src/services/zipper/zipper.schemas.ts"],"mappings":";;;;KAuHY;EACR;EACA;;KAGQ;EACR,SAAS"}
1
+ {"version":3,"file":"zipper.schemas.d.ts","names":[],"sources":["../../../src/services/zipper/zipper.schemas.ts"],"mappings":";;;;KAsHY;EACR;EACA;;KAGQ;EACR,SAAS"}
@@ -67,7 +67,6 @@ const DepositWithdrawConfigSchema = v.pipe(v.object({
67
67
  chains: v.array(ZipperChainConfigSchema),
68
68
  assets: v.array(ZipperAssetConfigSchema),
69
69
  tsSec: v.bigint(),
70
- polyesterChainId: v.number(),
71
70
  contracts: v.optional(v.array(ZipperChainContractConfigSchema), [])
72
71
  }), v.transform(({ tsSec, ...config }) => ({
73
72
  ...config,
@@ -1 +1 @@
1
- {"version":3,"file":"zipper.schemas.js","names":[],"sources":["../../../src/services/zipper/zipper.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport type {\n DepositWithdrawConfig,\n ZipperAssetChainVariant,\n ZipperAssetConfig,\n ZipperChainConfig,\n ZipperChainContractConfig,\n} from \"../../shared/catalog-config.js\";\nimport { scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\n\nexport type {\n DepositWithdrawConfig,\n ZipperAssetChainVariant,\n ZipperAssetConfig,\n ZipperChainConfig,\n ZipperChainContractConfig,\n};\n\nexport const ZipperChainConfigSchema = v.object({\n chainId: v.number(),\n code: v.string(),\n name: v.string(),\n nativeChainId: v.optional(v.string(), \"\"),\n nativeCurrencySymbol: v.string(),\n explorerUrl: v.string(),\n icon: v.string(),\n requiredConfirmations: v.number(),\n confirmationTimeSeconds: v.number(),\n isCaseSensitive: v.optional(v.boolean(), false),\n minAddressLength: v.number(),\n maxAddressLength: v.number(),\n});\n\nconst ZipperAssetChainVariantWireSchema = v.object({\n zippedAssetId: v.number(),\n chainId: v.number(),\n isNativeAsset: v.optional(v.boolean(), false),\n networkFee: v.optional(v.string(), \"0\"),\n networkFeeTsSec: v.pipe(v.optional(v.bigint(), 0n), v.transform(Number)),\n ztokenAddress: v.optional(v.string(), \"\"),\n sourceAddress: v.optional(v.string(), \"\"),\n sourceDecimals: v.optional(v.number(), 18),\n ztokenDecimals: v.optional(v.number(), 18),\n depositMinAmount: v.optional(v.string(), \"\"),\n withdrawMinAmount: v.optional(v.string(), \"\"),\n supplyQ: v.optional(v.bigint(), 0n),\n});\n\nfunction normalizeZipperAssetChainVariant(\n quantityScale: number,\n {\n sourceAddress,\n sourceDecimals,\n supplyQ,\n ztokenAddress,\n ztokenDecimals,\n ...variant\n }: v.InferOutput<typeof ZipperAssetChainVariantWireSchema>,\n): ZipperAssetChainVariant {\n return {\n ...variant,\n supply: scaledToDecimalOutput(supplyQ, quantityScale),\n sourceToken: {\n address: sourceAddress,\n decimals: sourceDecimals,\n },\n zToken: {\n address: ztokenAddress,\n decimals: ztokenDecimals,\n },\n };\n}\n\nexport const ZipperAssetConfigSchema = v.pipe(\n v.object({\n asset: v.string(),\n ledgerId: v.number(),\n name: v.string(),\n icon: v.string(),\n quantityScale: v.number(),\n quantityDisplayDecimals: v.number(),\n variants: v.array(ZipperAssetChainVariantWireSchema),\n uAssetId: v.optional(v.string(), \"\"),\n }),\n v.transform(({ variants, ...asset }) => ({\n ...asset,\n variants: variants.map((variant) =>\n normalizeZipperAssetChainVariant(asset.quantityScale, variant),\n ),\n })),\n);\n\nexport const ZipperChainContractConfigSchema = v.object({\n name: v.string(),\n address: v.string(),\n type: v.optional(v.string(), \"\"),\n description: v.optional(v.string(), \"\"),\n version: v.optional(v.number(), 0),\n});\n\nexport const DepositWithdrawConfigSchema = v.pipe(\n v.object({\n chains: v.array(ZipperChainConfigSchema),\n assets: v.array(ZipperAssetConfigSchema),\n tsSec: v.bigint(),\n polyesterChainId: v.number(),\n contracts: v.optional(v.array(ZipperChainContractConfigSchema), []),\n }),\n v.transform(({ tsSec, ...config }) => ({\n ...config,\n tsMs: Number(tsSec) * 1000,\n })),\n);\n\nconst ZippedAssetSupplyUpdateWireSchema = v.object({\n zippedAssetId: v.number(),\n supplyQ: v.bigint(),\n});\n\nexport type ZippedAssetSupplyUpdate = {\n zippedAssetId: number;\n supply: string;\n};\n\nexport type ZippedAssetSupplyBatch = {\n updates: ZippedAssetSupplyUpdate[];\n};\n\nexport function createZippedAssetSupplyBatchSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n updates: v.array(ZippedAssetSupplyUpdateWireSchema),\n }),\n v.transform(\n (batch): ZippedAssetSupplyBatch => ({\n updates: batch.updates.map((update) => ({\n zippedAssetId: update.zippedAssetId,\n supply: scaledToDecimalOutput(\n update.supplyQ,\n scales.zippedAssetAmount(update.zippedAssetId),\n ),\n })),\n }),\n ),\n );\n}\n"],"mappings":";;;AAkBA,MAAa,0BAA0B,EAAE,OAAO;CAC5C,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,OAAO;CACf,MAAM,EAAE,OAAO;CACf,eAAe,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACxC,sBAAsB,EAAE,OAAO;CAC/B,aAAa,EAAE,OAAO;CACtB,MAAM,EAAE,OAAO;CACf,uBAAuB,EAAE,OAAO;CAChC,yBAAyB,EAAE,OAAO;CAClC,iBAAiB,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK;CAC9C,kBAAkB,EAAE,OAAO;CAC3B,kBAAkB,EAAE,OAAO;AAC/B,CAAC;AAED,MAAM,oCAAoC,EAAE,OAAO;CAC/C,eAAe,EAAE,OAAO;CACxB,SAAS,EAAE,OAAO;CAClB,eAAe,EAAE,SAAS,EAAE,QAAQ,GAAG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AAS,EAAE,OAAO,GAAG,EAAE;CAC/B,aAAa,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACtC,SAAS,EAAE,SAAS,EAAE,OAAO,GAAG,CAAC;AACrC,CAAC;AAED,MAAa,8BAA8B,EAAE,KACzC,EAAE,OAAO;CACL,QAAQ,EAAE,MAAM,uBAAuB;CACvC,QAAQ,EAAE,MAAM,uBAAuB;CACvC,OAAO,EAAE,OAAO;CAChB,kBAAkB,EAAE,OAAO;CAC3B,WAAW,EAAE,SAAS,EAAE,MAAM,+BAA+B,GAAG,CAAC,CAAC;AACtE,CAAC,GACD,EAAE,WAAW,EAAE,OAAO,GAAG,cAAc;CACnC,GAAG;CACH,MAAM,OAAO,KAAK,IAAI;AAC1B,EAAE,CACN;AAEA,MAAM,oCAAoC,EAAE,OAAO;CAC/C,eAAe,EAAE,OAAO;CACxB,SAAS,EAAE,OAAO;AACtB,CAAC;AAWD,SAAgB,mCAAmC,QAAmB;CAClE,OAAO,EAAE,KACL,EAAE,OAAO,EACL,SAAS,EAAE,MAAM,iCAAiC,EACtD,CAAC,GACD,EAAE,WACG,WAAmC,EAChC,SAAS,MAAM,QAAQ,KAAK,YAAY;EACpC,eAAe,OAAO;EACtB,QAAQ,sBACJ,OAAO,SACP,OAAO,kBAAkB,OAAO,aAAa,CACjD;CACJ,EAAE,EACN,EACJ,CACJ;AACJ"}
1
+ {"version":3,"file":"zipper.schemas.js","names":[],"sources":["../../../src/services/zipper/zipper.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport type {\n DepositWithdrawConfig,\n ZipperAssetChainVariant,\n ZipperAssetConfig,\n ZipperChainConfig,\n ZipperChainContractConfig,\n} from \"../../shared/catalog-config.js\";\nimport { scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\n\nexport type {\n DepositWithdrawConfig,\n ZipperAssetChainVariant,\n ZipperAssetConfig,\n ZipperChainConfig,\n ZipperChainContractConfig,\n};\n\nexport const ZipperChainConfigSchema = v.object({\n chainId: v.number(),\n code: v.string(),\n name: v.string(),\n nativeChainId: v.optional(v.string(), \"\"),\n nativeCurrencySymbol: v.string(),\n explorerUrl: v.string(),\n icon: v.string(),\n requiredConfirmations: v.number(),\n confirmationTimeSeconds: v.number(),\n isCaseSensitive: v.optional(v.boolean(), false),\n minAddressLength: v.number(),\n maxAddressLength: v.number(),\n});\n\nconst ZipperAssetChainVariantWireSchema = v.object({\n zippedAssetId: v.number(),\n chainId: v.number(),\n isNativeAsset: v.optional(v.boolean(), false),\n networkFee: v.optional(v.string(), \"0\"),\n networkFeeTsSec: v.pipe(v.optional(v.bigint(), 0n), v.transform(Number)),\n ztokenAddress: v.optional(v.string(), \"\"),\n sourceAddress: v.optional(v.string(), \"\"),\n sourceDecimals: v.optional(v.number(), 18),\n ztokenDecimals: v.optional(v.number(), 18),\n depositMinAmount: v.optional(v.string(), \"\"),\n withdrawMinAmount: v.optional(v.string(), \"\"),\n supplyQ: v.optional(v.bigint(), 0n),\n});\n\nfunction normalizeZipperAssetChainVariant(\n quantityScale: number,\n {\n sourceAddress,\n sourceDecimals,\n supplyQ,\n ztokenAddress,\n ztokenDecimals,\n ...variant\n }: v.InferOutput<typeof ZipperAssetChainVariantWireSchema>,\n): ZipperAssetChainVariant {\n return {\n ...variant,\n supply: scaledToDecimalOutput(supplyQ, quantityScale),\n sourceToken: {\n address: sourceAddress,\n decimals: sourceDecimals,\n },\n zToken: {\n address: ztokenAddress,\n decimals: ztokenDecimals,\n },\n };\n}\n\nexport const ZipperAssetConfigSchema = v.pipe(\n v.object({\n asset: v.string(),\n ledgerId: v.number(),\n name: v.string(),\n icon: v.string(),\n quantityScale: v.number(),\n quantityDisplayDecimals: v.number(),\n variants: v.array(ZipperAssetChainVariantWireSchema),\n uAssetId: v.optional(v.string(), \"\"),\n }),\n v.transform(({ variants, ...asset }) => ({\n ...asset,\n variants: variants.map((variant) =>\n normalizeZipperAssetChainVariant(asset.quantityScale, variant),\n ),\n })),\n);\n\nexport const ZipperChainContractConfigSchema = v.object({\n name: v.string(),\n address: v.string(),\n type: v.optional(v.string(), \"\"),\n description: v.optional(v.string(), \"\"),\n version: v.optional(v.number(), 0),\n});\n\nexport const DepositWithdrawConfigSchema = v.pipe(\n v.object({\n chains: v.array(ZipperChainConfigSchema),\n assets: v.array(ZipperAssetConfigSchema),\n tsSec: v.bigint(),\n contracts: v.optional(v.array(ZipperChainContractConfigSchema), []),\n }),\n v.transform(({ tsSec, ...config }) => ({\n ...config,\n tsMs: Number(tsSec) * 1000,\n })),\n);\n\nconst ZippedAssetSupplyUpdateWireSchema = v.object({\n zippedAssetId: v.number(),\n supplyQ: v.bigint(),\n});\n\nexport type ZippedAssetSupplyUpdate = {\n zippedAssetId: number;\n supply: string;\n};\n\nexport type ZippedAssetSupplyBatch = {\n updates: ZippedAssetSupplyUpdate[];\n};\n\nexport function createZippedAssetSupplyBatchSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n updates: v.array(ZippedAssetSupplyUpdateWireSchema),\n }),\n v.transform(\n (batch): ZippedAssetSupplyBatch => ({\n updates: batch.updates.map((update) => ({\n zippedAssetId: update.zippedAssetId,\n supply: scaledToDecimalOutput(\n update.supplyQ,\n scales.zippedAssetAmount(update.zippedAssetId),\n ),\n })),\n }),\n ),\n );\n}\n"],"mappings":";;;AAkBA,MAAa,0BAA0B,EAAE,OAAO;CAC5C,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,OAAO;CACf,MAAM,EAAE,OAAO;CACf,eAAe,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACxC,sBAAsB,EAAE,OAAO;CAC/B,aAAa,EAAE,OAAO;CACtB,MAAM,EAAE,OAAO;CACf,uBAAuB,EAAE,OAAO;CAChC,yBAAyB,EAAE,OAAO;CAClC,iBAAiB,EAAE,SAAS,EAAE,QAAQ,GAAG,KAAK;CAC9C,kBAAkB,EAAE,OAAO;CAC3B,kBAAkB,EAAE,OAAO;AAC/B,CAAC;AAED,MAAM,oCAAoC,EAA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;AAEA,MAAa,kCAAkC,EAAE,OAAO;CACpD,MAAM,EAAE,OAAO;CACf,SAAS,EAAE,OAAO;CAClB,MAAM,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CAC/B,aAAa,EAAE,SAAS,EAAE,OAAO,GAAG,EAAE;CACtC,SAAS,EAAE,SAAS,EAAE,OAAO,GAAG,CAAC;AACrC,CAAC;AAED,MAAa,8BAA8B,EAAE,KACzC,EAAE,OAAO;CACL,QAAQ,EAAE,MAAM,uBAAuB;CACvC,QAAQ,EAAE,MAAM,uBAAuB;CACvC,OAAO,EAAE,OAAO;CAChB,WAAW,EAAE,SAAS,EAAE,MAAM,+BAA+B,GAAG,CAAC,CAAC;AACtE,CAAC,GACD,EAAE,WAAW,EAAE,OAAO,GAAG,cAAc;CACnC,GAAG;CACH,MAAM,OAAO,KAAK,IAAI;AAC1B,EAAE,CACN;AAEA,MAAM,oCAAoC,EAAE,OAAO;CAC/C,eAAe,EAAE,OAAO;CACxB,SAAS,EAAE,OAAO;AACtB,CAAC;AAWD,SAAgB,mCAAmC,QAAmB;CAClE,OAAO,EAAE,KACL,EAAE,OAAO,EACL,SAAS,EAAE,MAAM,iCAAiC,EACtD,CAAC,GACD,EAAE,WACG,WAAmC,EAChC,SAAS,MAAM,QAAQ,KAAK,YAAY;EACpC,eAAe,OAAO;EACtB,QAAQ,sBACJ,OAAO,SACP,OAAO,kBAAkB,OAAO,aAAa,CACjD;CACJ,EAAE,EACN,EACJ,CACJ;AACJ"}
@@ -86,7 +86,6 @@ interface ZipperChainContractConfig {
86
86
  interface DepositWithdrawConfig {
87
87
  chains: ZipperChainConfig[];
88
88
  assets: ZipperAssetConfig[];
89
- polyesterChainId: number;
90
89
  contracts: ZipperChainContractConfig[];
91
90
  tsMs: number;
92
91
  }
@@ -1 +1 @@
1
- {"version":3,"file":"catalog-config.d.ts","names":[],"sources":["../../src/shared/catalog-config.ts"],"mappings":";KAAY;EACR;;KAGQ;cAQC;UAQI;EACb;EACA;EACA;EACA;EACA;;UAGa;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;EACb;EACA;EACA;EACA;EACA,QAAQ;;UAGK;EACb,QAAQ;EACR,OAAO;EACP;;UAGa;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGa;EACb;EACA;;UAGa;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;EACb,QAAQ;;UAGK;EACb;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;EACV;;UAGa;EACb;EACA;EACA;EACA;EACA;;UAGa;EACb,QAAQ;EACR,QAAQ;EACR;EACA,WAAW;EACX"}
1
+ {"version":3,"file":"catalog-config.d.ts","names":[],"sources":["../../src/shared/catalog-config.ts"],"mappings":";KAAY;EACR;;KAGQ;cAQC;UAQI;EACb;EACA;EACA;EACA;EACA;;UAGa;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;EACb;EACA;EACA;EACA;EACA,QAAQ;;UAGK;EACb,QAAQ;EACR,OAAO;EACP;;UAGa;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;UAGa;EACb;EACA;;UAGa;EACb;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,aAAa;EACb,QAAQ;;UAGK;EACb;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;EACV;;UAGa;EACb;EACA;EACA;EACA;EACA;;UAGa;EACb,QAAQ;EACR,QAAQ;EACR,WAAW;EACX"}
@@ -1 +1 @@
1
- {"version":3,"file":"catalog-config.js","names":[],"sources":["../../src/shared/catalog-config.ts"],"sourcesContent":["export type PairMarketDataConfig = {\n orderbookPriceBuckets: number[];\n};\n\nexport type PairStatus =\n | \"enabled\"\n | \"disabled\"\n | \"cancel_only\"\n | \"post_only\"\n | \"reduce_only\"\n | \"unknown\";\n\nexport const PAIR_STATUSES = [\n \"enabled\",\n \"disabled\",\n \"cancel_only\",\n \"post_only\",\n \"reduce_only\",\n] as const satisfies readonly PairStatus[];\n\nexport interface AssetConfig {\n symbol: string;\n ledgerId: number;\n name: string;\n quantityDisplayDecimals: number;\n quantityScale: number;\n}\n\nexport interface PairConfig {\n symbolId: number;\n symbol: string;\n baseAsset: string;\n quoteAsset: string;\n tickSize: string;\n stepSize: string;\n minNotionalQuote: string;\n minQtyBase: string;\n allowBuyFeeFromBase: boolean;\n defaultMarketSlippagePctBuy: number;\n defaultMarketSlippagePctSell: number;\n maxClientRefDriftPct: number;\n marketdata?: PairMarketDataConfig;\n baseQuantityScale: number;\n quoteQuantityScale: number;\n listingAt?: number | null;\n delistingAt?: number | null;\n status: PairStatus;\n}\n\nexport interface SpotConfig {\n assets: AssetConfig[];\n pairs: PairConfig[];\n tsSec: number;\n}\n\nexport interface ZipperChainConfig {\n chainId: number;\n code: string;\n name: string;\n nativeChainId: string;\n nativeCurrencySymbol: string;\n explorerUrl: string;\n icon: string;\n requiredConfirmations: number;\n confirmationTimeSeconds: number;\n isCaseSensitive: boolean;\n minAddressLength: number;\n maxAddressLength: number;\n}\n\nexport interface ZipperTokenConfig {\n address: string;\n decimals: number;\n}\n\nexport interface ZipperAssetChainVariant {\n zippedAssetId: number;\n chainId: number;\n isNativeAsset: boolean;\n networkFee: string;\n networkFeeTsSec: number;\n depositMinAmount: string;\n withdrawMinAmount: string;\n supply: string;\n sourceToken: ZipperTokenConfig;\n zToken: ZipperTokenConfig;\n}\n\nexport interface ZipperAssetConfig {\n asset: string;\n ledgerId: number;\n name: string;\n icon: string;\n quantityScale: number;\n quantityDisplayDecimals: number;\n variants: ZipperAssetChainVariant[];\n uAssetId: string;\n}\n\nexport interface ZipperChainContractConfig {\n name: string;\n address: string;\n type: string;\n description: string;\n version: number;\n}\n\nexport interface DepositWithdrawConfig {\n chains: ZipperChainConfig[];\n assets: ZipperAssetConfig[];\n polyesterChainId: number;\n contracts: ZipperChainContractConfig[];\n tsMs: number;\n}\n"],"mappings":";AAYA,MAAa,gBAAgB;CACzB;CACA;CACA;CACA;CACA;AACJ"}
1
+ {"version":3,"file":"catalog-config.js","names":[],"sources":["../../src/shared/catalog-config.ts"],"sourcesContent":["export type PairMarketDataConfig = {\n orderbookPriceBuckets: number[];\n};\n\nexport type PairStatus =\n | \"enabled\"\n | \"disabled\"\n | \"cancel_only\"\n | \"post_only\"\n | \"reduce_only\"\n | \"unknown\";\n\nexport const PAIR_STATUSES = [\n \"enabled\",\n \"disabled\",\n \"cancel_only\",\n \"post_only\",\n \"reduce_only\",\n] as const satisfies readonly PairStatus[];\n\nexport interface AssetConfig {\n symbol: string;\n ledgerId: number;\n name: string;\n quantityDisplayDecimals: number;\n quantityScale: number;\n}\n\nexport interface PairConfig {\n symbolId: number;\n symbol: string;\n baseAsset: string;\n quoteAsset: string;\n tickSize: string;\n stepSize: string;\n minNotionalQuote: string;\n minQtyBase: string;\n allowBuyFeeFromBase: boolean;\n defaultMarketSlippagePctBuy: number;\n defaultMarketSlippagePctSell: number;\n maxClientRefDriftPct: number;\n marketdata?: PairMarketDataConfig;\n baseQuantityScale: number;\n quoteQuantityScale: number;\n listingAt?: number | null;\n delistingAt?: number | null;\n status: PairStatus;\n}\n\nexport interface SpotConfig {\n assets: AssetConfig[];\n pairs: PairConfig[];\n tsSec: number;\n}\n\nexport interface ZipperChainConfig {\n chainId: number;\n code: string;\n name: string;\n nativeChainId: string;\n nativeCurrencySymbol: string;\n explorerUrl: string;\n icon: string;\n requiredConfirmations: number;\n confirmationTimeSeconds: number;\n isCaseSensitive: boolean;\n minAddressLength: number;\n maxAddressLength: number;\n}\n\nexport interface ZipperTokenConfig {\n address: string;\n decimals: number;\n}\n\nexport interface ZipperAssetChainVariant {\n zippedAssetId: number;\n chainId: number;\n isNativeAsset: boolean;\n networkFee: string;\n networkFeeTsSec: number;\n depositMinAmount: string;\n withdrawMinAmount: string;\n supply: string;\n sourceToken: ZipperTokenConfig;\n zToken: ZipperTokenConfig;\n}\n\nexport interface ZipperAssetConfig {\n asset: string;\n ledgerId: number;\n name: string;\n icon: string;\n quantityScale: number;\n quantityDisplayDecimals: number;\n variants: ZipperAssetChainVariant[];\n uAssetId: string;\n}\n\nexport interface ZipperChainContractConfig {\n name: string;\n address: string;\n type: string;\n description: string;\n version: number;\n}\n\nexport interface DepositWithdrawConfig {\n chains: ZipperChainConfig[];\n assets: ZipperAssetConfig[];\n contracts: ZipperChainContractConfig[];\n tsMs: number;\n}\n"],"mappings":";AAYA,MAAa,gBAAgB;CACzB;CACA;CACA;CACA;CACA;AACJ"}
@@ -80,8 +80,9 @@ declare abstract class PolyesterError extends Error {
80
80
  }
81
81
  /**
82
82
  * A transient failure — the request may never have reached the backend or the
83
- * backend was temporarily unable to serve it. Safe to retry (use the same
84
- * `requestId`/`clientOrderId` for mutations; the backend dedupes).
83
+ * backend was temporarily unable to serve it. Follow the operation's retry
84
+ * contract: reuse requestId for idempotent mutations. For single-order creation,
85
+ * reconcile by clientOrderId; reusing it returns a conflict rather than replay.
85
86
  */
86
87
  declare class TransientError extends PolyesterError {
87
88
  readonly code: string;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","names":[],"sources":["../../src/shared/errors.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2DY;UA+BK;;EAEb;;EAEA,SAAS;;iBAKG,sBAAsB;;;;;;;;uBAWhB,uBAAuB;;oBAEvB;;oBAEA;WACT,QAAQ;EAEL,YAAA,iBAAiB,UAAU;;;;;;;cAc9B,uBAAuB;WACvB;WACA;EAEG,YAAA,iBAAiB,UAAU;;;cAO9B,qBAAqB;WACZ;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,qBAAqB;WACZ;EAEN,YAAA,iBAAiB,UAAU;;UAM1B,8BAA8B;;EAE3C;;EAEA,YAAY;;;cAIH,uBAAuB;WACd;;WAET;;WAEA,YAAY;EAET,YAAA,iBAAiB,UAA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AEN,YAAA,iBAAiB,UAAU;;;cAO9B,mCAAmC;WAC1B;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,4BAA4B;WACnB;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,sCAAsC;WAC7B;EAEN,YAAA,iBAAiB,UAAU;;;cAO9B,mCAAmC;WAC1B;EAEN,YAAA,iBAAiB,UAAU;;;KAO/B;;;;;cAWC,6BAA6B;WAKzB,QAAQ;WAJH;EAGd,YAAA,iBACS,QAAQ,8BACjB,UAAU;;;;;;;cAYL,4BAA4B;WAC5B;WACA;EAEG,YAAA,iBAAiB,UAAU;;;;;;;iBAW3B,aAAa;;iBAKb,oBACZ,gBACA,iBACA,UAAU,wBACX"}
@@ -20,8 +20,9 @@ var PolyesterError = class PolyesterError extends Error {
20
20
  };
21
21
  /**
22
22
  * A transient failure — the request may never have reached the backend or the
23
- * backend was temporarily unable to serve it. Safe to retry (use the same
24
- * `requestId`/`clientOrderId` for mutations; the backend dedupes).
23
+ * backend was temporarily unable to serve it. Follow the operation's retry
24
+ * contract: reuse requestId for idempotent mutations. For single-order creation,
25
+ * reconcile by clientOrderId; reusing it returns a conflict rather than replay.
25
26
  */
26
27
  var TransientError = class extends PolyesterError {
27
28
  code = "TRANSIENT_FAILURE";
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":[],"sources":["../../src/shared/errors.ts"],"sourcesContent":["import type { PolyesterErrorDetail } from \"./error-detail.js\";\nexport type { PolyesterErrorDetail } from \"./error-detail.js\";\nimport type { RateLimitDetail } from \"./rate-limit.schemas.js\";\n\n/**\n * Typed error hierarchy for the Polyester SDK.\n *\n * Every error raised by the SDK extends {@link PolyesterError}, which carries a\n * stable machine-readable `code` and a `retryable` flag. The tree splits on\n * retryability so callers can triage with a single `instanceof` check:\n *\n * ```\n * PolyesterError code retryable\n * ├── TransientError TRANSIENT_FAILURE true\n * │ ├── NetworkError NETWORK_ERROR true\n * │ ├── TimeoutError TIMEOUT true\n * │ ├── RateLimitError RATE_LIMITED true\n * │ └── ServiceUnavailableError SERVICE_UNAVAILABLE true\n * ├── RequestError REQUEST_FAILED false\n * │ ├── ValidationError VALIDATION_FAILED false\n * │ │ ├── StaleQuoteError STALE_QUOTE\n * │ │ └── PolicyScopeMismatchError POLICY_SCOPE_MISMATCH\n * │ ├── ResourceNotFoundError RESOURCE_NOT_FOUND false\n * │ ├── AlreadyExistsError ALREADY_EXISTS false\n * │ ├── PermissionError PERMISSION_DENIED false\n * │ ├── AuthenticationError UNAUTHENTICATED false\n * │ ├── PreconditionFailedError PRECONDITION_FAILED false\n * │ │ ├── RevisionConflictError REVISION_CONFLICT\n * │ │ ├── PolicyInUseError POLICY_IN_USE\n * │ │ ├── PolicyLockedError POLICY_LOCKED\n * │ │ └── MfaLastFactorRequiredError MFA_LAST_FACTOR_REQUIRED\n * │ ├── ConfigurationError INVALID_CONFIGURATION false\n * │ ├── MfaRequiredError MFA_REQUIRED false\n * │ │ ├── MfaEnrollmentRequiredError MFA_ENROLLMENT_REQUIRED\n * │ │ ├── StepUpRequiredError STEP_UP_REQUIRED\n * │ │ └── SessionElevationRequiredError SESSION_ELEVATION_REQUIRED\n * │ └── MfaVerificationError MFA_VERIFICATION_FAILED false\n * └── InternalServerError INTERNAL_SERVER_ERROR false\n * ```\n *\n * Catalog errors (`CatalogLookupError`, `CatalogConversionError`, …) plug into\n * the same tree under `RequestError`/`ValidationError`.\n *\n * Errors mapped from RPC failures keep the original `ConnectError` as `cause`.\n *\n * @example\n * ```ts\n * try {\n * await client.orders.createSpotOrder(input);\n * } catch (err) {\n * if (err instanceof RateLimitError) await sleep(err.retryAfterMs ?? 1000);\n * else if (err instanceof TransientError) retry();\n * else if (err instanceof StepUpRequiredError) promptForMfa();\n * else throw err;\n * }\n * ```\n */\n\n/** Stable machine-readable codes carried by built-in SDK errors. */\nexport type PolyesterErrorCode =\n | \"TRANSIENT_FAILURE\"\n | \"NETWORK_ERROR\"\n | \"TIMEOUT\"\n | \"RATE_LIMITED\"\n | \"SERVICE_UNAVAILABLE\"\n | \"REQUEST_FAILED\"\n | \"VALIDATION_FAILED\"\n | \"STALE_QUOTE\"\n | \"RESOURCE_NOT_FOUND\"\n | \"ALREADY_EXISTS\"\n | \"PERMISSION_DENIED\"\n | \"UNAUTHENTICATED\"\n | \"PRECONDITION_FAILED\"\n | \"REVISION_CONFLICT\"\n | \"POLICY_IN_USE\"\n | \"POLICY_LOCKED\"\n | \"POLICY_SCOPE_MISMATCH\"\n | \"INVALID_CONFIGURATION\"\n | \"MFA_REQUIRED\"\n | \"MFA_ENROLLMENT_REQUIRED\"\n | \"STEP_UP_REQUIRED\"\n | \"SESSION_ELEVATION_REQUIRED\"\n | \"MFA_LAST_FACTOR_REQUIRED\"\n | \"MFA_VERIFICATION_FAILED\"\n | \"INTERNAL_SERVER_ERROR\"\n | \"CATALOG_LOOKUP_MISS\"\n | \"CATALOG_NOT_READY\"\n | \"CATALOG_CONVERSION_INVALID\"\n | \"CATALOG_VALIDATION_FAILED\";\n\nexport interface PolyesterErrorOptions {\n /** Underlying error, typically the original `ConnectError` for RPC failures. */\n cause?: unknown;\n /** Recognized structured backend rejection, decoded at the RPC boundary. */\n detail?: PolyesterErrorDetail;\n}\n\nconst CONNECT_ERROR_PREFIX_RE = /^(?:\\[[a-z][a-z0-9_-]*]\\s*)+/i;\n\nexport function normalizeErrorMessage(message: string): string {\n return message.replace(CONNECT_ERROR_PREFIX_RE, \"\").trim();\n}\n\n/**\n * Base class for every error raised by the Polyester SDK.\n *\n * Check `retryable` (or `instanceof TransientError`) to decide whether the\n * same call can be safely retried, and switch on `code` for exhaustive,\n * minification-safe handling.\n */\nexport abstract class PolyesterError extends Error {\n /** Stable machine-readable error code, e.g. `\"RATE_LIMITED\"`. */\n abstract readonly code: string;\n /** Whether retrying the same operation may succeed. */\n abstract readonly retryable: boolean;\n readonly detail: PolyesterErrorDetail | undefined;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(normalizeErrorMessage(message), options);\n this.name = \"PolyesterError\";\n this.detail =\n options?.detail ??\n (options?.cause instanceof PolyesterError ? options.cause.detail : undefined);\n }\n}\n\n/**\n * A transient failure — the request may never have reached the backend or the\n * backend was temporarily unable to serve it. Safe to retry (use the same\n * `requestId`/`clientOrderId` for mutations; the backend dedupes).\n */\nexport class TransientError extends PolyesterError {\n readonly code: string = \"TRANSIENT_FAILURE\";\n readonly retryable = true;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"TransientError\";\n }\n}\n\n/** The request could not be sent or the connection failed mid-flight. */\nexport class NetworkError extends TransientError {\n override readonly code: string = \"NETWORK_ERROR\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"NetworkError\";\n }\n}\n\n/** The request timed out before the backend produced a response. */\nexport class TimeoutError extends TransientError {\n override readonly code: string = \"TIMEOUT\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"TimeoutError\";\n }\n}\n\nexport interface RateLimitErrorOptions extends PolyesterErrorOptions {\n /** Suggested wait before retrying, when the backend provided one. */\n retryAfterMs?: number;\n /** Structured quota state attached to the rejection, when provided. */\n rateLimit?: RateLimitDetail;\n}\n\n/** The backend rejected the request due to rate limiting. */\nexport class RateLimitError extends TransientError {\n override readonly code: string = \"RATE_LIMITED\";\n /** Suggested wait before retrying, in milliseconds, when known. */\n readonly retryAfterMs?: number;\n /** Structured quota state attached to the rejection, when provided. */\n readonly rateLimit?: RateLimitDetail;\n\n constructor(message: string, options?: RateLimitErrorOptions) {\n super(message, options);\n this.name = \"RateLimitError\";\n this.retryAfterMs = options?.retryAfterMs;\n this.rateLimit = options?.rateLimit;\n }\n}\n\n/** The backend is temporarily unavailable (e.g. overloaded or restarting). */\nexport class ServiceUnavailableError extends TransientError {\n override readonly code: string = \"SERVICE_UNAVAILABLE\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"ServiceUnavailableError\";\n }\n}\n\n/**\n * The request itself was rejected — retrying the identical call will fail the\n * same way. Fix the input, authentication, or permissions first.\n */\nexport class RequestError extends PolyesterError {\n readonly code: string = \"REQUEST_FAILED\";\n readonly retryable = false;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"RequestError\";\n }\n}\n\n/** The request input failed validation (client- or server-side). */\nexport class ValidationError extends RequestError {\n override readonly code: string = \"VALIDATION_FAILED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"ValidationError\";\n }\n}\n\n/** The submitted client reference quote exceeded the market's configured drift limit. */\nexport class StaleQuoteError extends ValidationError {\n override readonly code = \"STALE_QUOTE\" as const;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"StaleQuoteError\";\n }\n}\n\n/** The requested resource does not exist (or is not visible to the caller). */\nexport class ResourceNotFoundError extends RequestError {\n override readonly code: string = \"RESOURCE_NOT_FOUND\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"ResourceNotFoundError\";\n }\n}\n\n/** The resource already exists (e.g. a duplicate `clientOrderId`). */\nexport class AlreadyExistsError extends RequestError {\n override readonly code: string = \"ALREADY_EXISTS\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"AlreadyExistsError\";\n }\n}\n\n/** The caller is authenticated but not allowed to perform this operation. */\nexport class PermissionError extends RequestError {\n override readonly code: string = \"PERMISSION_DENIED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PermissionError\";\n }\n}\n\n/** The caller is not authenticated (missing, expired, or invalid credentials). */\nexport class AuthenticationError extends RequestError {\n override readonly code: string = \"UNAUTHENTICATED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"AuthenticationError\";\n }\n}\n\n/** The system is not in a state that allows this operation (e.g. insufficient balance). */\nexport class PreconditionFailedError extends RequestError {\n override readonly code: string = \"PRECONDITION_FAILED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PreconditionFailedError\";\n }\n}\n\n/**\n * The resource changed after it was read, so the submitted expected revision\n * is stale. Refetch and let the caller reconcile; do not blindly retry.\n */\nexport class RevisionConflictError extends PreconditionFailedError {\n override readonly code: string = \"REVISION_CONFLICT\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"RevisionConflictError\";\n }\n}\n\n/** The policy cannot be removed while accounts or API keys still use it. */\nexport class PolicyInUseError extends PreconditionFailedError {\n override readonly code: string = \"POLICY_IN_USE\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PolicyInUseError\";\n }\n}\n\n/** The policy is locked against the requested mutation. */\nexport class PolicyLockedError extends PreconditionFailedError {\n override readonly code: string = \"POLICY_LOCKED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PolicyLockedError\";\n }\n}\n\n/** The policy does not belong to the account scope targeted by the request. */\nexport class PolicyScopeMismatchError extends ValidationError {\n override readonly code: string = \"POLICY_SCOPE_MISMATCH\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PolicyScopeMismatchError\";\n }\n}\n\n/** The SDK was configured incorrectly (bad environment, missing credentials, …). */\nexport class ConfigurationError extends RequestError {\n override readonly code: string = \"INVALID_CONFIGURATION\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"ConfigurationError\";\n }\n}\n\n/**\n * The operation requires additional multi-factor authentication. Catch this\n * class to handle all MFA flows, or the subclasses to branch per flow.\n */\nexport class MfaRequiredError extends RequestError {\n override readonly code: string = \"MFA_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"MfaRequiredError\";\n }\n}\n\n/** The user must enroll in MFA before this operation can proceed. */\nexport class MfaEnrollmentRequiredError extends MfaRequiredError {\n override readonly code: string = \"MFA_ENROLLMENT_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"MfaEnrollmentRequiredError\";\n }\n}\n\n/** The operation requires a fresh MFA step-up proof (retry with `X-Auth-Step-Up`). */\nexport class StepUpRequiredError extends MfaRequiredError {\n override readonly code: string = \"STEP_UP_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"StepUpRequiredError\";\n }\n}\n\n/** The operation requires a recent MFA-elevated session, not a one-use step-up proof. */\nexport class SessionElevationRequiredError extends MfaRequiredError {\n override readonly code: string = \"SESSION_ELEVATION_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"SessionElevationRequiredError\";\n }\n}\n\n/** The requested deletion would leave the account without an active MFA factor. */\nexport class MfaLastFactorRequiredError extends PreconditionFailedError {\n override readonly code: string = \"MFA_LAST_FACTOR_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"MfaLastFactorRequiredError\";\n }\n}\n\n/** The reason an MFA challenge could not be completed. */\nexport type MfaVerificationFailureReason =\n | \"challenge-invalid\"\n | \"challenge-locked\"\n | \"otp-invalid\"\n | \"recovery-code-invalid\"\n | \"passkey-invalid\";\n\n/**\n * An expected MFA verification rejection. Callers should select their own\n * user-facing copy from `reason` instead of displaying the backend message.\n */\nexport class MfaVerificationError extends RequestError {\n override readonly code: string = \"MFA_VERIFICATION_FAILED\";\n\n constructor(\n message: string,\n readonly reason: MfaVerificationFailureReason,\n options?: PolyesterErrorOptions,\n ) {\n super(message, options);\n this.name = \"MfaVerificationError\";\n }\n}\n\n/**\n * The backend failed unexpectedly or returned a malformed response. Not\n * automatically retryable — the failure may recur and mutations may have\n * partially applied.\n */\nexport class InternalServerError extends PolyesterError {\n readonly code: string = \"INTERNAL_SERVER_ERROR\";\n readonly retryable = false;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"InternalServerError\";\n }\n}\n\n/**\n * Checks whether an error represents an aborted request (caller-initiated via\n * `AbortSignal`). Aborts are intentionally NOT part of the {@link PolyesterError}\n * tree and are never retryable.\n */\nexport function isAbortError(err: unknown): boolean {\n return err instanceof DOMException && err.name === \"AbortError\";\n}\n\n/** Maps a plain HTTP status code onto the SDK error tree. */\nexport function errorFromHttpStatus(\n status: number,\n message: string,\n options?: PolyesterErrorOptions,\n): PolyesterError {\n if (status === 401) return new AuthenticationError(message, options);\n if (status === 403) return new PermissionError(message, options);\n if (status === 404) return new ResourceNotFoundError(message, options);\n if (status === 408) return new TimeoutError(message, options);\n if (status === 409) return new AlreadyExistsError(message, options);\n if (status === 429) return new RateLimitError(message, options);\n if (status === 502 || status === 503 || status === 504) {\n return new ServiceUnavailableError(message, options);\n }\n if (status >= 500) return new InternalServerError(message, options);\n if (status >= 400) return new RequestError(message, options);\n return new NetworkError(message, options);\n}\n"],"mappings":";AAiGA,MAAM,0BAA0B;AAEhC,SAAgB,sBAAsB,SAAyB;CAC3D,OAAO,QAAQ,QAAQ,yBAAyB,EAAE,CAAC,CAAC,KAAK;AAC7D;;;;;;;;AASA,IAAsB,iBAAtB,MAAsB,uBAAuB,MAAM;CAK/C;CAEA,YAAY,SAAiB,SAAiC;EAC1D,MAAM,sBAAsB,OAAO,GAAG,OAAO;EAC7C,KAAK,OAAO;EACZ,KAAK,SACD,SAAS,WACR,SAAS,iBAAiB,iBAAiB,QAAQ,MAAM,SAAS,KAAA;CAC3E;AACJ;;;;;;AAOA,IAAa,iBAAb,cAAoC,eAAe;CAC/C,OAAwB;CACxB,YAAqB;CAErB,YAAY,SAAiB,SAAiC;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CAChB;AACJ;;AAGA,IAAa,eAAb,cAAkC,eAAe;CAC7C,OAAiC;CAEjC,YAAY,SAAiB,SAAiC;EAC1D,MAAM,SAAS,OAAO;EACtB,KAAK,OAAO;CAChB;AACJ;;AAGA,IAAa,eAAb,cAAkC,eA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oB,SAAS,OAAO;CAClE,IAAI,UAAU,KAAK,OAAO,IAAI,aAAa,SAAS,OAAO;CAC3D,OAAO,IAAI,aAAa,SAAS,OAAO;AAC5C"}
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../../src/shared/errors.ts"],"sourcesContent":["import type { PolyesterErrorDetail } from \"./error-detail.js\";\nexport type { PolyesterErrorDetail } from \"./error-detail.js\";\nimport type { RateLimitDetail } from \"./rate-limit.schemas.js\";\n\n/**\n * Typed error hierarchy for the Polyester SDK.\n *\n * Every error raised by the SDK extends {@link PolyesterError}, which carries a\n * stable machine-readable `code` and a `retryable` flag. The tree splits on\n * retryability so callers can triage with a single `instanceof` check:\n *\n * ```\n * PolyesterError code retryable\n * ├── TransientError TRANSIENT_FAILURE true\n * │ ├── NetworkError NETWORK_ERROR true\n * │ ├── TimeoutError TIMEOUT true\n * │ ├── RateLimitError RATE_LIMITED true\n * │ └── ServiceUnavailableError SERVICE_UNAVAILABLE true\n * ├── RequestError REQUEST_FAILED false\n * │ ├── ValidationError VALIDATION_FAILED false\n * │ │ ├── StaleQuoteError STALE_QUOTE\n * │ │ └── PolicyScopeMismatchError POLICY_SCOPE_MISMATCH\n * │ ├── ResourceNotFoundError RESOURCE_NOT_FOUND false\n * │ ├── AlreadyExistsError ALREADY_EXISTS false\n * │ ├── PermissionError PERMISSION_DENIED false\n * │ ├── AuthenticationError UNAUTHENTICATED false\n * │ ├── PreconditionFailedError PRECONDITION_FAILED false\n * │ │ ├── RevisionConflictError REVISION_CONFLICT\n * │ │ ├── PolicyInUseError POLICY_IN_USE\n * │ │ ├── PolicyLockedError POLICY_LOCKED\n * │ │ └── MfaLastFactorRequiredError MFA_LAST_FACTOR_REQUIRED\n * │ ├── ConfigurationError INVALID_CONFIGURATION false\n * │ ├── MfaRequiredError MFA_REQUIRED false\n * │ │ ├── MfaEnrollmentRequiredError MFA_ENROLLMENT_REQUIRED\n * │ │ ├── StepUpRequiredError STEP_UP_REQUIRED\n * │ │ └── SessionElevationRequiredError SESSION_ELEVATION_REQUIRED\n * │ └── MfaVerificationError MFA_VERIFICATION_FAILED false\n * └── InternalServerError INTERNAL_SERVER_ERROR false\n * ```\n *\n * Catalog errors (`CatalogLookupError`, `CatalogConversionError`, …) plug into\n * the same tree under `RequestError`/`ValidationError`.\n *\n * Errors mapped from RPC failures keep the original `ConnectError` as `cause`.\n *\n * @example\n * ```ts\n * try {\n * await client.orders.createSpotOrder(input);\n * } catch (err) {\n * if (err instanceof RateLimitError) await sleep(err.retryAfterMs ?? 1000);\n * else if (err instanceof TransientError) retry();\n * else if (err instanceof StepUpRequiredError) promptForMfa();\n * else throw err;\n * }\n * ```\n */\n\n/** Stable machine-readable codes carried by built-in SDK errors. */\nexport type PolyesterErrorCode =\n | \"TRANSIENT_FAILURE\"\n | \"NETWORK_ERROR\"\n | \"TIMEOUT\"\n | \"RATE_LIMITED\"\n | \"SERVICE_UNAVAILABLE\"\n | \"REQUEST_FAILED\"\n | \"VALIDATION_FAILED\"\n | \"STALE_QUOTE\"\n | \"RESOURCE_NOT_FOUND\"\n | \"ALREADY_EXISTS\"\n | \"PERMISSION_DENIED\"\n | \"UNAUTHENTICATED\"\n | \"PRECONDITION_FAILED\"\n | \"REVISION_CONFLICT\"\n | \"POLICY_IN_USE\"\n | \"POLICY_LOCKED\"\n | \"POLICY_SCOPE_MISMATCH\"\n | \"INVALID_CONFIGURATION\"\n | \"MFA_REQUIRED\"\n | \"MFA_ENROLLMENT_REQUIRED\"\n | \"STEP_UP_REQUIRED\"\n | \"SESSION_ELEVATION_REQUIRED\"\n | \"MFA_LAST_FACTOR_REQUIRED\"\n | \"MFA_VERIFICATION_FAILED\"\n | \"INTERNAL_SERVER_ERROR\"\n | \"CATALOG_LOOKUP_MISS\"\n | \"CATALOG_NOT_READY\"\n | \"CATALOG_CONVERSION_INVALID\"\n | \"CATALOG_VALIDATION_FAILED\";\n\nexport interface PolyesterErrorOptions {\n /** Underlying error, typically the original `ConnectError` for RPC failures. */\n cause?: unknown;\n /** Recognized structured backend rejection, decoded at the RPC boundary. */\n detail?: PolyesterErrorDetail;\n}\n\nconst CONNECT_ERROR_PREFIX_RE = /^(?:\\[[a-z][a-z0-9_-]*]\\s*)+/i;\n\nexport function normalizeErrorMessage(message: string): string {\n return message.replace(CONNECT_ERROR_PREFIX_RE, \"\").trim();\n}\n\n/**\n * Base class for every error raised by the Polyester SDK.\n *\n * Check `retryable` (or `instanceof TransientError`) to decide whether the\n * same call can be safely retried, and switch on `code` for exhaustive,\n * minification-safe handling.\n */\nexport abstract class PolyesterError extends Error {\n /** Stable machine-readable error code, e.g. `\"RATE_LIMITED\"`. */\n abstract readonly code: string;\n /** Whether retrying the same operation may succeed. */\n abstract readonly retryable: boolean;\n readonly detail: PolyesterErrorDetail | undefined;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(normalizeErrorMessage(message), options);\n this.name = \"PolyesterError\";\n this.detail =\n options?.detail ??\n (options?.cause instanceof PolyesterError ? options.cause.detail : undefined);\n }\n}\n\n/**\n * A transient failure — the request may never have reached the backend or the\n * backend was temporarily unable to serve it. Follow the operation's retry\n * contract: reuse requestId for idempotent mutations. For single-order creation,\n * reconcile by clientOrderId; reusing it returns a conflict rather than replay.\n */\nexport class TransientError extends PolyesterError {\n readonly code: string = \"TRANSIENT_FAILURE\";\n readonly retryable = true;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"TransientError\";\n }\n}\n\n/** The request could not be sent or the connection failed mid-flight. */\nexport class NetworkError extends TransientError {\n override readonly code: string = \"NETWORK_ERROR\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"NetworkError\";\n }\n}\n\n/** The request timed out before the backend produced a response. */\nexport class TimeoutError extends TransientError {\n override readonly code: string = \"TIMEOUT\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"TimeoutError\";\n }\n}\n\nexport interface RateLimitErrorOptions extends PolyesterErrorOptions {\n /** Suggested wait before retrying, when the backend provided one. */\n retryAfterMs?: number;\n /** Structured quota state attached to the rejection, when provided. */\n rateLimit?: RateLimitDetail;\n}\n\n/** The backend rejected the request due to rate limiting. */\nexport class RateLimitError extends TransientError {\n override readonly code: string = \"RATE_LIMITED\";\n /** Suggested wait before retrying, in milliseconds, when known. */\n readonly retryAfterMs?: number;\n /** Structured quota state attached to the rejection, when provided. */\n readonly rateLimit?: RateLimitDetail;\n\n constructor(message: string, options?: RateLimitErrorOptions) {\n super(message, options);\n this.name = \"RateLimitError\";\n this.retryAfterMs = options?.retryAfterMs;\n this.rateLimit = options?.rateLimit;\n }\n}\n\n/** The backend is temporarily unavailable (e.g. overloaded or restarting). */\nexport class ServiceUnavailableError extends TransientError {\n override readonly code: string = \"SERVICE_UNAVAILABLE\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"ServiceUnavailableError\";\n }\n}\n\n/**\n * The request itself was rejected — retrying the identical call will fail the\n * same way. Fix the input, authentication, or permissions first.\n */\nexport class RequestError extends PolyesterError {\n readonly code: string = \"REQUEST_FAILED\";\n readonly retryable = false;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"RequestError\";\n }\n}\n\n/** The request input failed validation (client- or server-side). */\nexport class ValidationError extends RequestError {\n override readonly code: string = \"VALIDATION_FAILED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"ValidationError\";\n }\n}\n\n/** The submitted client reference quote exceeded the market's configured drift limit. */\nexport class StaleQuoteError extends ValidationError {\n override readonly code = \"STALE_QUOTE\" as const;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"StaleQuoteError\";\n }\n}\n\n/** The requested resource does not exist (or is not visible to the caller). */\nexport class ResourceNotFoundError extends RequestError {\n override readonly code: string = \"RESOURCE_NOT_FOUND\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"ResourceNotFoundError\";\n }\n}\n\n/** The resource already exists (e.g. a duplicate `clientOrderId`). */\nexport class AlreadyExistsError extends RequestError {\n override readonly code: string = \"ALREADY_EXISTS\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"AlreadyExistsError\";\n }\n}\n\n/** The caller is authenticated but not allowed to perform this operation. */\nexport class PermissionError extends RequestError {\n override readonly code: string = \"PERMISSION_DENIED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PermissionError\";\n }\n}\n\n/** The caller is not authenticated (missing, expired, or invalid credentials). */\nexport class AuthenticationError extends RequestError {\n override readonly code: string = \"UNAUTHENTICATED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"AuthenticationError\";\n }\n}\n\n/** The system is not in a state that allows this operation (e.g. insufficient balance). */\nexport class PreconditionFailedError extends RequestError {\n override readonly code: string = \"PRECONDITION_FAILED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PreconditionFailedError\";\n }\n}\n\n/**\n * The resource changed after it was read, so the submitted expected revision\n * is stale. Refetch and let the caller reconcile; do not blindly retry.\n */\nexport class RevisionConflictError extends PreconditionFailedError {\n override readonly code: string = \"REVISION_CONFLICT\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"RevisionConflictError\";\n }\n}\n\n/** The policy cannot be removed while accounts or API keys still use it. */\nexport class PolicyInUseError extends PreconditionFailedError {\n override readonly code: string = \"POLICY_IN_USE\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PolicyInUseError\";\n }\n}\n\n/** The policy is locked against the requested mutation. */\nexport class PolicyLockedError extends PreconditionFailedError {\n override readonly code: string = \"POLICY_LOCKED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PolicyLockedError\";\n }\n}\n\n/** The policy does not belong to the account scope targeted by the request. */\nexport class PolicyScopeMismatchError extends ValidationError {\n override readonly code: string = \"POLICY_SCOPE_MISMATCH\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"PolicyScopeMismatchError\";\n }\n}\n\n/** The SDK was configured incorrectly (bad environment, missing credentials, …). */\nexport class ConfigurationError extends RequestError {\n override readonly code: string = \"INVALID_CONFIGURATION\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"ConfigurationError\";\n }\n}\n\n/**\n * The operation requires additional multi-factor authentication. Catch this\n * class to handle all MFA flows, or the subclasses to branch per flow.\n */\nexport class MfaRequiredError extends RequestError {\n override readonly code: string = \"MFA_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"MfaRequiredError\";\n }\n}\n\n/** The user must enroll in MFA before this operation can proceed. */\nexport class MfaEnrollmentRequiredError extends MfaRequiredError {\n override readonly code: string = \"MFA_ENROLLMENT_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"MfaEnrollmentRequiredError\";\n }\n}\n\n/** The operation requires a fresh MFA step-up proof (retry with `X-Auth-Step-Up`). */\nexport class StepUpRequiredError extends MfaRequiredError {\n override readonly code: string = \"STEP_UP_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"StepUpRequiredError\";\n }\n}\n\n/** The operation requires a recent MFA-elevated session, not a one-use step-up proof. */\nexport class SessionElevationRequiredError extends MfaRequiredError {\n override readonly code: string = \"SESSION_ELEVATION_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"SessionElevationRequiredError\";\n }\n}\n\n/** The requested deletion would leave the account without an active MFA factor. */\nexport class MfaLastFactorRequiredError extends PreconditionFailedError {\n override readonly code: string = \"MFA_LAST_FACTOR_REQUIRED\";\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"MfaLastFactorRequiredError\";\n }\n}\n\n/** The reason an MFA challenge could not be completed. */\nexport type MfaVerificationFailureReason =\n | \"challenge-invalid\"\n | \"challenge-locked\"\n | \"otp-invalid\"\n | \"recovery-code-invalid\"\n | \"passkey-invalid\";\n\n/**\n * An expected MFA verification rejection. Callers should select their own\n * user-facing copy from `reason` instead of displaying the backend message.\n */\nexport class MfaVerificationError extends RequestError {\n override readonly code: string = \"MFA_VERIFICATION_FAILED\";\n\n constructor(\n message: string,\n readonly reason: MfaVerificationFailureReason,\n options?: PolyesterErrorOptions,\n ) {\n super(message, options);\n this.name = \"MfaVerificationError\";\n }\n}\n\n/**\n * The backend failed unexpectedly or returned a malformed response. Not\n * automatically retryable — the failure may recur and mutations may have\n * partially applied.\n */\nexport class InternalServerError extends PolyesterError {\n readonly code: string = \"INTERNAL_SERVER_ERROR\";\n readonly retryable = false;\n\n constructor(message: string, options?: PolyesterErrorOptions) {\n super(message, options);\n this.name = \"InternalServerError\";\n }\n}\n\n/**\n * Checks whether an error represents an aborted request (caller-initiated via\n * `AbortSignal`). Aborts are intentionally NOT part of the {@link PolyesterError}\n * tree and are never retryable.\n */\nexport function isAbortError(err: unknown): boolean {\n return err instanceof DOMException && err.name === \"AbortError\";\n}\n\n/** Maps a plain HTTP status code onto the SDK error tree. */\nexport function errorFromHttpStatus(\n status: number,\n message: string,\n options?: PolyesterErrorOptions,\n): PolyesterError {\n if (status === 401) return new AuthenticationError(message, options);\n if (status === 403) return new PermissionError(message, options);\n if (status === 404) return new ResourceNotFoundError(message, options);\n if (status === 408) return new TimeoutError(message, options);\n if (status === 409) return new AlreadyExistsError(message, options);\n if (status === 429) return new RateLimitError(message, options);\n if (status === 502 || status === 503 || status === 504) {\n return new ServiceUnavailableError(message, options);\n }\n if (status >= 500) return new InternalServerError(message, options);\n if (status >= 400) return new RequestError(message, options);\n return new NetworkError(message, options);\n}\n"],"mappings":";AAiGA,MAAM,0BAA0B;AAEhC,SAAgB,sBAAsB,SAAyB;CAC3D,OAAO,QAAQ,Q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CAChB;AACJ;;;;;;AAOA,SAAgB,aAAa,KAAuB;CAChD,OAAO,eAAe,gBAAgB,IAAI,SAAS;AACvD;;AAGA,SAAgB,oBACZ,QACA,SACA,SACc;CACd,IAAI,WAAW,KAAK,OAAO,IAAI,oBAAoB,SAAS,OAAO;CACnE,IAAI,WAAW,KAAK,OAAO,IAAI,gBAAgB,SAAS,OAAO;CAC/D,IAAI,WAAW,KAAK,OAAO,IAAI,sBAAsB,SAAS,OAAO;CACrE,IAAI,WAAW,KAAK,OAAO,IAAI,aAAa,SAAS,OAAO;CAC5D,IAAI,WAAW,KAAK,OAAO,IAAI,mBAAmB,SAAS,OAAO;CAClE,IAAI,WAAW,KAAK,OAAO,IAAI,eAAe,SAAS,OAAO;CAC9D,IAAI,WAAW,OAAO,WAAW,OAAO,WAAW,KAC/C,OAAO,IAAI,wBAAwB,SAAS,OAAO;CAEvD,IAAI,UAAU,KAAK,OAAO,IAAI,oBAAoB,SAAS,OAAO;CAClE,IAAI,UAAU,KAAK,OAAO,IAAI,aAAa,SAAS,OAAO;CAC3D,OAAO,IAAI,aAAa,SAAS,OAAO;AAC5C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polyester/sdk",
3
- "version": "0.21.1",
3
+ "version": "0.22.0",
4
4
  "private": false,
5
5
  "description": "TypeScript SDK providing access to APIs on Polyester Exchange.",
6
6
  "homepage": "https://github.com/Fabric-Labs/polyester-sdk-typescript#readme",
@@ -111,7 +111,7 @@
111
111
  "oxlint": "1.76.0",
112
112
  "tsdown": "0.22.14",
113
113
  "typescript": "6.0.3",
114
- "vitest": "4.1.10"
114
+ "vitest": "4.1.11"
115
115
  },
116
116
  "packageManager": "bun@1.3.11"
117
117
  }