@otim/utils 0.0.4 → 0.0.6

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 (467) hide show
  1. package/dist/api/index.d.mts +1858 -7
  2. package/dist/api/index.d.mts.map +1 -0
  3. package/dist/api/index.d.ts +1857 -6
  4. package/dist/api/index.d.ts.map +1 -1
  5. package/dist/api/index.js +1514 -1994
  6. package/dist/api/index.js.map +1 -7
  7. package/dist/api/index.mjs +1394 -1962
  8. package/dist/api/index.mjs.map +1 -7
  9. package/dist/api-urls-B-GTEiT3.d.mts +49 -0
  10. package/dist/api-urls-B-GTEiT3.d.mts.map +1 -0
  11. package/dist/api-urls-Cd20DG4i.js +171 -0
  12. package/dist/api-urls-Cd20DG4i.js.map +1 -0
  13. package/dist/api-urls-DJcIKBCy.mjs +135 -0
  14. package/dist/api-urls-DJcIKBCy.mjs.map +1 -0
  15. package/dist/api-urls-SKeIQMoZ.d.ts +49 -0
  16. package/dist/api-urls-SKeIQMoZ.d.ts.map +1 -0
  17. package/dist/chains/index.d.mts +13568 -16
  18. package/dist/chains/index.d.mts.map +1 -0
  19. package/dist/chains/index.d.ts +13567 -15
  20. package/dist/chains/index.d.ts.map +1 -1
  21. package/dist/chains/index.js +3615 -424
  22. package/dist/chains/index.js.map +1 -7
  23. package/dist/chains/index.mjs +3561 -440
  24. package/dist/chains/index.mjs.map +1 -7
  25. package/dist/chunk-kSYXY2_d.js +34 -0
  26. package/dist/client-factory-7xUSPC9I.mjs +42 -0
  27. package/dist/client-factory-7xUSPC9I.mjs.map +1 -0
  28. package/dist/client-factory-C3A4RPdj.d.ts +22 -0
  29. package/dist/client-factory-C3A4RPdj.d.ts.map +1 -0
  30. package/dist/client-factory-CTI_Nt35.js +49 -0
  31. package/dist/client-factory-CTI_Nt35.js.map +1 -0
  32. package/dist/client-factory-DOL0ZTWy.d.mts +22 -0
  33. package/dist/client-factory-DOL0ZTWy.d.mts.map +1 -0
  34. package/dist/constants.d.mts +14 -24
  35. package/dist/constants.d.mts.map +1 -0
  36. package/dist/constants.d.ts +13 -23
  37. package/dist/constants.d.ts.map +1 -1
  38. package/dist/constants.js +31 -46
  39. package/dist/constants.js.map +1 -7
  40. package/dist/constants.mjs +22 -26
  41. package/dist/constants.mjs.map +1 -7
  42. package/dist/date-CFzrYcjE.js +536 -0
  43. package/dist/date-CFzrYcjE.js.map +1 -0
  44. package/dist/date-gBac-Om9.mjs +313 -0
  45. package/dist/date-gBac-Om9.mjs.map +1 -0
  46. package/dist/defineProperty-DbMdhrDE.js +49 -0
  47. package/dist/defineProperty-DzhmunJg.mjs +43 -0
  48. package/dist/formatters/index.d.mts +1 -2
  49. package/dist/formatters/index.d.ts +1 -2
  50. package/dist/formatters/index.js +0 -19
  51. package/dist/formatters/index.mjs +1 -1
  52. package/dist/helpers/index.d.mts +562 -19
  53. package/dist/helpers/index.d.mts.map +1 -0
  54. package/dist/helpers/index.d.ts +561 -18
  55. package/dist/helpers/index.d.ts.map +1 -1
  56. package/dist/helpers/index.js +106 -1344
  57. package/dist/helpers/index.mjs +3 -1315
  58. package/dist/helpers-BNiSxjGq.mjs +895 -0
  59. package/dist/helpers-BNiSxjGq.mjs.map +1 -0
  60. package/dist/helpers-DoC7Xl12.js +1291 -0
  61. package/dist/helpers-DoC7Xl12.js.map +1 -0
  62. package/dist/index-Bv0kUz4w.d.ts +540 -0
  63. package/dist/index-Bv0kUz4w.d.ts.map +1 -0
  64. package/dist/index-DartTKk2.d.mts +540 -0
  65. package/dist/index-DartTKk2.d.mts.map +1 -0
  66. package/dist/index.d.mts +1 -1
  67. package/dist/index.d.ts +1 -1
  68. package/dist/index.js +0 -2
  69. package/dist/index.mjs +1 -1
  70. package/dist/instructions/index.d.mts +687 -6
  71. package/dist/instructions/index.d.mts.map +1 -0
  72. package/dist/instructions/index.d.ts +686 -5
  73. package/dist/instructions/index.d.ts.map +1 -1
  74. package/dist/instructions/index.js +1912 -1091
  75. package/dist/instructions/index.js.map +1 -7
  76. package/dist/instructions/index.mjs +1887 -1058
  77. package/dist/instructions/index.mjs.map +1 -7
  78. package/dist/payments/index.d.mts +322 -16
  79. package/dist/payments/index.d.mts.map +1 -0
  80. package/dist/payments/index.d.ts +321 -15
  81. package/dist/payments/index.d.ts.map +1 -1
  82. package/dist/payments/index.js +616 -1258
  83. package/dist/payments/index.js.map +1 -7
  84. package/dist/payments/index.mjs +594 -1236
  85. package/dist/payments/index.mjs.map +1 -7
  86. package/dist/schemas/index.d.mts +2 -10
  87. package/dist/schemas/index.d.ts +2 -10
  88. package/dist/schemas/index.js +350 -393
  89. package/dist/schemas/index.js.map +1 -7
  90. package/dist/schemas/index.mjs +283 -371
  91. package/dist/schemas/index.mjs.map +1 -7
  92. package/dist/server/index.d.mts +354 -3
  93. package/dist/server/index.d.mts.map +1 -0
  94. package/dist/server/index.d.ts +353 -2
  95. package/dist/server/index.d.ts.map +1 -1
  96. package/dist/server/index.js +248 -435
  97. package/dist/server/index.js.map +1 -7
  98. package/dist/server/index.mjs +199 -404
  99. package/dist/server/index.mjs.map +1 -7
  100. package/dist/server/react.d.mts +16 -0
  101. package/dist/server/react.d.mts.map +1 -0
  102. package/dist/server/react.d.ts +16 -0
  103. package/dist/server/react.d.ts.map +1 -0
  104. package/dist/server/react.js +30 -0
  105. package/dist/server/react.js.map +1 -0
  106. package/dist/server/react.mjs +28 -0
  107. package/dist/server/react.mjs.map +1 -0
  108. package/dist/wallet/wagmi/index.d.mts +23 -2
  109. package/dist/wallet/wagmi/index.d.mts.map +1 -0
  110. package/dist/wallet/wagmi/index.d.ts +22 -1
  111. package/dist/wallet/wagmi/index.d.ts.map +1 -1
  112. package/dist/wallet/wagmi/index.js +86 -417
  113. package/dist/wallet/wagmi/index.js.map +1 -7
  114. package/dist/wallet/wagmi/index.mjs +82 -418
  115. package/dist/wallet/wagmi/index.mjs.map +1 -7
  116. package/package.json +39 -28
  117. package/dist/api/api.d.mts +0 -18
  118. package/dist/api/api.d.ts +0 -18
  119. package/dist/api/api.d.ts.map +0 -1
  120. package/dist/api/core/error.d.mts +0 -74
  121. package/dist/api/core/error.d.ts +0 -74
  122. package/dist/api/core/error.d.ts.map +0 -1
  123. package/dist/api/core/index.d.mts +0 -4
  124. package/dist/api/core/index.d.ts +0 -4
  125. package/dist/api/core/index.d.ts.map +0 -1
  126. package/dist/api/core/instance.d.mts +0 -13
  127. package/dist/api/core/instance.d.ts +0 -13
  128. package/dist/api/core/instance.d.ts.map +0 -1
  129. package/dist/api/core/service.d.mts +0 -51
  130. package/dist/api/core/service.d.ts +0 -51
  131. package/dist/api/core/service.d.ts.map +0 -1
  132. package/dist/api/schemas/account.d.mts +0 -44
  133. package/dist/api/schemas/account.d.ts +0 -44
  134. package/dist/api/schemas/account.d.ts.map +0 -1
  135. package/dist/api/schemas/activity.d.mts +0 -277
  136. package/dist/api/schemas/activity.d.ts +0 -277
  137. package/dist/api/schemas/activity.d.ts.map +0 -1
  138. package/dist/api/schemas/auth.d.mts +0 -127
  139. package/dist/api/schemas/auth.d.ts +0 -127
  140. package/dist/api/schemas/auth.d.ts.map +0 -1
  141. package/dist/api/schemas/chain.d.mts +0 -15
  142. package/dist/api/schemas/chain.d.ts +0 -15
  143. package/dist/api/schemas/chain.d.ts.map +0 -1
  144. package/dist/api/schemas/config.d.mts +0 -33
  145. package/dist/api/schemas/config.d.ts +0 -33
  146. package/dist/api/schemas/config.d.ts.map +0 -1
  147. package/dist/api/schemas/contacts.d.mts +0 -27
  148. package/dist/api/schemas/contacts.d.ts +0 -27
  149. package/dist/api/schemas/contacts.d.ts.map +0 -1
  150. package/dist/api/schemas/index.d.mts +0 -12
  151. package/dist/api/schemas/index.d.ts +0 -12
  152. package/dist/api/schemas/index.d.ts.map +0 -1
  153. package/dist/api/schemas/instruction.d.mts +0 -446
  154. package/dist/api/schemas/instruction.d.ts +0 -446
  155. package/dist/api/schemas/instruction.d.ts.map +0 -1
  156. package/dist/api/schemas/integration.d.mts +0 -166
  157. package/dist/api/schemas/integration.d.ts +0 -166
  158. package/dist/api/schemas/integration.d.ts.map +0 -1
  159. package/dist/api/schemas/operating-account.d.mts +0 -11
  160. package/dist/api/schemas/operating-account.d.ts +0 -11
  161. package/dist/api/schemas/operating-account.d.ts.map +0 -1
  162. package/dist/api/schemas/payments.d.mts +0 -234
  163. package/dist/api/schemas/payments.d.ts +0 -234
  164. package/dist/api/schemas/payments.d.ts.map +0 -1
  165. package/dist/api/schemas/transaction.d.mts +0 -37
  166. package/dist/api/schemas/transaction.d.ts +0 -37
  167. package/dist/api/schemas/transaction.d.ts.map +0 -1
  168. package/dist/api/services/account.d.mts +0 -8
  169. package/dist/api/services/account.d.ts +0 -8
  170. package/dist/api/services/account.d.ts.map +0 -1
  171. package/dist/api/services/activity.d.mts +0 -7
  172. package/dist/api/services/activity.d.ts +0 -7
  173. package/dist/api/services/activity.d.ts.map +0 -1
  174. package/dist/api/services/auth.d.mts +0 -12
  175. package/dist/api/services/auth.d.ts +0 -12
  176. package/dist/api/services/auth.d.ts.map +0 -1
  177. package/dist/api/services/base.d.mts +0 -10
  178. package/dist/api/services/base.d.ts +0 -10
  179. package/dist/api/services/base.d.ts.map +0 -1
  180. package/dist/api/services/config.d.mts +0 -10
  181. package/dist/api/services/config.d.ts +0 -10
  182. package/dist/api/services/config.d.ts.map +0 -1
  183. package/dist/api/services/contacts.d.mts +0 -8
  184. package/dist/api/services/contacts.d.ts +0 -8
  185. package/dist/api/services/contacts.d.ts.map +0 -1
  186. package/dist/api/services/developer.d.mts +0 -6
  187. package/dist/api/services/developer.d.ts +0 -6
  188. package/dist/api/services/developer.d.ts.map +0 -1
  189. package/dist/api/services/index.d.mts +0 -13
  190. package/dist/api/services/index.d.ts +0 -13
  191. package/dist/api/services/index.d.ts.map +0 -1
  192. package/dist/api/services/instruction.d.mts +0 -12
  193. package/dist/api/services/instruction.d.ts +0 -12
  194. package/dist/api/services/instruction.d.ts.map +0 -1
  195. package/dist/api/services/integration.d.mts +0 -8
  196. package/dist/api/services/integration.d.ts +0 -8
  197. package/dist/api/services/integration.d.ts.map +0 -1
  198. package/dist/api/services/operating-account.d.mts +0 -8
  199. package/dist/api/services/operating-account.d.ts +0 -8
  200. package/dist/api/services/operating-account.d.ts.map +0 -1
  201. package/dist/api/services/payments.d.mts +0 -14
  202. package/dist/api/services/payments.d.ts +0 -14
  203. package/dist/api/services/payments.d.ts.map +0 -1
  204. package/dist/api/services/transaction.d.mts +0 -8
  205. package/dist/api/services/transaction.d.ts +0 -8
  206. package/dist/api/services/transaction.d.ts.map +0 -1
  207. package/dist/api/services/uniswap-token-list-service.d.mts +0 -66
  208. package/dist/api/services/uniswap-token-list-service.d.ts +0 -66
  209. package/dist/api/services/uniswap-token-list-service.d.ts.map +0 -1
  210. package/dist/api/utils/index.d.mts +0 -2
  211. package/dist/api/utils/index.d.ts +0 -2
  212. package/dist/api/utils/index.d.ts.map +0 -1
  213. package/dist/api/utils/pagination.d.mts +0 -32
  214. package/dist/api/utils/pagination.d.ts +0 -32
  215. package/dist/api/utils/pagination.d.ts.map +0 -1
  216. package/dist/chains/config/all-chains.d.mts +0 -4243
  217. package/dist/chains/config/all-chains.d.ts +0 -4243
  218. package/dist/chains/config/all-chains.d.ts.map +0 -1
  219. package/dist/chains/config/custom-chains.d.mts +0 -49
  220. package/dist/chains/config/custom-chains.d.ts +0 -49
  221. package/dist/chains/config/custom-chains.d.ts.map +0 -1
  222. package/dist/chains/config/mainnet-chains.d.mts +0 -1063
  223. package/dist/chains/config/mainnet-chains.d.ts +0 -1063
  224. package/dist/chains/config/mainnet-chains.d.ts.map +0 -1
  225. package/dist/chains/config/supported-chains.d.mts +0 -2172
  226. package/dist/chains/config/supported-chains.d.ts +0 -2172
  227. package/dist/chains/config/supported-chains.d.ts.map +0 -1
  228. package/dist/chains/config/testnet-chains.d.mts +0 -1110
  229. package/dist/chains/config/testnet-chains.d.ts +0 -1110
  230. package/dist/chains/config/testnet-chains.d.ts.map +0 -1
  231. package/dist/chains/lambda/chain-mapping.d.mts +0 -55
  232. package/dist/chains/lambda/chain-mapping.d.ts +0 -55
  233. package/dist/chains/lambda/chain-mapping.d.ts.map +0 -1
  234. package/dist/chains/lambda/index.d.mts +0 -2
  235. package/dist/chains/lambda/index.d.ts +0 -2
  236. package/dist/chains/lambda/index.d.ts.map +0 -1
  237. package/dist/chains/tokens/chain-tokens.d.mts +0 -6
  238. package/dist/chains/tokens/chain-tokens.d.ts +0 -6
  239. package/dist/chains/tokens/chain-tokens.d.ts.map +0 -1
  240. package/dist/chains/tokens/token-addresses.d.mts +0 -8
  241. package/dist/chains/tokens/token-addresses.d.ts +0 -8
  242. package/dist/chains/tokens/token-addresses.d.ts.map +0 -1
  243. package/dist/chains/tokens/token-metadata.d.mts +0 -5
  244. package/dist/chains/tokens/token-metadata.d.ts +0 -5
  245. package/dist/chains/tokens/token-metadata.d.ts.map +0 -1
  246. package/dist/chains/types.d.mts +0 -23
  247. package/dist/chains/types.d.ts +0 -23
  248. package/dist/chains/types.d.ts.map +0 -1
  249. package/dist/chains/utils/filter-tokens.d.mts +0 -3
  250. package/dist/chains/utils/filter-tokens.d.ts +0 -3
  251. package/dist/chains/utils/filter-tokens.d.ts.map +0 -1
  252. package/dist/chains/utils/stablecoin.d.mts +0 -7
  253. package/dist/chains/utils/stablecoin.d.ts +0 -7
  254. package/dist/chains/utils/stablecoin.d.ts.map +0 -1
  255. package/dist/chains/utils/token-maps.d.mts +0 -10
  256. package/dist/chains/utils/token-maps.d.ts +0 -10
  257. package/dist/chains/utils/token-maps.d.ts.map +0 -1
  258. package/dist/env.d.mts +0 -17
  259. package/dist/env.d.ts +0 -17
  260. package/dist/env.d.ts.map +0 -1
  261. package/dist/formatters/index.d.ts.map +0 -1
  262. package/dist/formatters/index.js.map +0 -7
  263. package/dist/formatters/index.mjs.map +0 -7
  264. package/dist/helpers/address.d.mts +0 -7
  265. package/dist/helpers/address.d.ts +0 -7
  266. package/dist/helpers/address.d.ts.map +0 -1
  267. package/dist/helpers/blockchain.d.mts +0 -41
  268. package/dist/helpers/blockchain.d.ts +0 -41
  269. package/dist/helpers/blockchain.d.ts.map +0 -1
  270. package/dist/helpers/date.d.mts +0 -70
  271. package/dist/helpers/date.d.ts +0 -70
  272. package/dist/helpers/date.d.ts.map +0 -1
  273. package/dist/helpers/datetime.d.mts +0 -57
  274. package/dist/helpers/datetime.d.ts +0 -57
  275. package/dist/helpers/datetime.d.ts.map +0 -1
  276. package/dist/helpers/domain.d.mts +0 -2
  277. package/dist/helpers/domain.d.ts +0 -2
  278. package/dist/helpers/domain.d.ts.map +0 -1
  279. package/dist/helpers/index.js.map +0 -7
  280. package/dist/helpers/index.mjs.map +0 -7
  281. package/dist/helpers/intl.d.mts +0 -20
  282. package/dist/helpers/intl.d.ts +0 -20
  283. package/dist/helpers/intl.d.ts.map +0 -1
  284. package/dist/helpers/logger.d.mts +0 -26
  285. package/dist/helpers/logger.d.ts +0 -26
  286. package/dist/helpers/logger.d.ts.map +0 -1
  287. package/dist/helpers/mask-options.d.mts +0 -10
  288. package/dist/helpers/mask-options.d.ts +0 -10
  289. package/dist/helpers/mask-options.d.ts.map +0 -1
  290. package/dist/helpers/num-formatter.d.mts +0 -3
  291. package/dist/helpers/num-formatter.d.ts +0 -3
  292. package/dist/helpers/num-formatter.d.ts.map +0 -1
  293. package/dist/helpers/polling.d.mts +0 -39
  294. package/dist/helpers/polling.d.ts +0 -39
  295. package/dist/helpers/polling.d.ts.map +0 -1
  296. package/dist/helpers/random.d.mts +0 -10
  297. package/dist/helpers/random.d.ts +0 -10
  298. package/dist/helpers/random.d.ts.map +0 -1
  299. package/dist/helpers/sdk-loader.d.mts +0 -25
  300. package/dist/helpers/sdk-loader.d.ts +0 -25
  301. package/dist/helpers/sdk-loader.d.ts.map +0 -1
  302. package/dist/helpers/signatures.d.mts +0 -17
  303. package/dist/helpers/signatures.d.ts +0 -17
  304. package/dist/helpers/signatures.d.ts.map +0 -1
  305. package/dist/helpers/string.d.mts +0 -17
  306. package/dist/helpers/string.d.ts +0 -17
  307. package/dist/helpers/string.d.ts.map +0 -1
  308. package/dist/helpers/types.d.mts +0 -39
  309. package/dist/helpers/types.d.ts +0 -39
  310. package/dist/helpers/types.d.ts.map +0 -1
  311. package/dist/helpers/url.d.mts +0 -11
  312. package/dist/helpers/url.d.ts +0 -11
  313. package/dist/helpers/url.d.ts.map +0 -1
  314. package/dist/helpers/window.d.mts +0 -37
  315. package/dist/helpers/window.d.ts +0 -37
  316. package/dist/helpers/window.d.ts.map +0 -1
  317. package/dist/helpers/zod.d.mts +0 -51
  318. package/dist/helpers/zod.d.ts +0 -51
  319. package/dist/helpers/zod.d.ts.map +0 -1
  320. package/dist/index.d.ts.map +0 -1
  321. package/dist/index.js.map +0 -7
  322. package/dist/index.mjs.map +0 -7
  323. package/dist/instructions/actions/index.d.mts +0 -5
  324. package/dist/instructions/actions/index.d.ts +0 -5
  325. package/dist/instructions/actions/index.d.ts.map +0 -1
  326. package/dist/instructions/actions/refuel/index.d.mts +0 -15
  327. package/dist/instructions/actions/refuel/index.d.ts +0 -15
  328. package/dist/instructions/actions/refuel/index.d.ts.map +0 -1
  329. package/dist/instructions/actions/swap/index.d.mts +0 -19
  330. package/dist/instructions/actions/swap/index.d.ts +0 -19
  331. package/dist/instructions/actions/swap/index.d.ts.map +0 -1
  332. package/dist/instructions/actions/sweep/index.d.mts +0 -16
  333. package/dist/instructions/actions/sweep/index.d.ts +0 -16
  334. package/dist/instructions/actions/sweep/index.d.ts.map +0 -1
  335. package/dist/instructions/actions/transfer/index.d.mts +0 -13
  336. package/dist/instructions/actions/transfer/index.d.ts +0 -13
  337. package/dist/instructions/actions/transfer/index.d.ts.map +0 -1
  338. package/dist/instructions/activate.d.mts +0 -84
  339. package/dist/instructions/activate.d.ts +0 -84
  340. package/dist/instructions/activate.d.ts.map +0 -1
  341. package/dist/instructions/build.d.mts +0 -146
  342. package/dist/instructions/build.d.ts +0 -146
  343. package/dist/instructions/build.d.ts.map +0 -1
  344. package/dist/instructions/constants.d.mts +0 -9
  345. package/dist/instructions/constants.d.ts +0 -9
  346. package/dist/instructions/constants.d.ts.map +0 -1
  347. package/dist/instructions/contracts/artifacts/abi/build-instruction-action-arguments-abi.d.mts +0 -609
  348. package/dist/instructions/contracts/artifacts/abi/build-instruction-action-arguments-abi.d.ts +0 -609
  349. package/dist/instructions/contracts/artifacts/abi/build-instruction-action-arguments-abi.d.ts.map +0 -1
  350. package/dist/instructions/types.d.mts +0 -289
  351. package/dist/instructions/types.d.ts +0 -289
  352. package/dist/instructions/types.d.ts.map +0 -1
  353. package/dist/payments/action-names.d.mts +0 -16
  354. package/dist/payments/action-names.d.ts +0 -16
  355. package/dist/payments/action-names.d.ts.map +0 -1
  356. package/dist/payments/actions/index.d.mts +0 -5
  357. package/dist/payments/actions/index.d.ts +0 -5
  358. package/dist/payments/actions/index.d.ts.map +0 -1
  359. package/dist/payments/actions/sweep-cctp.d.mts +0 -15
  360. package/dist/payments/actions/sweep-cctp.d.ts +0 -15
  361. package/dist/payments/actions/sweep-cctp.d.ts.map +0 -1
  362. package/dist/payments/actions/sweep-erc20.d.mts +0 -12
  363. package/dist/payments/actions/sweep-erc20.d.ts +0 -12
  364. package/dist/payments/actions/sweep-erc20.d.ts.map +0 -1
  365. package/dist/payments/actions/sweep-uniswap-v3.d.mts +0 -17
  366. package/dist/payments/actions/sweep-uniswap-v3.d.ts +0 -17
  367. package/dist/payments/actions/sweep-uniswap-v3.d.ts.map +0 -1
  368. package/dist/payments/actions/sweep.d.mts +0 -12
  369. package/dist/payments/actions/sweep.d.ts +0 -12
  370. package/dist/payments/actions/sweep.d.ts.map +0 -1
  371. package/dist/payments/build.d.mts +0 -28
  372. package/dist/payments/build.d.ts +0 -28
  373. package/dist/payments/build.d.ts.map +0 -1
  374. package/dist/payments/chain-token-config-builder.d.mts +0 -10
  375. package/dist/payments/chain-token-config-builder.d.ts +0 -10
  376. package/dist/payments/chain-token-config-builder.d.ts.map +0 -1
  377. package/dist/payments/comprehensive-payment-request.d.mts +0 -26
  378. package/dist/payments/comprehensive-payment-request.d.ts +0 -26
  379. package/dist/payments/comprehensive-payment-request.d.ts.map +0 -1
  380. package/dist/payments/config/cctp.d.mts +0 -14
  381. package/dist/payments/config/cctp.d.ts +0 -14
  382. package/dist/payments/config/cctp.d.ts.map +0 -1
  383. package/dist/payments/config/index.d.mts +0 -3
  384. package/dist/payments/config/index.d.ts +0 -3
  385. package/dist/payments/config/index.d.ts.map +0 -1
  386. package/dist/payments/config/tokens.d.mts +0 -14
  387. package/dist/payments/config/tokens.d.ts +0 -14
  388. package/dist/payments/config/tokens.d.ts.map +0 -1
  389. package/dist/payments/instruction-registry.d.mts +0 -19
  390. package/dist/payments/instruction-registry.d.ts +0 -19
  391. package/dist/payments/instruction-registry.d.ts.map +0 -1
  392. package/dist/payments/payment-metadata-builder.d.mts +0 -56
  393. package/dist/payments/payment-metadata-builder.d.ts +0 -56
  394. package/dist/payments/payment-metadata-builder.d.ts.map +0 -1
  395. package/dist/payments/payment-metadata.d.mts +0 -15
  396. package/dist/payments/payment-metadata.d.ts +0 -15
  397. package/dist/payments/payment-metadata.d.ts.map +0 -1
  398. package/dist/payments/payment-request-token-resolver.d.mts +0 -25
  399. package/dist/payments/payment-request-token-resolver.d.ts +0 -25
  400. package/dist/payments/payment-request-token-resolver.d.ts.map +0 -1
  401. package/dist/payments/types.d.mts +0 -40
  402. package/dist/payments/types.d.ts +0 -40
  403. package/dist/payments/types.d.ts.map +0 -1
  404. package/dist/payments/validation.d.mts +0 -19
  405. package/dist/payments/validation.d.ts +0 -19
  406. package/dist/payments/validation.d.ts.map +0 -1
  407. package/dist/schemas/account.d.mts +0 -9
  408. package/dist/schemas/account.d.ts +0 -9
  409. package/dist/schemas/account.d.ts.map +0 -1
  410. package/dist/schemas/brand.d.mts +0 -7
  411. package/dist/schemas/brand.d.ts +0 -7
  412. package/dist/schemas/brand.d.ts.map +0 -1
  413. package/dist/schemas/contact.d.mts +0 -18
  414. package/dist/schemas/contact.d.ts +0 -18
  415. package/dist/schemas/contact.d.ts.map +0 -1
  416. package/dist/schemas/index.d.ts.map +0 -1
  417. package/dist/schemas/instruction.d.mts +0 -248
  418. package/dist/schemas/instruction.d.ts +0 -248
  419. package/dist/schemas/instruction.d.ts.map +0 -1
  420. package/dist/schemas/misc.d.mts +0 -36
  421. package/dist/schemas/misc.d.ts +0 -36
  422. package/dist/schemas/misc.d.ts.map +0 -1
  423. package/dist/schemas/payment.d.mts +0 -64
  424. package/dist/schemas/payment.d.ts +0 -64
  425. package/dist/schemas/payment.d.ts.map +0 -1
  426. package/dist/schemas/token.d.mts +0 -17
  427. package/dist/schemas/token.d.ts +0 -17
  428. package/dist/schemas/token.d.ts.map +0 -1
  429. package/dist/schemas/transaction.d.mts +0 -65
  430. package/dist/schemas/transaction.d.ts +0 -65
  431. package/dist/schemas/transaction.d.ts.map +0 -1
  432. package/dist/schemas/user.d.mts +0 -24
  433. package/dist/schemas/user.d.ts +0 -24
  434. package/dist/schemas/user.d.ts.map +0 -1
  435. package/dist/server/client.d.mts +0 -3
  436. package/dist/server/client.d.ts +0 -3
  437. package/dist/server/client.d.ts.map +0 -1
  438. package/dist/server/routes/account.d.mts +0 -4
  439. package/dist/server/routes/account.d.ts +0 -4
  440. package/dist/server/routes/account.d.ts.map +0 -1
  441. package/dist/server/routes/auth.d.mts +0 -28
  442. package/dist/server/routes/auth.d.ts +0 -28
  443. package/dist/server/routes/auth.d.ts.map +0 -1
  444. package/dist/server/routes/bridge.d.mts +0 -254
  445. package/dist/server/routes/bridge.d.ts +0 -254
  446. package/dist/server/routes/bridge.d.ts.map +0 -1
  447. package/dist/server/routes/config.d.mts +0 -3
  448. package/dist/server/routes/config.d.ts +0 -3
  449. package/dist/server/routes/config.d.ts.map +0 -1
  450. package/dist/server/routes/index.d.mts +0 -8
  451. package/dist/server/routes/index.d.ts +0 -8
  452. package/dist/server/routes/index.d.ts.map +0 -1
  453. package/dist/server/routes/instruction.d.mts +0 -4
  454. package/dist/server/routes/instruction.d.ts +0 -4
  455. package/dist/server/routes/instruction.d.ts.map +0 -1
  456. package/dist/server/routes/integration.d.mts +0 -4
  457. package/dist/server/routes/integration.d.ts +0 -4
  458. package/dist/server/routes/integration.d.ts.map +0 -1
  459. package/dist/server/routes/payments.d.mts +0 -5
  460. package/dist/server/routes/payments.d.ts +0 -5
  461. package/dist/server/routes/payments.d.ts.map +0 -1
  462. package/dist/server/routes/verify.d.mts +0 -3
  463. package/dist/server/routes/verify.d.ts +0 -3
  464. package/dist/server/routes/verify.d.ts.map +0 -1
  465. package/dist/wallet/wagmi/config.d.mts +0 -18
  466. package/dist/wallet/wagmi/config.d.ts +0 -18
  467. package/dist/wallet/wagmi/config.d.ts.map +0 -1
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/payments/index.ts", "../../src/payments/types.ts", "../../src/payments/config/cctp.ts", "../../src/helpers/blockchain.ts", "../../src/helpers/date.ts", "../../src/helpers/types.ts", "../../src/chains/utils/stablecoin.ts", "../../src/payments/config/tokens.ts", "../../src/payments/build.ts", "../../src/payments/comprehensive-payment-request.ts", "../../src/payments/actions/sweep-cctp.ts", "../../src/payments/actions/sweep-erc20.ts", "../../src/payments/actions/sweep-uniswap-v3.ts", "../../src/payments/actions/sweep.ts", "../../src/instructions/contracts/schemas/eip-712/actions/deactivate-instruction.json", "../../src/instructions/contracts/schemas/eip-712/actions/refuel-erc20.json", "../../src/instructions/contracts/schemas/eip-712/actions/refuel.json", "../../src/instructions/contracts/schemas/eip-712/actions/sweep-cctp.json", "../../src/instructions/contracts/schemas/eip-712/actions/sweep-deposit-account-erc20.json", "../../src/instructions/contracts/schemas/eip-712/actions/sweep-deposit-account.json", "../../src/instructions/contracts/schemas/eip-712/actions/sweep-erc20.json", "../../src/instructions/contracts/schemas/eip-712/actions/sweep-skip-cctp-deposit-account.json", "../../src/instructions/contracts/schemas/eip-712/actions/sweep-uniswap-v3.json", "../../src/instructions/contracts/schemas/eip-712/actions/sweep.json", "../../src/instructions/contracts/schemas/eip-712/actions/transfer-erc20.json", "../../src/instructions/contracts/schemas/eip-712/actions/transfer.json", "../../src/instructions/contracts/schemas/eip-712/actions/uniswap-v3-exact-input.json", "../../src/instructions/types.ts", "../../src/payments/instruction-registry.ts", "../../src/payments/action-names.ts", "../../src/payments/validation.ts", "../../src/payments/chain-token-config-builder.ts", "../../src/payments/payment-request-token-resolver.ts", "../../src/payments/payment-metadata-builder.ts"],
4
- "sourcesContent": ["export * from \"./types\";\n\nexport * from \"./config\";\n\nexport * from \"./build\";\nexport { createComprehensivePaymentRequest } from \"./comprehensive-payment-request\";\nexport type { ChainTokenConfig } from \"./comprehensive-payment-request\";\n\nexport * from \"./actions\";\n\nexport { instructionRegistry } from \"./instruction-registry\";\nexport type { InstructionTypeDefinition } from \"./instruction-registry\";\n\nexport {\n addActionNamesToInstructions,\n extractActionNamesMap,\n} from \"./action-names\";\nexport type { PaymentResponseWithActionNames } from \"./action-names\";\n\nexport * from \"./validation\";\n\nexport { createChainTokenConfigs } from \"./chain-token-config-builder\";\n\nexport {\n isNativeToken,\n resolvePreferredStablecoin,\n createTokenIdentifier,\n} from \"./payment-request-token-resolver\";\n\nexport * from \"./payment-metadata-builder\";\nexport * from \"./payment-metadata\";\n", "import type { Address, HexString } from \"@otim/utils/schemas\";\n\nexport const PaymentAction = {\n Sweep: \"sweep\",\n SweepCCTP: \"sweepCCTP\",\n SweepERC20: \"sweepERC20\",\n SweepUniswapV3: \"sweepUniswapV3\",\n} as const;\nexport type PaymentAction = (typeof PaymentAction)[keyof typeof PaymentAction];\nexport interface BaseEphemeralInstructionPayload {\n chainId: number;\n maxExecutions: number;\n fee: {\n maxBaseFeePerGas: HexString;\n maxPriorityFeePerGas: HexString;\n token: Address;\n };\n}\n\nexport interface TokenSpec {\n address: Address;\n decimals: number;\n symbol: string;\n}\n\nexport interface PaymentRequestMetadata extends Record<string, unknown> {\n payer?: { name?: string; address?: Address };\n}\n\n/**\n * Uniswap V3 fee tiers. Used to specify the fee tier for a Uniswap V3 swap.\n * @see https://docs.uniswap.org/concepts/protocol/fees\n */\nexport const UniswapV3FeeTier = {\n Lowest: \"100\",\n Low: \"500\",\n Medium: \"3000\",\n High: \"10000\",\n} as const;\nexport type UniswapV3FeeTier =\n (typeof UniswapV3FeeTier)[keyof typeof UniswapV3FeeTier];\n", "import type { Nullable } from \"@otim/utils/helpers\";\n\nimport {\n arbitrum,\n arbitrumSepolia,\n base,\n baseSepolia,\n mainnet,\n optimism,\n optimismSepolia,\n sepolia,\n} from \"viem/chains\";\n\nexport interface CCTPConfig {\n supportedChainIds: Set<number>;\n isSupported(chainId: number): boolean;\n getDomain(chainId: number): Nullable<number>;\n}\n\n/**\n * List of chains that support CCTP\n * Only includes chains that have confirmed CCTP support from Circle\n * @see https://developers.circle.com/stablecoins/docs/supported-domains\n */\nconst cctpSupportedChains = new Set([\n mainnet.id,\n optimism.id,\n arbitrum.id,\n base.id,\n sepolia.id,\n optimismSepolia.id,\n arbitrumSepolia.id,\n baseSepolia.id,\n]);\n\n/**\n * CCTP Domain Mapping - Maps chain IDs to their Circle CCTP domain identifiers\n * Source: https://developers.circle.com/stablecoins/docs/supported-domains\n *\n * Domain IDs are used by Circle's Cross-Chain Transfer Protocol (CCTP) to\n * identify destination chains when burning and minting USDC across different\n * networks.\n */\nconst cctpDomainMapping: Record<number, number> = {\n [mainnet.id]: 0,\n [optimism.id]: 2,\n [arbitrum.id]: 3,\n [base.id]: 6,\n [sepolia.id]: 0,\n [optimismSepolia.id]: 2,\n [arbitrumSepolia.id]: 3,\n [baseSepolia.id]: 6,\n};\n\nexport class DefaultCCTPConfig implements CCTPConfig {\n supportedChainIds: Set<number>;\n\n constructor() {\n this.supportedChainIds = cctpSupportedChains;\n }\n\n isSupported(chainId: number): boolean {\n return this.supportedChainIds.has(chainId);\n }\n\n getDomain(chainId: number): Nullable<number> {\n return cctpDomainMapping[chainId] ?? null;\n }\n}\n\nexport const defaultCCTPConfig = new DefaultCCTPConfig();\n", "import type { EIP2098Signature, HexString, VRS } from \"@otim/utils/schemas\";\nimport type { Chain } from \"viem\";\n\nimport { isAddressEqual } from \"viem\";\n\nexport const truncateAddress = (address: string): string => {\n if (!address) return \"\";\n return `${address.slice(0, 6)}...${address.slice(-4)}`;\n};\n\n/**\n * Ethereum address regex pattern\n * Matches addresses like 0x1234...abcd (40 hex characters after 0x prefix)\n */\nexport const ETHEREUM_ADDRESS_REGEX = /^0x[a-fA-F0-9]{40}$/;\n\n/**\n * Validates if a string is a valid Ethereum address format\n * @param address - The address string to validate\n * @returns true if the address matches the Ethereum address format\n */\nexport const isValidEthereumAddress = (address: string): boolean => {\n return ETHEREUM_ADDRESS_REGEX.test(address);\n};\n\n/**\n * Parses a signature string into its v, r, s components.\n * @param signature - The signature string to parse (must be 0x-prefixed, 132 chars total)\n * @returns VRS object containing v, r, and s values\n */\nexport const parseSignatureToVRS = (signature: string): VRS => {\n if (typeof signature !== \"string\") {\n throw new Error(\"Signature must be a string\");\n }\n\n if (!signature.startsWith(\"0x\")) {\n throw new Error('Signature must start with \"0x\"');\n }\n\n if (signature.length !== 132) {\n throw new Error(\n 'Signature must be 65 bytes (130 hex chars) plus \"0x\" = 132 total length',\n );\n }\n\n const r = signature.slice(2, 66);\n const s = signature.slice(66, 130);\n const vHex = signature.slice(130, 132);\n const v = parseInt(vHex, 16);\n return { v, r: `0x${r}`, s: `0x${s}` };\n};\n\n/**\n * Checks if a v value is valid according to EIP-155.\n */\nexport const isValidV = (v: number): boolean => {\n return v === 0 || v === 1 || v === 27 || v === 28 || v >= 35;\n};\n\n/**\n * Normalizes v value for EIP-155 compliance.\n */\nexport const normalizeV = (v: number) => {\n if (!isValidV(v)) return 0;\n\n const cmp = v <= 1 ? 1 : 0;\n const result = v % 2 === cmp;\n\n return Number(result) % 2;\n};\n\n/**\n * Creates an EIP-2098 compact signature from VRS components.\n * @param vrs - The VRS signature components\n * @returns EIP2098Signature object with yParity, r, and s\n */\nexport const createEIP2098Signature = (vrs: VRS): EIP2098Signature => {\n const v = vrs.v;\n const r = vrs.r;\n const s = vrs.s;\n\n return { yParity: normalizeV(v), r, s };\n};\n\nexport const getChainRpcUrl = (\n chainId: number,\n chains: readonly [Chain, ...Chain[]],\n) => {\n const chain = chains.find((chain) => chain.id === chainId);\n return chain?.rpcUrls.default;\n};\n\nexport const DEFAULT_ADDRESS = \"0x0000000000000000000000000000000000000000\";\n\nexport const isNullAddress = (address: HexString) => {\n return isAddressEqual(address, DEFAULT_ADDRESS);\n};\n", "import z from \"zod\";\n\nimport { logger } from \"./logger\";\n\ntype Locale = \"en\" | \"es\";\n\ntype FormatDateFunc<T> = (date: Date) => T;\n\nexport const iso8601DateSchema = z\n .string()\n .regex(\n /^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d{3})?Z$/,\n \"Must be a valid ISO 8601 date format (e.g., 2024-12-31T23:59:59.000Z)\",\n );\n\nexport const TimeUnit = {\n Day: \"day\",\n Month: \"month\",\n Year: \"year\",\n} as const;\n\nexport type TimeUnit = (typeof TimeUnit)[keyof typeof TimeUnit];\n\nconst units = {\n [TimeUnit.Day]: {\n one: \"day\",\n other: \"days\",\n },\n [TimeUnit.Month]: {\n one: \"month\",\n other: \"months\",\n },\n [TimeUnit.Year]: {\n one: \"year\",\n other: \"years\",\n },\n} as const;\n\nconst formatDateAsUSStandard = (\n date: Date,\n opts?: Intl.DateTimeFormatOptions,\n) =>\n date.toLocaleString(\"en-US\", {\n month: \"2-digit\",\n day: \"2-digit\",\n year: \"numeric\",\n ...opts,\n });\n\nexport const formatDateAsISO = (date: Date) => date.toISOString();\n\nconst formatFullDate = (date: Date): string => {\n const options: Intl.DateTimeFormatOptions = {\n year: \"numeric\",\n month: \"long\",\n day: \"2-digit\",\n timeZone: \"UTC\",\n };\n return new Intl.DateTimeFormat(\"en-US\", options).format(date);\n};\n\nconst formatTime = (date: Date): string => {\n return date.toLocaleTimeString(\"en-US\", {\n hour: \"2-digit\",\n minute: \"2-digit\",\n second: \"2-digit\",\n timeZone: \"UTC\",\n timeZoneName: \"short\",\n });\n};\n\nconst formatDateTime = (date: Date): string => {\n const dateOptions: Intl.DateTimeFormatOptions = {\n month: \"short\",\n day: \"numeric\",\n year: \"numeric\",\n timeZone: \"UTC\",\n };\n const timeOptions: Intl.DateTimeFormatOptions = {\n hour: \"2-digit\",\n minute: \"2-digit\",\n timeZone: \"UTC\",\n };\n\n const formattedDate = new Intl.DateTimeFormat(\"en-US\", dateOptions).format(\n date,\n );\n const formattedTime = new Intl.DateTimeFormat(\"en-US\", timeOptions).format(\n date,\n );\n\n return `${formattedDate} at ${formattedTime}`;\n};\n\n/**\n * Formats a date in long format (e.g., \"June 19, 2025\")\n * @param date - Date object to format\n * @returns Formatted date string\n */\nconst formatLongDate = (date: Date): string => {\n const options: Intl.DateTimeFormatOptions = {\n year: \"numeric\",\n month: \"long\",\n day: \"numeric\",\n timeZone: \"UTC\",\n };\n return new Intl.DateTimeFormat(\"en-US\", options).format(date);\n};\n\n/**\n * Formats a date with time in long format (e.g., \"June 19, 2025 at 07:00 AM\")\n * @param date - Date object to format\n * @returns Formatted date and time string\n */\nconst formatLongDateTime = (date: Date): string => {\n const dateOptions: Intl.DateTimeFormatOptions = {\n year: \"numeric\",\n month: \"long\",\n day: \"numeric\",\n timeZone: \"UTC\",\n };\n const timeOptions: Intl.DateTimeFormatOptions = {\n hour: \"2-digit\",\n minute: \"2-digit\",\n hour12: true,\n timeZone: \"UTC\",\n };\n\n const formattedDate = new Intl.DateTimeFormat(\"en-US\", dateOptions).format(\n date,\n );\n const formattedTime = new Intl.DateTimeFormat(\"en-US\", timeOptions)\n .format(date)\n .toLowerCase();\n\n return `${formattedDate} at ${formattedTime}`;\n};\n\nconst formatToShortDate = (dateString: string | Date) => {\n const date =\n typeof dateString === \"string\" ? new Date(dateString) : dateString;\n\n if (isNaN(date.getTime())) {\n return \"Jan 1\";\n }\n\n return date.toLocaleDateString(\"en-US\", {\n month: \"short\",\n day: \"numeric\",\n timeZone: \"UTC\",\n });\n};\n\nconst formatToShortDateWithYear = (dateString: string | Date) => {\n const date =\n typeof dateString === \"string\" ? new Date(dateString) : dateString;\n\n if (isNaN(date.getTime())) {\n return \"Unknown\";\n }\n\n return date.toLocaleDateString(\"en-US\", {\n month: \"short\",\n day: \"numeric\",\n year: \"numeric\",\n timeZone: \"UTC\",\n });\n};\n\nexport const formatToJustDate = (dateString: string) => {\n const date = new Date(dateString);\n\n if (isNaN(date.getTime())) {\n return \"1\";\n }\n\n return date.getUTCDate().toString();\n};\n\nexport const formatDateToYYYYMMDD = (date: Date) => {\n return new Intl.DateTimeFormat(\"en-CA\", {\n year: \"numeric\",\n month: \"2-digit\",\n day: \"2-digit\",\n }).format(date);\n};\n\nconst isDateInvalid = (date: Date) => {\n return date.toString() === \"Invalid Date\";\n};\n\n/**\n * Validates if a date is valid (opposite of isDateInvalid)\n * Checks both the Date object validity and the timestamp\n */\nconst isValidDate = (date: Date): boolean => {\n return !isDateInvalid(date) && !isNaN(date.getTime());\n};\n\nconst isDateEpoc = (date: Date) => {\n return date.getTime() <= 0;\n};\n\nconst isDateInRange = (arg: unknown): boolean => {\n if (typeof arg !== \"string\") {\n return false;\n }\n\n const date = new Date(arg);\n const startDate = new Date(\"1800-01-01T00:00:00.000Z\");\n const endDate = new Date(\"2999-12-31T23:59:59.999Z\");\n\n return date >= startDate && date <= endDate;\n};\n\nconst isDateInPast = (input: string | number | Date): boolean => {\n let date: Date;\n if (input instanceof Date) {\n date = input;\n } else if (typeof input === \"number\") {\n const ms = input < 1e12 ? input * 1000 : input;\n date = new Date(ms);\n } else {\n date = new Date(input);\n }\n\n if (isNaN(date.getTime())) {\n return false;\n }\n\n return date.getTime() < Date.now();\n};\n\nconst isSameDate = (dateA: Date, dateB: Date) => {\n return (\n dateA.getFullYear() === dateB.getFullYear() &&\n dateA.getMonth() === dateB.getMonth() &&\n dateA.getDate() === dateB.getDate()\n );\n};\n\nconst getPluralizedUnit = (\n unit: keyof typeof units,\n count: number,\n locale: Locale = \"en\",\n) => {\n const pluralRules = new Intl.PluralRules(locale, {\n type: \"cardinal\",\n });\n const pluralCategory = pluralRules.select(count);\n\n if (pluralCategory === \"one\" || pluralCategory === \"other\") {\n return `${count} ${units[unit][pluralCategory]}`;\n }\n\n return `${count} ${units[unit].other}`;\n};\n\nconst getRelativeDateDescription = (\n targetDate: Date,\n locale: Locale = \"en\",\n) => {\n const currentDate = new Date();\n\n const oneDay = 1000 * 60 * 60 * 24;\n const oneMonth = oneDay * 30;\n const oneYear = oneDay * 365;\n\n const diffInMilliseconds = targetDate.getTime() - currentDate.getTime();\n const diffInDays = Math.round(diffInMilliseconds / oneDay);\n const diffInMonths = Math.round(diffInMilliseconds / oneMonth);\n const diffInYears = Math.round(diffInMilliseconds / oneYear);\n\n if (Math.abs(diffInYears) >= 1) {\n return getPluralizedUnit(\"year\", Math.abs(diffInYears), locale);\n }\n\n if (Math.abs(diffInMonths) >= 1) {\n return getPluralizedUnit(\"month\", Math.abs(diffInMonths), locale);\n }\n\n return getPluralizedUnit(\"day\", Math.abs(diffInDays), locale);\n};\n\n/**\n * Safely formats a date with validation and fallback support\n * @param date - String or Date to format\n * @param formatter - Function that formats the Date object\n * @param fallback - Value to return if date is invalid\n * @returns Formatted string or fallback value\n */\nconst safeFormatDate = <T = string>(\n date: string | Date,\n formatter: FormatDateFunc<T>,\n fallback: T,\n): T => {\n const dateObj = typeof date === \"string\" ? new Date(date) : date;\n\n if (!isValidDate(dateObj)) {\n return fallback;\n }\n\n try {\n return formatter(dateObj);\n } catch (error) {\n logger.logError(error, {\n context: safeFormatDate.name,\n });\n return fallback;\n }\n};\n\nconst parseDateTime = (dateInput: string, timeInput?: string) => {\n const dateRegex = /^(\\d{1,2})\\/(\\d{1,2})\\/(\\d{4})$/;\n const timeRegex = /^(\\d{1,2}):(\\d{2})(?::(\\d{2}))?\\s*(AM|PM|am|pm)?$/;\n\n const dateMatch = dateRegex.exec(dateInput);\n if (!dateMatch) {\n return undefined;\n }\n\n const month = parseInt(dateMatch[1]!, 10) - 1;\n const day = parseInt(dateMatch[2]!, 10);\n const year = parseInt(dateMatch[3]!, 10);\n\n let hours = 0;\n let minutes = 0;\n let seconds = 0;\n\n if (timeInput) {\n timeInput = timeInput.replace(/\\u00A0/g, \" \").trim();\n\n const timeMatch = timeRegex.exec(timeInput);\n if (!timeMatch) {\n return undefined;\n }\n\n hours = parseInt(timeMatch[1]!, 10);\n minutes = parseInt(timeMatch[2]!, 10);\n seconds = timeMatch[3] ? parseInt(timeMatch[3], 10) : 0;\n const meridiem = timeMatch[4] ? timeMatch[4].toUpperCase() : null;\n\n if (meridiem === \"PM\" && hours < 12) {\n hours += 12;\n } else if (meridiem === \"AM\" && hours === 12) {\n hours = 0;\n }\n }\n\n const date = new Date(Date.UTC(year, month, day, hours, minutes, seconds));\n if (isNaN(date.getTime())) {\n return undefined;\n }\n\n return date;\n};\n\nconst validateIso8601Date = (dueDate: string): void => {\n const result = iso8601DateSchema.safeParse(dueDate);\n if (!result.success) {\n const errorMessage =\n result.error.issues[0]?.message || \"Invalid ISO 8601 format\";\n throw new Error(`Invalid due date format: ${errorMessage}`);\n }\n};\n\nexport {\n formatDateAsUSStandard,\n formatToShortDate,\n formatToShortDateWithYear,\n formatFullDate,\n formatTime,\n formatDateTime,\n formatLongDate,\n formatLongDateTime,\n getPluralizedUnit,\n getRelativeDateDescription,\n isDateInvalid,\n isValidDate,\n validateIso8601Date,\n isDateEpoc,\n isDateInRange,\n isDateInPast,\n isSameDate,\n safeFormatDate,\n parseDateTime,\n};\nexport type { FormatDateFunc };\n", "import type { z, ZodObject } from \"zod\";\n\nexport type Nullable<T> = T | null;\nexport type Nullish<T> = T | null | undefined;\nexport type Optional<T> = T | undefined;\n// eslint-disable-next-line @typescript-eslint/no-explicit-any -- any is ok\nexport type Any = any;\n\nexport type NumberOrString = number | string;\n\nexport type OverrideProps<T, TOverridden> = Omit<T, keyof TOverridden> &\n TOverridden;\n\nexport type NonEmptyArray<T> = [T, ...T[]];\n\nexport interface DataRecord {\n [value: string]: Nullish<DataRecord | string | number | boolean>;\n}\n\nexport interface Input<T> {\n input: T;\n}\n\nexport type ZodCustom<Values extends object> = ZodObject<{\n [P in keyof Values]: z.ZodType<Values[P]>;\n}>;\n\nexport const isError = (value: unknown): value is Error =>\n value instanceof Error;\n\nexport const isFunction = (\n value: unknown,\n): value is (...args: unknown[]) => unknown => typeof value === \"function\";\n\nexport const isObject = (value: unknown): value is Record<string, unknown> =>\n typeof value === \"object\" && value !== null;\n\nexport const isNumber = (value: unknown): value is number =>\n typeof value === \"number\";\n\nexport const isString = (value: unknown): value is string =>\n typeof value === \"string\";\n\nexport const isUndefined = (value: unknown): value is undefined =>\n typeof value === \"undefined\";\n\nexport const isBoolean = (value: unknown): value is boolean =>\n typeof value === \"boolean\";\n\n/**\n * Safely extracts a string from an unknown value.\n * @param value - The value to extract from\n * @param fallback - Optional fallback value if extraction fails\n * @returns The extracted string or fallback/undefined\n */\nexport const extractString = (\n value: unknown,\n fallback?: string,\n): Optional<string> => {\n return isString(value) ? value : fallback;\n};\n\n/**\n * Safely extracts a number from an unknown value.\n * Handles both number and string representations.\n * @param value - The value to extract from\n * @returns The extracted number or undefined\n */\nexport const extractNumber = (value: unknown): Optional<number> => {\n if (isNumber(value)) {\n return value;\n }\n\n if (isString(value)) {\n const parsed = Number.parseFloat(value);\n return Number.isNaN(parsed) ? undefined : parsed;\n }\n\n return undefined;\n};\n", "/**\n * List of supported stablecoin symbols\n */\nconst stablecoinSymbols = [\"USDC\", \"USDT\"] as const;\n\n/**\n * Checks if a token symbol is a stablecoin\n * @param symbol - Token symbol to check (e.g., \"USDC\", \"ETH\")\n * @returns true if the symbol is a recognized stablecoin\n */\nexport function isStablecoin(symbol: string | string[]): boolean {\n if (typeof symbol === \"string\") {\n return stablecoinSymbols.includes(\n symbol as (typeof stablecoinSymbols)[number],\n );\n }\n\n return symbol.every((s) =>\n stablecoinSymbols.includes(s as (typeof stablecoinSymbols)[number]),\n );\n}\n", "import { isStablecoin } from \"@otim/utils/chains\";\n\nimport { UniswapV3FeeTier } from \"../types\";\n\n/**\n * Determines the recommended Uniswap V3 fee tier for a token pair\n *\n * Stable pairs (USDC/USDT swaps) use the Low fee tier (0.05%) since price\n * volatility is minimal. All other pairs use the Medium fee tier (0.3%) to\n * account for higher price volatility\n *\n * @param tokenIn - Symbol of the input token (e.g., \"USDC\", \"USDT\")\n * @param tokenOut - Symbol of the output token (e.g., \"USDC\", \"USDT\")\n * @returns The recommended Uniswap V3 fee tier for the swap\n */\nexport function getRecommendedFeeTier(\n tokenIn: string,\n tokenOut: string,\n): UniswapV3FeeTier {\n if (isStablecoin([tokenIn, tokenOut])) {\n return UniswapV3FeeTier.Low;\n }\n\n return UniswapV3FeeTier.Medium;\n}\n", "import type { PaymentRequestMetadata } from \"./types\";\nimport type { PaymentRequestBuildRequest } from \"@otim/utils/api\";\nimport type { Nullable } from \"@otim/utils/helpers\";\nimport type { Address, HexString } from \"@otim/utils/schemas\";\n\nimport { DEFAULT_ADDRESS } from \"@otim/utils/helpers\";\n\nexport interface EphemeralInstructionSpec {\n chainId: number;\n salt?: number;\n maxExecutions: number;\n actionArguments: Record<string, unknown>;\n setEphemeralTarget?: boolean;\n}\n\nexport interface BuildPaymentRequestParams {\n payerAddress?: Nullable<Address>;\n completionInstructions: EphemeralInstructionSpec[];\n instructions?: EphemeralInstructionSpec[];\n metadata?: PaymentRequestMetadata;\n maxRuns?: number;\n}\n\ninterface ProcessedInstruction {\n chainId: number;\n salt: number;\n maxExecutions: number;\n actionArguments: Record<string, unknown>;\n setEphemeralTarget: boolean;\n}\n\nexport interface FeeConfig {\n executionFee: number;\n maxBaseFeePerGas: `0x${string}`;\n maxPriorityFeePerGas: `0x${string}`;\n token: Address;\n}\n\nconst DEFAULT_SET_EPHEMERAL_TARGET = true;\n\nexport function createPaymentRequestBuildPayload(\n params: BuildPaymentRequestParams,\n): PaymentRequestBuildRequest {\n const {\n payerAddress = null,\n completionInstructions,\n instructions = [],\n metadata = {},\n maxRuns,\n } = params;\n\n return {\n payerAddress,\n completionInstructions: completionInstructions.map(processInstruction),\n instructions: instructions.map(processInstruction),\n metadata,\n maxRuns,\n };\n}\n\nfunction processInstruction(\n spec: EphemeralInstructionSpec,\n): ProcessedInstruction {\n return {\n chainId: spec.chainId,\n salt: spec.salt ?? generateRandomSalt(),\n maxExecutions: spec.maxExecutions,\n actionArguments: spec.actionArguments,\n setEphemeralTarget: spec.setEphemeralTarget ?? DEFAULT_SET_EPHEMERAL_TARGET,\n };\n}\n\nfunction generateRandomSalt(): number {\n return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);\n}\n\nexport function createDefaultFee(\n executionFee = 0,\n maxBaseFeePerGas: HexString = \"0x0\",\n maxPriorityFeePerGas: HexString = \"0x0\",\n token: Address = DEFAULT_ADDRESS,\n): FeeConfig {\n return {\n token,\n executionFee,\n maxBaseFeePerGas,\n maxPriorityFeePerGas,\n };\n}\n\nexport function createFeeWithToken(\n token?: Address,\n maxPriorityFeePerGas?: `0x${string}`,\n): FeeConfig {\n return createDefaultFee(0, \"0x0\", maxPriorityFeePerGas ?? \"0x0\", token);\n}\n", "import type { EphemeralInstructionSpec } from \"./build\";\nimport type { CCTPConfig } from \"./config/cctp\";\nimport type { PaymentRequestMetadata } from \"./types\";\nimport type { PaymentRequestBuildRequest } from \"@otim/utils/api\";\nimport type { Address } from \"@otim/utils/schemas\";\n\nimport { parseUnits, toHex } from \"viem\";\n\nimport { isStablecoin } from \"@otim/utils/chains\";\n\nimport { createSweepCCTPActionArguments } from \"./actions/sweep-cctp\";\nimport { createSweepERC20ActionArguments } from \"./actions/sweep-erc20\";\nimport { createSweepUniswapV3ActionArguments } from \"./actions/sweep-uniswap-v3\";\nimport { createFeeWithToken, createPaymentRequestBuildPayload } from \"./build\";\nimport { defaultCCTPConfig } from \"./config/cctp\";\nimport { getRecommendedFeeTier } from \"./config/tokens\";\n\nexport interface ChainTokenConfig {\n chainId: number;\n tokens: Array<{\n symbol: string;\n address: Address;\n decimals: number;\n }>;\n}\n\nexport interface ComprehensivePaymentRequestParams {\n settlementChainId: number;\n recipient: Address;\n amount: string;\n ephemeralWalletAddress: Address;\n chainTokenConfigs: ChainTokenConfig[];\n payerAddress?: Address | null;\n metadata?: PaymentRequestMetadata;\n feeToken?: Address;\n cctpConfig?: CCTPConfig;\n maxRuns?: number;\n}\n\ninterface SettlementTokenInfo {\n address: Address;\n decimals: number;\n}\n\nconst USDC_SYMBOL = \"USDC\";\nconst USDT_SYMBOL = \"USDT\";\nconst MINIMUM_THRESHOLD = 1n;\nconst UNISWAP_MEAN_PRICE_LOOKBACK = 600;\n\n/**\n * For payment requests, endBalance is always 0 across all instruction types\n * (Sweep, SweepERC20, SweepCCTP, SweepUniswapV3). This ensures all available\n * tokens are swept/bridged/swapped without leaving dust in the ephemeral\n * wallet.\n */\nconst ZERO_BALANCE = 0n;\n\nconst USDT_MAX_PRICE_DEVIATION_BPS = 200;\nconst DEFAULT_MAX_PRICE_DEVIATION_BPS = 500;\n\nconst STABLE_SLIPPAGE_BPS = 1;\nconst NON_STABLE_SLIPPAGE_BPS = 50;\n\nexport function createComprehensivePaymentRequest(\n params: ComprehensivePaymentRequestParams,\n): PaymentRequestBuildRequest {\n const {\n settlementChainId,\n recipient,\n amount,\n ephemeralWalletAddress,\n chainTokenConfigs,\n payerAddress,\n metadata,\n feeToken,\n cctpConfig = defaultCCTPConfig,\n maxRuns = 1,\n } = params;\n\n validateSettlementChainSupport(settlementChainId, cctpConfig);\n\n const settlementConfig = findChainConfig(\n settlementChainId,\n chainTokenConfigs,\n );\n const settlementUSDC = findSettlementUSDC(settlementConfig);\n const threshold = calculateThreshold(amount, settlementUSDC.decimals);\n\n /**\n * For payment requests, we don't charge in-protocol fees, so all fee values\n * are set to zero. This provides slight gas savings by pushing fewer non-zero\n * bytes on-chain.\n */\n const instructionFee = createFeeWithToken(feeToken);\n\n const completionInstructions = createCompletionInstructions(\n settlementChainId,\n settlementUSDC.address,\n recipient,\n threshold,\n instructionFee,\n chainTokenConfigs,\n );\n\n const instructions = createCrossChainInstructions(\n chainTokenConfigs,\n settlementChainId,\n ephemeralWalletAddress,\n instructionFee,\n cctpConfig,\n );\n\n return createPaymentRequestBuildPayload({\n payerAddress,\n completionInstructions,\n instructions,\n metadata,\n maxRuns,\n });\n}\n\nfunction validateSettlementChainSupport(\n chainId: number,\n cctpConfig: CCTPConfig,\n): void {\n if (!cctpConfig.isSupported(chainId)) {\n throw new Error(`Settlement chain ${chainId} does not support CCTP`);\n }\n}\n\nfunction findChainConfig(\n chainId: number,\n configs: ChainTokenConfig[],\n): ChainTokenConfig {\n const config = configs.find((c) => c.chainId === chainId);\n\n if (!config) {\n throw new Error(\n `Settlement chain ${chainId} not found in chain token configs`,\n );\n }\n\n return config;\n}\n\nfunction findSettlementUSDC(\n settlementConfig: ChainTokenConfig,\n): SettlementTokenInfo {\n const usdc = settlementConfig.tokens.find(\n (token) => token.symbol.toUpperCase() === USDC_SYMBOL,\n );\n\n if (!usdc) {\n throw new Error(\n `Settlement chain ${settlementConfig.chainId} does not have USDC configured`,\n );\n }\n\n return {\n address: usdc.address,\n decimals: usdc.decimals,\n };\n}\n\nfunction calculateThreshold(amount: string, decimals: number): `0x${string}` {\n return toHex(parseUnits(amount, decimals));\n}\n\nfunction createCompletionInstructions(\n settlementChainId: number,\n settlementUSDCAddress: Address,\n recipient: Address,\n threshold: `0x${string}`,\n instructionFee: ReturnType<typeof createFeeWithToken>,\n chainTokenConfigs: ChainTokenConfig[],\n): EphemeralInstructionSpec[] {\n const instructions: EphemeralInstructionSpec[] = [];\n\n instructions.push(\n createSettlementSweepInstruction(\n settlementChainId,\n settlementUSDCAddress,\n recipient,\n threshold,\n instructionFee,\n ),\n );\n\n const swapInstructions = createTokenSwapInstructions(\n settlementChainId,\n chainTokenConfigs,\n recipient,\n threshold,\n instructionFee,\n );\n\n instructions.push(...swapInstructions);\n\n return instructions;\n}\n\n/**\n * Creates the final settlement sweep instruction that sends USDC to the\n * recipient. For payment requests, endBalance is always 0 to sweep all\n * available tokens.\n */\nfunction createSettlementSweepInstruction(\n chainId: number,\n tokenAddress: Address,\n recipient: Address,\n threshold: `0x${string}`,\n fee: ReturnType<typeof createFeeWithToken>,\n): EphemeralInstructionSpec {\n return {\n chainId,\n maxExecutions: 0,\n actionArguments: createSweepERC20ActionArguments({\n chainId,\n maxExecutions: 0,\n token: tokenAddress,\n target: recipient,\n threshold,\n endBalance: toHex(ZERO_BALANCE),\n fee,\n }),\n setEphemeralTarget: false,\n };\n}\n\nfunction createTokenSwapInstructions(\n settlementChainId: number,\n chainTokenConfigs: ChainTokenConfig[],\n settlementRecipient: Address,\n threshold: `0x${string}`,\n instructionFee: ReturnType<typeof createFeeWithToken>,\n): EphemeralInstructionSpec[] {\n const swapInstructions: EphemeralInstructionSpec[] = [];\n\n const settlementConfig = chainTokenConfigs.find(\n (c) => c.chainId === settlementChainId,\n );\n\n if (!settlementConfig) {\n return swapInstructions;\n }\n\n const settlementUSDC = settlementConfig.tokens.find(\n (t) => t.symbol.toUpperCase() === USDC_SYMBOL,\n );\n\n if (!settlementUSDC) {\n return swapInstructions;\n }\n\n for (const sourceToken of settlementConfig.tokens) {\n if (sourceToken.symbol.toUpperCase() === USDC_SYMBOL) {\n continue;\n }\n\n const swapInstruction = createSwapInstruction(\n settlementChainId,\n sourceToken,\n settlementUSDC,\n settlementRecipient,\n threshold,\n instructionFee,\n );\n\n swapInstructions.push(swapInstruction);\n }\n\n return swapInstructions;\n}\n\n/**\n * Creates a Uniswap V3 swap instruction as a completion instruction.\n * Uses appropriate slippage tolerance based on token pair (tighter for\n * stables). For payment requests, endBalance is always 0.\n */\nfunction createSwapInstruction(\n chainId: number,\n tokenIn: ChainTokenConfig[\"tokens\"][number],\n tokenOut: ChainTokenConfig[\"tokens\"][number],\n settlementRecipient: Address,\n threshold: `0x${string}`,\n fee: ReturnType<typeof createFeeWithToken>,\n): EphemeralInstructionSpec {\n const { instruction } = createSwapInstructionWithFloor(\n chainId,\n tokenIn,\n tokenOut,\n settlementRecipient,\n threshold,\n fee,\n false,\n );\n return instruction;\n}\n\n/**\n * Creates a Uniswap V3 swap instruction and returns both the instruction\n * and the calculated floorAmountOut for downstream threshold calculations.\n */\nfunction createSwapInstructionWithFloor(\n chainId: number,\n tokenIn: ChainTokenConfig[\"tokens\"][number],\n tokenOut: ChainTokenConfig[\"tokens\"][number],\n recipient: Address,\n threshold: `0x${string}`,\n fee: ReturnType<typeof createFeeWithToken>,\n setEphemeralTarget: boolean,\n): { instruction: EphemeralInstructionSpec; floorAmountOut: bigint } {\n const feeTier = getRecommendedFeeTier(\n tokenIn.symbol.toUpperCase(),\n USDC_SYMBOL,\n );\n\n const isStableToStableSwap = isStablecoin([\n tokenIn.symbol.toUpperCase(),\n tokenOut.symbol.toUpperCase(),\n ]);\n\n const slippageBps = isStableToStableSwap\n ? STABLE_SLIPPAGE_BPS\n : NON_STABLE_SLIPPAGE_BPS;\n\n const maxPriceDeviationBps =\n tokenIn.symbol.toUpperCase() === USDT_SYMBOL\n ? USDT_MAX_PRICE_DEVIATION_BPS\n : DEFAULT_MAX_PRICE_DEVIATION_BPS;\n\n const baseAmount = BigInt(threshold);\n const afterFeeAmount =\n (baseAmount * BigInt(1000000 - Number(feeTier))) / 1000000n;\n const floorAmountOut =\n (afterFeeAmount * BigInt(10000 - slippageBps)) / 10000n;\n\n const instruction: EphemeralInstructionSpec = {\n chainId,\n maxExecutions: 0,\n actionArguments: createSweepUniswapV3ActionArguments({\n chainId,\n maxExecutions: 0,\n recipient,\n tokenIn: tokenIn.address,\n tokenOut: tokenOut.address,\n feeTier,\n threshold,\n endBalance: toHex(ZERO_BALANCE),\n floorAmountOut: toHex(floorAmountOut),\n meanPriceLookBack: UNISWAP_MEAN_PRICE_LOOKBACK,\n maxPriceDeviationBps,\n fee,\n }),\n setEphemeralTarget,\n };\n\n return { instruction, floorAmountOut };\n}\n\n/**\n * Creates swap instructions for non-USDC tokens on non-settlement chains.\n * These swaps send to the ephemeral wallet so the resulting USDC can be\n * bridged.\n *\n * For cross-chain swaps, we set floorAmountOut to 0 because we cannot predict\n * the actual amount that will be swapped. The TWAP oracle provides price\n * manipulation protection at execution time based on the actual swap amount.\n */\nfunction createCrossChainSwapInstructions(\n chainConfig: ChainTokenConfig,\n chainUSDC: ChainTokenConfig[\"tokens\"][number],\n ephemeralWalletAddress: Address,\n instructionFee: ReturnType<typeof createFeeWithToken>,\n): EphemeralInstructionSpec[] {\n const swapInstructions: EphemeralInstructionSpec[] = [];\n\n for (const sourceToken of chainConfig.tokens) {\n if (sourceToken.symbol.toUpperCase() === USDC_SYMBOL) {\n continue;\n }\n\n const feeTier = getRecommendedFeeTier(\n sourceToken.symbol.toUpperCase(),\n USDC_SYMBOL,\n );\n\n const maxPriceDeviationBps =\n sourceToken.symbol.toUpperCase() === USDT_SYMBOL\n ? USDT_MAX_PRICE_DEVIATION_BPS\n : DEFAULT_MAX_PRICE_DEVIATION_BPS;\n\n const instruction: EphemeralInstructionSpec = {\n chainId: chainConfig.chainId,\n maxExecutions: 0,\n actionArguments: createSweepUniswapV3ActionArguments({\n chainId: chainConfig.chainId,\n maxExecutions: 0,\n recipient: ephemeralWalletAddress,\n tokenIn: sourceToken.address,\n tokenOut: chainUSDC.address,\n feeTier,\n threshold: toHex(MINIMUM_THRESHOLD),\n endBalance: toHex(ZERO_BALANCE),\n floorAmountOut: toHex(0n),\n meanPriceLookBack: UNISWAP_MEAN_PRICE_LOOKBACK,\n maxPriceDeviationBps,\n fee: instructionFee,\n }),\n setEphemeralTarget: true,\n };\n\n swapInstructions.push(instruction);\n }\n\n return swapInstructions;\n}\n\nfunction createCrossChainInstructions(\n chainTokenConfigs: ChainTokenConfig[],\n settlementChainId: number,\n ephemeralWalletAddress: Address,\n instructionFee: ReturnType<typeof createFeeWithToken>,\n cctpConfig: CCTPConfig,\n): EphemeralInstructionSpec[] {\n const instructions: EphemeralInstructionSpec[] = [];\n\n for (const chainConfig of chainTokenConfigs) {\n if (chainConfig.chainId === settlementChainId) {\n continue;\n }\n\n const chainUSDC = chainConfig.tokens.find(\n (token) => token.symbol.toUpperCase() === USDC_SYMBOL,\n );\n\n if (!chainUSDC || !cctpConfig.isSupported(chainConfig.chainId)) {\n continue;\n }\n\n const swapInstructions = createCrossChainSwapInstructions(\n chainConfig,\n chainUSDC,\n ephemeralWalletAddress,\n instructionFee,\n );\n\n instructions.push(...swapInstructions);\n\n const bridgeInstruction = createCCTPBridgeInstruction(\n chainConfig.chainId,\n chainUSDC.address,\n settlementChainId,\n ephemeralWalletAddress,\n toHex(MINIMUM_THRESHOLD),\n instructionFee,\n cctpConfig,\n );\n\n instructions.push(bridgeInstruction);\n }\n\n return instructions;\n}\n\n/**\n * Creates a CCTP bridge instruction to move USDC across chains.\n * For payment requests, endBalance is always 0 to bridge all available USDC.\n *\n * The threshold is set to MINIMUM_THRESHOLD (1 wei) so the bridge executes\n * as soon as any USDC is available from upstream swaps, regardless of the\n * actual amount swapped (which is unpredictable).\n */\nfunction createCCTPBridgeInstruction(\n sourceChainId: number,\n tokenAddress: Address,\n destinationChainId: number,\n ephemeralWalletAddress: Address,\n threshold: `0x${string}`,\n fee: ReturnType<typeof createFeeWithToken>,\n cctpConfig: CCTPConfig,\n): EphemeralInstructionSpec {\n return {\n chainId: sourceChainId,\n maxExecutions: 0,\n actionArguments: createSweepCCTPActionArguments({\n chainId: sourceChainId,\n maxExecutions: 0,\n token: tokenAddress,\n destinationChainId,\n destinationMintRecipient: ephemeralWalletAddress,\n threshold,\n endBalance: toHex(ZERO_BALANCE),\n fee,\n cctpConfig,\n }),\n setEphemeralTarget: true,\n };\n}\n", "import type { CCTPConfig } from \"../config/cctp\";\nimport type { BaseEphemeralInstructionPayload } from \"../types\";\nimport type { Address } from \"@otim/utils/schemas\";\n\nimport { pad } from \"viem\";\n\nimport { defaultCCTPConfig } from \"../config/cctp\";\nimport { PaymentAction } from \"../types\";\n\nexport interface SweepCCTPEphemeralPayload\n extends BaseEphemeralInstructionPayload {\n token: Address;\n destinationChainId: number;\n destinationMintRecipient: Address;\n threshold: string;\n endBalance: string;\n cctpConfig?: CCTPConfig;\n}\n\ntype SweepCCTPActionArguments = Record<string, unknown>;\n\nexport function createSweepCCTPActionArguments(\n payload: SweepCCTPEphemeralPayload,\n): SweepCCTPActionArguments {\n const cctpConfig = payload.cctpConfig ?? defaultCCTPConfig;\n const destinationDomain = resolveCCTPDomain(\n payload.destinationChainId,\n cctpConfig,\n );\n\n return {\n [PaymentAction.SweepCCTP]: {\n token: payload.token,\n destinationDomain,\n /* CCTP requires the recipient address to be padded to 32 bytes */\n destinationMintRecipient: pad(payload.destinationMintRecipient, {\n size: 32,\n }),\n threshold: payload.threshold,\n endBalance: payload.endBalance,\n fee: payload.fee,\n },\n };\n}\n\nfunction resolveCCTPDomain(\n destinationChainId: number,\n cctpConfig: CCTPConfig,\n): number {\n const domain = cctpConfig.getDomain(destinationChainId);\n\n if (domain === null) {\n throw new Error(`Chain ${destinationChainId} does not support CCTP`);\n }\n\n return domain;\n}\n", "import type { BaseEphemeralInstructionPayload } from \"../types\";\nimport type { Address } from \"@otim/utils/schemas\";\n\nimport { PaymentAction } from \"../types\";\n\nexport interface SweepERC20EphemeralPayload\n extends BaseEphemeralInstructionPayload {\n token: Address;\n target: Address;\n threshold: string;\n endBalance: string;\n}\n\ntype SweepERC20ActionArguments = Record<string, unknown>;\n\nexport function createSweepERC20ActionArguments(\n payload: SweepERC20EphemeralPayload,\n): SweepERC20ActionArguments {\n return {\n [PaymentAction.SweepERC20]: {\n token: payload.token,\n target: payload.target,\n threshold: payload.threshold,\n endBalance: payload.endBalance,\n fee: payload.fee,\n },\n };\n}\n", "import type {\n BaseEphemeralInstructionPayload,\n UniswapV3FeeTier,\n} from \"../types\";\nimport type { Address } from \"@otim/utils/schemas\";\n\nimport { PaymentAction } from \"../types\";\n\nexport interface SweepUniswapV3EphemeralPayload\n extends BaseEphemeralInstructionPayload {\n recipient: Address;\n tokenIn: Address;\n tokenOut: Address;\n feeTier: UniswapV3FeeTier;\n threshold: string;\n endBalance: string;\n floorAmountOut: string;\n meanPriceLookBack: number;\n maxPriceDeviationBps: number;\n}\n\ntype SweepUniswapV3ActionArguments = Record<string, unknown>;\n\nexport function createSweepUniswapV3ActionArguments(\n payload: SweepUniswapV3EphemeralPayload,\n): SweepUniswapV3ActionArguments {\n return {\n [PaymentAction.SweepUniswapV3]: {\n recipient: payload.recipient,\n tokenIn: payload.tokenIn,\n tokenOut: payload.tokenOut,\n feeTier: payload.feeTier,\n threshold: payload.threshold,\n endBalance: payload.endBalance,\n floorAmountOut: payload.floorAmountOut,\n meanPriceLookBack: payload.meanPriceLookBack,\n maxPriceDeviationBps: payload.maxPriceDeviationBps,\n fee: payload.fee,\n },\n };\n}\n", "import type { BaseEphemeralInstructionPayload } from \"../types\";\nimport type { Address } from \"@otim/utils/schemas\";\n\nimport { toHex } from \"viem\";\n\nimport { PaymentAction } from \"../types\";\n\nexport interface SweepEphemeralPayload extends BaseEphemeralInstructionPayload {\n target: Address;\n threshold: string;\n endBalance: string;\n gasLimit: number;\n}\n\ntype SweepActionArguments = Record<string, unknown>;\n\nexport function createSweepActionArguments(\n payload: SweepEphemeralPayload,\n): SweepActionArguments {\n return {\n [PaymentAction.Sweep]: {\n target: payload.target,\n threshold: payload.threshold,\n endBalance: payload.endBalance,\n gasLimit: toHex(payload.gasLimit),\n fee: payload.fee,\n },\n };\n}\n", "{\n \"types\": {\n \"Instruction\": [\n { \"name\": \"salt\", \"type\": \"uint256\" },\n { \"name\": \"maxExecutions\", \"type\": \"uint256\" },\n { \"name\": \"action\", \"type\": \"address\" },\n { \"name\": \"deactivateInstruction\", \"type\": \"DeactivateInstruction\" }\n ],\n \"DeactivateInstruction\": [\n { \"name\": \"instructionId\", \"type\": \"bytes32\" },\n { \"name\": \"fee\", \"type\": \"Fee\" }\n ],\n \"Fee\": [\n { \"name\": \"token\", \"type\": \"address\" },\n { \"name\": \"maxBaseFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"maxPriorityFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"executionFee\", \"type\": \"uint256\" }\n ]\n }\n}\n", "{\n \"types\": {\n \"Instruction\": [\n { \"name\": \"salt\", \"type\": \"uint256\" },\n { \"name\": \"maxExecutions\", \"type\": \"uint256\" },\n { \"name\": \"action\", \"type\": \"address\" },\n { \"name\": \"refuelERC20\", \"type\": \"RefuelERC20\" }\n ],\n \"RefuelERC20\": [\n { \"name\": \"token\", \"type\": \"address\" },\n { \"name\": \"target\", \"type\": \"address\" },\n { \"name\": \"threshold\", \"type\": \"uint256\" },\n { \"name\": \"endBalance\", \"type\": \"uint256\" },\n { \"name\": \"fee\", \"type\": \"Fee\" }\n ],\n \"Fee\": [\n { \"name\": \"token\", \"type\": \"address\" },\n { \"name\": \"maxBaseFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"maxPriorityFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"executionFee\", \"type\": \"uint256\" }\n ]\n }\n}\n", "{\n \"types\": {\n \"Instruction\": [\n { \"name\": \"salt\", \"type\": \"uint256\" },\n { \"name\": \"maxExecutions\", \"type\": \"uint256\" },\n { \"name\": \"action\", \"type\": \"address\" },\n { \"name\": \"refuel\", \"type\": \"Refuel\" }\n ],\n \"Refuel\": [\n { \"name\": \"target\", \"type\": \"address\" },\n { \"name\": \"threshold\", \"type\": \"uint256\" },\n { \"name\": \"endBalance\", \"type\": \"uint256\" },\n { \"name\": \"gasLimit\", \"type\": \"uint256\" },\n { \"name\": \"fee\", \"type\": \"Fee\" }\n ],\n \"Fee\": [\n { \"name\": \"token\", \"type\": \"address\" },\n { \"name\": \"maxBaseFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"maxPriorityFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"executionFee\", \"type\": \"uint256\" }\n ]\n }\n}\n", "{\n \"types\": {\n \"Instruction\": [\n { \"name\": \"salt\", \"type\": \"uint256\" },\n { \"name\": \"maxExecutions\", \"type\": \"uint256\" },\n { \"name\": \"action\", \"type\": \"address\" },\n { \"name\": \"sweepCCTP\", \"type\": \"SweepCCTP\" }\n ],\n \"SweepCCTP\": [\n { \"name\": \"token\", \"type\": \"address\" },\n { \"name\": \"destinationDomain\", \"type\": \"uint32\" },\n { \"name\": \"destinationMintRecipient\", \"type\": \"bytes32\" },\n { \"name\": \"threshold\", \"type\": \"uint256\" },\n { \"name\": \"endBalance\", \"type\": \"uint256\" },\n { \"name\": \"fee\", \"type\": \"Fee\" }\n ],\n \"Fee\": [\n { \"name\": \"token\", \"type\": \"address\" },\n { \"name\": \"maxBaseFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"maxPriorityFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"executionFee\", \"type\": \"uint256\" }\n ]\n }\n}\n", "{\n \"types\": {\n \"Instruction\": [\n { \"name\": \"salt\", \"type\": \"uint256\" },\n { \"name\": \"maxExecutions\", \"type\": \"uint256\" },\n { \"name\": \"action\", \"type\": \"address\" },\n { \"name\": \"sweepDepositAccountERC20\", \"type\": \"SweepDepositAccountERC20\" }\n ],\n \"SweepDepositAccountERC20\": [\n { \"name\": \"token\", \"type\": \"address\" },\n { \"name\": \"depositor\", \"type\": \"address\" },\n { \"name\": \"recipient\", \"type\": \"address\" },\n { \"name\": \"threshold\", \"type\": \"uint256\" },\n { \"name\": \"fee\", \"type\": \"Fee\" }\n ],\n \"Fee\": [\n { \"name\": \"token\", \"type\": \"address\" },\n { \"name\": \"maxBaseFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"maxPriorityFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"executionFee\", \"type\": \"uint256\" }\n ]\n }\n}\n", "{\n \"types\": {\n \"Instruction\": [\n { \"name\": \"salt\", \"type\": \"uint256\" },\n { \"name\": \"maxExecutions\", \"type\": \"uint256\" },\n { \"name\": \"action\", \"type\": \"address\" },\n { \"name\": \"sweepDepositAccount\", \"type\": \"SweepDepositAccount\" }\n ],\n \"SweepDepositAccount\": [\n { \"name\": \"depositor\", \"type\": \"address\" },\n { \"name\": \"recipient\", \"type\": \"address\" },\n { \"name\": \"threshold\", \"type\": \"uint256\" },\n { \"name\": \"fee\", \"type\": \"Fee\" }\n ],\n \"Fee\": [\n { \"name\": \"token\", \"type\": \"address\" },\n { \"name\": \"maxBaseFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"maxPriorityFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"executionFee\", \"type\": \"uint256\" }\n ]\n }\n}\n", "{\n \"types\": {\n \"Instruction\": [\n { \"name\": \"salt\", \"type\": \"uint256\" },\n { \"name\": \"maxExecutions\", \"type\": \"uint256\" },\n { \"name\": \"action\", \"type\": \"address\" },\n { \"name\": \"sweepERC20\", \"type\": \"SweepERC20\" }\n ],\n \"SweepERC20\": [\n { \"name\": \"token\", \"type\": \"address\" },\n { \"name\": \"target\", \"type\": \"address\" },\n { \"name\": \"threshold\", \"type\": \"uint256\" },\n { \"name\": \"endBalance\", \"type\": \"uint256\" },\n { \"name\": \"fee\", \"type\": \"Fee\" }\n ],\n \"Fee\": [\n { \"name\": \"token\", \"type\": \"address\" },\n { \"name\": \"maxBaseFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"maxPriorityFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"executionFee\", \"type\": \"uint256\" }\n ]\n }\n}\n", "{\n \"types\": {\n \"Instruction\": [\n { \"name\": \"salt\", \"type\": \"uint256\" },\n { \"name\": \"maxExecutions\", \"type\": \"uint256\" },\n { \"name\": \"action\", \"type\": \"address\" },\n {\n \"name\": \"sweepSkipCCTPDepositAccount\",\n \"type\": \"SweepSkipCCTPDepositAccount\"\n }\n ],\n \"SweepSkipCCTPDepositAccount\": [\n { \"name\": \"depositor\", \"type\": \"address\" },\n { \"name\": \"destinationDomain\", \"type\": \"uint32\" },\n { \"name\": \"destinationMintRecipient\", \"type\": \"bytes32\" },\n { \"name\": \"threshold\", \"type\": \"uint256\" },\n { \"name\": \"fee\", \"type\": \"Fee\" }\n ],\n \"Fee\": [\n { \"name\": \"token\", \"type\": \"address\" },\n { \"name\": \"maxBaseFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"maxPriorityFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"executionFee\", \"type\": \"uint256\" }\n ]\n }\n}\n", "{\n \"types\": {\n \"Instruction\": [\n { \"name\": \"salt\", \"type\": \"uint256\" },\n { \"name\": \"maxExecutions\", \"type\": \"uint256\" },\n { \"name\": \"action\", \"type\": \"address\" },\n { \"name\": \"sweepUniswapV3\", \"type\": \"SweepUniswapV3\" }\n ],\n \"SweepUniswapV3\": [\n { \"name\": \"recipient\", \"type\": \"address\" },\n { \"name\": \"tokenIn\", \"type\": \"address\" },\n { \"name\": \"tokenOut\", \"type\": \"address\" },\n { \"name\": \"feeTier\", \"type\": \"uint24\" },\n { \"name\": \"threshold\", \"type\": \"uint256\" },\n { \"name\": \"endBalance\", \"type\": \"uint256\" },\n { \"name\": \"floorAmountOut\", \"type\": \"uint256\" },\n { \"name\": \"meanPriceLookBack\", \"type\": \"uint32\" },\n { \"name\": \"maxPriceDeviationBPS\", \"type\": \"uint32\" },\n { \"name\": \"fee\", \"type\": \"Fee\" }\n ],\n \"Fee\": [\n { \"name\": \"token\", \"type\": \"address\" },\n { \"name\": \"maxBaseFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"maxPriorityFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"executionFee\", \"type\": \"uint256\" }\n ]\n }\n}\n", "{\n \"types\": {\n \"Instruction\": [\n { \"name\": \"salt\", \"type\": \"uint256\" },\n { \"name\": \"maxExecutions\", \"type\": \"uint256\" },\n { \"name\": \"action\", \"type\": \"address\" },\n { \"name\": \"sweep\", \"type\": \"Sweep\" }\n ],\n \"Sweep\": [\n { \"name\": \"target\", \"type\": \"address\" },\n { \"name\": \"threshold\", \"type\": \"uint256\" },\n { \"name\": \"endBalance\", \"type\": \"uint256\" },\n { \"name\": \"gasLimit\", \"type\": \"uint256\" },\n { \"name\": \"fee\", \"type\": \"Fee\" }\n ],\n \"Fee\": [\n { \"name\": \"token\", \"type\": \"address\" },\n { \"name\": \"maxBaseFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"maxPriorityFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"executionFee\", \"type\": \"uint256\" }\n ]\n }\n}\n", "{\n \"types\": {\n \"Instruction\": [\n { \"name\": \"salt\", \"type\": \"uint256\" },\n { \"name\": \"maxExecutions\", \"type\": \"uint256\" },\n { \"name\": \"action\", \"type\": \"address\" },\n { \"name\": \"transferERC20\", \"type\": \"TransferERC20\" }\n ],\n \"TransferERC20\": [\n { \"name\": \"token\", \"type\": \"address\" },\n { \"name\": \"target\", \"type\": \"address\" },\n { \"name\": \"value\", \"type\": \"uint256\" },\n { \"name\": \"schedule\", \"type\": \"Schedule\" },\n { \"name\": \"fee\", \"type\": \"Fee\" }\n ],\n \"Schedule\": [\n { \"name\": \"startAt\", \"type\": \"uint256\" },\n { \"name\": \"startBy\", \"type\": \"uint256\" },\n { \"name\": \"interval\", \"type\": \"uint256\" },\n { \"name\": \"timeout\", \"type\": \"uint256\" }\n ],\n \"Fee\": [\n { \"name\": \"token\", \"type\": \"address\" },\n { \"name\": \"maxBaseFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"maxPriorityFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"executionFee\", \"type\": \"uint256\" }\n ]\n }\n}\n", "{\n \"types\": {\n \"Instruction\": [\n { \"name\": \"salt\", \"type\": \"uint256\" },\n { \"name\": \"maxExecutions\", \"type\": \"uint256\" },\n { \"name\": \"action\", \"type\": \"address\" },\n { \"name\": \"transfer\", \"type\": \"Transfer\" }\n ],\n \"Transfer\": [\n { \"name\": \"target\", \"type\": \"address\" },\n { \"name\": \"value\", \"type\": \"uint256\" },\n { \"name\": \"gasLimit\", \"type\": \"uint256\" },\n { \"name\": \"schedule\", \"type\": \"Schedule\" },\n { \"name\": \"fee\", \"type\": \"Fee\" }\n ],\n \"Schedule\": [\n { \"name\": \"startAt\", \"type\": \"uint256\" },\n { \"name\": \"startBy\", \"type\": \"uint256\" },\n { \"name\": \"interval\", \"type\": \"uint256\" },\n { \"name\": \"timeout\", \"type\": \"uint256\" }\n ],\n \"Fee\": [\n { \"name\": \"token\", \"type\": \"address\" },\n { \"name\": \"maxBaseFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"maxPriorityFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"executionFee\", \"type\": \"uint256\" }\n ]\n }\n}\n", "{\n \"types\": {\n \"Instruction\": [\n { \"name\": \"salt\", \"type\": \"uint256\" },\n { \"name\": \"maxExecutions\", \"type\": \"uint256\" },\n { \"name\": \"action\", \"type\": \"address\" },\n { \"name\": \"uniswapV3ExactInput\", \"type\": \"UniswapV3ExactInput\" }\n ],\n \"UniswapV3ExactInput\": [\n { \"name\": \"recipient\", \"type\": \"address\" },\n { \"name\": \"tokenIn\", \"type\": \"address\" },\n { \"name\": \"tokenOut\", \"type\": \"address\" },\n { \"name\": \"feeTier\", \"type\": \"uint24\" },\n { \"name\": \"amountIn\", \"type\": \"uint256\" },\n { \"name\": \"floorAmountOut\", \"type\": \"uint256\" },\n { \"name\": \"meanPriceLookBack\", \"type\": \"uint32\" },\n { \"name\": \"maxPriceDeviationBPS\", \"type\": \"uint32\" },\n { \"name\": \"schedule\", \"type\": \"Schedule\" },\n { \"name\": \"fee\", \"type\": \"Fee\" }\n ],\n \"Schedule\": [\n { \"name\": \"startAt\", \"type\": \"uint256\" },\n { \"name\": \"startBy\", \"type\": \"uint256\" },\n { \"name\": \"interval\", \"type\": \"uint256\" },\n { \"name\": \"timeout\", \"type\": \"uint256\" }\n ],\n \"Fee\": [\n { \"name\": \"token\", \"type\": \"address\" },\n { \"name\": \"maxBaseFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"maxPriorityFeePerGas\", \"type\": \"uint256\" },\n { \"name\": \"executionFee\", \"type\": \"uint256\" }\n ]\n }\n}\n", "import type { Address } from \"@otim/utils/schemas\";\n\nimport deactivateInstructionTypes from \"./contracts/schemas/eip-712/actions/deactivate-instruction.json\";\nimport refuelERC20Types from \"./contracts/schemas/eip-712/actions/refuel-erc20.json\";\nimport refuelTypes from \"./contracts/schemas/eip-712/actions/refuel.json\";\nimport sweepCCTPTypes from \"./contracts/schemas/eip-712/actions/sweep-cctp.json\";\nimport sweepDepositAccountERC20Types from \"./contracts/schemas/eip-712/actions/sweep-deposit-account-erc20.json\";\nimport sweepDepositAccountTypes from \"./contracts/schemas/eip-712/actions/sweep-deposit-account.json\";\nimport sweepERC20Types from \"./contracts/schemas/eip-712/actions/sweep-erc20.json\";\nimport sweepSkipCCTPDepositAccountTypes from \"./contracts/schemas/eip-712/actions/sweep-skip-cctp-deposit-account.json\";\nimport sweepUniswapV3Types from \"./contracts/schemas/eip-712/actions/sweep-uniswap-v3.json\";\nimport sweepTypes from \"./contracts/schemas/eip-712/actions/sweep.json\";\nimport transferERC20Types from \"./contracts/schemas/eip-712/actions/transfer-erc20.json\";\nimport transferTypes from \"./contracts/schemas/eip-712/actions/transfer.json\";\nimport uniswapV3ExactInputTypes from \"./contracts/schemas/eip-712/actions/uniswap-v3-exact-input.json\";\n\n/**\n * EIP-712 types structure for instruction signatures.\n */\nexport interface EIP712Types {\n types: {\n [key: string]: Array<{ name: string; type: string }>;\n Instruction: Array<{ name: string; type: string }>;\n };\n}\n\n/**\n * Map of instruction actions to their EIP-712 type definitions.\n * Used for creating typed data structures for instruction signatures.\n *\n * @example\n * ```ts\n * const types = eip712TypesMap['transfer'];\n * ```\n */\nexport const eip712TypesMap = {\n refuel: refuelTypes,\n refuelERC20: refuelERC20Types,\n transfer: transferTypes,\n transferERC20: transferERC20Types,\n uniswapV3ExactInput: uniswapV3ExactInputTypes,\n sweep: sweepTypes,\n sweepERC20: sweepERC20Types,\n sweepCCTP: sweepCCTPTypes,\n sweepUniswapV3: sweepUniswapV3Types,\n sweepDepositAccount: sweepDepositAccountTypes,\n sweepDepositAccountERC20: sweepDepositAccountERC20Types,\n sweepSkipCCTPDepositAccount: sweepSkipCCTPDepositAccountTypes,\n deactivateInstruction: deactivateInstructionTypes,\n} as const satisfies Partial<Record<string, EIP712Types>>;\n\n/**\n * Base instruction build payload containing fields common to all instructions.\n */\nexport interface BaseInstructionBuildPayload {\n // Account address that will execute the instruction\n address: Address;\n // Chain ID where the instruction will be executed\n chainId: number;\n // Maximum number of times the instruction can be executed (0 = unlimited)\n maxExecutions: number;\n // Optional salt for uniqueness\n salt?: number;\n // Fee configuration for instruction execution\n fee: {\n executionFee: string;\n maxBaseFeePerGas: string;\n maxPriorityFeePerGas: string;\n token: Address;\n };\n}\n\n/**\n * Extended base payload for instructions that support scheduling.\n * Includes all base fields plus schedule configuration.\n */\nexport interface ScheduledInstructionBuildPayload\n extends BaseInstructionBuildPayload {\n // Schedule configuration for when and how often the instruction runs\n schedule: {\n // Unix timestamp (seconds) when instruction should start (0 = immediate)\n startAt: number;\n // Unix timestamp (seconds) by which instruction must start (0 = no deadline)\n startBy: number;\n // Interval (seconds) between executions\n interval: number;\n // Maximum latency (seconds) allowed for scheduled execution (0 = no limit)\n timeout: number;\n };\n}\n\n/**\n * Extended payload for instructions that support an optional token parameter.\n * This is typically used for ERC20 variants of actions.\n */\nexport interface TokenInstructionPayload {\n // Optional token address (if not provided, uses native currency)\n token?: Address;\n}\n\n/**\n * Extended payload for instructions that support gas limit configuration.\n * Used by actions like transfer and refuel.\n */\nexport interface GasLimitConfigurablePayload {\n // Optional gas limit for the action (0 or undefined = auto)\n gasLimit?: number;\n}\n", "import type { EIP712Types } from \"@otim/utils/instructions\";\nimport type { AbiParameter } from \"abitype\";\n\nimport { eip712TypesMap } from \"@otim/utils/instructions\";\n\nconst feeAbiComponent = {\n name: \"fee\",\n type: \"tuple\",\n components: [\n { name: \"token\", type: \"address\" },\n { name: \"maxBaseFeePerGas\", type: \"uint256\" },\n { name: \"maxPriorityFeePerGas\", type: \"uint256\" },\n { name: \"executionFee\", type: \"uint256\" },\n ],\n} as const satisfies AbiParameter;\n\nconst sweepAbi: readonly AbiParameter[] = [\n {\n type: \"tuple\",\n components: [\n { name: \"target\", type: \"address\" },\n { name: \"threshold\", type: \"uint256\" },\n { name: \"endBalance\", type: \"uint256\" },\n { name: \"gasLimit\", type: \"uint256\" },\n feeAbiComponent,\n ],\n },\n] as const;\n\nconst sweepERC20Abi: readonly AbiParameter[] = [\n {\n type: \"tuple\",\n components: [\n { name: \"token\", type: \"address\" },\n { name: \"target\", type: \"address\" },\n { name: \"threshold\", type: \"uint256\" },\n { name: \"endBalance\", type: \"uint256\" },\n feeAbiComponent,\n ],\n },\n] as const;\n\nconst sweepCCTPAbi: readonly AbiParameter[] = [\n {\n type: \"tuple\",\n components: [\n { name: \"token\", type: \"address\" },\n { name: \"destinationDomain\", type: \"uint32\" },\n { name: \"destinationMintRecipient\", type: \"bytes32\" },\n { name: \"threshold\", type: \"uint256\" },\n { name: \"endBalance\", type: \"uint256\" },\n feeAbiComponent,\n ],\n },\n] as const;\n\nconst sweepUniswapV3Abi: readonly AbiParameter[] = [\n {\n type: \"tuple\",\n components: [\n { name: \"recipient\", type: \"address\" },\n { name: \"tokenIn\", type: \"address\" },\n { name: \"tokenOut\", type: \"address\" },\n { name: \"feeTier\", type: \"uint24\" },\n { name: \"threshold\", type: \"uint256\" },\n { name: \"endBalance\", type: \"uint256\" },\n { name: \"floorAmountOut\", type: \"uint256\" },\n { name: \"meanPriceLookBack\", type: \"uint32\" },\n { name: \"maxPriceDeviationBPS\", type: \"uint32\" },\n feeAbiComponent,\n ],\n },\n] as const;\n\nconst sweepDepositAccountAbi: readonly AbiParameter[] = [\n {\n type: \"tuple\",\n components: [\n { name: \"depositor\", type: \"address\" },\n { name: \"recipient\", type: \"address\" },\n { name: \"threshold\", type: \"uint256\" },\n feeAbiComponent,\n ],\n },\n] as const;\n\nconst sweepDepositAccountERC20Abi: readonly AbiParameter[] = [\n {\n type: \"tuple\",\n components: [\n { name: \"token\", type: \"address\" },\n { name: \"depositor\", type: \"address\" },\n { name: \"recipient\", type: \"address\" },\n { name: \"threshold\", type: \"uint256\" },\n feeAbiComponent,\n ],\n },\n] as const;\n\nconst sweepSkipCCTPDepositAccountAbi: readonly AbiParameter[] = [\n {\n type: \"tuple\",\n components: [\n { name: \"depositor\", type: \"address\" },\n { name: \"destinationDomain\", type: \"uint32\" },\n { name: \"destinationMintRecipient\", type: \"bytes32\" },\n { name: \"threshold\", type: \"uint256\" },\n feeAbiComponent,\n ],\n },\n] as const;\n\nconst actionAbiMap = {\n sweep: sweepAbi,\n sweepERC20: sweepERC20Abi,\n sweepCCTP: sweepCCTPAbi,\n sweepUniswapV3: sweepUniswapV3Abi,\n sweepDepositAccount: sweepDepositAccountAbi,\n sweepDepositAccountERC20: sweepDepositAccountERC20Abi,\n sweepSkipCCTPDepositAccount: sweepSkipCCTPDepositAccountAbi,\n} as const;\n\nexport interface InstructionTypeDefinition {\n abi: readonly AbiParameter[];\n eip712Types: EIP712Types;\n}\n\ntype ActionName = keyof typeof actionAbiMap;\n\nclass InstructionTypeRegistry {\n private registry = new Map<string, InstructionTypeDefinition>();\n\n constructor() {\n this.initializeDefaultTypes();\n }\n\n register(actionName: string, definition: InstructionTypeDefinition): void {\n this.registry.set(actionName, definition);\n }\n\n get(actionName: string): InstructionTypeDefinition {\n const definition = this.registry.get(actionName);\n\n if (!definition) {\n throw this.createUnsupportedTypeError(actionName);\n }\n\n return definition;\n }\n\n has(actionName: string): boolean {\n return this.registry.has(actionName);\n }\n\n getAvailableTypes(): string[] {\n return Array.from(this.registry.keys());\n }\n\n private initializeDefaultTypes(): void {\n const actionNames = Object.keys(actionAbiMap) as ActionName[];\n\n for (const actionName of actionNames) {\n const abi = actionAbiMap[actionName];\n const eip712Types = eip712TypesMap[actionName];\n\n if (abi && eip712Types) {\n this.register(actionName, { abi, eip712Types });\n }\n }\n }\n\n private createUnsupportedTypeError(actionName: string): Error {\n const availableTypes = this.getAvailableTypes().join(\", \");\n return new Error(\n `Unsupported instruction type: ${actionName}. Available: ${availableTypes}`,\n );\n }\n}\n\nexport const instructionRegistry = new InstructionTypeRegistry();\n", "import type { PaymentRequestBuildResponse } from \"@otim/utils/api\";\nimport type { Optional } from \"@otim/utils/helpers\";\n\ninterface InstructionWithActionName {\n actionName?: string;\n}\n\nexport interface PaymentResponseWithActionNames\n extends PaymentRequestBuildResponse {\n completionInstructions: Array<\n PaymentRequestBuildResponse[\"completionInstructions\"][number] &\n InstructionWithActionName\n >;\n instructions: Array<\n PaymentRequestBuildResponse[\"instructions\"][number] &\n InstructionWithActionName\n >;\n}\n\ninterface InstructionWithArguments {\n actionArguments: Record<string, unknown>;\n}\n\ntype ActionNamesMap = Record<number, string>;\n\nexport function addActionNamesToInstructions(\n buildResponse: PaymentRequestBuildResponse,\n actionNames: ActionNamesMap,\n): PaymentResponseWithActionNames {\n const completionInstructionCount =\n buildResponse.completionInstructions.length;\n\n return {\n ...buildResponse,\n completionInstructions: buildResponse.completionInstructions.map(\n (instruction, index) => ({\n ...instruction,\n actionName: actionNames[index],\n }),\n ),\n instructions: buildResponse.instructions.map((instruction, index) => ({\n ...instruction,\n actionName: actionNames[completionInstructionCount + index],\n })),\n };\n}\n\nexport function extractActionNamesMap(\n completionInstructions: InstructionWithArguments[],\n instructions: InstructionWithArguments[] = [],\n): ActionNamesMap {\n const allInstructions = [...completionInstructions, ...instructions];\n\n return allInstructions.reduce<ActionNamesMap>(\n (actionNamesMap, instruction, index) => {\n const actionName = getFirstActionArgumentKey(instruction.actionArguments);\n if (actionName) {\n actionNamesMap[index] = actionName;\n }\n return actionNamesMap;\n },\n {},\n );\n}\n\nfunction getFirstActionArgumentKey(\n actionArguments: Record<string, unknown>,\n): Optional<string> {\n const keys = Object.keys(actionArguments);\n return keys[0];\n}\n", "interface SignatureCountAssertion {\n expected: number;\n received: number;\n}\n\n/**\n * Used to validate the number of signatures in a payment request.\n */\nexport class SignatureValidator {\n static assertExactCount(context: SignatureCountAssertion): void {\n if (context.received !== context.expected) {\n throw new Error(\n `Signature count mismatch: expected ${context.expected}, received ${context.received}`,\n );\n }\n }\n\n static assertMinimumCount(context: SignatureCountAssertion): void {\n if (context.received < context.expected) {\n throw new Error(\n `Insufficient signatures: expected at least ${context.expected}, received ${context.received}`,\n );\n }\n }\n}\n\nexport function assertSignatureCount<T>(\n signatures: T[],\n expectedCount: number,\n): asserts signatures is T[] & { length: typeof expectedCount } {\n SignatureValidator.assertExactCount({\n expected: expectedCount,\n received: signatures.length,\n });\n}\n\nexport function assertMinimumSignatures<T>(\n signatures: T[],\n minimumCount: number,\n): asserts signatures is T[] & { length: number } {\n SignatureValidator.assertMinimumCount({\n expected: minimumCount,\n received: signatures.length,\n });\n}\n", "import type { HexString } from \"../schemas\";\nimport type { ChainTokenConfig } from \"./comprehensive-payment-request\";\n\ninterface Token {\n address: string;\n symbol: string;\n chainId: number;\n decimals: number;\n}\n\nexport function createChainTokenConfigs(tokens: Token[]): ChainTokenConfig[] {\n const tokensByChain = groupTokensByChainId(tokens);\n return convertToChainConfigs(tokensByChain);\n}\n\nfunction groupTokensByChainId(tokens: Token[]): Map<number, Token[]> {\n const grouped = new Map<number, Token[]>();\n\n for (const token of tokens) {\n const chainTokens = grouped.get(token.chainId) ?? [];\n chainTokens.push(token);\n grouped.set(token.chainId, chainTokens);\n }\n\n return grouped;\n}\n\nfunction convertToChainConfigs(\n tokensByChain: Map<number, Token[]>,\n): ChainTokenConfig[] {\n return Array.from(tokensByChain.entries()).map(([chainId, tokens]) => ({\n chainId,\n tokens: tokens.map((token) => ({\n symbol: token.symbol,\n address: token.address as HexString,\n decimals: token.decimals,\n })),\n }));\n}\n", "import type { Nullable, Nullish } from \"@otim/utils/helpers\";\nimport type { Address } from \"@otim/utils/schemas\";\n\nimport { isStablecoin } from \"@otim/utils/chains\";\nimport { DEFAULT_ADDRESS } from \"@otim/utils/helpers\";\n\ninterface Token {\n symbol: string;\n address: string;\n}\n\n/**\n * Checks if a token is the native blockchain token (ETH)\n */\nexport function isNativeToken<T extends Pick<Token, \"symbol\" | \"address\">>(\n token: Nullish<T>,\n): boolean {\n if (!token) {\n return false;\n }\n\n return (\n token.symbol === \"ETH\" ||\n token.address.toLowerCase() === DEFAULT_ADDRESS.toLowerCase()\n );\n}\n\ninterface ResolveStablecoinParams<T extends Token> {\n preferredToken: Nullish<T>;\n getStablecoinBySymbol: (symbol: string) => Nullable<T>;\n}\n\n/**\n * Resolves the stablecoin to use for a payment request.\n * Falls back to USDC or USDT if the preferred token is invalid.\n */\nexport function resolvePreferredStablecoin<T extends Token>({\n preferredToken,\n getStablecoinBySymbol,\n}: ResolveStablecoinParams<T>): Nullable<T> {\n const stablecoin = getValidStablecoin(preferredToken);\n if (stablecoin) {\n return stablecoin;\n }\n\n return getDefaultStablecoin(getStablecoinBySymbol);\n}\n\n/**\n * Validates that a token is a non-native stablecoin\n */\nfunction getValidStablecoin<T extends Token>(token: Nullish<T>): Nullable<T> {\n if (!token || isNativeToken(token) || !isStablecoin(token.symbol)) {\n return null;\n }\n\n return token;\n}\n\n/**\n * Returns a default stablecoin with priority: USDC > USDT\n */\nfunction getDefaultStablecoin<T extends Token>(\n getStablecoinBySymbol: (symbol: string) => Nullable<T>,\n): Nullable<T> {\n const usdc = getStablecoinBySymbol(\"USDC\");\n if (usdc) {\n return usdc;\n }\n\n const usdt = getStablecoinBySymbol(\"USDT\");\n if (usdt) {\n return usdt;\n }\n\n return null;\n}\n\n/**\n * Creates a unique identifier for a token by combining chain ID and address\n */\nexport function createTokenIdentifier(\n chainId: number,\n tokenAddress: Address,\n): string {\n return `${chainId}:${tokenAddress}`;\n}\n", "/**\n * Payment Metadata Builder\n *\n * Handles metadata construction for payment requests with two distinct flows:\n * manual payments (user-entered data) and invoice-based payments (from\n * integrations). Ensures consistent metadata structure across both flows while\n * preventing data conflicts.\n */\n\nimport type { InvoiceMetadata } from \"./payment-metadata\";\nimport type { Nullable } from \"@otim/utils/helpers\";\nimport type { PaymentRequestMetadata } from \"@otim/utils/payments\";\n\nimport { isNumber, isValidDate } from \"@otim/utils/helpers\";\n\n/**\n * Default currency for payments\n */\nconst DEFAULT_CURRENCY = \"USD\" as const;\n\n/**\n * Configuration for manual payment request metadata\n */\nexport interface BuildPaymentMetadataParams {\n tokenSymbol: string;\n note?: string;\n dueDate?: string;\n amountInUSD?: Nullable<number>;\n /**\n * Prevents amount/currency conflicts when invoice metadata will be merged\n * later.\n */\n hasInvoiceMetadata?: boolean;\n fromAccountAddress?: string;\n}\n\n/**\n * Configuration for merging invoice data with payment metadata\n */\nexport interface BuildInvoiceMetadataParams {\n invoiceMetadata: InvoiceMetadata;\n baseMetadata: PaymentRequestMetadata;\n}\n\n/**\n * Validates that a value is a safe, finite number suitable for monetary\n * amounts. Excludes NaN and Infinity which could cause calculation errors\n * downstream.\n */\nfunction isValidAmount(value: unknown): value is number {\n return isNumber(value) && Number.isFinite(value);\n}\n\n/**\n * Constructs payment metadata for manually created payment requests.\n * Conditionally includes amount/currency to avoid conflicts when invoice data\n * will be merged later (invoice data should be the source of truth for amounts).\n */\nexport function buildPaymentMetadata(\n params: BuildPaymentMetadataParams,\n): PaymentRequestMetadata {\n const {\n note,\n tokenSymbol,\n dueDate,\n amountInUSD,\n hasInvoiceMetadata = false,\n fromAccountAddress,\n } = params;\n\n const metadata: PaymentRequestMetadata = {\n token: tokenSymbol,\n };\n\n /**\n * Exclude amount/currency when invoice metadata exists to prevent\n * discrepancies between manually entered and invoice-sourced amounts\n */\n if (!hasInvoiceMetadata) {\n if (isValidAmount(amountInUSD)) {\n metadata.amountDue = amountInUSD.toFixed(2);\n }\n metadata.currency = DEFAULT_CURRENCY;\n }\n\n if (dueDate) {\n metadata.dueDate = dueDate;\n }\n\n if (note) {\n metadata.note = note;\n }\n\n if (fromAccountAddress) {\n metadata.fromAccountAddress = fromAccountAddress;\n }\n\n return metadata;\n}\n\n/**\n * Merges invoice data from external integrations (Stripe, QuickBooks,\n * Bill.com, Clio) with base payment metadata. Invoice fields override manual\n * entries to ensure accuracy and maintain audit trail through source/invoiceId\n * tracking.\n */\nexport function buildInvoiceMetadata(\n params: BuildInvoiceMetadataParams,\n): PaymentRequestMetadata {\n const { invoiceMetadata, baseMetadata } = params;\n\n return {\n ...baseMetadata,\n /**\n * Invoice amounts/dates are authoritative - they override any manually\n * entered values to prevent sync issues with external systems\n */\n amountDue: Number(invoiceMetadata.amount).toFixed(2),\n currency: invoiceMetadata.currency,\n dueDate: invoiceMetadata.dueDate,\n /** Preserve user's manual note if invoice doesn't provide one */\n note: invoiceMetadata.description ?? baseMetadata.note,\n /** Track integration source for reconciliation and debugging */\n source: invoiceMetadata.source,\n invoiceId: invoiceMetadata.invoiceId,\n invoiceNumber: invoiceMetadata.invoiceNumber,\n };\n}\n\n/**\n * Validates metadata structure before sending to backend API.\n * Catches type mismatches and invalid values that would cause payment\n * creation failures or blockchain transaction errors.\n */\nexport function validatePaymentMetadata(metadata: PaymentRequestMetadata): {\n isValid: boolean;\n errors: string[];\n} {\n const errors: string[] = [];\n\n /** Token symbol is required for all payment types (stablecoin or native) */\n const token = metadata[\"token\"];\n if (!token || typeof token !== \"string\") {\n errors.push(\"Token symbol is required\");\n }\n\n /**\n * Amount validation handles both string and number types since\n * different integrations may provide amounts in different formats\n */\n const amountDue = metadata[\"amountDue\"];\n if (amountDue !== undefined && amountDue !== null) {\n const amount =\n typeof amountDue === \"string\" ? parseFloat(amountDue) : Number(amountDue);\n if (!isValidAmount(amount) || amount < 0) {\n errors.push(\"Amount must be a valid positive number\");\n }\n }\n\n /**\n * Due dates must be valid ISO strings for consistent timezone handling\n * and proper comparison in payment status calculations\n */\n const dueDate = metadata[\"dueDate\"];\n if (dueDate !== undefined && dueDate !== null) {\n if (typeof dueDate !== \"string\") {\n errors.push(\"Due date must be a string\");\n } else {\n const date = new Date(dueDate);\n if (!isValidDate(date)) {\n errors.push(\"Due date must be a valid ISO date string\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AAc,MAAM,KAAK,SAAS,GAAG;AACxC,aAAO,KAAK,wCAAwC;AAAA,IACtD;AAAA,EACF;AAMA,QAAM,UAAU,SAAS,SAAS;AAClC,MAAI,YAAY,UAAa,YAAY,MAAM;AAC7C,QAAI,OAAO,YAAY,UAAU;AAC/B,aAAO,KAAK,2BAA2B;AAAA,IACzC,OAAO;AACL,YAAM,OAAO,IAAI,KAAK,OAAO;AAC7B,UAAI,CAAC,YAAY,IAAI,GAAG;AACtB,eAAO,KAAK,0CAA0C;AAAA,MACxD;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,SAAS,OAAO,WAAW;AAAA,IAC3B;AAAA,EACF;AACF;",
6
- "names": ["z", "import_viem", "import_viem", "import_viem"]
7
- }
1
+ {"version":3,"file":"index.js","names":["mainnet","optimism","arbitrum","base","sepolia","baseSepolia","DEFAULT_ADDRESS","InstructionAction","eip712TypesMap","DEFAULT_ADDRESS","isValidDate","isNumber"],"sources":["../../src/payments/types.ts","../../src/payments/config/cctp.ts","../../src/payments/config/tokens.ts","../../src/payments/build.ts","../../src/payments/instruction-registry.ts","../../src/payments/action-names.ts","../../src/payments/validation.ts","../../src/payments/chain-token-config-builder.ts","../../src/payments/payment-request-token-resolver.ts","../../src/payments/payment-metadata-builder.ts"],"sourcesContent":["import type { Address, HexString } from \"@otim/utils/schemas\";\n\nexport const PaymentAction = {\n Sweep: \"Sweep\",\n SweepCCTP: \"SweepCCTP\",\n SweepERC20: \"SweepERC20\",\n SweepUniswapV3: \"SweepUniswapV3\",\n SweepDepositERC4626: \"SweepDepositERC4626\",\n} as const;\nexport type PaymentAction = (typeof PaymentAction)[keyof typeof PaymentAction];\nexport interface BaseEphemeralInstructionPayload {\n chainId: number;\n maxExecutions: number;\n fee: {\n maxBaseFeePerGas: HexString;\n maxPriorityFeePerGas: HexString;\n token: Address;\n };\n}\n\nexport interface TokenSpec {\n address: Address;\n decimals: number;\n symbol: string;\n}\n\n/**\n * Orchestration type discriminant.\n * Must match the Rust OrchestrationMetadata enum variants.\n */\nexport const OrchestrationType = {\n PaymentRequest: \"PaymentRequest\",\n AutoEarn: \"AutoEarn\",\n} as const;\nexport type OrchestrationType =\n (typeof OrchestrationType)[keyof typeof OrchestrationType];\n\n/**\n * Payer information for a payment request.\n * Matches Rust `Payer` struct in orchestration.rs.\n */\nexport interface Payer {\n /* Name of the payer (required, can be empty string if unknown) */\n readonly name: string;\n /* Wallet address of the payer */\n readonly address: Address;\n}\n\n/**\n * Payment request metadata stored in orchestration.\n * Matches Rust `PaymentRequestMetadata` struct with serde camelCase renaming.\n *\n * Required fields are enforced at type level to prevent runtime errors.\n * Optional fields match Rust `Option<T>` semantics.\n *\n * Extends Record<string, unknown> for API schema compatibility with\n * `buildSettlementRequestSchema` which expects a flexible metadata object.\n */\nexport interface PaymentRequestMetadata extends Record<string, unknown> {\n /* Discriminant field for backend OrchestrationMetadata enum. Always \"PaymentRequest\". */\n type: typeof OrchestrationType.PaymentRequest;\n /* Token symbol (e.g., \"USDC\", \"USDT\") */\n token: string;\n /* Amount due as a decimal string (e.g., \"150.00\") */\n amountDue: string;\n /* Currency code (e.g., \"USD\") */\n currency: string;\n /* Due date in NaiveDateTime format (YYYY-MM-DDTHH:mm:ss, no timezone) */\n dueDate?: string;\n /* Address of the account receiving payment */\n fromAccountAddress: Address;\n /* Payer information. Optional for payment requests without known payer. */\n payer?: Payer;\n /* Source of the payment request (e.g., \"Manual\", \"Stripe\", \"QuickBooks\") */\n source: string;\n /* Optional note or description for the payment */\n note?: string;\n /* External invoice ID from the source system */\n invoiceId?: string;\n /* Human-readable invoice number */\n invoiceNumber?: string;\n /* URL to the invoice attachment */\n attachmentUrl?: string;\n /* Filename of the attachment */\n attachmentName?: string;\n}\n\n/**\n * Auto-earn metadata stored in orchestration.\n * Matches Rust `AutoEarnMetadata` struct with serde camelCase renaming.\n */\nexport interface AutoEarnMetadata extends Record<string, unknown> {\n /* Discriminant field for backend OrchestrationMetadata enum. Always \"AutoEarn\". */\n type: typeof OrchestrationType.AutoEarn;\n /* Token symbol (e.g., \"USDC\") */\n tokenSymbol: string;\n /* Address of the vault contract */\n vaultAddress: Address;\n /* Human-readable name of the vault */\n vaultName: string;\n}\n\n/**\n * Union type for orchestration metadata.\n */\nexport type OrchestrationMetadata = PaymentRequestMetadata | AutoEarnMetadata;\n\n/**\n * Uniswap V3 fee tiers. Used to specify the fee tier for a Uniswap V3 swap.\n * @see https://docs.uniswap.org/concepts/protocol/fees\n */\nexport const UniswapV3FeeTier = {\n Lowest: \"100\",\n Low: \"500\",\n Medium: \"3000\",\n High: \"10000\",\n} as const;\nexport type UniswapV3FeeTier =\n (typeof UniswapV3FeeTier)[keyof typeof UniswapV3FeeTier];\n","import type { Nullable } from \"@otim/utils/helpers\";\n\nimport {\n arbitrum,\n base,\n baseSepolia,\n mainnet,\n optimism,\n sepolia,\n} from \"viem/chains\";\n\nexport interface CCTPConfig {\n supportedChainIds: Set<number>;\n isSupported(chainId: number): boolean;\n getDomain(chainId: number): Nullable<number>;\n}\n\n/**\n * List of chains that support CCTP\n * Only includes chains that have confirmed CCTP support from Circle\n * @see https://developers.circle.com/stablecoins/docs/supported-domains\n */\nconst cctpSupportedChains = new Set([\n mainnet.id,\n optimism.id,\n arbitrum.id,\n base.id,\n sepolia.id,\n baseSepolia.id,\n]);\n\n/**\n * CCTP Domain Mapping - Maps chain IDs to their Circle CCTP domain identifiers\n * Source: https://developers.circle.com/stablecoins/docs/supported-domains\n *\n * Domain IDs are used by Circle's Cross-Chain Transfer Protocol (CCTP) to\n * identify destination chains when burning and minting USDC across different\n * networks.\n */\nconst cctpDomainMapping: Record<number, number> = {\n [mainnet.id]: 0,\n [optimism.id]: 2,\n [arbitrum.id]: 3,\n [base.id]: 6,\n [sepolia.id]: 0,\n [baseSepolia.id]: 6,\n};\n\nexport class DefaultCCTPConfig implements CCTPConfig {\n supportedChainIds: Set<number>;\n\n constructor() {\n this.supportedChainIds = cctpSupportedChains;\n }\n\n isSupported(chainId: number): boolean {\n return this.supportedChainIds.has(chainId);\n }\n\n getDomain(chainId: number): Nullable<number> {\n return cctpDomainMapping[chainId] ?? null;\n }\n}\n\nexport const defaultCCTPConfig = new DefaultCCTPConfig();\n","import { isStablecoin } from \"@otim/utils/chains\";\n\nimport { UniswapV3FeeTier } from \"../types\";\n\n/**\n * Determines the recommended Uniswap V3 fee tier for a token pair\n *\n * Stable pairs (USDC/USDT swaps) use the Low fee tier (0.05%) since price\n * volatility is minimal. All other pairs use the Medium fee tier (0.3%) to\n * account for higher price volatility\n *\n * @param tokenIn - Symbol of the input token (e.g., \"USDC\", \"USDT\")\n * @param tokenOut - Symbol of the output token (e.g., \"USDC\", \"USDT\")\n * @returns The recommended Uniswap V3 fee tier for the swap\n */\nexport function getRecommendedFeeTier(\n tokenIn: string,\n tokenOut: string,\n): UniswapV3FeeTier {\n if (isStablecoin([tokenIn, tokenOut])) {\n return UniswapV3FeeTier.Low;\n }\n\n return UniswapV3FeeTier.Medium;\n}\n","import type { PaymentRequestBuildRequest } from \"@otim/utils/api\";\nimport type { Nullable } from \"@otim/utils/helpers\";\nimport type { Address, HexString } from \"@otim/utils/schemas\";\n\nimport { DEFAULT_ADDRESS } from \"@otim/utils/helpers\";\n\nexport interface EphemeralInstructionSpec {\n chainId: number;\n salt?: number;\n maxExecutions: number;\n actionArguments: Record<string, unknown>;\n setEphemeralTarget?: boolean;\n}\n\nexport interface BuildPaymentRequestParams {\n payerAddress?: Nullable<Address>;\n completionInstructions: EphemeralInstructionSpec[];\n instructions?: EphemeralInstructionSpec[];\n /** Flexible metadata object - matches API schema z.record(z.string(), z.unknown()) */\n metadata?: Record<string, unknown>;\n maxRuns?: number;\n}\n\ninterface ProcessedInstruction {\n chainId: number;\n salt: number;\n maxExecutions: number;\n actionArguments: Record<string, unknown>;\n setEphemeralTarget: boolean;\n}\n\nexport interface FeeConfig {\n executionFee: number;\n maxBaseFeePerGas: `0x${string}`;\n maxPriorityFeePerGas: `0x${string}`;\n token: Address;\n}\n\nconst DEFAULT_SET_EPHEMERAL_TARGET = true;\n\nexport function createPaymentRequestBuildPayload(\n params: BuildPaymentRequestParams,\n): PaymentRequestBuildRequest {\n const {\n payerAddress = null,\n completionInstructions,\n instructions = [],\n metadata = {},\n maxRuns,\n } = params;\n\n return {\n payerAddress,\n completionInstructions: completionInstructions.map(processInstruction),\n instructions: instructions.map(processInstruction),\n metadata,\n maxRuns,\n };\n}\n\nfunction processInstruction(\n spec: EphemeralInstructionSpec,\n): ProcessedInstruction {\n return {\n chainId: spec.chainId,\n salt: spec.salt ?? generateRandomSalt(),\n maxExecutions: spec.maxExecutions,\n actionArguments: spec.actionArguments,\n setEphemeralTarget: spec.setEphemeralTarget ?? DEFAULT_SET_EPHEMERAL_TARGET,\n };\n}\n\nfunction generateRandomSalt(): number {\n return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);\n}\n\nexport function createDefaultFee(\n executionFee = 0,\n maxBaseFeePerGas: HexString = \"0x0\",\n maxPriorityFeePerGas: HexString = \"0x0\",\n token: Address = DEFAULT_ADDRESS,\n): FeeConfig {\n return {\n token,\n executionFee,\n maxBaseFeePerGas,\n maxPriorityFeePerGas,\n };\n}\n\nexport function createFeeWithToken(\n token?: Address,\n maxPriorityFeePerGas?: `0x${string}`,\n): FeeConfig {\n return createDefaultFee(0, \"0x0\", maxPriorityFeePerGas ?? \"0x0\", token);\n}\n","import type { EIP712Types } from \"@otim/utils/instructions\";\nimport type { AbiParameter } from \"abitype\";\n\nimport { eip712TypesMap } from \"@otim/utils/instructions\";\nimport { InstructionAction } from \"@otim/utils/schemas\";\n\nconst feeAbiComponent = {\n name: \"fee\",\n type: \"tuple\",\n components: [\n { name: \"token\", type: \"address\" },\n { name: \"maxBaseFeePerGas\", type: \"uint256\" },\n { name: \"maxPriorityFeePerGas\", type: \"uint256\" },\n { name: \"executionFee\", type: \"uint256\" },\n ],\n} as const satisfies AbiParameter;\n\nconst sweepAbi: readonly AbiParameter[] = [\n {\n type: \"tuple\",\n components: [\n { name: \"target\", type: \"address\" },\n { name: \"threshold\", type: \"uint256\" },\n { name: \"endBalance\", type: \"uint256\" },\n { name: \"gasLimit\", type: \"uint256\" },\n feeAbiComponent,\n ],\n },\n] as const;\n\nconst sweepERC20Abi: readonly AbiParameter[] = [\n {\n type: \"tuple\",\n components: [\n { name: \"token\", type: \"address\" },\n { name: \"target\", type: \"address\" },\n { name: \"threshold\", type: \"uint256\" },\n { name: \"endBalance\", type: \"uint256\" },\n feeAbiComponent,\n ],\n },\n] as const;\n\nconst sweepCCTPAbi: readonly AbiParameter[] = [\n {\n type: \"tuple\",\n components: [\n { name: \"token\", type: \"address\" },\n { name: \"destinationDomain\", type: \"uint32\" },\n { name: \"destinationMintRecipient\", type: \"bytes32\" },\n { name: \"threshold\", type: \"uint256\" },\n { name: \"endBalance\", type: \"uint256\" },\n feeAbiComponent,\n ],\n },\n] as const;\n\nconst sweepUniswapV3Abi: readonly AbiParameter[] = [\n {\n type: \"tuple\",\n components: [\n { name: \"recipient\", type: \"address\" },\n { name: \"tokenIn\", type: \"address\" },\n { name: \"tokenOut\", type: \"address\" },\n { name: \"feeTier\", type: \"uint24\" },\n { name: \"threshold\", type: \"uint256\" },\n { name: \"endBalance\", type: \"uint256\" },\n { name: \"floorAmountOut\", type: \"uint256\" },\n { name: \"meanPriceLookBack\", type: \"uint32\" },\n { name: \"maxPriceDeviationBPS\", type: \"uint32\" },\n feeAbiComponent,\n ],\n },\n] as const;\n\nconst sweepSkipCCTPDepositAccountAbi: readonly AbiParameter[] = [\n {\n type: \"tuple\",\n components: [\n { name: \"depositor\", type: \"address\" },\n { name: \"destinationDomain\", type: \"uint32\" },\n { name: \"destinationMintRecipient\", type: \"bytes32\" },\n { name: \"threshold\", type: \"uint256\" },\n feeAbiComponent,\n ],\n },\n] as const;\n\nconst sweepDepositERC4626Abi: readonly AbiParameter[] = [\n {\n type: \"tuple\",\n components: [\n { name: \"vault\", type: \"address\" },\n { name: \"recipient\", type: \"address\" },\n { name: \"threshold\", type: \"uint256\" },\n { name: \"endBalance\", type: \"uint256\" },\n { name: \"minDeposit\", type: \"uint256\" },\n { name: \"minTotalShares\", type: \"uint256\" },\n feeAbiComponent,\n ],\n },\n] as const;\n\nconst sweepWithdrawERC4626Abi: readonly AbiParameter[] = [\n {\n type: \"tuple\",\n components: [\n { name: \"vault\", type: \"address\" },\n { name: \"recipient\", type: \"address\" },\n { name: \"threshold\", type: \"uint256\" },\n { name: \"endBalance\", type: \"uint256\" },\n { name: \"minWithdraw\", type: \"uint256\" },\n feeAbiComponent,\n ],\n },\n] as const;\n\nconst actionAbiMap = {\n [InstructionAction.Sweep]: sweepAbi,\n [InstructionAction.SweepERC20]: sweepERC20Abi,\n [InstructionAction.SweepCCTP]: sweepCCTPAbi,\n [InstructionAction.SweepUniswapV3]: sweepUniswapV3Abi,\n [InstructionAction.SweepSkipCCTPDepositAccount]: sweepSkipCCTPDepositAccountAbi,\n [InstructionAction.SweepDepositERC4626]: sweepDepositERC4626Abi,\n [InstructionAction.SweepWithdrawERC4626]: sweepWithdrawERC4626Abi,\n} as const;\n\nexport interface InstructionTypeDefinition {\n abi: readonly AbiParameter[];\n eip712Types: EIP712Types;\n}\n\ntype ActionName = keyof typeof actionAbiMap;\n\nclass InstructionTypeRegistry {\n private registry = new Map<string, InstructionTypeDefinition>();\n\n constructor() {\n this.initializeDefaultTypes();\n }\n\n register(actionName: string, definition: InstructionTypeDefinition): void {\n this.registry.set(actionName, definition);\n }\n\n get(actionName: string): InstructionTypeDefinition {\n const definition = this.registry.get(actionName);\n\n if (!definition) {\n throw this.createUnsupportedTypeError(actionName);\n }\n\n return definition;\n }\n\n has(actionName: string): boolean {\n return this.registry.has(actionName);\n }\n\n getAvailableTypes(): string[] {\n return Array.from(this.registry.keys());\n }\n\n private initializeDefaultTypes(): void {\n const actionNames = Object.keys(actionAbiMap) as ActionName[];\n\n for (const actionName of actionNames) {\n const abi = actionAbiMap[actionName];\n const eip712Types = eip712TypesMap[actionName];\n\n if (abi && eip712Types) {\n this.register(actionName, { abi, eip712Types });\n }\n }\n }\n\n private createUnsupportedTypeError(actionName: string): Error {\n const availableTypes = this.getAvailableTypes().join(\", \");\n return new Error(\n `Unsupported instruction type: ${actionName}. Available: ${availableTypes}`,\n );\n }\n}\n\nexport const instructionRegistry = new InstructionTypeRegistry();\n","import type { PaymentRequestBuildResponse } from \"@otim/utils/api\";\nimport type { Optional } from \"@otim/utils/helpers\";\n\ninterface InstructionWithActionName {\n actionName?: string;\n}\n\nexport interface PaymentResponseWithActionNames extends PaymentRequestBuildResponse {\n completionInstructions: Array<\n PaymentRequestBuildResponse[\"completionInstructions\"][number] &\n InstructionWithActionName\n >;\n instructions: Array<\n PaymentRequestBuildResponse[\"instructions\"][number] &\n InstructionWithActionName\n >;\n}\n\ninterface InstructionWithArguments {\n actionArguments: Record<string, unknown>;\n}\n\ntype ActionNamesMap = Record<number, string>;\n\nexport function addActionNamesToInstructions(\n buildResponse: PaymentRequestBuildResponse,\n actionNames: ActionNamesMap,\n): PaymentResponseWithActionNames {\n const completionInstructionCount =\n buildResponse.completionInstructions.length;\n\n return {\n ...buildResponse,\n completionInstructions: buildResponse.completionInstructions.map(\n (instruction, index) => ({\n ...instruction,\n actionName: actionNames[index],\n }),\n ),\n instructions: buildResponse.instructions.map((instruction, index) => ({\n ...instruction,\n actionName: actionNames[completionInstructionCount + index],\n })),\n };\n}\n\nexport function extractActionNamesMap(\n completionInstructions: InstructionWithArguments[],\n instructions: InstructionWithArguments[] = [],\n): ActionNamesMap {\n const allInstructions = [...completionInstructions, ...instructions];\n\n return allInstructions.reduce<ActionNamesMap>(\n (actionNamesMap, instruction, index) => {\n const actionName = getFirstActionArgumentKey(instruction.actionArguments);\n if (actionName) {\n actionNamesMap[index] = actionName;\n }\n return actionNamesMap;\n },\n {},\n );\n}\n\nfunction getFirstActionArgumentKey(\n actionArguments: Record<string, unknown>,\n): Optional<string> {\n const keys = Object.keys(actionArguments);\n return keys[0];\n}\n","interface SignatureCountAssertion {\n expected: number;\n received: number;\n}\n\n/* Used to validate the number of signatures in a payment request. */\nexport class SignatureValidator {\n static assertExactCount(context: SignatureCountAssertion): void {\n if (context.received !== context.expected) {\n throw new Error(\n `Signature count mismatch: expected ${context.expected}, received ${context.received}`,\n );\n }\n }\n\n static assertMinimumCount(context: SignatureCountAssertion): void {\n if (context.received < context.expected) {\n throw new Error(\n `Insufficient signatures: expected at least ${context.expected}, received ${context.received}`,\n );\n }\n }\n}\n\nexport function assertSignatureCount<T>(\n signatures: T[],\n expectedCount: number,\n): asserts signatures is T[] & { length: typeof expectedCount } {\n SignatureValidator.assertExactCount({\n expected: expectedCount,\n received: signatures.length,\n });\n}\n\nexport function assertMinimumSignatures<T>(\n signatures: T[],\n minimumCount: number,\n): asserts signatures is T[] & { length: number } {\n SignatureValidator.assertMinimumCount({\n expected: minimumCount,\n received: signatures.length,\n });\n}\n","import type { HexString } from \"../schemas\";\nimport type { ChainTokenConfig } from \"./comprehensive-payment-request\";\n\ninterface Token {\n address: string;\n symbol: string;\n chainId: number;\n decimals: number;\n}\n\nexport function createChainTokenConfigs(tokens: Token[]): ChainTokenConfig[] {\n const tokensByChain = groupTokensByChainId(tokens);\n return convertToChainConfigs(tokensByChain);\n}\n\nfunction groupTokensByChainId(tokens: Token[]): Map<number, Token[]> {\n const grouped = new Map<number, Token[]>();\n\n for (const token of tokens) {\n const chainTokens = grouped.get(token.chainId) ?? [];\n chainTokens.push(token);\n grouped.set(token.chainId, chainTokens);\n }\n\n return grouped;\n}\n\nfunction convertToChainConfigs(\n tokensByChain: Map<number, Token[]>,\n): ChainTokenConfig[] {\n return Array.from(tokensByChain.entries()).map(([chainId, tokens]) => ({\n chainId,\n tokens: tokens.map((token) => ({\n symbol: token.symbol,\n address: token.address as HexString,\n decimals: token.decimals,\n })),\n }));\n}\n","import type { Nullish } from \"@otim/utils/helpers\";\nimport type { Address } from \"@otim/utils/schemas\";\n\nimport { DEFAULT_ADDRESS } from \"@otim/utils/helpers\";\n\ninterface Token {\n symbol: string;\n address: string;\n}\n\n/* Checks if a token is the native blockchain token (ETH). */\nexport function isNativeToken<T extends Pick<Token, \"symbol\" | \"address\">>(\n token: Nullish<T>,\n): boolean {\n if (!token) return false;\n\n return (\n token.symbol === \"ETH\" ||\n token.address.toLowerCase() === DEFAULT_ADDRESS.toLowerCase()\n );\n}\n\n/* Creates unique identifier for a token by combining chain ID and address. */\nexport function createTokenIdentifier(\n chainId: number,\n tokenAddress: Address,\n): string {\n return `${chainId}:${tokenAddress}`;\n}\n","import type { InvoiceMetadata } from \"./payment-metadata\";\nimport type { Payer, PaymentRequestMetadata } from \"./types\";\nimport type { Address } from \"../schemas\";\n\nimport { OrchestrationType } from \"./types\";\nimport { isValidDate } from \"../helpers/date\";\nimport { isNumber } from \"../helpers/types\";\n\n/* Default currency for payments. Centralized for easy modification. */\nconst DEFAULT_CURRENCY = \"USD\" as const;\n\n/* Default source for manually created payment requests */\nconst DEFAULT_SOURCE = \"Manual\" as const;\n\n/**\n * Input parameters for building manual payment metadata.\n * All fields are explicit and required unless marked optional.\n */\nexport interface BuildPaymentMetadataParams {\n /* Token symbol (e.g., \"USDC\", \"USDT\") */\n readonly tokenSymbol: string;\n /* Due date in ISO 8601 or parseable date format */\n readonly dueDate: string;\n /* Amount in USD (numeric, will be formatted to 2 decimal places) */\n readonly amountInUSD: number;\n /* Address of the account receiving payment */\n readonly fromAccountAddress: Address;\n /* Payer information */\n readonly payer: Payer;\n /* Optional note for the payment */\n readonly note?: string;\n /* Source of the payment request. Defaults to \"Manual\". */\n readonly source?: string;\n}\n\n/**\n * Input parameters for building payment metadata from invoice integration.\n * Invoice fields take precedence over any manual overrides.\n */\nexport interface BuildPaymentMetadataFromInvoiceParams {\n /* Token symbol (e.g., \"USDC\", \"USDT\") */\n readonly tokenSymbol: string;\n /* Address of the account receiving payment */\n readonly fromAccountAddress: Address;\n /* Payer information */\n readonly payer: Payer;\n /* Invoice metadata from external integration */\n readonly invoiceMetadata: InvoiceMetadata;\n}\n\n/**\n * Input parameters for merging invoice data with existing base metadata.\n * Invoice fields override base metadata to ensure accuracy.\n */\nexport interface BuildInvoiceMetadataParams {\n /* Invoice metadata from external integration */\n readonly invoiceMetadata: InvoiceMetadata;\n /* Base payment metadata to merge with invoice data */\n readonly baseMetadata: PaymentRequestMetadata;\n}\n\n/**\n * Result of metadata validation.\n * Immutable result object for type safety.\n */\nexport interface MetadataValidationResult {\n readonly isValid: boolean;\n readonly errors: readonly string[];\n}\n\n/**\n * Formats a date to NaiveDateTime format expected by Rust backend.\n * Converts ISO 8601 strings like \"2025-01-15T00:00:00.000Z\" to \"2025-01-15T00:00:00\".\n *\n * Rust's chrono::NaiveDateTime expects format without timezone suffix.\n *\n * @param dateInput - Date string or Date object to format\n * @returns Formatted NaiveDateTime string\n * @throws Error if date is invalid\n */\nfunction formatToNaiveDateTime(dateInput: string | Date): string {\n const date = typeof dateInput === \"string\" ? new Date(dateInput) : dateInput;\n\n if (!isValidDate(date)) {\n throw new Error(`Invalid date provided: ${String(dateInput)}`);\n }\n\n const year = date.getUTCFullYear();\n const month = String(date.getUTCMonth() + 1).padStart(2, \"0\");\n const day = String(date.getUTCDate()).padStart(2, \"0\");\n const hours = String(date.getUTCHours()).padStart(2, \"0\");\n const minutes = String(date.getUTCMinutes()).padStart(2, \"0\");\n const seconds = String(date.getUTCSeconds()).padStart(2, \"0\");\n\n return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}`;\n}\n\n/**\n * Formats a numeric amount to a decimal string with 2 decimal places.\n * Ensures consistent formatting for monetary values.\n *\n * @param amount - Numeric amount to format\n * @returns Formatted amount string (e.g., \"150.00\")\n */\nfunction formatAmount(amount: number): string {\n return amount.toFixed(2);\n}\n\n/**\n * Validates that a value is a safe, finite number suitable for monetary amounts.\n * Excludes NaN and Infinity which could cause calculation errors downstream.\n *\n * @param value - Value to validate\n * @returns True if value is a valid monetary amount\n */\nfunction isValidMonetaryAmount(value: unknown): value is number {\n return isNumber(value) && Number.isFinite(value);\n}\n\n/**\n * Constructs payment metadata for manually created payment requests.\n * Pure function with explicit input/output contract.\n *\n * @param params - Configuration for manual payment request\n * @returns Immutable PaymentRequestMetadata object\n */\nexport function buildPaymentMetadata(\n params: BuildPaymentMetadataParams,\n): PaymentRequestMetadata {\n const {\n tokenSymbol,\n note,\n dueDate,\n amountInUSD,\n fromAccountAddress,\n payer,\n source = DEFAULT_SOURCE,\n } = params;\n\n const baseMetadata: PaymentRequestMetadata = {\n type: OrchestrationType.PaymentRequest,\n token: tokenSymbol,\n amountDue: formatAmount(amountInUSD),\n currency: DEFAULT_CURRENCY,\n dueDate: formatToNaiveDateTime(dueDate),\n fromAccountAddress,\n payer,\n source,\n };\n\n // Conditionally add optional fields (pure spread, no mutation)\n if (note !== undefined && note !== \"\") {\n return { ...baseMetadata, note };\n }\n\n return baseMetadata;\n}\n\n/**\n * Constructs payment metadata from invoice integration data.\n * Invoice fields are authoritative and override any defaults.\n * Pure function ensuring consistent metadata structure for integrations.\n *\n * @param params - Invoice and account configuration\n * @returns Immutable PaymentRequestMetadata object\n */\nexport function buildPaymentMetadataFromInvoice(\n params: BuildPaymentMetadataFromInvoiceParams,\n): PaymentRequestMetadata {\n const { tokenSymbol, fromAccountAddress, payer, invoiceMetadata } = params;\n\n const baseMetadata: PaymentRequestMetadata = {\n type: OrchestrationType.PaymentRequest,\n token: tokenSymbol,\n amountDue: formatAmount(Number(invoiceMetadata.amount)),\n currency: invoiceMetadata.currency,\n dueDate: formatToNaiveDateTime(invoiceMetadata.dueDate),\n fromAccountAddress,\n payer,\n source: invoiceMetadata.source,\n invoiceId: invoiceMetadata.invoiceId,\n invoiceNumber: invoiceMetadata.invoiceNumber,\n };\n\n // Build optional fields immutably\n const optionalFields: Partial<PaymentRequestMetadata> = {\n ...(invoiceMetadata.description && { note: invoiceMetadata.description }),\n ...(invoiceMetadata.attachmentUrl && {\n attachmentUrl: invoiceMetadata.attachmentUrl,\n }),\n ...(invoiceMetadata.attachmentName && {\n attachmentName: invoiceMetadata.attachmentName,\n }),\n };\n\n return { ...baseMetadata, ...optionalFields };\n}\n\n/**\n * Merges invoice data from external integrations with base payment metadata.\n * Invoice fields override manual entries to ensure accuracy and maintain\n * audit trail through source/invoiceId tracking.\n *\n * @param params - Invoice and base metadata configuration\n * @returns Immutable PaymentRequestMetadata with merged fields\n */\nexport function buildInvoiceMetadata(\n params: BuildInvoiceMetadataParams,\n): PaymentRequestMetadata {\n const { invoiceMetadata, baseMetadata } = params;\n\n const mergedMetadata: PaymentRequestMetadata = {\n ...baseMetadata,\n // Invoice amounts/dates are authoritative\n amountDue: formatAmount(Number(invoiceMetadata.amount)),\n currency: invoiceMetadata.currency,\n dueDate: formatToNaiveDateTime(invoiceMetadata.dueDate),\n // Preserve user's manual note if invoice doesn't provide one\n note: invoiceMetadata.description ?? baseMetadata.note,\n // Track integration source for reconciliation and debugging\n source: invoiceMetadata.source,\n invoiceId: invoiceMetadata.invoiceId,\n invoiceNumber: invoiceMetadata.invoiceNumber,\n };\n\n // Build optional attachment fields immutably\n const attachmentFields: Partial<PaymentRequestMetadata> = {\n ...(invoiceMetadata.attachmentUrl && {\n attachmentUrl: invoiceMetadata.attachmentUrl,\n }),\n ...(invoiceMetadata.attachmentName && {\n attachmentName: invoiceMetadata.attachmentName,\n }),\n };\n\n return { ...mergedMetadata, ...attachmentFields };\n}\n\n/**\n * Validates payment metadata structure before sending to backend API.\n * Catches type mismatches and invalid values that would cause payment\n * creation failures or blockchain transaction errors.\n *\n * Pure function returning immutable result object.\n *\n * @param metadata - Metadata to validate\n * @returns Validation result with explicit errors array\n */\nexport function validatePaymentMetadata(\n metadata: PaymentRequestMetadata,\n): MetadataValidationResult {\n const errors: string[] = [];\n\n // Type discriminator validation\n if (metadata.type !== OrchestrationType.PaymentRequest) {\n errors.push(\n `Metadata type must be '${OrchestrationType.PaymentRequest}', got '${String(metadata.type)}'`,\n );\n }\n\n // Token symbol validation\n if (!metadata.token || typeof metadata.token !== \"string\") {\n errors.push(\"Token symbol is required and must be a string\");\n }\n\n // Amount validation - must be valid positive decimal string\n if (!metadata.amountDue || typeof metadata.amountDue !== \"string\") {\n errors.push(\"Amount due is required and must be a string\");\n } else {\n const amount = parseFloat(metadata.amountDue);\n if (!isValidMonetaryAmount(amount) || amount < 0) {\n errors.push(\n `Amount must be a valid non-negative number, got '${metadata.amountDue}'`,\n );\n }\n }\n\n // Currency validation\n if (!metadata.currency || typeof metadata.currency !== \"string\") {\n errors.push(\"Currency is required and must be a string\");\n }\n\n // Due date validation - must be valid date string\n if (!metadata.dueDate || typeof metadata.dueDate !== \"string\") {\n errors.push(\"Due date is required and must be a string\");\n } else {\n const date = new Date(metadata.dueDate);\n if (!isValidDate(date)) {\n errors.push(\n `Due date must be a valid date string, got '${metadata.dueDate}'`,\n );\n }\n }\n\n // From account address validation\n if (\n !metadata.fromAccountAddress ||\n typeof metadata.fromAccountAddress !== \"string\"\n ) {\n errors.push(\"From account address is required and must be a string\");\n }\n\n // Payer validation - required with both name and address\n if (!metadata.payer) {\n errors.push(\"Payer information is required\");\n } else {\n if (typeof metadata.payer.name !== \"string\") {\n errors.push(\"Payer name must be a string\");\n }\n if (!metadata.payer.address || typeof metadata.payer.address !== \"string\") {\n errors.push(\"Payer address is required and must be a string\");\n }\n }\n\n // Source validation\n if (!metadata.source || typeof metadata.source !== \"string\") {\n errors.push(\"Source is required and must be a string\");\n }\n\n return {\n isValid: errors.length === 0,\n errors,\n };\n}\n"],"mappings":";;;;;;;;;;AAEA,MAAa,gBAAgB;CAC3B,OAAO;CACP,WAAW;CACX,YAAY;CACZ,gBAAgB;CAChB,qBAAqB;CACtB;;;;;AAsBD,MAAa,oBAAoB;CAC/B,gBAAgB;CAChB,UAAU;CACX;;;;;AA8ED,MAAa,mBAAmB;CAC9B,QAAQ;CACR,KAAK;CACL,QAAQ;CACR,MAAM;CACP;;;;;;;;;AC9FD,MAAM,sBAAsB,IAAI,IAAI;CAClCA,oBAAQ;CACRC,qBAAS;CACTC,qBA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