@polyester/sdk 0.3.0 → 0.4.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 (316) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/README.md +63 -17
  3. package/dist/_virtual/_rolldown/runtime.js +15 -1
  4. package/dist/account-signer/types.d.ts.map +1 -1
  5. package/dist/account-signer/types.js +6 -3
  6. package/dist/account-signer/types.js.map +1 -1
  7. package/dist/browser-client.d.ts +4 -2
  8. package/dist/browser-client.d.ts.map +1 -1
  9. package/dist/browser-client.js +3 -4
  10. package/dist/browser-client.js.map +1 -1
  11. package/dist/catalogs/client-catalog.d.ts.map +1 -1
  12. package/dist/catalogs/client-catalog.js +11 -4
  13. package/dist/catalogs/client-catalog.js.map +1 -1
  14. package/dist/catalogs/index.js +1 -1
  15. package/dist/catalogs/readers.d.ts.map +1 -1
  16. package/dist/catalogs/readers.js +3 -1
  17. package/dist/catalogs/readers.js.map +1 -1
  18. package/dist/catalogs/snapshot-validation.js +132 -0
  19. package/dist/catalogs/snapshot-validation.js.map +1 -0
  20. package/dist/catalogs/snapshot.d.ts.map +1 -1
  21. package/dist/catalogs/snapshot.js +16 -7
  22. package/dist/catalogs/snapshot.js.map +1 -1
  23. package/dist/catalogs/zipper-supply.d.ts.map +1 -1
  24. package/dist/catalogs/zipper-supply.js +10 -7
  25. package/dist/catalogs/zipper-supply.js.map +1 -1
  26. package/dist/core-client.d.ts +24 -17
  27. package/dist/core-client.d.ts.map +1 -1
  28. package/dist/core-client.js +21 -3
  29. package/dist/core-client.js.map +1 -1
  30. package/dist/environment.d.ts.map +1 -1
  31. package/dist/environment.js +32 -1
  32. package/dist/environment.js.map +1 -1
  33. package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts +7 -0
  34. package/dist/gen/marketoverview/v1/marketoverview_pb.d.ts.map +1 -1
  35. package/dist/gen/marketoverview/v1/marketoverview_pb.js +1 -1
  36. package/dist/gen/marketoverview/v1/marketoverview_pb.js.map +1 -1
  37. package/dist/index.js +3 -3
  38. package/dist/realtime/client.js +13 -2
  39. package/dist/realtime/client.js.map +1 -1
  40. package/dist/realtime/snapshot-then-stream.js +1 -1
  41. package/dist/realtime/snapshot-then-stream.js.map +1 -1
  42. package/dist/realtime/types.d.ts +2 -0
  43. package/dist/realtime/types.d.ts.map +1 -1
  44. package/dist/server-client.d.ts +17 -8
  45. package/dist/server-client.d.ts.map +1 -1
  46. package/dist/server-client.js +8 -11
  47. package/dist/server-client.js.map +1 -1
  48. package/dist/services/accounts/accounts.js +3 -3
  49. package/dist/services/accounts/accounts.js.map +1 -1
  50. package/dist/services/accounts/accounts.schemas.d.ts +13 -13
  51. package/dist/services/accounts/accounts.schemas.d.ts.map +1 -1
  52. package/dist/services/accounts/accounts.schemas.js +11 -11
  53. package/dist/services/accounts/accounts.schemas.js.map +1 -1
  54. package/dist/services/address-book/address-book.js +28 -28
  55. package/dist/services/address-book/address-book.js.map +1 -1
  56. package/dist/services/address-book/address-book.schemas.d.ts +751 -751
  57. package/dist/services/address-book/address-book.schemas.d.ts.map +1 -1
  58. package/dist/services/address-book/address-book.schemas.js +160 -160
  59. package/dist/services/address-book/address-book.schemas.js.map +1 -1
  60. package/dist/services/api-keys/api-keys.d.ts +6 -6
  61. package/dist/services/api-keys/api-keys.d.ts.map +1 -1
  62. package/dist/services/api-keys/api-keys.js +12 -12
  63. package/dist/services/api-keys/api-keys.js.map +1 -1
  64. package/dist/services/api-keys/api-keys.schemas.d.ts +62 -62
  65. package/dist/services/api-keys/api-keys.schemas.d.ts.map +1 -1
  66. package/dist/services/api-keys/api-keys.schemas.js +34 -34
  67. package/dist/services/api-keys/api-keys.schemas.js.map +1 -1
  68. package/dist/services/auth/auth.d.ts +46 -40
  69. package/dist/services/auth/auth.d.ts.map +1 -1
  70. package/dist/services/auth/auth.js +28 -25
  71. package/dist/services/auth/auth.js.map +1 -1
  72. package/dist/services/auth/profile/profile.d.ts +2 -2
  73. package/dist/services/auth/profile/profile.d.ts.map +1 -1
  74. package/dist/services/auth/profile/profile.js +7 -7
  75. package/dist/services/auth/profile/profile.js.map +1 -1
  76. package/dist/services/auth/profile/profile.schemas.d.ts +41 -41
  77. package/dist/services/auth/profile/profile.schemas.d.ts.map +1 -1
  78. package/dist/services/auth/profile/profile.schemas.js +27 -27
  79. package/dist/services/auth/profile/profile.schemas.js.map +1 -1
  80. package/dist/services/auth/session.d.ts +1 -1
  81. package/dist/services/auth/session.d.ts.map +1 -1
  82. package/dist/services/auth/session.js +6 -2
  83. package/dist/services/auth/session.js.map +1 -1
  84. package/dist/services/auth/session.schemas.js +17 -17
  85. package/dist/services/auth/session.schemas.js.map +1 -1
  86. package/dist/services/auth/session.types.d.ts +3 -2
  87. package/dist/services/auth/session.types.d.ts.map +1 -1
  88. package/dist/services/balances/balances.d.ts +1 -1
  89. package/dist/services/balances/balances.js +9 -9
  90. package/dist/services/balances/balances.js.map +1 -1
  91. package/dist/services/balances/balances.schemas.d.ts +95 -95
  92. package/dist/services/balances/balances.schemas.d.ts.map +1 -1
  93. package/dist/services/balances/balances.schemas.js +61 -61
  94. package/dist/services/balances/balances.schemas.js.map +1 -1
  95. package/dist/services/candles/candles.js +12 -12
  96. package/dist/services/candles/candles.js.map +1 -1
  97. package/dist/services/candles/candles.schemas.d.ts +64 -64
  98. package/dist/services/candles/candles.schemas.d.ts.map +1 -1
  99. package/dist/services/candles/candles.schemas.js +47 -48
  100. package/dist/services/candles/candles.schemas.js.map +1 -1
  101. package/dist/services/chain-analytics/chain-analytics.js +7 -7
  102. package/dist/services/chain-analytics/chain-analytics.js.map +1 -1
  103. package/dist/services/chain-analytics/chain-analytics.schemas.d.ts +68 -68
  104. package/dist/services/chain-analytics/chain-analytics.schemas.d.ts.map +1 -1
  105. package/dist/services/chain-analytics/chain-analytics.schemas.js +29 -29
  106. package/dist/services/chain-analytics/chain-analytics.schemas.js.map +1 -1
  107. package/dist/services/deposit/deposit.js +5 -5
  108. package/dist/services/deposit/deposit.js.map +1 -1
  109. package/dist/services/deposit/deposit.schemas.d.ts +17 -17
  110. package/dist/services/deposit/deposit.schemas.d.ts.map +1 -1
  111. package/dist/services/deposit/deposit.schemas.js +11 -11
  112. package/dist/services/deposit/deposit.schemas.js.map +1 -1
  113. package/dist/services/guard-signer/guard-signer.js +13 -13
  114. package/dist/services/guard-signer/guard-signer.js.map +1 -1
  115. package/dist/services/guard-signer/guard-signer.schemas.d.ts +75 -75
  116. package/dist/services/guard-signer/guard-signer.schemas.d.ts.map +1 -1
  117. package/dist/services/guard-signer/guard-signer.schemas.js +42 -42
  118. package/dist/services/guard-signer/guard-signer.schemas.js.map +1 -1
  119. package/dist/services/heatmap/heatmap.js +9 -9
  120. package/dist/services/heatmap/heatmap.js.map +1 -1
  121. package/dist/services/heatmap/heatmap.schemas.d.ts +141 -141
  122. package/dist/services/heatmap/heatmap.schemas.d.ts.map +1 -1
  123. package/dist/services/heatmap/heatmap.schemas.js +47 -47
  124. package/dist/services/heatmap/heatmap.schemas.js.map +1 -1
  125. package/dist/services/internal-transfers/internal-transfers.js +3 -3
  126. package/dist/services/internal-transfers/internal-transfers.js.map +1 -1
  127. package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +53 -53
  128. package/dist/services/internal-transfers/internal-transfers.schemas.d.ts.map +1 -1
  129. package/dist/services/internal-transfers/internal-transfers.schemas.js +27 -27
  130. package/dist/services/internal-transfers/internal-transfers.schemas.js.map +1 -1
  131. package/dist/services/lifecycle/lifecycle.js +10 -10
  132. package/dist/services/lifecycle/lifecycle.js.map +1 -1
  133. package/dist/services/lifecycle/lifecycle.schemas.d.ts +614 -614
  134. package/dist/services/lifecycle/lifecycle.schemas.d.ts.map +1 -1
  135. package/dist/services/lifecycle/lifecycle.schemas.js +146 -146
  136. package/dist/services/lifecycle/lifecycle.schemas.js.map +1 -1
  137. package/dist/services/market-data/market-data.js +6 -6
  138. package/dist/services/market-data/market-data.js.map +1 -1
  139. package/dist/services/market-data/market-data.schemas.d.ts +20 -20
  140. package/dist/services/market-data/market-data.schemas.d.ts.map +1 -1
  141. package/dist/services/market-data/market-data.schemas.js +51 -55
  142. package/dist/services/market-data/market-data.schemas.js.map +1 -1
  143. package/dist/services/market-overview/market-overview.d.ts +1 -1
  144. package/dist/services/market-overview/market-overview.js +5 -5
  145. package/dist/services/market-overview/market-overview.js.map +1 -1
  146. package/dist/services/market-overview/market-overview.schemas.d.ts +39 -36
  147. package/dist/services/market-overview/market-overview.schemas.d.ts.map +1 -1
  148. package/dist/services/market-overview/market-overview.schemas.js +34 -32
  149. package/dist/services/market-overview/market-overview.schemas.js.map +1 -1
  150. package/dist/services/mfa/mfa.js +27 -27
  151. package/dist/services/mfa/mfa.js.map +1 -1
  152. package/dist/services/mfa/mfa.schemas.d.ts +206 -206
  153. package/dist/services/mfa/mfa.schemas.d.ts.map +1 -1
  154. package/dist/services/mfa/mfa.schemas.js +83 -83
  155. package/dist/services/mfa/mfa.schemas.js.map +1 -1
  156. package/dist/services/orderbook/orderbook.d.ts +2 -2
  157. package/dist/services/orderbook/orderbook.d.ts.map +1 -1
  158. package/dist/services/orderbook/orderbook.js +5 -5
  159. package/dist/services/orderbook/orderbook.js.map +1 -1
  160. package/dist/services/orderbook/orderbook.schemas.d.ts +23 -23
  161. package/dist/services/orderbook/orderbook.schemas.d.ts.map +1 -1
  162. package/dist/services/orderbook/orderbook.schemas.js +15 -15
  163. package/dist/services/orderbook/orderbook.schemas.js.map +1 -1
  164. package/dist/services/orders/order-errors.schemas.d.ts +18 -18
  165. package/dist/services/orders/order-errors.schemas.d.ts.map +1 -1
  166. package/dist/services/orders/order-errors.schemas.js +8 -8
  167. package/dist/services/orders/order-errors.schemas.js.map +1 -1
  168. package/dist/services/orders/orders-batch.schemas.d.ts +492 -492
  169. package/dist/services/orders/orders-batch.schemas.d.ts.map +1 -1
  170. package/dist/services/orders/orders-batch.schemas.js +118 -118
  171. package/dist/services/orders/orders-batch.schemas.js.map +1 -1
  172. package/dist/services/orders/orders-identifiers.schemas.js +5 -5
  173. package/dist/services/orders/orders-identifiers.schemas.js.map +1 -1
  174. package/dist/services/orders/orders-input.schemas.d.ts +657 -648
  175. package/dist/services/orders/orders-input.schemas.d.ts.map +1 -1
  176. package/dist/services/orders/orders-input.schemas.js +100 -96
  177. package/dist/services/orders/orders-input.schemas.js.map +1 -1
  178. package/dist/services/orders/orders-modify.schemas.d.ts +370 -351
  179. package/dist/services/orders/orders-modify.schemas.d.ts.map +1 -1
  180. package/dist/services/orders/orders-modify.schemas.js +48 -44
  181. package/dist/services/orders/orders-modify.schemas.js.map +1 -1
  182. package/dist/services/orders/orders-output.schemas.d.ts +179 -179
  183. package/dist/services/orders/orders-output.schemas.d.ts.map +1 -1
  184. package/dist/services/orders/orders-output.schemas.js +49 -49
  185. package/dist/services/orders/orders-output.schemas.js.map +1 -1
  186. package/dist/services/orders/orders-risk.schemas.d.ts +226 -226
  187. package/dist/services/orders/orders-risk.schemas.d.ts.map +1 -1
  188. package/dist/services/orders/orders-risk.schemas.js +69 -69
  189. package/dist/services/orders/orders-risk.schemas.js.map +1 -1
  190. package/dist/services/orders/orders.d.ts +8 -8
  191. package/dist/services/orders/orders.d.ts.map +1 -1
  192. package/dist/services/orders/orders.js +44 -32
  193. package/dist/services/orders/orders.js.map +1 -1
  194. package/dist/services/policies/api-key-policies/api-key-policies.d.ts +6 -6
  195. package/dist/services/policies/api-key-policies/api-key-policies.d.ts.map +1 -1
  196. package/dist/services/policies/api-key-policies/api-key-policies.js +11 -11
  197. package/dist/services/policies/api-key-policies/api-key-policies.js.map +1 -1
  198. package/dist/services/policies/api-key-policies/api-key-policies.schemas.d.ts +105 -105
  199. package/dist/services/policies/api-key-policies/api-key-policies.schemas.d.ts.map +1 -1
  200. package/dist/services/policies/api-key-policies/api-key-policies.schemas.js +49 -49
  201. package/dist/services/policies/api-key-policies/api-key-policies.schemas.js.map +1 -1
  202. package/dist/services/policies/shared.d.ts +5 -5
  203. package/dist/services/policies/shared.d.ts.map +1 -1
  204. package/dist/services/policies/shared.js +10 -10
  205. package/dist/services/policies/shared.js.map +1 -1
  206. package/dist/services/policies/subaccount-policies/subaccount-policies.d.ts +6 -6
  207. package/dist/services/policies/subaccount-policies/subaccount-policies.d.ts.map +1 -1
  208. package/dist/services/policies/subaccount-policies/subaccount-policies.js +13 -13
  209. package/dist/services/policies/subaccount-policies/subaccount-policies.js.map +1 -1
  210. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts +124 -124
  211. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts.map +1 -1
  212. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js +75 -75
  213. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js.map +1 -1
  214. package/dist/services/shared.js +11 -11
  215. package/dist/services/shared.js.map +1 -1
  216. package/dist/services/social-verification/social-verification.d.ts +3 -3
  217. package/dist/services/social-verification/social-verification.d.ts.map +1 -1
  218. package/dist/services/social-verification/social-verification.js +7 -7
  219. package/dist/services/social-verification/social-verification.js.map +1 -1
  220. package/dist/services/social-verification/social-verification.schemas.d.ts +54 -54
  221. package/dist/services/social-verification/social-verification.schemas.d.ts.map +1 -1
  222. package/dist/services/social-verification/social-verification.schemas.js +28 -28
  223. package/dist/services/social-verification/social-verification.schemas.js.map +1 -1
  224. package/dist/services/subaccount-resolver.js +5 -3
  225. package/dist/services/subaccount-resolver.js.map +1 -1
  226. package/dist/services/subaccounts/subaccounts.d.ts +15 -15
  227. package/dist/services/subaccounts/subaccounts.d.ts.map +1 -1
  228. package/dist/services/subaccounts/subaccounts.js +35 -35
  229. package/dist/services/subaccounts/subaccounts.js.map +1 -1
  230. package/dist/services/subaccounts/subaccounts.schemas.d.ts +137 -137
  231. package/dist/services/subaccounts/subaccounts.schemas.d.ts.map +1 -1
  232. package/dist/services/subaccounts/subaccounts.schemas.js +72 -72
  233. package/dist/services/subaccounts/subaccounts.schemas.js.map +1 -1
  234. package/dist/services/trades/trades.d.ts +2 -2
  235. package/dist/services/trades/trades.d.ts.map +1 -1
  236. package/dist/services/trades/trades.js +5 -5
  237. package/dist/services/trades/trades.js.map +1 -1
  238. package/dist/services/trades/trades.schemas.d.ts +31 -31
  239. package/dist/services/trades/trades.schemas.d.ts.map +1 -1
  240. package/dist/services/trades/trades.schemas.js +24 -24
  241. package/dist/services/trades/trades.schemas.js.map +1 -1
  242. package/dist/services/trading-withdraws/trading-withdraws.js +8 -8
  243. package/dist/services/trading-withdraws/trading-withdraws.js.map +1 -1
  244. package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts +45 -45
  245. package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts.map +1 -1
  246. package/dist/services/trading-withdraws/trading-withdraws.schemas.js +36 -36
  247. package/dist/services/trading-withdraws/trading-withdraws.schemas.js.map +1 -1
  248. package/dist/services/transfers/transfers.d.ts +1 -1
  249. package/dist/services/transfers/transfers.d.ts.map +1 -1
  250. package/dist/services/transfers/transfers.js +5 -5
  251. package/dist/services/transfers/transfers.js.map +1 -1
  252. package/dist/services/transfers/transfers.schemas.d.ts +42 -42
  253. package/dist/services/transfers/transfers.schemas.d.ts.map +1 -1
  254. package/dist/services/transfers/transfers.schemas.js +30 -30
  255. package/dist/services/transfers/transfers.schemas.js.map +1 -1
  256. package/dist/services/triggers/trigger-child-order.schemas.js +23 -23
  257. package/dist/services/triggers/trigger-child-order.schemas.js.map +1 -1
  258. package/dist/services/triggers/trigger-input.schemas.d.ts +226 -226
  259. package/dist/services/triggers/trigger-input.schemas.d.ts.map +1 -1
  260. package/dist/services/triggers/trigger-input.schemas.js +53 -53
  261. package/dist/services/triggers/trigger-input.schemas.js.map +1 -1
  262. package/dist/services/triggers/triggers-output.schemas.d.ts +218 -218
  263. package/dist/services/triggers/triggers-output.schemas.d.ts.map +1 -1
  264. package/dist/services/triggers/triggers-output.schemas.js +152 -152
  265. package/dist/services/triggers/triggers-output.schemas.js.map +1 -1
  266. package/dist/services/triggers/triggers.js +21 -21
  267. package/dist/services/triggers/triggers.js.map +1 -1
  268. package/dist/services/whiteboard/whiteboard.js +15 -15
  269. package/dist/services/whiteboard/whiteboard.js.map +1 -1
  270. package/dist/services/whiteboard/whiteboard.schemas.d.ts +379 -379
  271. package/dist/services/whiteboard/whiteboard.schemas.d.ts.map +1 -1
  272. package/dist/services/whiteboard/whiteboard.schemas.js +71 -71
  273. package/dist/services/whiteboard/whiteboard.schemas.js.map +1 -1
  274. package/dist/services/zipper/zipper.js +3 -3
  275. package/dist/services/zipper/zipper.js.map +1 -1
  276. package/dist/services/zipper/zipper.schemas.d.ts +1 -1
  277. package/dist/services/zipper/zipper.schemas.js +54 -54
  278. package/dist/services/zipper/zipper.schemas.js.map +1 -1
  279. package/dist/shared/account-scope.d.ts +6 -6
  280. package/dist/shared/account-scope.d.ts.map +1 -1
  281. package/dist/shared/account-scope.js +3 -3
  282. package/dist/shared/account-scope.js.map +1 -1
  283. package/dist/shared/connect-error-mapping.d.ts +1 -1
  284. package/dist/shared/connect-error-mapping.js +29 -3
  285. package/dist/shared/connect-error-mapping.js.map +1 -1
  286. package/dist/shared/rate-limit.schemas.d.ts +12 -12
  287. package/dist/shared/rate-limit.schemas.d.ts.map +1 -1
  288. package/dist/shared/rate-limit.schemas.js +7 -7
  289. package/dist/shared/rate-limit.schemas.js.map +1 -1
  290. package/dist/shared/schemas.js +26 -26
  291. package/dist/shared/schemas.js.map +1 -1
  292. package/dist/shared/transports.js +7 -12
  293. package/dist/shared/transports.js.map +1 -1
  294. package/dist/shared/types.d.ts +12 -0
  295. package/dist/shared/types.d.ts.map +1 -1
  296. package/dist/shared/validation.d.ts +14 -0
  297. package/dist/shared/validation.d.ts.map +1 -0
  298. package/dist/shared/validation.js +24 -0
  299. package/dist/shared/validation.js.map +1 -0
  300. package/dist/utils/connect-order-errors.js +2 -2
  301. package/dist/utils/connect-order-errors.js.map +1 -1
  302. package/dist/utils/cookies.d.ts +8 -3
  303. package/dist/utils/cookies.d.ts.map +1 -1
  304. package/dist/utils/cookies.js +7 -1
  305. package/dist/utils/cookies.js.map +1 -1
  306. package/dist/utils/event-emitter.d.ts +1 -1
  307. package/dist/utils/event-emitter.d.ts.map +1 -1
  308. package/dist/utils/event-emitter.js +4 -2
  309. package/dist/utils/event-emitter.js.map +1 -1
  310. package/dist/utils/evm.js +2 -2
  311. package/dist/utils/evm.js.map +1 -1
  312. package/dist/utils/jwt.d.ts +2 -2
  313. package/dist/utils/jwt.d.ts.map +1 -1
  314. package/dist/utils/jwt.js +2 -2
  315. package/dist/utils/jwt.js.map +1 -1
  316. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"trades.schemas.js","names":[],"sources":["../../../src/services/trades/trades.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { tsNsToISO, tsNsToMs } from \"../../utils/time.js\";\nimport { SideSchema } from \"../shared.js\";\nimport { FeeAssetCodec, OrderSideCodec } from \"../orders/orders.codecs.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport { optionalUint64DecimalFilterSchema } from \"../../shared/schemas.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { TradeSideCodec } from \"./trades.codecs.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport { E18_SCALE, scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { fromU128 } from \"../../utils/u128.js\";\n\nconst U128Schema = v.object({\n hi: v.bigint(),\n lo: v.bigint(),\n});\n\n/** Parses a generated user-trade fill into the SDK's JSON-safe public shape. */\nexport function createUserTradeSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n orderId: v.bigint(),\n symbolId: v.number(),\n side: v.number(),\n isMaker: v.boolean(),\n feeAsset: v.number(),\n qtyScaled: v.bigint(),\n priceTicks: v.bigint(),\n feeAmountE18: v.optional(U128Schema),\n referralShareAmountE18: v.optional(U128Schema),\n feeIsRebate: v.boolean(),\n tsNs: v.bigint(),\n matchId: v.bigint(),\n }),\n v.transform((t) => {\n const feeAsset = requiredEnumLabel(\n FeeAssetCodec.protoToOutput,\n t.feeAsset,\n \"UserTradeSchema\",\n \"fee asset\",\n );\n return {\n orderId: formatId(t.orderId),\n symbolId: t.symbolId,\n sideLabel: requiredEnumLabel(\n OrderSideCodec.protoToOutput,\n t.side,\n \"UserTradeSchema\",\n \"side\",\n ),\n liquidityLabel: t.isMaker ? (\"maker\" as const) : (\"taker\" as const),\n feeAsset,\n qty: scaledToDecimalOutput(t.qtyScaled, scales.baseQty(t.symbolId)),\n price: scaledToDecimalOutput(t.priceTicks, scales.price()),\n fee: scaledToDecimalOutput(fromU128(t.feeAmountE18), E18_SCALE),\n ...(t.referralShareAmountE18 === undefined\n ? {}\n : {\n referralShare: scaledToDecimalOutput(\n fromU128(t.referralShareAmountE18),\n E18_SCALE,\n ),\n }),\n feeIsRebate: t.feeIsRebate,\n tsNs: t.tsNs.toString(),\n tsIso: tsNsToISO(t.tsNs),\n tsMs: tsNsToMs(t.tsNs),\n matchId: t.matchId.toString(),\n };\n }),\n );\n}\n\n/** A JSON-safe authenticated trade fill returned by the SDK. */\nexport type Trade = v.InferOutput<ReturnType<typeof createUserTradeSchema>>;\n\n/** Validates filters accepted by {@link TradesService.list}. */\nexport const GetUserTradesInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n symbolId: v.pipe(\n v.optional(v.pipe(v.string(), v.trim())),\n v.transform((v) => {\n if (!v) return undefined;\n const sid = Number(v);\n return Number.isFinite(sid) && sid > 0 ? sid : undefined;\n }),\n ),\n side: v.pipe(\n v.optional(SideSchema),\n v.transform((v) => (v ? TradeSideCodec.inputToProto[v] : undefined)),\n ),\n startTsNs: optionalUint64DecimalFilterSchema(\"startTsNs\"),\n endTsNs: optionalUint64DecimalFilterSchema(\"endTsNs\"),\n limit: v.optional(v.number()),\n pageToken: v.optional(v.pipe(v.string(), v.trim())),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\n/** Filters accepted by {@link TradesService.list}. */\nexport type GetUserTradesInput = v.InferInput<typeof GetUserTradesInputSchema>;\n"],"mappings":";;;;;;;;;;;;AAeA,MAAM,aAAa,EAAE,OAAO;CACxB,IAAI,EAAE,OAAO;CACb,IAAI,EAAE,OAAO;AACjB,CAAC;;AAGD,SAAgB,sBAAsB,QAAmB;CACrD,OAAO,EAAE,KACL,EAAE,OAAO;EACL,SAAS,EAAE,OAAO;EAClB,UAAU,EAAE,OAAO;EACnB,MAAM,EAAE,OAAO;EACf,SAAS,EAAE,QAAQ;EACnB,UAAU,EAAE,OAAO;EACnB,WAAW,EAAE,OAAO;EACpB,YAAY,EAAE,OAAO;EACrB,cAAc,EAAE,SAAS,UAAU;EACnC,wBAAwB,EAAE,SAAS,UAAU;EAC7C,aAAa,EAAE,QAAQ;EACvB,MAAM,EAAE,OAAO;EACf,SAAS,EAAE,OAAO;CACtB,CAAC,GACD,EAAE,WAAW,MAAM;EACf,MAAM,WAAW,kBACb,cAAc,eACd,EAAE,UACF,mBACA,WACJ;EACA,OAAO;GACH,SAAS,SAAS,EAAE,OAAO;GAC3B,UAAU,EAAE;GACZ,WAAW,kBACP,eAAe,eACf,EAAE,MACF,mBACA,MACJ;GACA,gBAAgB,EAAE,UAAW,UAAqB;GAClD;GACA,KAAK,sBAAsB,EAAE,WAAW,OAAO,QAAQ,EAAE,QAAQ,CAAC;GAClE,OAAO,sBAAsB,EAAE,YAAY,OAAO,MAAM,CAAC;GACzD,KAAK,sBAAsB,SAAS,EAAE,YAAY,GAAA,EAAY;GAC9D,GAAI,EAAE,2BAA2B,KAAA,IAC3B,CAAC,IACD,EACI,eAAe,sBACX,SAAS,EAAE,sBAAsB,GAAA,EAErC,EACJ;GACN,aAAa,EAAE;GACf,MAAM,EAAE,KAAK,SAAS;GACtB,OAAO,UAAU,EAAE,IAAI;GACvB,MAAM,SAAS,EAAE,IAAI;GACrB,SAAS,EAAE,QAAQ,SAAS;EAChC;CACJ,CAAC,CACL;AACJ;;AAMA,MAAa,2BAA2B,EAAE,KACtC,EAAE,aAAa;CACX,GAAG;CACH,UAAU,EAAE,KACR,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,CAAC,GACvC,EAAE,WAAW,MAAM;EACf,IAAI,CAAC,GAAG,OAAO,KAAA;EACf,MAAM,MAAM,OAAO,CAAC;EACpB,OAAO,OAAO,SAAS,GAAG,KAAK,MAAM,IAAI,MAAM,KAAA;CACnD,CAAC,CACL;CACA,MAAM,EAAE,KACJ,EAAE,SAAS,UAAU,GACrB,EAAE,WAAW,MAAO,IAAI,eAAe,aAAa,KAAK,KAAA,CAAU,CACvE;CACA,WAAW,kCAAkC,WAAW;CACxD,SAAS,kCAAkC,SAAS;CACpD,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC;CAC5B,WAAW,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,CAAC;AACtD,CAAC,GACD,EAAE,WAAW,EAAE,SAAS,GAAG,aAAa;CACpC,GAAG;CACH,cAAc,2BAA2B,OAAO;AACpD,EAAE,CACN"}
1
+ {"version":3,"file":"trades.schemas.js","names":["v"],"sources":["../../../src/services/trades/trades.schemas.ts"],"sourcesContent":["import * as v from \"../../shared/validation.js\";\nimport { tsNsToISO, tsNsToMs } from \"../../utils/time.js\";\nimport { SideSchema } from \"../shared.js\";\nimport { FeeAssetCodec, OrderSideCodec } from \"../orders/orders.codecs.js\";\nimport { formatId } from \"../../utils/base58-id.js\";\nimport { optionalUint64DecimalFilterSchema } from \"../../shared/schemas.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { TradeSideCodec } from \"./trades.codecs.js\";\nimport { requiredEnumLabel } from \"../../shared/proto-enum-codec.js\";\nimport { E18_SCALE, scaledToDecimalOutput, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { fromU128 } from \"../../utils/u128.js\";\n\nconst U128Schema = v.object({\n hi: v.bigint(),\n lo: v.bigint(),\n});\n\n/** Parses a generated user-trade fill into the SDK's JSON-safe public shape. */\nexport function createUserTradeSchema(scales: SdkScales) {\n return v.pipe(\n v.object({\n orderId: v.bigint(),\n symbolId: v.number(),\n side: v.number(),\n isMaker: v.boolean(),\n feeAsset: v.number(),\n qtyScaled: v.bigint(),\n priceTicks: v.bigint(),\n feeAmountE18: v.optional(U128Schema),\n referralShareAmountE18: v.optional(U128Schema),\n feeIsRebate: v.boolean(),\n tsNs: v.bigint(),\n matchId: v.bigint(),\n }),\n v.transform((t) => {\n const feeAsset = requiredEnumLabel(\n FeeAssetCodec.protoToOutput,\n t.feeAsset,\n \"UserTradeSchema\",\n \"fee asset\",\n );\n return {\n orderId: formatId(t.orderId),\n symbolId: t.symbolId,\n sideLabel: requiredEnumLabel(\n OrderSideCodec.protoToOutput,\n t.side,\n \"UserTradeSchema\",\n \"side\",\n ),\n liquidityLabel: t.isMaker ? (\"maker\" as const) : (\"taker\" as const),\n feeAsset,\n qty: scaledToDecimalOutput(t.qtyScaled, scales.baseQty(t.symbolId)),\n price: scaledToDecimalOutput(t.priceTicks, scales.price()),\n fee: scaledToDecimalOutput(fromU128(t.feeAmountE18), E18_SCALE),\n ...(t.referralShareAmountE18 === undefined\n ? {}\n : {\n referralShare: scaledToDecimalOutput(\n fromU128(t.referralShareAmountE18),\n E18_SCALE,\n ),\n }),\n feeIsRebate: t.feeIsRebate,\n tsNs: t.tsNs.toString(),\n tsIso: tsNsToISO(t.tsNs),\n tsMs: tsNsToMs(t.tsNs),\n matchId: t.matchId.toString(),\n };\n }),\n );\n}\n\n/** A JSON-safe authenticated trade fill returned by the SDK. */\nexport type Trade = v.InferOutput<ReturnType<typeof createUserTradeSchema>>;\n\n/** Validates filters accepted by {@link TradesService.list}. */\nexport const GetUserTradesInputSchema = v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n symbolId: v.pipe(\n v.optional(v.pipe(v.string(), v.trim())),\n v.transform((v) => {\n if (!v) return undefined;\n const sid = Number(v);\n return Number.isFinite(sid) && sid > 0 ? sid : undefined;\n }),\n ),\n side: v.pipe(\n v.optional(SideSchema),\n v.transform((v) => (v ? TradeSideCodec.inputToProto[v] : undefined)),\n ),\n startTsNs: optionalUint64DecimalFilterSchema(\"startTsNs\"),\n endTsNs: optionalUint64DecimalFilterSchema(\"endTsNs\"),\n limit: v.optional(v.number()),\n pageToken: v.optional(v.pipe(v.string(), v.trim())),\n }),\n v.transform(({ account, ...input }) => ({\n ...input,\n subaccountId: accountScopeToSubaccountId(account),\n })),\n);\n\n/** Filters accepted by {@link TradesService.list}. */\nexport type GetUserTradesInput = v.InferInput<typeof GetUserTradesInputSchema>;\n"],"mappings":";;;;;;;;;;;;AAeA,MAAM,aAAaA,mBAAE,OAAO;CACxB,IAAIA,mBAAE,OAAO;CACb,IAAIA,mBAAE,OAAO;AACjB,CAAC;;AAGD,SAAgB,sBAAsB,QAAmB;CACrD,OAAOA,mBAAE,KACLA,mBAAE,OAAO;EACL,SAASA,mBAAE,OAAO;EAClB,UAAUA,mBAAE,OAAO;EACnB,MAAMA,mBAAE,OAAO;EACf,SAASA,mBAAE,QAAQ;EACnB,UAAUA,mBAAE,OAAO;EACnB,WAAWA,mBAAE,OAAO;EACpB,YAAYA,mBAAE,OAAO;EACrB,cAAcA,mBAAE,SAAS,UAAU;EACnC,wBAAwBA,mBAAE,SAAS,UAAU;EAC7C,aAAaA,mBAAE,QAAQ;EACvB,MAAMA,mBAAE,OAAO;EACf,SAASA,mBAAE,OAAO;CACtB,CAAC,GACDA,mBAAE,WAAW,MAAM;EACf,MAAM,WAAW,kBACb,cAAc,eACd,EAAE,UACF,mBACA,WACJ;EACA,OAAO;GACH,SAAS,SAAS,EAAE,OAAO;GAC3B,UAAU,EAAE;GACZ,WAAW,kBACP,eAAe,eACf,EAAE,MACF,mBACA,MACJ;GACA,gBAAgB,EAAE,UAAW,UAAqB;GAClD;GACA,KAAK,s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/validation.js";
2
3
  import { idToBigInt } from "../../utils/base58-id.js";
4
+ import { checksumEvmAddress, evmHexToBytes, evmUtf8ToBytes, keccak256Hex } from "../../utils/evm.js";
3
5
  import { toConnectCallOptions } from "../../shared/request-options.js";
4
6
  import { removeUndefined } from "../../utils/remove-undefined.js";
5
7
  import { resolveAccountScopedInput } from "../subaccount-resolver.js";
6
- import { checksumEvmAddress, evmHexToBytes, evmUtf8ToBytes, keccak256Hex } from "../../utils/evm.js";
7
8
  import { WithdrawService } from "../../gen/chain/withdraw/v1/withdraw_pb.js";
8
9
  import { CreateTradingWithdrawResultSchema, CreateWalletTradingWithdrawResultSchema, ValidateWithdrawDestinationInputSchema, ValidateWithdrawDestinationResultSchema, createCreateTradingWithdrawToExternalChainInputSchema, createCreateTradingWithdrawToFundingInputSchema } from "./trading-withdraws.schemas.js";
9
10
  import { createClient } from "@connectrpc/connect";
10
- import * as v from "valibot";
11
11
  //#region src/services/trading-withdraws/trading-withdraws.ts
12
12
  function fromU128(value) {
13
13
  if (!value) return 0n;
@@ -144,9 +144,9 @@ var TradingWithdrawsService = class {
144
144
  * Checks whether an external-chain destination can receive a withdrawal without creating, signing, or reserving one.
145
145
  */
146
146
  async validateDestination(input, options) {
147
- const request = v.parse(ValidateWithdrawDestinationInputSchema, input);
147
+ const request = parse(ValidateWithdrawDestinationInputSchema, input);
148
148
  const response = await this.#client.validateWithdrawDestination(request, toConnectCallOptions(options));
149
- return v.parse(ValidateWithdrawDestinationResultSchema, response);
149
+ return parse(ValidateWithdrawDestinationResultSchema, response);
150
150
  }
151
151
  /**
152
152
  * Builds a Trading-to-Funding withdraw intent payload with asset id, decimal amount, destination address, five-minute deadline, nonce, and idempotency key. If a wallet signer is provided, it signs EIP-712 typed data and calls the wallet endpoint; otherwise a payload signature is required for the backend-authorized endpoint.
@@ -162,7 +162,7 @@ var TradingWithdrawsService = class {
162
162
  await this.#scales.ready();
163
163
  const { walletSigner, ...inputForValidation } = input;
164
164
  const resolvedInput = resolveAccountScopedInput(inputForValidation, this.#resolver);
165
- const validated = v.parse(this.#toFundingInputSchema, resolvedInput);
165
+ const validated = parse(this.#toFundingInputSchema, resolvedInput);
166
166
  return this.#prepareWithdraw(validated, walletSigner);
167
167
  }
168
168
  /**
@@ -179,7 +179,7 @@ var TradingWithdrawsService = class {
179
179
  await this.#scales.ready();
180
180
  const { walletSigner, ...inputForValidation } = input;
181
181
  const resolvedInput = resolveAccountScopedInput(inputForValidation, this.#resolver);
182
- const validated = v.parse(this.#toExternalChainInputSchema, resolvedInput);
182
+ const validated = parse(this.#toExternalChainInputSchema, resolvedInput);
183
183
  return this.#prepareWithdraw(validated, walletSigner);
184
184
  }
185
185
  async #prepareWithdraw(validated, walletSigner) {
@@ -206,7 +206,7 @@ var TradingWithdrawsService = class {
206
206
  });
207
207
  return { submit: async (options) => {
208
208
  const response = await this.#client.createWalletTradingWithdraw(request, toConnectCallOptions(options));
209
- return v.parse(CreateWalletTradingWithdrawResultSchema, response);
209
+ return parse(CreateWalletTradingWithdrawResultSchema, response);
210
210
  } };
211
211
  }
212
212
  if (!validated.payloadSignature) throw new ValidationError("Trading withdraw requires a wallet signer or payload signature.");
@@ -216,7 +216,7 @@ var TradingWithdrawsService = class {
216
216
  });
217
217
  return { submit: async (options) => {
218
218
  const response = await this.#client.createTradingWithdraw(request, toConnectCallOptions(options));
219
- return v.parse(CreateTradingWithdrawResultSchema, response);
219
+ return parse(CreateTradingWithdrawResultSchema, response);
220
220
  } };
221
221
  }
222
222
  };
@@ -1 +1 @@
1
- {"version":3,"file":"trading-withdraws.js","names":["#client","Proto.WithdrawService","#resolver","#signingConfig","#catalog","#scales","#toFundingInputSchema","#toExternalChainInputSchema","#prepareWithdraw"],"sources":["../../../src/services/trading-withdraws/trading-withdraws.ts"],"sourcesContent":["import { ValidationError } from \"../../shared/errors.js\";\nimport { createClient, type Client, type Transport } from \"@connectrpc/connect\";\nimport type { Address, Hex } from \"viem\";\nimport {\n checksumEvmAddress,\n evmHexToBytes,\n evmUtf8ToBytes,\n keccak256Hex,\n} from \"../../utils/evm.js\";\nimport type { ClientCatalog } from \"../../catalogs/types.js\";\nimport * as Proto from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { idToBigInt } from \"../../utils/base58-id.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport * as v from \"valibot\";\nimport {\n createCreateTradingWithdrawToExternalChainInputSchema,\n createCreateTradingWithdrawToFundingInputSchema,\n CreateTradingWithdrawResultSchema,\n CreateWalletTradingWithdrawResultSchema,\n ValidateWithdrawDestinationInputSchema,\n ValidateWithdrawDestinationResultSchema,\n type CreateTradingWithdrawResult,\n type CreateTradingWithdrawToExternalChainInput,\n type CreateTradingWithdrawToExternalChainRequest,\n type CreateTradingWithdrawToFundingInput,\n type CreateTradingWithdrawToFundingRequest,\n type TradingWithdrawIntentPayloadRequest,\n type ValidateWithdrawDestinationInput,\n type ValidateWithdrawDestinationResult,\n} from \"./trading-withdraws.schemas.js\";\n\nexport type TradingWithdrawWalletTypedData = ReturnType<typeof buildTradingWithdrawWalletTypedData>;\n\nexport type TradingWithdrawWalletSigner = {\n signerWallet: string;\n accountId: string;\n signTypedData: (typedData: TradingWithdrawWalletTypedData) => Promise<Hex>;\n};\n\nexport type TradingWithdrawSigningConfig = {\n chainId: number;\n tradingGatewayAddress: Address;\n};\n\nexport type CreateTradingWithdrawToFundingServiceInput = CreateTradingWithdrawToFundingInput & {\n walletSigner?: TradingWithdrawWalletSigner;\n};\n\nexport type CreateTradingWithdrawToExternalChainServiceInput =\n CreateTradingWithdrawToExternalChainInput & {\n walletSigner?: TradingWithdrawWalletSigner;\n };\n\nexport type PreparedTradingWithdraw = Readonly<{\n /**\n * Submits the exact payload and signature produced during preparation.\n * Repeated calls only change transport options such as the step-up token.\n */\n submit: (options?: PolyesterMutationOptions) => Promise<CreateTradingWithdrawResult>;\n}>;\n\ntype TradingWithdrawRequest =\n | CreateTradingWithdrawToFundingRequest\n | CreateTradingWithdrawToExternalChainRequest;\n\nfunction fromU128(value: TradingWithdrawIntentPayloadRequest[\"amountE18\"] | undefined): bigint {\n if (!value) return 0n;\n return (value.hi << 64n) + value.lo;\n}\n\nfunction resolveTradingWithdrawTargetAccountId(params: {\n subaccountId: bigint | undefined;\n rootAccountId: string;\n}): bigint {\n if (params.subaccountId !== undefined) return params.subaccountId;\n return idToBigInt(params.rootAccountId, \"targetAccountId\");\n}\n\nasync function resolveTradingWithdrawSigningConfig(params: {\n fallback: TradingWithdrawSigningConfig;\n catalog?: ClientCatalog;\n}): Promise<TradingWithdrawSigningConfig> {\n if (!params.catalog) return params.fallback;\n\n try {\n await params.catalog.ensureReady();\n const gateway = params.catalog.zipper.getContractByName(\"tradingGateway\");\n const address = gateway?.address?.trim();\n if (!address?.startsWith(\"0x\")) return params.fallback;\n\n return {\n chainId: params.fallback.chainId,\n tradingGatewayAddress: checksumEvmAddress(address),\n };\n } catch {\n return params.fallback;\n }\n}\n\nfunction buildTradingWithdrawWalletTypedData(params: {\n signingConfig: TradingWithdrawSigningConfig;\n payload: TradingWithdrawIntentPayloadRequest;\n signerWallet: Address;\n accountId: bigint;\n targetAccountId: bigint;\n}) {\n const payload = params.payload;\n const destinationAddress = (payload.destinationAddress ?? \"\").trim();\n const idempotencyKey = payload.idempotencyKey.trim();\n\n return {\n domain: {\n name: \"Polyester Trading Withdraw\",\n version: \"1\",\n chainId: params.signingConfig.chainId,\n verifyingContract: params.signingConfig.tradingGatewayAddress,\n },\n types: {\n WalletTradingWithdraw: [\n { name: \"signerWallet\", type: \"address\" },\n { name: \"actionType\", type: \"uint8\" },\n { name: \"accountId\", type: \"uint64\" },\n { name: \"targetAccountId\", type: \"uint64\" },\n { name: \"assetId\", type: \"uint32\" },\n { name: \"destinationChainId\", type: \"uint64\" },\n { name: \"amountQ\", type: \"uint128\" },\n { name: \"destinationHash\", type: \"bytes32\" },\n { name: \"deadlineTsSec\", type: \"uint256\" },\n { name: \"nonce\", type: \"uint128\" },\n { name: \"idempotencyKeyHash\", type: \"bytes32\" },\n ],\n },\n primaryType: \"WalletTradingWithdraw\",\n message: {\n signerWallet: params.signerWallet,\n actionType: payload.action,\n accountId: params.accountId,\n targetAccountId: params.targetAccountId,\n assetId: payload.assetId,\n destinationChainId: payload.destinationChainId ?? 0n,\n amountQ: fromU128(payload.amountE18),\n destinationHash: keccak256Hex(evmUtf8ToBytes(destinationAddress)),\n deadlineTsSec: payload.deadlineTsSec,\n nonce: fromU128(payload.nonce),\n idempotencyKeyHash: keccak256Hex(evmUtf8ToBytes(idempotencyKey)),\n },\n } as const;\n}\n\nasync function resolveWalletSignature(params: {\n signingConfig: TradingWithdrawSigningConfig;\n payload: TradingWithdrawIntentPayloadRequest;\n walletSigner: TradingWithdrawWalletSigner;\n targetAccountId: bigint;\n}): Promise<{ signerWallet: string; payloadSignature: Uint8Array }> {\n const signerWallet = params.walletSigner.signerWallet.trim();\n if (!signerWallet.startsWith(\"0x\")) {\n throw new ValidationError(\"Trading withdraw signer wallet is required.\");\n }\n const accountId = idToBigInt(params.walletSigner.accountId, \"accountId\");\n const signature = await params.walletSigner.signTypedData(\n buildTradingWithdrawWalletTypedData({\n signingConfig: params.signingConfig,\n payload: params.payload,\n signerWallet: signerWallet as Address,\n accountId,\n targetAccountId: params.targetAccountId,\n }),\n );\n return {\n signerWallet,\n payloadSignature: evmHexToBytes(signature),\n };\n}\n\n/**\n * Creates durable Trading withdrawal intents to Funding using API signatures or wallet EIP-712 signatures.\n */\nexport class TradingWithdrawsService {\n #client: Client<typeof Proto.WithdrawService>;\n #resolver?: SubaccountResolver;\n #signingConfig: TradingWithdrawSigningConfig;\n #catalog?: ClientCatalog;\n #scales: SdkScales;\n #toFundingInputSchema: ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>;\n #toExternalChainInputSchema: ReturnType<\n typeof createCreateTradingWithdrawToExternalChainInputSchema\n >;\n\n constructor(\n transport: Transport,\n resolver: SubaccountResolver | undefined,\n signingConfig: TradingWithdrawSigningConfig,\n scales: SdkScales,\n catalog?: ClientCatalog,\n ) {\n this.#client = createClient(Proto.WithdrawService, transport);\n this.#resolver = resolver;\n this.#signingConfig = signingConfig;\n this.#catalog = catalog;\n this.#scales = scales;\n this.#toFundingInputSchema = createCreateTradingWithdrawToFundingInputSchema(scales);\n this.#toExternalChainInputSchema =\n createCreateTradingWithdrawToExternalChainInputSchema(scales);\n }\n\n /**\n * Checks whether an external-chain destination can receive a withdrawal without creating, signing, or reserving one.\n */\n async validateDestination(\n input: ValidateWithdrawDestinationInput,\n options?: PolyesterRequestOptions,\n ): Promise<ValidateWithdrawDestinationResult> {\n const request = v.parse(ValidateWithdrawDestinationInputSchema, input);\n const response = await this.#client.validateWithdrawDestination(\n request,\n toConnectCallOptions(options),\n );\n return v.parse(ValidateWithdrawDestinationResultSchema, response);\n }\n\n /**\n * Builds a Trading-to-Funding withdraw intent payload with asset id, decimal amount, destination address, five-minute deadline, nonce, and idempotency key. If a wallet signer is provided, it signs EIP-712 typed data and calls the wallet endpoint; otherwise a payload signature is required for the backend-authorized endpoint.\n */\n async createToFunding(\n input: CreateTradingWithdrawToFundingServiceInput,\n options?: PolyesterMutationOptions,\n ): Promise<CreateTradingWithdrawResult> {\n const prepared = await this.prepareToFunding(input);\n return prepared.submit(options);\n }\n\n /**\n * Builds and signs a Trading-to-Funding withdrawal once so the exact request can be\n * resubmitted after backend-directed authorization such as MFA step-up.\n */\n async prepareToFunding(\n input: CreateTradingWithdrawToFundingServiceInput,\n ): Promise<PreparedTradingWithdraw> {\n await this.#scales.ready();\n const { walletSigner, ...inputForValidation } = input;\n const resolvedInput = resolveAccountScopedInput(inputForValidation, this.#resolver);\n const validated = v.parse(this.#toFundingInputSchema, resolvedInput);\n return this.#prepareWithdraw(validated, walletSigner);\n }\n\n /**\n * Builds a Trading-to-external-chain withdraw intent payload with asset id, decimal gross amount, destination network, destination address, five-minute deadline, nonce, and idempotency key. If a wallet signer is provided, it signs EIP-712 typed data and calls the wallet endpoint; otherwise a payload signature is required for the backend-authorized endpoint.\n */\n async createToExternalChain(\n input: CreateTradingWithdrawToExternalChainServiceInput,\n options?: PolyesterMutationOptions,\n ): Promise<CreateTradingWithdrawResult> {\n const prepared = await this.prepareToExternalChain(input);\n return prepared.submit(options);\n }\n\n /**\n * Builds and signs a Trading-to-external-chain withdrawal once so the exact request can\n * be resubmitted after backend-directed authorization such as MFA step-up.\n */\n async prepareToExternalChain(\n input: CreateTradingWithdrawToExternalChainServiceInput,\n ): Promise<PreparedTradingWithdraw> {\n await this.#scales.ready();\n const { walletSigner, ...inputForValidation } = input;\n const resolvedInput = resolveAccountScopedInput(inputForValidation, this.#resolver);\n const validated = v.parse(this.#toExternalChainInputSchema, resolvedInput);\n return this.#prepareWithdraw(validated, walletSigner);\n }\n\n async #prepareWithdraw(\n validated: TradingWithdrawRequest,\n walletSigner: TradingWithdrawWalletSigner | undefined,\n ): Promise<PreparedTradingWithdraw> {\n if (walletSigner) {\n const signingConfig = await resolveTradingWithdrawSigningConfig({\n fallback: this.#signingConfig,\n catalog: this.#catalog,\n });\n const targetAccountId = resolveTradingWithdrawTargetAccountId({\n subaccountId: validated.subaccountId,\n rootAccountId: walletSigner.accountId,\n });\n\n const walletSignature = await resolveWalletSignature({\n signingConfig,\n payload: validated.payload,\n walletSigner,\n targetAccountId,\n });\n const request = removeUndefined({\n payload: validated.payload,\n subaccountId: validated.subaccountId,\n signerWallet: walletSignature.signerWallet,\n payloadSignature: walletSignature.payloadSignature,\n });\n return {\n submit: async (options) => {\n const response = await this.#client.createWalletTradingWithdraw(\n request,\n toConnectCallOptions(options),\n );\n return v.parse(CreateWalletTradingWithdrawResultSchema, response);\n },\n };\n }\n\n if (!validated.payloadSignature) {\n throw new ValidationError(\n \"Trading withdraw requires a wallet signer or payload signature.\",\n );\n }\n\n const request = removeUndefined({\n payload: validated.payload,\n payloadSignature: validated.payloadSignature,\n });\n return {\n submit: async (options) => {\n const response = await this.#client.createTradingWithdraw(\n request,\n toConnectCallOptions(options),\n );\n return v.parse(CreateTradingWithdrawResultSchema, response);\n },\n };\n }\n}\n"],"mappings":";;;;;;;;;;;AAwEA,SAAS,SAAS,OAA6E;CAC3F,IAAI,CAAC,OAAO,OAAO;CACnB,QAAQ,MAAM,MAAM,OAAO,MAAM;AACrC;AAEA,SAAS,sCAAsC,QAGpC;CACP,IAAI,OAAO,iBAAiB,KAAA,GAAW,OAAO,OAAO;CACrD,OAAO,WAAW,OAAO,eAAe,iBAAiB;AAC7D;AAEA,eAAe,oCAAoC,QAGT;CACtC,IAAI,CAAC,OAAO,SAAS,OAAO,OAAO;CAEnC,IAAI;EACA,MAAM,OAAO,QAAQ,YAAY;EAEjC,MAAM,UADU,OAAO,QAAQ,OAAO,kBAAkB,gBAClC,CAAC,EAAE,SAAS,KAAK;EACvC,IAAI,CAAC,SAAS,WAAW,IAAI,GAAG,OAAO,OAAO;EAE9C,OAAO;GACH,SAAS,OAAO,SAAS;GACzB,uBAAuB,mBAAmB,OAAO;EACrD;CACJ,QAAQ;EACJ,OAAO,OAAO;CAClB;AACJ;AAEA,SAAS,oCAAoC,QAM1C;CACC,MAAM,UAAU,OAAO;CACvB,MAAM,sBAAsB,QAAQ,sBAAsB,GAAA,CAAI,KAAK;CACnE,MAAM,iBAAiB,QAAQ,eAAe,KAAK;CAEnD,OAAO;EACH,QAAQ;GACJ,MAAM;GACN,SAAS;GACT,SAAS,OAAO,cAAc;GAC9B,mBAAmB,OAAO,cAAc;EAC5C;EACA,OAAO,EACH,uBAAuB;GACnB;IAAE,MAAM;IAAgB,MAAM;GAAU;GACxC;IAAE,MAAM;IAAc,MAAM;GAAQ;GACpC;IAAE,MAAM;IAAa,MAAM;GAAS;GACpC;IAAE,MAAM;IAAmB,MAAM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;GACD,MAAM,UAAU,gBAAgB;IAC5B,SAAS,UAAU;IACnB,cAAc,UAAU;IACxB,cAAc,gBAAgB;IAC9B,kBAAkB,gBAAgB;GACtC,CAAC;GACD,OAAO,EACH,QAAQ,OAAO,YAAY;IACvB,MAAM,WAAW,MAAM,KAAKJ,QAAQ,4BAChC,SACA,qBAAqB,OAAO,CAChC;IACA,OAAO,EAAE,MAAM,yCAAyC,QAAQ;GACpE,EACJ;EACJ;EAEA,IAAI,CAAC,UAAU,kBACX,MAAM,IAAI,gBACN,iEACJ;EAGJ,MAAM,UAAU,gBAAgB;GAC5B,SAAS,UAAU;GACnB,kBAAkB,UAAU;EAChC,CAAC;EACD,OAAO,EACH,QAAQ,OAAO,YAAY;GACvB,MAAM,WAAW,MAAM,KAAKA,QAAQ,sBAChC,SACA,qBAAqB,OAAO,CAChC;GACA,OAAO,EAAE,MAAM,mCAAmC,QAAQ;EAC9D,EACJ;CACJ;AACJ"}
1
+ {"version":3,"file":"trading-withdraws.js","names":["#client","Proto.WithdrawService","#resolver","#signingConfig","#catalog","#scales","#toFundingInputSchema","#toExternalChainInputSchema","v.parse","#prepareWithdraw"],"sources":["../../../src/services/trading-withdraws/trading-withdraws.ts"],"sourcesContent":["import { ValidationError } from \"../../shared/errors.js\";\nimport { createClient, type Client, type Transport } from \"@connectrpc/connect\";\nimport type { Address, Hex } from \"viem\";\nimport {\n checksumEvmAddress,\n evmHexToBytes,\n evmUtf8ToBytes,\n keccak256Hex,\n} from \"../../utils/evm.js\";\nimport type { ClientCatalog } from \"../../catalogs/types.js\";\nimport * as Proto from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { idToBigInt } from \"../../utils/base58-id.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport * as v from \"../../shared/validation.js\";\nimport {\n createCreateTradingWithdrawToExternalChainInputSchema,\n createCreateTradingWithdrawToFundingInputSchema,\n CreateTradingWithdrawResultSchema,\n CreateWalletTradingWithdrawResultSchema,\n ValidateWithdrawDestinationInputSchema,\n ValidateWithdrawDestinationResultSchema,\n type CreateTradingWithdrawResult,\n type CreateTradingWithdrawToExternalChainInput,\n type CreateTradingWithdrawToExternalChainRequest,\n type CreateTradingWithdrawToFundingInput,\n type CreateTradingWithdrawToFundingRequest,\n type TradingWithdrawIntentPayloadRequest,\n type ValidateWithdrawDestinationInput,\n type ValidateWithdrawDestinationResult,\n} from \"./trading-withdraws.schemas.js\";\n\nexport type TradingWithdrawWalletTypedData = ReturnType<typeof buildTradingWithdrawWalletTypedData>;\n\nexport type TradingWithdrawWalletSigner = {\n signerWallet: string;\n accountId: string;\n signTypedData: (typedData: TradingWithdrawWalletTypedData) => Promise<Hex>;\n};\n\nexport type TradingWithdrawSigningConfig = {\n chainId: number;\n tradingGatewayAddress: Address;\n};\n\nexport type CreateTradingWithdrawToFundingServiceInput = CreateTradingWithdrawToFundingInput & {\n walletSigner?: TradingWithdrawWalletSigner;\n};\n\nexport type CreateTradingWithdrawToExternalChainServiceInput =\n CreateTradingWithdrawToExternalChainInput & {\n walletSigner?: TradingWithdrawWalletSigner;\n };\n\nexport type PreparedTradingWithdraw = Readonly<{\n /**\n * Submits the exact payload and signature produced during preparation.\n * Repeated calls only change transport options such as the step-up token.\n */\n submit: (options?: PolyesterMutationOptions) => Promise<CreateTradingWithdrawResult>;\n}>;\n\ntype TradingWithdrawRequest =\n | CreateTradingWithdrawToFundingRequest\n | CreateTradingWithdrawToExternalChainRequest;\n\nfunction fromU128(value: TradingWithdrawIntentPayloadRequest[\"amountE18\"] | undefined): bigint {\n if (!value) return 0n;\n return (value.hi << 64n) + value.lo;\n}\n\nfunction resolveTradingWithdrawTargetAccountId(params: {\n subaccountId: bigint | undefined;\n rootAccountId: string;\n}): bigint {\n if (params.subaccountId !== undefined) return params.subaccountId;\n return idToBigInt(params.rootAccountId, \"targetAccountId\");\n}\n\nasync function resolveTradingWithdrawSigningConfig(params: {\n fallback: TradingWithdrawSigningConfig;\n catalog?: ClientCatalog;\n}): Promise<TradingWithdrawSigningConfig> {\n if (!params.catalog) return params.fallback;\n\n try {\n await params.catalog.ensureReady();\n const gateway = params.catalog.zipper.getContractByName(\"tradingGateway\");\n const address = gateway?.address?.trim();\n if (!address?.startsWith(\"0x\")) return params.fallback;\n\n return {\n chainId: params.fallback.chainId,\n tradingGatewayAddress: checksumEvmAddress(address),\n };\n } catch {\n return params.fallback;\n }\n}\n\nfunction buildTradingWithdrawWalletTypedData(params: {\n signingConfig: TradingWithdrawSigningConfig;\n payload: TradingWithdrawIntentPayloadRequest;\n signerWallet: Address;\n accountId: bigint;\n targetAccountId: bigint;\n}) {\n const payload = params.payload;\n const destinationAddress = (payload.destinationAddress ?? \"\").trim();\n const idempotencyKey = payload.idempotencyKey.trim();\n\n return {\n domain: {\n name: \"Polyester Trading Withdraw\",\n version: \"1\",\n chainId: params.signingConfig.chainId,\n verifyingContract: params.signingConfig.tradingGatewayAddress,\n },\n types: {\n WalletTradingWithdraw: [\n { name: \"signerWallet\", type: \"address\" },\n { name: \"actionType\", type: \"uint8\" },\n { name: \"accountId\", type: \"uint64\" },\n { name: \"targetAccountId\", type: \"uint64\" },\n { name: \"assetId\", type: \"uint32\" },\n { name: \"destinationChainId\", type: \"uint64\" },\n { name: \"amountQ\", type: \"uint128\" },\n { name: \"destinationHash\", type: \"bytes32\" },\n { name: \"deadlineTsSec\", type: \"uint256\" },\n { name: \"nonce\", type: \"uint128\" },\n { name: \"idempotencyKeyHash\", type: \"bytes32\" },\n ],\n },\n primaryType: \"WalletTradingWithdraw\",\n message: {\n signerWallet: params.signerWallet,\n actionType: payload.action,\n accountId: params.accountId,\n targetAccountId: params.targetAccountId,\n assetId: payload.assetId,\n destinationChainId: payload.destinationChainId ?? 0n,\n amountQ: fromU128(payload.amountE18),\n destinationHash: keccak256Hex(evmUtf8ToBytes(destinationAddress)),\n deadlineTsSec: payload.deadlineTsSec,\n nonce: fromU128(payload.nonce),\n idempotencyKeyHash: keccak256Hex(evmUtf8ToBytes(idempotencyKey)),\n },\n } as const;\n}\n\nasync function resolveWalletSignature(params: {\n signingConfig: TradingWithdrawSigningConfig;\n payload: TradingWithdrawIntentPayloadRequest;\n walletSigner: TradingWithdrawWalletSigner;\n targetAccountId: bigint;\n}): Promise<{ signerWallet: string; payloadSignature: Uint8Array }> {\n const signerWallet = params.walletSigner.signerWallet.trim();\n if (!signerWallet.startsWith(\"0x\")) {\n throw new ValidationError(\"Trading withdraw signer wallet is required.\");\n }\n const accountId = idToBigInt(params.walletSigner.accountId, \"accountId\");\n const signature = await params.walletSigner.signTypedData(\n buildTradingWithdrawWalletTypedData({\n signingConfig: params.signingConfig,\n payload: params.payload,\n signerWallet: signerWallet as Address,\n accountId,\n targetAccountId: params.targetAccountId,\n }),\n );\n return {\n signerWallet,\n payloadSignature: evmHexToBytes(signature),\n };\n}\n\n/**\n * Creates durable Trading withdrawal intents to Funding using API signatures or wallet EIP-712 signatures.\n */\nexport class TradingWithdrawsService {\n #client: Client<typeof Proto.WithdrawService>;\n #resolver?: SubaccountResolver;\n #signingConfig: TradingWithdrawSigningConfig;\n #catalog?: ClientCatalog;\n #scales: SdkScales;\n #toFundingInputSchema: ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>;\n #toExternalChainInputSchema: ReturnType<\n typeof createCreateTradingWithdrawToExternalChainInputSchema\n >;\n\n constructor(\n transport: Transport,\n resolver: SubaccountResolver | undefined,\n signingConfig: TradingWithdrawSigningConfig,\n scales: SdkScales,\n catalog?: ClientCatalog,\n ) {\n this.#client = createClient(Proto.WithdrawService, transport);\n this.#resolver = resolver;\n this.#signingConfig = signingConfig;\n this.#catalog = catalog;\n this.#scales = scales;\n this.#toFundingInputSchema = createCreateTradingWithdrawToFundingInputSchema(scales);\n this.#toExternalChainInputSchema =\n createCreateTradingWithdrawToExternalChainInputSchema(scales);\n }\n\n /**\n * Checks whether an external-chain destination can receive a withdrawal without creating, signing, or reserving one.\n */\n async validateDestination(\n input: ValidateWithdrawDestinationInput,\n options?: PolyesterRequestOptions,\n ): Promise<ValidateWithdrawDestinationResult> {\n const request = v.parse(ValidateWithdrawDestinationInputSchema, input);\n const response = await this.#client.validateWithdrawDestination(\n request,\n toConnectCallOptions(options),\n );\n return v.parse(ValidateWithdrawDestinationResultSchema, response);\n }\n\n /**\n * Builds a Trading-to-Funding withdraw intent payload with asset id, decimal amount, destination address, five-minute deadline, nonce, and idempotency key. If a wallet signer is provided, it signs EIP-712 typed data and calls the wallet endpoint; otherwise a payload signature is required for the backend-authorized endpoint.\n */\n async createToFunding(\n input: CreateTradingWithdrawToFundingServiceInput,\n options?: PolyesterMutationOptions,\n ): Promise<CreateTradingWithdrawResult> {\n const prepared = await this.prepareToFunding(input);\n return prepared.submit(options);\n }\n\n /**\n * Builds and signs a Trading-to-Funding withdrawal once so the exact request can be\n * resubmitted after backend-directed authorization such as MFA step-up.\n */\n async prepareToFunding(\n input: CreateTradingWithdrawToFundingServiceInput,\n ): Promise<PreparedTradingWithdraw> {\n await this.#scales.ready();\n const { walletSigner, ...inputForValidation } = input;\n const resolvedInput = resolveAccountScopedInput(inputForValidation, this.#resolver);\n const validated = v.parse(this.#toFundingInputSchema, resolvedInput);\n return this.#prepareWithdraw(validated, walletSigner);\n }\n\n /**\n * Builds a Trading-to-external-chain withdraw intent payload with asset id, decimal gross amount, destination network, destination address, five-minute deadline, nonce, and idempotency key. If a wallet signer is provided, it signs EIP-712 typed data and calls the wallet endpoint; otherwise a payload signature is required for the backend-authorized endpoint.\n */\n async createToExternalChain(\n input: CreateTradingWithdrawToExternalChainServiceInput,\n options?: PolyesterMutationOptions,\n ): Promise<CreateTradingWithdrawResult> {\n const prepared = await this.prepareToExternalChain(input);\n return prepared.submit(options);\n }\n\n /**\n * Builds and signs a Trading-to-external-chain withdrawal once so the exact request can\n * be resubmitted after backend-directed authorization such as MFA step-up.\n */\n async prepareToExternalChain(\n input: CreateTradingWithdrawToExternalChainServiceInput,\n ): Promise<PreparedTradingWithdraw> {\n await this.#scales.ready();\n const { walletSigner, ...inputForValidation } = input;\n const resolvedInput = resolveAccountScopedInput(inputForValidation, this.#resolver);\n const validated = v.parse(this.#toExternalChainInputSchema, resolvedInput);\n return this.#prepareWithdraw(validated, walletSigner);\n }\n\n async #prepareWithdraw(\n validated: TradingWithdrawRequest,\n walletSigner: TradingWithdrawWalletSigner | undefined,\n ): Promise<PreparedTradingWithdraw> {\n if (walletSigner) {\n const signingConfig = await resolveTradingWithdrawSigningConfig({\n fallback: this.#signingConfig,\n catalog: this.#catalog,\n });\n const targetAccountId = resolveTradingWithdrawTargetAccountId({\n subaccountId: validated.subaccountId,\n rootAccountId: walletSigner.accountId,\n });\n\n const walletSignature = await resolveWalletSignature({\n signingConfig,\n payload: validated.payload,\n walletSigner,\n targetAccountId,\n });\n const request = removeUndefined({\n payload: validated.payload,\n subaccountId: validated.subaccountId,\n signerWallet: walletSignature.signerWallet,\n payloadSignature: walletSignature.payloadSignature,\n });\n return {\n submit: async (options) => {\n const response = await this.#client.createWalletTradingWithdraw(\n request,\n toConnectCallOptions(options),\n );\n return v.parse(CreateWalletTradingWithdrawResultSchema, response);\n },\n };\n }\n\n if (!validated.payloadSignature) {\n throw new ValidationError(\n \"Trading withdraw requires a wallet signer or payload signature.\",\n );\n }\n\n const request = removeUndefined({\n payload: validated.payload,\n payloadSignature: validated.payloadSignature,\n });\n return {\n submit: async (options) => {\n const response = await this.#client.createTradingWithdraw(\n request,\n toConnectCallOptions(options),\n );\n return v.parse(CreateTradingWithdrawResultSchema, response);\n },\n };\n }\n}\n"],"mappings":";;;;;;;;;;;AAwEA,SAAS,SAAS,OAA6E;CAC3F,IAAI,CAAC,OAAO,OAAO;CACnB,QAAQ,MAAM,MAAM,OAAO,MAAM;AACrC;AAE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AU,gBAAgB;GAC5B,SAAS,UAAU;GACnB,kBAAkB,UAAU;EAChC,CAAC;EACD,OAAO,EACH,QAAQ,OAAO,YAAY;GACvB,MAAM,WAAW,MAAM,KAAKR,QAAQ,sBAChC,SACA,qBAAqB,OAAO,CAChC;GACA,OAAOQ,MAAQ,mCAAmC,QAAQ;EAC9D,EACJ;CACJ;AACJ"}
@@ -1,7 +1,7 @@
1
+ import { validation_d_exports } from "../../shared/validation.js";
1
2
  import { TradingWithdrawAction, WithdrawDestinationValidationCode } from "../../gen/chain/withdraw/v1/withdraw_pb.js";
2
3
  import { SdkScales } from "../../shared/decimal-surface.js";
3
4
  import { U128Value } from "../../utils/u128.js";
4
- import * as v from "valibot";
5
5
  //#region src/services/trading-withdraws/trading-withdraws.schemas.d.ts
6
6
  type TradingWithdrawIntentPayloadRequest = {
7
7
  action: TradingWithdrawAction;
@@ -18,17 +18,17 @@ type CreateTradingWithdrawRequestBase = {
18
18
  payload: TradingWithdrawIntentPayloadRequest;
19
19
  payloadSignature?: Uint8Array;
20
20
  };
21
- declare function createCreateTradingWithdrawToFundingInputSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
22
- readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
23
- readonly quantity: v.StringSchema<undefined>;
24
- readonly idempotencyKey: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
25
- readonly destinationAddress: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
26
- readonly signerWallet: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
27
- readonly payloadSignature: v.OptionalSchema<v.InstanceSchema<Uint8ArrayConstructor, undefined>, undefined>;
28
- readonly account: v.OptionalSchema<v.UnionSchema<[v.PicklistSchema<["active", "main"], undefined>, v.StrictObjectSchema<{
29
- readonly subaccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
21
+ declare function createCreateTradingWithdrawToFundingInputSchema(scales: SdkScales): validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.StrictObjectSchema<{
22
+ readonly assetId: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.NumberSchema<undefined>, validation_d_exports.IntegerAction<number, undefined>, validation_d_exports.GtValueAction<number, 0, undefined>]>;
23
+ readonly quantity: validation_d_exports.StringSchema<undefined>;
24
+ readonly idempotencyKey: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.StringSchema<undefined>, validation_d_exports.TrimAction, validation_d_exports.MinLengthAction<string, 1, undefined>]>;
25
+ readonly destinationAddress: validation_d_exports.OptionalSchema<validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.StringSchema<undefined>, validation_d_exports.TrimAction]>, "">;
26
+ readonly signerWallet: validation_d_exports.OptionalSchema<validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.StringSchema<undefined>, validation_d_exports.TrimAction]>, "">;
27
+ readonly payloadSignature: validation_d_exports.OptionalSchema<validation_d_exports.InstanceSchema<Uint8ArrayConstructor, undefined>, undefined>;
28
+ readonly account: validation_d_exports.OptionalSchema<validation_d_exports.UnionSchema<[validation_d_exports.PicklistSchema<["active", "main"], undefined>, validation_d_exports.StrictObjectSchema<{
29
+ readonly subaccountId: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.StringSchema<undefined>, validation_d_exports.TrimAction, validation_d_exports.MinLengthAction<string, 1, undefined>]>;
30
30
  }, undefined>], undefined>, undefined>;
31
- }, undefined>, v.TransformAction<{
31
+ }, undefined>, validation_d_exports.TransformAction<{
32
32
  assetId: number;
33
33
  quantity: string;
34
34
  idempotencyKey: string;
@@ -39,18 +39,18 @@ declare function createCreateTradingWithdrawToFundingInputSchema(scales: SdkScal
39
39
  subaccountId: string;
40
40
  } | undefined;
41
41
  }, CreateTradingWithdrawRequestBase>]>;
42
- declare function createCreateTradingWithdrawToExternalChainInputSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
43
- readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>]>;
44
- readonly quantity: v.StringSchema<undefined>;
45
- readonly destinationChainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, number, undefined>]>;
46
- readonly destinationAddress: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
47
- readonly idempotencyKey: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
48
- readonly signerWallet: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
49
- readonly payloadSignature: v.OptionalSchema<v.InstanceSchema<Uint8ArrayConstructor, undefined>, undefined>;
50
- readonly account: v.OptionalSchema<v.UnionSchema<[v.PicklistSchema<["active", "main"], undefined>, v.StrictObjectSchema<{
51
- readonly subaccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
42
+ declare function createCreateTradingWithdrawToExternalChainInputSchema(scales: SdkScales): validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.StrictObjectSchema<{
43
+ readonly assetId: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.NumberSchema<undefined>, validation_d_exports.IntegerAction<number, undefined>, validation_d_exports.GtValueAction<number, 0, undefined>]>;
44
+ readonly quantity: validation_d_exports.StringSchema<undefined>;
45
+ readonly destinationChainId: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.NumberSchema<undefined>, validation_d_exports.IntegerAction<number, undefined>, validation_d_exports.GtValueAction<number, 0, undefined>, validation_d_exports.MaxValueAction<number, number, undefined>]>;
46
+ readonly destinationAddress: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.StringSchema<undefined>, validation_d_exports.TrimAction, validation_d_exports.MinLengthAction<string, 1, undefined>]>;
47
+ readonly idempotencyKey: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.StringSchema<undefined>, validation_d_exports.TrimAction, validation_d_exports.MinLengthAction<string, 1, undefined>]>;
48
+ readonly signerWallet: validation_d_exports.OptionalSchema<validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.StringSchema<undefined>, validation_d_exports.TrimAction]>, "">;
49
+ readonly payloadSignature: validation_d_exports.OptionalSchema<validation_d_exports.InstanceSchema<Uint8ArrayConstructor, undefined>, undefined>;
50
+ readonly account: validation_d_exports.OptionalSchema<validation_d_exports.UnionSchema<[validation_d_exports.PicklistSchema<["active", "main"], undefined>, validation_d_exports.StrictObjectSchema<{
51
+ readonly subaccountId: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.StringSchema<undefined>, validation_d_exports.TrimAction, validation_d_exports.MinLengthAction<string, 1, undefined>]>;
52
52
  }, undefined>], undefined>, undefined>;
53
- }, undefined>, v.TransformAction<{
53
+ }, undefined>, validation_d_exports.TransformAction<{
54
54
  assetId: number;
55
55
  quantity: string;
56
56
  destinationChainId: number;
@@ -62,29 +62,29 @@ declare function createCreateTradingWithdrawToExternalChainInputSchema(scales: S
62
62
  subaccountId: string;
63
63
  } | undefined;
64
64
  }, CreateTradingWithdrawRequestBase>]>;
65
- type CreateTradingWithdrawToFundingInput = v.InferInput<ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>>;
66
- type CreateTradingWithdrawToExternalChainInput = v.InferInput<ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>>;
67
- declare const CreateTradingWithdrawResultSchema: v.ObjectSchema<{
68
- readonly intentId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
65
+ type CreateTradingWithdrawToFundingInput = validation_d_exports.InferInput<ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>>;
66
+ type CreateTradingWithdrawToExternalChainInput = validation_d_exports.InferInput<ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>>;
67
+ declare const CreateTradingWithdrawResultSchema: validation_d_exports.ObjectSchema<{
68
+ readonly intentId: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.StringSchema<undefined>, validation_d_exports.TrimAction, validation_d_exports.MinLengthAction<string, 1, undefined>]>;
69
69
  }, undefined>;
70
- type CreateTradingWithdrawResult = v.InferOutput<typeof CreateTradingWithdrawResultSchema>;
71
- declare const ValidateWithdrawDestinationInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
72
- readonly destinationChainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, number, undefined>]>;
73
- readonly destinationAddress: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
74
- }, undefined>, v.TransformAction<{
70
+ type CreateTradingWithdrawResult = validation_d_exports.InferOutput<typeof CreateTradingWithdrawResultSchema>;
71
+ declare const ValidateWithdrawDestinationInputSchema: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.StrictObjectSchema<{
72
+ readonly destinationChainId: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.NumberSchema<undefined>, validation_d_exports.IntegerAction<number, undefined>, validation_d_exports.GtValueAction<number, 0, undefined>, validation_d_exports.MaxValueAction<number, number, undefined>]>;
73
+ readonly destinationAddress: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.StringSchema<undefined>, validation_d_exports.TrimAction, validation_d_exports.MinLengthAction<string, 1, undefined>]>;
74
+ }, undefined>, validation_d_exports.TransformAction<{
75
75
  destinationChainId: number;
76
76
  destinationAddress: string;
77
77
  }, {
78
78
  destinationChainId: bigint;
79
79
  destinationAddress: string;
80
80
  }>]>;
81
- type ValidateWithdrawDestinationInput = v.InferInput<typeof ValidateWithdrawDestinationInputSchema>;
82
- declare const ValidateWithdrawDestinationResultSchema: v.UnionSchema<[v.SchemaWithPipe<readonly [v.ObjectSchema<{
83
- readonly valid: v.LiteralSchema<true, undefined>;
84
- readonly code: v.LiteralSchema<WithdrawDestinationValidationCode.VALID, undefined>;
85
- readonly message: v.StringSchema<undefined>;
86
- readonly canonicalDestinationAddress: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
87
- }, undefined>, v.TransformAction<{
81
+ type ValidateWithdrawDestinationInput = validation_d_exports.InferInput<typeof ValidateWithdrawDestinationInputSchema>;
82
+ declare const ValidateWithdrawDestinationResultSchema: validation_d_exports.UnionSchema<[validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.ObjectSchema<{
83
+ readonly valid: validation_d_exports.LiteralSchema<true, undefined>;
84
+ readonly code: validation_d_exports.LiteralSchema<WithdrawDestinationValidationCode.VALID, undefined>;
85
+ readonly message: validation_d_exports.StringSchema<undefined>;
86
+ readonly canonicalDestinationAddress: validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.StringSchema<undefined>, validation_d_exports.TrimAction, validation_d_exports.MinLengthAction<string, 1, undefined>]>;
87
+ }, undefined>, validation_d_exports.TransformAction<{
88
88
  valid: true;
89
89
  code: WithdrawDestinationValidationCode.VALID;
90
90
  message: string;
@@ -94,12 +94,12 @@ declare const ValidateWithdrawDestinationResultSchema: v.UnionSchema<[v.SchemaWi
94
94
  valid: true;
95
95
  message: string;
96
96
  canonicalDestinationAddress: string;
97
- }>]>, v.SchemaWithPipe<readonly [v.ObjectSchema<{
98
- readonly valid: v.LiteralSchema<false, undefined>;
99
- readonly code: v.PicklistSchema<[WithdrawDestinationValidationCode.RESULT_UNSPECIFIED, WithdrawDestinationValidationCode.INVALID_ADDRESS, WithdrawDestinationValidationCode.UNSUPPORTED_CHAIN, WithdrawDestinationValidationCode.POLYESTER_SMART_ACCOUNT, WithdrawDestinationValidationCode.TOKEN_CONTRACT, WithdrawDestinationValidationCode.DENYLISTED_ADDRESS], undefined>;
100
- readonly message: v.StringSchema<undefined>;
101
- readonly canonicalDestinationAddress: v.StringSchema<undefined>;
102
- }, undefined>, v.TransformAction<{
97
+ }>]>, validation_d_exports.SchemaWithPipe<readonly [validation_d_exports.ObjectSchema<{
98
+ readonly valid: validation_d_exports.LiteralSchema<false, undefined>;
99
+ readonly code: validation_d_exports.PicklistSchema<[WithdrawDestinationValidationCode.RESULT_UNSPECIFIED, WithdrawDestinationValidationCode.INVALID_ADDRESS, WithdrawDestinationValidationCode.UNSUPPORTED_CHAIN, WithdrawDestinationValidationCode.POLYESTER_SMART_ACCOUNT, WithdrawDestinationValidationCode.TOKEN_CONTRACT, WithdrawDestinationValidationCode.DENYLISTED_ADDRESS], undefined>;
100
+ readonly message: validation_d_exports.StringSchema<undefined>;
101
+ readonly canonicalDestinationAddress: validation_d_exports.StringSchema<undefined>;
102
+ }, undefined>, validation_d_exports.TransformAction<{
103
103
  valid: false;
104
104
  code: WithdrawDestinationValidationCode.RESULT_UNSPECIFIED | WithdrawDestinationValidationCode.INVALID_ADDRESS | WithdrawDestinationValidationCode.UNSUPPORTED_CHAIN | WithdrawDestinationValidationCode.POLYESTER_SMART_ACCOUNT | WithdrawDestinationValidationCode.TOKEN_CONTRACT | WithdrawDestinationValidationCode.DENYLISTED_ADDRESS;
105
105
  message: string;
@@ -110,7 +110,7 @@ declare const ValidateWithdrawDestinationResultSchema: v.UnionSchema<[v.SchemaWi
110
110
  message: string;
111
111
  canonicalDestinationAddress: string;
112
112
  }>]>], undefined>;
113
- type ValidateWithdrawDestinationResult = v.InferOutput<typeof ValidateWithdrawDestinationResultSchema>;
113
+ type ValidateWithdrawDestinationResult = validation_d_exports.InferOutput<typeof ValidateWithdrawDestinationResultSchema>;
114
114
  //#endregion
115
115
  export { CreateTradingWithdrawResult, CreateTradingWithdrawResultSchema, CreateTradingWithdrawToExternalChainInput, CreateTradingWithdrawToFundingInput, TradingWithdrawIntentPayloadRequest, ValidateWithdrawDestinationInput, ValidateWithdrawDestinationInputSchema, ValidateWithdrawDestinationResult, ValidateWithdrawDestinationResultSchema, createCreateTradingWithdrawToExternalChainInputSchema, createCreateTradingWithdrawToFundingInputSchema };
116
116
  //# sourceMappingURL=trading-withdraws.schemas.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"trading-withdraws.schemas.d.ts","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"mappings":";;;;;KAgBY;EACR,QAAQ;EACR;EACA;EACA,WAAW;EACX;EACA,OAAO;EACP;EACA;;KAGC;EACD;EACA,SAAS;EACT,mBAAmB;;iBAoCP,gDAAgD,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;GA+BhF;iBAEe,sDAAsD,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;GAqCtF;KAEW,sCAAsC,EAAE,WAChD,kBAAkB;KAOV,4CAA4C,EAAE,WACtD,kBAAkB;cAOT,mCAAiC,EAAA;;;KAIlC,8BAA8B,EAAE,mBAAmB;cAOlD,wCAAsC,EAAA,yBAAA,EAAA;;;;;;;;;;KAgBvC,mCAAmC,EAAE,kBACtC;cA4CE,yCAAuC,EAAA,aAAA,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAKxC,oCAAoC,EAAE,mBACvC"}
1
+ {"version":3,"file":"trading-withdraws.schemas.d.ts","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"mappings":";;;;;KAgBY;EACR,QAAQ;EACR;EACA;EACA,WAAW;EACX;EACA,OAAO;EACP;EACA;;KAGC;EACD;EACA,SAAS;EACT,mBAAmB;;iBAoCP,gDAAgD,QAAQ,YAAS,qBAAA,yBAAA,qBAAA;;;;;;;;;;;;;;;;;;;;GA+BhF;iBAEe,sDAAsD,QAAQ,YAAS,qBAAA,yBAAA,qBAAA;;;;;;;;;;;;;;;;;;;;;;GAqCtF;KAEW,sCAAsC,qBAAE,WAChD,kBAAkB;KAOV,4CAA4C,qBAAE,WACtD,kBAAkB;cAOT,mCAAiC,qBAAA;;;KAIlC,8BAA8B,qBAAE,mBAAmB;cAOlD,wCAAsC,qBAAA,yBAAA,qBAAA;;;;;;;;;;KAgBvC,mCAAmC,qBAAE,kBACtC;cA4CE,yCAAuC,qBAAA,aAAA,qBAAA,yBAAA,qBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAKxC,oCAAoC,qBAAE,mBACvC"}
@@ -1,9 +1,9 @@
1
+ import { validation_exports } from "../../shared/validation.js";
1
2
  import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
2
3
  import { quantityInputToE18 } from "../../shared/decimal-surface.js";
3
4
  import { toU128 } from "../../utils/u128.js";
4
5
  import "../../gen/chain/withdraw/v1/withdraw_pb.js";
5
6
  import { TradingWithdrawActionCodec, WithdrawDestinationValidationCodeCodec } from "./trading-withdraws.codecs.js";
6
- import * as v from "valibot";
7
7
  //#region src/services/trading-withdraws/trading-withdraws.schemas.ts
8
8
  const DEFAULT_DEADLINE_SECONDS = 300;
9
9
  function createNonce() {
@@ -30,15 +30,15 @@ function createTradingWithdrawPayload(input) {
30
30
  };
31
31
  }
32
32
  function createCreateTradingWithdrawToFundingInputSchema(scales) {
33
- return v.pipe(v.strictObject({
33
+ return validation_exports.pipe(validation_exports.strictObject({
34
34
  ...AccountScopeInputEntries,
35
- assetId: v.pipe(v.number(), v.integer(), v.gtValue(0)),
36
- quantity: v.string(),
37
- idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),
38
- destinationAddress: v.optional(v.pipe(v.string(), v.trim()), ""),
39
- signerWallet: v.optional(v.pipe(v.string(), v.trim()), ""),
40
- payloadSignature: v.optional(v.instance(Uint8Array))
41
- }), v.transform((input) => {
35
+ assetId: validation_exports.pipe(validation_exports.number(), validation_exports.integer(), validation_exports.gtValue(0)),
36
+ quantity: validation_exports.string(),
37
+ idempotencyKey: validation_exports.pipe(validation_exports.string(), validation_exports.trim(), validation_exports.minLength(1)),
38
+ destinationAddress: validation_exports.optional(validation_exports.pipe(validation_exports.string(), validation_exports.trim()), ""),
39
+ signerWallet: validation_exports.optional(validation_exports.pipe(validation_exports.string(), validation_exports.trim()), ""),
40
+ payloadSignature: validation_exports.optional(validation_exports.instance(Uint8Array))
41
+ }), validation_exports.transform((input) => {
42
42
  const quantityScaled = quantityInputToE18({
43
43
  scales,
44
44
  assetId: input.assetId,
@@ -59,16 +59,16 @@ function createCreateTradingWithdrawToFundingInputSchema(scales) {
59
59
  }));
60
60
  }
61
61
  function createCreateTradingWithdrawToExternalChainInputSchema(scales) {
62
- return v.pipe(v.strictObject({
62
+ return validation_exports.pipe(validation_exports.strictObject({
63
63
  ...AccountScopeInputEntries,
64
- assetId: v.pipe(v.number(), v.integer(), v.gtValue(0)),
65
- quantity: v.string(),
66
- destinationChainId: v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(Number.MAX_SAFE_INTEGER)),
67
- destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),
68
- idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),
69
- signerWallet: v.optional(v.pipe(v.string(), v.trim()), ""),
70
- payloadSignature: v.optional(v.instance(Uint8Array))
71
- }), v.transform((input) => {
64
+ assetId: validation_exports.pipe(validation_exports.number(), validation_exports.integer(), validation_exports.gtValue(0)),
65
+ quantity: validation_exports.string(),
66
+ destinationChainId: validation_exports.pipe(validation_exports.number(), validation_exports.integer(), validation_exports.gtValue(0), validation_exports.maxValue(Number.MAX_SAFE_INTEGER)),
67
+ destinationAddress: validation_exports.pipe(validation_exports.string(), validation_exports.trim(), validation_exports.minLength(1)),
68
+ idempotencyKey: validation_exports.pipe(validation_exports.string(), validation_exports.trim(), validation_exports.minLength(1)),
69
+ signerWallet: validation_exports.optional(validation_exports.pipe(validation_exports.string(), validation_exports.trim()), ""),
70
+ payloadSignature: validation_exports.optional(validation_exports.instance(Uint8Array))
71
+ }), validation_exports.transform((input) => {
72
72
  const quantityScaled = quantityInputToE18({
73
73
  scales,
74
74
  assetId: input.assetId,
@@ -88,28 +88,28 @@ function createCreateTradingWithdrawToExternalChainInputSchema(scales) {
88
88
  };
89
89
  }));
90
90
  }
91
- const CreateTradingWithdrawResultSchema = v.object({ intentId: v.pipe(v.string(), v.trim(), v.minLength(1)) });
91
+ const CreateTradingWithdrawResultSchema = validation_exports.object({ intentId: validation_exports.pipe(validation_exports.string(), validation_exports.trim(), validation_exports.minLength(1)) });
92
92
  const CreateWalletTradingWithdrawResultSchema = CreateTradingWithdrawResultSchema;
93
- const ValidateWithdrawDestinationInputSchema = v.pipe(v.strictObject({
94
- destinationChainId: v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(Number.MAX_SAFE_INTEGER)),
95
- destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1))
96
- }), v.transform((input) => ({
93
+ const ValidateWithdrawDestinationInputSchema = validation_exports.pipe(validation_exports.strictObject({
94
+ destinationChainId: validation_exports.pipe(validation_exports.number(), validation_exports.integer(), validation_exports.gtValue(0), validation_exports.maxValue(Number.MAX_SAFE_INTEGER)),
95
+ destinationAddress: validation_exports.pipe(validation_exports.string(), validation_exports.trim(), validation_exports.minLength(1))
96
+ }), validation_exports.transform((input) => ({
97
97
  destinationChainId: BigInt(input.destinationChainId),
98
98
  destinationAddress: input.destinationAddress
99
99
  })));
100
- const ValidWithdrawDestinationResultSchema = v.pipe(v.object({
101
- valid: v.literal(true),
102
- code: v.literal(1),
103
- message: v.string(),
104
- canonicalDestinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1))
105
- }), v.transform((result) => ({
100
+ const ValidWithdrawDestinationResultSchema = validation_exports.pipe(validation_exports.object({
101
+ valid: validation_exports.literal(true),
102
+ code: validation_exports.literal(1),
103
+ message: validation_exports.string(),
104
+ canonicalDestinationAddress: validation_exports.pipe(validation_exports.string(), validation_exports.trim(), validation_exports.minLength(1))
105
+ }), validation_exports.transform((result) => ({
106
106
  ...result,
107
107
  code: WithdrawDestinationValidationCodeCodec.protoToOutput[result.code]
108
108
  })));
109
109
  const { [1]: _validWithdrawDestinationCode, ...InvalidWithdrawDestinationCodeCodec } = WithdrawDestinationValidationCodeCodec.protoToOutput;
110
- const InvalidWithdrawDestinationResultSchema = v.pipe(v.object({
111
- valid: v.literal(false),
112
- code: v.picklist([
110
+ const InvalidWithdrawDestinationResultSchema = validation_exports.pipe(validation_exports.object({
111
+ valid: validation_exports.literal(false),
112
+ code: validation_exports.picklist([
113
113
  0,
114
114
  2,
115
115
  3,
@@ -117,13 +117,13 @@ const InvalidWithdrawDestinationResultSchema = v.pipe(v.object({
117
117
  5,
118
118
  6
119
119
  ]),
120
- message: v.string(),
121
- canonicalDestinationAddress: v.string()
122
- }), v.transform((result) => ({
120
+ message: validation_exports.string(),
121
+ canonicalDestinationAddress: validation_exports.string()
122
+ }), validation_exports.transform((result) => ({
123
123
  ...result,
124
124
  code: InvalidWithdrawDestinationCodeCodec[result.code]
125
125
  })));
126
- const ValidateWithdrawDestinationResultSchema = v.union([ValidWithdrawDestinationResultSchema, InvalidWithdrawDestinationResultSchema]);
126
+ const ValidateWithdrawDestinationResultSchema = validation_exports.union([ValidWithdrawDestinationResultSchema, InvalidWithdrawDestinationResultSchema]);
127
127
  //#endregion
128
128
  export { CreateTradingWithdrawResultSchema, CreateWalletTradingWithdrawResultSchema, ValidateWithdrawDestinationInputSchema, ValidateWithdrawDestinationResultSchema, createCreateTradingWithdrawToExternalChainInputSchema, createCreateTradingWithdrawToFundingInputSchema };
129
129
 
@@ -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 { 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: v.pipe(v.number(), v.integer(), v.gtValue(0)),\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: v.pipe(v.number(), v.integer(), v.gtValue(0)),\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":";;;;;;;AAcA,MAAM,2BAA2B;AAmBjC,SAAS,cAAsB;CAC3B,MAAM,SAAS,WAAW,QAAQ,iBAAiB,KAAK,WAAW,MAAM;CACzE,IAAI,CAAC,QAAQ;EACT,MAAM,QAAQ,OAAO,KAAK,IAAI,CAAC;EAC/B,OAAO,UAAU,KAAK,KAAK;CAC/B;CAEA,MAAM,wBAAQ,IAAI,eAAe,CAAC;CAClC,OAAO,KAAK;CACZ,MAAM,QAAQ,MAAM,MAAM,OAAO,KAAK,IAAI,CAAC;CAC3C,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,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,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":["v"],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"sourcesContent":["import * as v from \"../../shared/validation.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: v.pipe(v.number(), v.integer(), v.gtValue(0)),\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: v.pipe(v.number(), v.integer(), v.gtValue(0)),\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":";;;;;;;AAcA,MAAM,2BAA2B;AAmBjC,SAAS,cAAsB;CAC3B,MAAM,SAAS,WAAW,QAAQ,iBAAiB,KAAK,WAAW,MAAM;CACzE,IAAI,CAAC,QAAQ;EACT,MAAM,QAAQ,OAAO,KAAK,IAAI,CAAC;EAC/B,OAAO,UAAU,KAAK,KAAK;CAC/B;CAEA,MAAM,wBAAQ,IAAI,eAAe,CAAC;CAClC,OAAO,KAAK;CACZ,MAAM,QAAQ,MAAM,MAAM,OAAO,KAAK,IAAI,CAAC;CAC3C,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,wBAAwB;EAC9E,OAAO,OAAO,YAAY,CAAC;EAC3B,oBAAoB,MAAM;EAC1B,gBAAgB,MAAM;CAC1B;AACJ;AAEA,SAAgB,gDAAgD,QAAmB;CAC/E,OAAOA,mBAAE,KACLA,mBAAE,aAAa;EACX,GAAG;EACH,SAASA,mBAAE,KAAKA,mBAAE,OAAO,GAAGA,mBAAE,QAAQ,GAAGA,mBAAE,QAAQ,CAAC,CAAC;EACrD,UAAUA,mBAAE,OAAO;EACnB,gBAAgBA,mBAAE,KAAKA,mBAAE,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AAC,CAAC;AAC5E,CAAC,GACDA,mBAAE,WAAW,YAAY;CACrB,GAAG;CACH,MAAM,uCAAuC,cAAc,OAAO;AACtE,EAAE,CACN;AAEA,MAAM,GAAA,IACyC,+BAC3C,GAAG,wCACH,uCAAuC;AAE3C,MAAM,yCAAyCA,mBAAE,KAC7CA,mBAAE,OAAO;CACL,OAAOA,mBAAE,QAAQ,KAAK;CACtB,MAAMA,mBAAE,SAAS;;;;;;;CAOjB,CAAC;CACD,SAASA,mBAAE,OAAO;CAClB,6BAA6BA,mBAAE,OAAO;AAC1C,CAAC,GACDA,mBAAE,WAAW,YAAY;CACrB,GAAG;CACH,MAAM,oCAAoC,OAAO;AACrD,EAAE,CACN;AAEA,MAAa,0CAA0CA,mBAAE,MAAM,CAC3D,sCACA,sCACJ,CAAC"}
@@ -19,7 +19,7 @@ declare class TransfersService {
19
19
  /**
20
20
  * Returns ledger transfers for the resolved account scope with limit, direction, timestamp, code, ledger, and page-token filters.
21
21
  */
22
- list(input: ListTransfersInput, options?: PolyesterRequestOptions): Promise<{
22
+ list(input?: ListTransfersInput, options?: PolyesterRequestOptions): Promise<{
23
23
  transfers: LedgerTransfer[];
24
24
  nextPageToken: string;
25
25
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"transfers.d.ts","names":[],"sources":["../../../src/services/transfers/transfers.ts"],"mappings":";;;;;;;;;UAmBU,gCAAgC,mBAAmB;EACzD;;;;;cAMS;;EAQL,YAAA,WAAW,WACX,UAAU,mBACV,UAAU,gCACV,QAAQ;;;;EAYN,KACF,OAAO,oBACP,UAAU,0BACX;IAAU,WAAW;IAAkB;;;;;EAY1C,UAAU,OAAO"}
1
+ {"version":3,"file":"transfers.d.ts","names":[],"sources":["../../../src/services/transfers/transfers.ts"],"mappings":";;;;;;;;;UAmBU,gCAAgC,mBAAmB;EACzD;;;;;cAMS;;EAQL,YAAA,WAAW,WACX,UAAU,mBACV,UAAU,gCACV,QAAQ;;;;EAYN,KACF,QAAO,oBACP,UAAU,0BACX;IAAU,WAAW;IAAkB;;;;;EAY1C,UAAU,OAAO"}
@@ -1,3 +1,4 @@
1
+ import { parse, validation_exports } from "../../shared/validation.js";
1
2
  import { toConnectCallOptions } from "../../shared/request-options.js";
2
3
  import { resolveAccountScopedInput } from "../subaccount-resolver.js";
3
4
  import { LedgerReadService, TransferRowSchema } from "../../gen/ledger/read/v1/ledger_read_pb.js";
@@ -5,7 +6,6 @@ import { publicationHandlerErrorContext } from "../../shared/subscription-errors
5
6
  import { createReadyGate } from "../../shared/decimal-surface.js";
6
7
  import { ListTransfersInputSchema, createLedgerTransferSchema } from "./transfers.schemas.js";
7
8
  import { createClient } from "@connectrpc/connect";
8
- import * as v from "valibot";
9
9
  //#region src/services/transfers/transfers.ts
10
10
  /**
11
11
  * Reads and streams ledger transfer activity for the authenticated account scope.
@@ -26,13 +26,13 @@ var TransfersService = class {
26
26
  /**
27
27
  * Returns ledger transfers for the resolved account scope with limit, direction, timestamp, code, ledger, and page-token filters.
28
28
  */
29
- async list(input, options) {
29
+ async list(input = {}, options) {
30
30
  await this.#scales.ready();
31
31
  const resolved = resolveAccountScopedInput(input, this.#resolver);
32
- const validatedInput = v.parse(ListTransfersInputSchema, resolved);
32
+ const validatedInput = parse(ListTransfersInputSchema, resolved);
33
33
  const res = await this.#client.listTransfers(validatedInput, toConnectCallOptions(options));
34
34
  return {
35
- transfers: v.parse(v.array(this.#ledgerTransferSchema), res.transfers),
35
+ transfers: parse(validation_exports.array(this.#ledgerTransferSchema), res.transfers),
36
36
  nextPageToken: res.nextPageToken
37
37
  };
38
38
  }
@@ -47,7 +47,7 @@ var TransfersService = class {
47
47
  schema: TransferRowSchema,
48
48
  onPublication: (m) => {
49
49
  gate.run(() => {
50
- const tr = v.parse(this.#ledgerTransferSchema, m);
50
+ const tr = parse(this.#ledgerTransferSchema, m);
51
51
  input.onEvent(tr);
52
52
  });
53
53
  },