@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,1285 +1,643 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
-
5
- // src/payments/types.ts
6
- var PaymentAction = {
7
- Sweep: "sweep",
8
- SweepCCTP: "sweepCCTP",
9
- SweepERC20: "sweepERC20",
10
- SweepUniswapV3: "sweepUniswapV3"
1
+ import { t as _defineProperty } from "../defineProperty-DzhmunJg.mjs";
2
+ import { P as isNumber, b as isValidDate } from "../date-gBac-Om9.mjs";
3
+ import { InstructionAction } from "@otim/utils/schemas";
4
+ import { DEFAULT_ADDRESS } from "@otim/utils/helpers";
5
+ import { arbitrum, base, baseSepolia, mainnet, optimism, sepolia } from "viem/chains";
6
+ import { isStablecoin } from "@otim/utils/chains";
7
+ import { eip712TypesMap } from "@otim/utils/instructions";
8
+
9
+ //#region src/payments/types.ts
10
+ const PaymentAction = {
11
+ Sweep: "Sweep",
12
+ SweepCCTP: "SweepCCTP",
13
+ SweepERC20: "SweepERC20",
14
+ SweepUniswapV3: "SweepUniswapV3",
15
+ SweepDepositERC4626: "SweepDepositERC4626"
16
+ };
17
+ /**
18
+ * Orchestration type discriminant.
19
+ * Must match the Rust OrchestrationMetadata enum variants.
20
+ */
21
+ const OrchestrationType = {
22
+ PaymentRequest: "PaymentRequest",
23
+ AutoEarn: "AutoEarn"
11
24
  };
12
- var UniswapV3FeeTier = {
13
- Lowest: "100",
14
- Low: "500",
15
- Medium: "3000",
16
- High: "10000"
25
+ /**
26
+ * Uniswap V3 fee tiers. Used to specify the fee tier for a Uniswap V3 swap.
27
+ * @see https://docs.uniswap.org/concepts/protocol/fees
28
+ */
29
+ const UniswapV3FeeTier = {
30
+ Lowest: "100",
31
+ Low: "500",
32
+ Medium: "3000",
33
+ High: "10000"
17
34
  };
18
35
 
19
- // src/payments/config/cctp.ts
20
- import {
21
- arbitrum,
22
- arbitrumSepolia,
23
- base,
24
- baseSepolia,
25
- mainnet,
26
- optimism,
27
- optimismSepolia,
28
- sepolia
29
- } from "viem/chains";
30
- var cctpSupportedChains = /* @__PURE__ */ new Set([
31
- mainnet.id,
32
- optimism.id,
33
- arbitrum.id,
34
- base.id,
35
- sepolia.id,
36
- optimismSepolia.id,
37
- arbitrumSepolia.id,
38
- baseSepolia.id
36
+ //#endregion
37
+ //#region src/payments/config/cctp.ts
38
+ /**
39
+ * List of chains that support CCTP
40
+ * Only includes chains that have confirmed CCTP support from Circle
41
+ * @see https://developers.circle.com/stablecoins/docs/supported-domains
42
+ */
43
+ const cctpSupportedChains = new Set([
44
+ mainnet.id,
45
+ optimism.id,
46
+ arbitrum.id,
47
+ base.id,
48
+ sepolia.id,
49
+ baseSepolia.id
39
50
  ]);
40
- var cctpDomainMapping = {
41
- [mainnet.id]: 0,
42
- [optimism.id]: 2,
43
- [arbitrum.id]: 3,
44
- [base.id]: 6,
45
- [sepolia.id]: 0,
46
- [optimismSepolia.id]: 2,
47
- [arbitrumSepolia.id]: 3,
48
- [baseSepolia.id]: 6
51
+ /**
52
+ * CCTP Domain Mapping - Maps chain IDs to their Circle CCTP domain identifiers
53
+ * Source: https://developers.circle.com/stablecoins/docs/supported-domains
54
+ *
55
+ * Domain IDs are used by Circle's Cross-Chain Transfer Protocol (CCTP) to
56
+ * identify destination chains when burning and minting USDC across different
57
+ * networks.
58
+ */
59
+ const cctpDomainMapping = {
60
+ [mainnet.id]: 0,
61
+ [optimism.id]: 2,
62
+ [arbitrum.id]: 3,
63
+ [base.id]: 6,
64
+ [sepolia.id]: 0,
65
+ [baseSepolia.id]: 6
49
66
  };
50
67
  var DefaultCCTPConfig = class {
51
- constructor() {
52
- __publicField(this, "supportedChainIds");
53
- this.supportedChainIds = cctpSupportedChains;
54
- }
55
- isSupported(chainId) {
56
- return this.supportedChainIds.has(chainId);
57
- }
58
- getDomain(chainId) {
59
- return cctpDomainMapping[chainId] ?? null;
60
- }
61
- };
62
- var defaultCCTPConfig = new DefaultCCTPConfig();
63
-
64
- // src/helpers/blockchain.ts
65
- import { isAddressEqual } from "viem";
66
- var DEFAULT_ADDRESS = "0x0000000000000000000000000000000000000000";
67
-
68
- // src/helpers/date.ts
69
- import z from "zod";
70
- var iso8601DateSchema = z.string().regex(
71
- /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?Z$/,
72
- "Must be a valid ISO 8601 date format (e.g., 2024-12-31T23:59:59.000Z)"
73
- );
74
- var TimeUnit = {
75
- Day: "day",
76
- Month: "month",
77
- Year: "year"
68
+ constructor() {
69
+ _defineProperty(this, "supportedChainIds", void 0);
70
+ this.supportedChainIds = cctpSupportedChains;
71
+ }
72
+ isSupported(chainId) {
73
+ return this.supportedChainIds.has(chainId);
74
+ }
75
+ getDomain(chainId) {
76
+ return cctpDomainMapping[chainId] ?? null;
77
+ }
78
78
  };
79
- var units = {
80
- [TimeUnit.Day]: {
81
- one: "day",
82
- other: "days"
83
- },
84
- [TimeUnit.Month]: {
85
- one: "month",
86
- other: "months"
87
- },
88
- [TimeUnit.Year]: {
89
- one: "year",
90
- other: "years"
91
- }
92
- };
93
- var isDateInvalid = (date) => {
94
- return date.toString() === "Invalid Date";
95
- };
96
- var isValidDate = (date) => {
97
- return !isDateInvalid(date) && !isNaN(date.getTime());
98
- };
99
-
100
- // src/helpers/types.ts
101
- var isNumber = (value) => typeof value === "number";
102
-
103
- // src/chains/utils/stablecoin.ts
104
- var stablecoinSymbols = ["USDC", "USDT"];
105
- function isStablecoin(symbol) {
106
- if (typeof symbol === "string") {
107
- return stablecoinSymbols.includes(
108
- symbol
109
- );
110
- }
111
- return symbol.every(
112
- (s) => stablecoinSymbols.includes(s)
113
- );
114
- }
115
-
116
- // src/payments/config/tokens.ts
79
+ const defaultCCTPConfig = new DefaultCCTPConfig();
80
+
81
+ //#endregion
82
+ //#region src/payments/config/tokens.ts
83
+ /**
84
+ * Determines the recommended Uniswap V3 fee tier for a token pair
85
+ *
86
+ * Stable pairs (USDC/USDT swaps) use the Low fee tier (0.05%) since price
87
+ * volatility is minimal. All other pairs use the Medium fee tier (0.3%) to
88
+ * account for higher price volatility
89
+ *
90
+ * @param tokenIn - Symbol of the input token (e.g., "USDC", "USDT")
91
+ * @param tokenOut - Symbol of the output token (e.g., "USDC", "USDT")
92
+ * @returns The recommended Uniswap V3 fee tier for the swap
93
+ */
117
94
  function getRecommendedFeeTier(tokenIn, tokenOut) {
118
- if (isStablecoin([tokenIn, tokenOut])) {
119
- return UniswapV3FeeTier.Low;
120
- }
121
- return UniswapV3FeeTier.Medium;
95
+ if (isStablecoin([tokenIn, tokenOut])) return UniswapV3FeeTier.Low;
96
+ return UniswapV3FeeTier.Medium;
122
97
  }
123
98
 
124
- // src/payments/build.ts
125
- var DEFAULT_SET_EPHEMERAL_TARGET = true;
99
+ //#endregion
100
+ //#region src/payments/build.ts
101
+ const DEFAULT_SET_EPHEMERAL_TARGET = true;
126
102
  function createPaymentRequestBuildPayload(params) {
127
- const {
128
- payerAddress = null,
129
- completionInstructions,
130
- instructions = [],
131
- metadata = {},
132
- maxRuns
133
- } = params;
134
- return {
135
- payerAddress,
136
- completionInstructions: completionInstructions.map(processInstruction),
137
- instructions: instructions.map(processInstruction),
138
- metadata,
139
- maxRuns
140
- };
103
+ const { payerAddress = null, completionInstructions, instructions = [], metadata = {}, maxRuns } = params;
104
+ return {
105
+ payerAddress,
106
+ completionInstructions: completionInstructions.map(processInstruction),
107
+ instructions: instructions.map(processInstruction),
108
+ metadata,
109
+ maxRuns
110
+ };
141
111
  }
142
112
  function processInstruction(spec) {
143
- return {
144
- chainId: spec.chainId,
145
- salt: spec.salt ?? generateRandomSalt(),
146
- maxExecutions: spec.maxExecutions,
147
- actionArguments: spec.actionArguments,
148
- setEphemeralTarget: spec.setEphemeralTarget ?? DEFAULT_SET_EPHEMERAL_TARGET
149
- };
113
+ return {
114
+ chainId: spec.chainId,
115
+ salt: spec.salt ?? generateRandomSalt(),
116
+ maxExecutions: spec.maxExecutions,
117
+ actionArguments: spec.actionArguments,
118
+ setEphemeralTarget: spec.setEphemeralTarget ?? DEFAULT_SET_EPHEMERAL_TARGET
119
+ };
150
120
  }
151
121
  function generateRandomSalt() {
152
- return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
122
+ return Math.floor(Math.random() * Number.MAX_SAFE_INTEGER);
153
123
  }
154
124
  function createDefaultFee(executionFee = 0, maxBaseFeePerGas = "0x0", maxPriorityFeePerGas = "0x0", token = DEFAULT_ADDRESS) {
155
- return {
156
- token,
157
- executionFee,
158
- maxBaseFeePerGas,
159
- maxPriorityFeePerGas
160
- };
125
+ return {
126
+ token,
127
+ executionFee,
128
+ maxBaseFeePerGas,
129
+ maxPriorityFeePerGas
130
+ };
161
131
  }
162
132
  function createFeeWithToken(token, maxPriorityFeePerGas) {
163
- return createDefaultFee(0, "0x0", maxPriorityFeePerGas ?? "0x0", token);
164
- }
165
-
166
- // src/payments/comprehensive-payment-request.ts
167
- import { parseUnits, toHex } from "viem";
168
-
169
- // src/payments/actions/sweep-cctp.ts
170
- import { pad } from "viem";
171
- function createSweepCCTPActionArguments(payload) {
172
- const cctpConfig = payload.cctpConfig ?? defaultCCTPConfig;
173
- const destinationDomain = resolveCCTPDomain(
174
- payload.destinationChainId,
175
- cctpConfig
176
- );
177
- return {
178
- [PaymentAction.SweepCCTP]: {
179
- token: payload.token,
180
- destinationDomain,
181
- /* CCTP requires the recipient address to be padded to 32 bytes */
182
- destinationMintRecipient: pad(payload.destinationMintRecipient, {
183
- size: 32
184
- }),
185
- threshold: payload.threshold,
186
- endBalance: payload.endBalance,
187
- fee: payload.fee
188
- }
189
- };
190
- }
191
- function resolveCCTPDomain(destinationChainId, cctpConfig) {
192
- const domain = cctpConfig.getDomain(destinationChainId);
193
- if (domain === null) {
194
- throw new Error(`Chain ${destinationChainId} does not support CCTP`);
195
- }
196
- return domain;
197
- }
198
-
199
- // src/payments/actions/sweep-erc20.ts
200
- function createSweepERC20ActionArguments(payload) {
201
- return {
202
- [PaymentAction.SweepERC20]: {
203
- token: payload.token,
204
- target: payload.target,
205
- threshold: payload.threshold,
206
- endBalance: payload.endBalance,
207
- fee: payload.fee
208
- }
209
- };
210
- }
211
-
212
- // src/payments/actions/sweep-uniswap-v3.ts
213
- function createSweepUniswapV3ActionArguments(payload) {
214
- return {
215
- [PaymentAction.SweepUniswapV3]: {
216
- recipient: payload.recipient,
217
- tokenIn: payload.tokenIn,
218
- tokenOut: payload.tokenOut,
219
- feeTier: payload.feeTier,
220
- threshold: payload.threshold,
221
- endBalance: payload.endBalance,
222
- floorAmountOut: payload.floorAmountOut,
223
- meanPriceLookBack: payload.meanPriceLookBack,
224
- maxPriceDeviationBps: payload.maxPriceDeviationBps,
225
- fee: payload.fee
226
- }
227
- };
228
- }
229
-
230
- // src/payments/comprehensive-payment-request.ts
231
- var USDC_SYMBOL = "USDC";
232
- var USDT_SYMBOL = "USDT";
233
- var MINIMUM_THRESHOLD = 1n;
234
- var UNISWAP_MEAN_PRICE_LOOKBACK = 600;
235
- var ZERO_BALANCE = 0n;
236
- var USDT_MAX_PRICE_DEVIATION_BPS = 200;
237
- var DEFAULT_MAX_PRICE_DEVIATION_BPS = 500;
238
- var STABLE_SLIPPAGE_BPS = 1;
239
- var NON_STABLE_SLIPPAGE_BPS = 50;
240
- function createComprehensivePaymentRequest(params) {
241
- const {
242
- settlementChainId,
243
- recipient,
244
- amount,
245
- ephemeralWalletAddress,
246
- chainTokenConfigs,
247
- payerAddress,
248
- metadata,
249
- feeToken,
250
- cctpConfig = defaultCCTPConfig,
251
- maxRuns = 1
252
- } = params;
253
- validateSettlementChainSupport(settlementChainId, cctpConfig);
254
- const settlementConfig = findChainConfig(
255
- settlementChainId,
256
- chainTokenConfigs
257
- );
258
- const settlementUSDC = findSettlementUSDC(settlementConfig);
259
- const threshold = calculateThreshold(amount, settlementUSDC.decimals);
260
- const instructionFee = createFeeWithToken(feeToken);
261
- const completionInstructions = createCompletionInstructions(
262
- settlementChainId,
263
- settlementUSDC.address,
264
- recipient,
265
- threshold,
266
- instructionFee,
267
- chainTokenConfigs
268
- );
269
- const instructions = createCrossChainInstructions(
270
- chainTokenConfigs,
271
- settlementChainId,
272
- ephemeralWalletAddress,
273
- instructionFee,
274
- cctpConfig
275
- );
276
- return createPaymentRequestBuildPayload({
277
- payerAddress,
278
- completionInstructions,
279
- instructions,
280
- metadata,
281
- maxRuns
282
- });
283
- }
284
- function validateSettlementChainSupport(chainId, cctpConfig) {
285
- if (!cctpConfig.isSupported(chainId)) {
286
- throw new Error(`Settlement chain ${chainId} does not support CCTP`);
287
- }
288
- }
289
- function findChainConfig(chainId, configs) {
290
- const config = configs.find((c) => c.chainId === chainId);
291
- if (!config) {
292
- throw new Error(
293
- `Settlement chain ${chainId} not found in chain token configs`
294
- );
295
- }
296
- return config;
297
- }
298
- function findSettlementUSDC(settlementConfig) {
299
- const usdc = settlementConfig.tokens.find(
300
- (token) => token.symbol.toUpperCase() === USDC_SYMBOL
301
- );
302
- if (!usdc) {
303
- throw new Error(
304
- `Settlement chain ${settlementConfig.chainId} does not have USDC configured`
305
- );
306
- }
307
- return {
308
- address: usdc.address,
309
- decimals: usdc.decimals
310
- };
311
- }
312
- function calculateThreshold(amount, decimals) {
313
- return toHex(parseUnits(amount, decimals));
314
- }
315
- function createCompletionInstructions(settlementChainId, settlementUSDCAddress, recipient, threshold, instructionFee, chainTokenConfigs) {
316
- const instructions = [];
317
- instructions.push(
318
- createSettlementSweepInstruction(
319
- settlementChainId,
320
- settlementUSDCAddress,
321
- recipient,
322
- threshold,
323
- instructionFee
324
- )
325
- );
326
- const swapInstructions = createTokenSwapInstructions(
327
- settlementChainId,
328
- chainTokenConfigs,
329
- recipient,
330
- threshold,
331
- instructionFee
332
- );
333
- instructions.push(...swapInstructions);
334
- return instructions;
335
- }
336
- function createSettlementSweepInstruction(chainId, tokenAddress, recipient, threshold, fee) {
337
- return {
338
- chainId,
339
- maxExecutions: 0,
340
- actionArguments: createSweepERC20ActionArguments({
341
- chainId,
342
- maxExecutions: 0,
343
- token: tokenAddress,
344
- target: recipient,
345
- threshold,
346
- endBalance: toHex(ZERO_BALANCE),
347
- fee
348
- }),
349
- setEphemeralTarget: false
350
- };
351
- }
352
- function createTokenSwapInstructions(settlementChainId, chainTokenConfigs, settlementRecipient, threshold, instructionFee) {
353
- const swapInstructions = [];
354
- const settlementConfig = chainTokenConfigs.find(
355
- (c) => c.chainId === settlementChainId
356
- );
357
- if (!settlementConfig) {
358
- return swapInstructions;
359
- }
360
- const settlementUSDC = settlementConfig.tokens.find(
361
- (t) => t.symbol.toUpperCase() === USDC_SYMBOL
362
- );
363
- if (!settlementUSDC) {
364
- return swapInstructions;
365
- }
366
- for (const sourceToken of settlementConfig.tokens) {
367
- if (sourceToken.symbol.toUpperCase() === USDC_SYMBOL) {
368
- continue;
369
- }
370
- const swapInstruction = createSwapInstruction(
371
- settlementChainId,
372
- sourceToken,
373
- settlementUSDC,
374
- settlementRecipient,
375
- threshold,
376
- instructionFee
377
- );
378
- swapInstructions.push(swapInstruction);
379
- }
380
- return swapInstructions;
381
- }
382
- function createSwapInstruction(chainId, tokenIn, tokenOut, settlementRecipient, threshold, fee) {
383
- const { instruction } = createSwapInstructionWithFloor(
384
- chainId,
385
- tokenIn,
386
- tokenOut,
387
- settlementRecipient,
388
- threshold,
389
- fee,
390
- false
391
- );
392
- return instruction;
393
- }
394
- function createSwapInstructionWithFloor(chainId, tokenIn, tokenOut, recipient, threshold, fee, setEphemeralTarget) {
395
- const feeTier = getRecommendedFeeTier(
396
- tokenIn.symbol.toUpperCase(),
397
- USDC_SYMBOL
398
- );
399
- const isStableToStableSwap = isStablecoin([
400
- tokenIn.symbol.toUpperCase(),
401
- tokenOut.symbol.toUpperCase()
402
- ]);
403
- const slippageBps = isStableToStableSwap ? STABLE_SLIPPAGE_BPS : NON_STABLE_SLIPPAGE_BPS;
404
- const maxPriceDeviationBps = tokenIn.symbol.toUpperCase() === USDT_SYMBOL ? USDT_MAX_PRICE_DEVIATION_BPS : DEFAULT_MAX_PRICE_DEVIATION_BPS;
405
- const baseAmount = BigInt(threshold);
406
- const afterFeeAmount = baseAmount * BigInt(1e6 - Number(feeTier)) / 1000000n;
407
- const floorAmountOut = afterFeeAmount * BigInt(1e4 - slippageBps) / 10000n;
408
- const instruction = {
409
- chainId,
410
- maxExecutions: 0,
411
- actionArguments: createSweepUniswapV3ActionArguments({
412
- chainId,
413
- maxExecutions: 0,
414
- recipient,
415
- tokenIn: tokenIn.address,
416
- tokenOut: tokenOut.address,
417
- feeTier,
418
- threshold,
419
- endBalance: toHex(ZERO_BALANCE),
420
- floorAmountOut: toHex(floorAmountOut),
421
- meanPriceLookBack: UNISWAP_MEAN_PRICE_LOOKBACK,
422
- maxPriceDeviationBps,
423
- fee
424
- }),
425
- setEphemeralTarget
426
- };
427
- return { instruction, floorAmountOut };
428
- }
429
- function createCrossChainSwapInstructions(chainConfig, chainUSDC, ephemeralWalletAddress, instructionFee) {
430
- const swapInstructions = [];
431
- for (const sourceToken of chainConfig.tokens) {
432
- if (sourceToken.symbol.toUpperCase() === USDC_SYMBOL) {
433
- continue;
434
- }
435
- const feeTier = getRecommendedFeeTier(
436
- sourceToken.symbol.toUpperCase(),
437
- USDC_SYMBOL
438
- );
439
- const maxPriceDeviationBps = sourceToken.symbol.toUpperCase() === USDT_SYMBOL ? USDT_MAX_PRICE_DEVIATION_BPS : DEFAULT_MAX_PRICE_DEVIATION_BPS;
440
- const instruction = {
441
- chainId: chainConfig.chainId,
442
- maxExecutions: 0,
443
- actionArguments: createSweepUniswapV3ActionArguments({
444
- chainId: chainConfig.chainId,
445
- maxExecutions: 0,
446
- recipient: ephemeralWalletAddress,
447
- tokenIn: sourceToken.address,
448
- tokenOut: chainUSDC.address,
449
- feeTier,
450
- threshold: toHex(MINIMUM_THRESHOLD),
451
- endBalance: toHex(ZERO_BALANCE),
452
- floorAmountOut: toHex(0n),
453
- meanPriceLookBack: UNISWAP_MEAN_PRICE_LOOKBACK,
454
- maxPriceDeviationBps,
455
- fee: instructionFee
456
- }),
457
- setEphemeralTarget: true
458
- };
459
- swapInstructions.push(instruction);
460
- }
461
- return swapInstructions;
462
- }
463
- function createCrossChainInstructions(chainTokenConfigs, settlementChainId, ephemeralWalletAddress, instructionFee, cctpConfig) {
464
- const instructions = [];
465
- for (const chainConfig of chainTokenConfigs) {
466
- if (chainConfig.chainId === settlementChainId) {
467
- continue;
468
- }
469
- const chainUSDC = chainConfig.tokens.find(
470
- (token) => token.symbol.toUpperCase() === USDC_SYMBOL
471
- );
472
- if (!chainUSDC || !cctpConfig.isSupported(chainConfig.chainId)) {
473
- continue;
474
- }
475
- const swapInstructions = createCrossChainSwapInstructions(
476
- chainConfig,
477
- chainUSDC,
478
- ephemeralWalletAddress,
479
- instructionFee
480
- );
481
- instructions.push(...swapInstructions);
482
- const bridgeInstruction = createCCTPBridgeInstruction(
483
- chainConfig.chainId,
484
- chainUSDC.address,
485
- settlementChainId,
486
- ephemeralWalletAddress,
487
- toHex(MINIMUM_THRESHOLD),
488
- instructionFee,
489
- cctpConfig
490
- );
491
- instructions.push(bridgeInstruction);
492
- }
493
- return instructions;
494
- }
495
- function createCCTPBridgeInstruction(sourceChainId, tokenAddress, destinationChainId, ephemeralWalletAddress, threshold, fee, cctpConfig) {
496
- return {
497
- chainId: sourceChainId,
498
- maxExecutions: 0,
499
- actionArguments: createSweepCCTPActionArguments({
500
- chainId: sourceChainId,
501
- maxExecutions: 0,
502
- token: tokenAddress,
503
- destinationChainId,
504
- destinationMintRecipient: ephemeralWalletAddress,
505
- threshold,
506
- endBalance: toHex(ZERO_BALANCE),
507
- fee,
508
- cctpConfig
509
- }),
510
- setEphemeralTarget: true
511
- };
512
- }
513
-
514
- // src/payments/actions/sweep.ts
515
- import { toHex as toHex2 } from "viem";
516
- function createSweepActionArguments(payload) {
517
- return {
518
- [PaymentAction.Sweep]: {
519
- target: payload.target,
520
- threshold: payload.threshold,
521
- endBalance: payload.endBalance,
522
- gasLimit: toHex2(payload.gasLimit),
523
- fee: payload.fee
524
- }
525
- };
526
- }
527
-
528
- // src/instructions/contracts/schemas/eip-712/actions/deactivate-instruction.json
529
- var deactivate_instruction_default = {
530
- types: {
531
- Instruction: [
532
- { name: "salt", type: "uint256" },
533
- { name: "maxExecutions", type: "uint256" },
534
- { name: "action", type: "address" },
535
- { name: "deactivateInstruction", type: "DeactivateInstruction" }
536
- ],
537
- DeactivateInstruction: [
538
- { name: "instructionId", type: "bytes32" },
539
- { name: "fee", type: "Fee" }
540
- ],
541
- Fee: [
542
- { name: "token", type: "address" },
543
- { name: "maxBaseFeePerGas", type: "uint256" },
544
- { name: "maxPriorityFeePerGas", type: "uint256" },
545
- { name: "executionFee", type: "uint256" }
546
- ]
547
- }
548
- };
549
-
550
- // src/instructions/contracts/schemas/eip-712/actions/refuel-erc20.json
551
- var refuel_erc20_default = {
552
- types: {
553
- Instruction: [
554
- { name: "salt", type: "uint256" },
555
- { name: "maxExecutions", type: "uint256" },
556
- { name: "action", type: "address" },
557
- { name: "refuelERC20", type: "RefuelERC20" }
558
- ],
559
- RefuelERC20: [
560
- { name: "token", type: "address" },
561
- { name: "target", type: "address" },
562
- { name: "threshold", type: "uint256" },
563
- { name: "endBalance", type: "uint256" },
564
- { name: "fee", type: "Fee" }
565
- ],
566
- Fee: [
567
- { name: "token", type: "address" },
568
- { name: "maxBaseFeePerGas", type: "uint256" },
569
- { name: "maxPriorityFeePerGas", type: "uint256" },
570
- { name: "executionFee", type: "uint256" }
571
- ]
572
- }
573
- };
574
-
575
- // src/instructions/contracts/schemas/eip-712/actions/refuel.json
576
- var refuel_default = {
577
- types: {
578
- Instruction: [
579
- { name: "salt", type: "uint256" },
580
- { name: "maxExecutions", type: "uint256" },
581
- { name: "action", type: "address" },
582
- { name: "refuel", type: "Refuel" }
583
- ],
584
- Refuel: [
585
- { name: "target", type: "address" },
586
- { name: "threshold", type: "uint256" },
587
- { name: "endBalance", type: "uint256" },
588
- { name: "gasLimit", type: "uint256" },
589
- { name: "fee", type: "Fee" }
590
- ],
591
- Fee: [
592
- { name: "token", type: "address" },
593
- { name: "maxBaseFeePerGas", type: "uint256" },
594
- { name: "maxPriorityFeePerGas", type: "uint256" },
595
- { name: "executionFee", type: "uint256" }
596
- ]
597
- }
598
- };
599
-
600
- // src/instructions/contracts/schemas/eip-712/actions/sweep-cctp.json
601
- var sweep_cctp_default = {
602
- types: {
603
- Instruction: [
604
- { name: "salt", type: "uint256" },
605
- { name: "maxExecutions", type: "uint256" },
606
- { name: "action", type: "address" },
607
- { name: "sweepCCTP", type: "SweepCCTP" }
608
- ],
609
- SweepCCTP: [
610
- { name: "token", type: "address" },
611
- { name: "destinationDomain", type: "uint32" },
612
- { name: "destinationMintRecipient", type: "bytes32" },
613
- { name: "threshold", type: "uint256" },
614
- { name: "endBalance", type: "uint256" },
615
- { name: "fee", type: "Fee" }
616
- ],
617
- Fee: [
618
- { name: "token", type: "address" },
619
- { name: "maxBaseFeePerGas", type: "uint256" },
620
- { name: "maxPriorityFeePerGas", type: "uint256" },
621
- { name: "executionFee", type: "uint256" }
622
- ]
623
- }
624
- };
625
-
626
- // src/instructions/contracts/schemas/eip-712/actions/sweep-deposit-account-erc20.json
627
- var sweep_deposit_account_erc20_default = {
628
- types: {
629
- Instruction: [
630
- { name: "salt", type: "uint256" },
631
- { name: "maxExecutions", type: "uint256" },
632
- { name: "action", type: "address" },
633
- { name: "sweepDepositAccountERC20", type: "SweepDepositAccountERC20" }
634
- ],
635
- SweepDepositAccountERC20: [
636
- { name: "token", type: "address" },
637
- { name: "depositor", type: "address" },
638
- { name: "recipient", type: "address" },
639
- { name: "threshold", type: "uint256" },
640
- { name: "fee", type: "Fee" }
641
- ],
642
- Fee: [
643
- { name: "token", type: "address" },
644
- { name: "maxBaseFeePerGas", type: "uint256" },
645
- { name: "maxPriorityFeePerGas", type: "uint256" },
646
- { name: "executionFee", type: "uint256" }
647
- ]
648
- }
649
- };
650
-
651
- // src/instructions/contracts/schemas/eip-712/actions/sweep-deposit-account.json
652
- var sweep_deposit_account_default = {
653
- types: {
654
- Instruction: [
655
- { name: "salt", type: "uint256" },
656
- { name: "maxExecutions", type: "uint256" },
657
- { name: "action", type: "address" },
658
- { name: "sweepDepositAccount", type: "SweepDepositAccount" }
659
- ],
660
- SweepDepositAccount: [
661
- { name: "depositor", type: "address" },
662
- { name: "recipient", type: "address" },
663
- { name: "threshold", type: "uint256" },
664
- { name: "fee", type: "Fee" }
665
- ],
666
- Fee: [
667
- { name: "token", type: "address" },
668
- { name: "maxBaseFeePerGas", type: "uint256" },
669
- { name: "maxPriorityFeePerGas", type: "uint256" },
670
- { name: "executionFee", type: "uint256" }
671
- ]
672
- }
673
- };
674
-
675
- // src/instructions/contracts/schemas/eip-712/actions/sweep-erc20.json
676
- var sweep_erc20_default = {
677
- types: {
678
- Instruction: [
679
- { name: "salt", type: "uint256" },
680
- { name: "maxExecutions", type: "uint256" },
681
- { name: "action", type: "address" },
682
- { name: "sweepERC20", type: "SweepERC20" }
683
- ],
684
- SweepERC20: [
685
- { name: "token", type: "address" },
686
- { name: "target", type: "address" },
687
- { name: "threshold", type: "uint256" },
688
- { name: "endBalance", type: "uint256" },
689
- { name: "fee", type: "Fee" }
690
- ],
691
- Fee: [
692
- { name: "token", type: "address" },
693
- { name: "maxBaseFeePerGas", type: "uint256" },
694
- { name: "maxPriorityFeePerGas", type: "uint256" },
695
- { name: "executionFee", type: "uint256" }
696
- ]
697
- }
698
- };
699
-
700
- // src/instructions/contracts/schemas/eip-712/actions/sweep-skip-cctp-deposit-account.json
701
- var sweep_skip_cctp_deposit_account_default = {
702
- types: {
703
- Instruction: [
704
- { name: "salt", type: "uint256" },
705
- { name: "maxExecutions", type: "uint256" },
706
- { name: "action", type: "address" },
707
- {
708
- name: "sweepSkipCCTPDepositAccount",
709
- type: "SweepSkipCCTPDepositAccount"
710
- }
711
- ],
712
- SweepSkipCCTPDepositAccount: [
713
- { name: "depositor", type: "address" },
714
- { name: "destinationDomain", type: "uint32" },
715
- { name: "destinationMintRecipient", type: "bytes32" },
716
- { name: "threshold", type: "uint256" },
717
- { name: "fee", type: "Fee" }
718
- ],
719
- Fee: [
720
- { name: "token", type: "address" },
721
- { name: "maxBaseFeePerGas", type: "uint256" },
722
- { name: "maxPriorityFeePerGas", type: "uint256" },
723
- { name: "executionFee", type: "uint256" }
724
- ]
725
- }
726
- };
727
-
728
- // src/instructions/contracts/schemas/eip-712/actions/sweep-uniswap-v3.json
729
- var sweep_uniswap_v3_default = {
730
- types: {
731
- Instruction: [
732
- { name: "salt", type: "uint256" },
733
- { name: "maxExecutions", type: "uint256" },
734
- { name: "action", type: "address" },
735
- { name: "sweepUniswapV3", type: "SweepUniswapV3" }
736
- ],
737
- SweepUniswapV3: [
738
- { name: "recipient", type: "address" },
739
- { name: "tokenIn", type: "address" },
740
- { name: "tokenOut", type: "address" },
741
- { name: "feeTier", type: "uint24" },
742
- { name: "threshold", type: "uint256" },
743
- { name: "endBalance", type: "uint256" },
744
- { name: "floorAmountOut", type: "uint256" },
745
- { name: "meanPriceLookBack", type: "uint32" },
746
- { name: "maxPriceDeviationBPS", type: "uint32" },
747
- { name: "fee", type: "Fee" }
748
- ],
749
- Fee: [
750
- { name: "token", type: "address" },
751
- { name: "maxBaseFeePerGas", type: "uint256" },
752
- { name: "maxPriorityFeePerGas", type: "uint256" },
753
- { name: "executionFee", type: "uint256" }
754
- ]
755
- }
133
+ return createDefaultFee(0, "0x0", maxPriorityFeePerGas ?? "0x0", token);
134
+ }
135
+
136
+ //#endregion
137
+ //#region src/payments/instruction-registry.ts
138
+ const feeAbiComponent = {
139
+ name: "fee",
140
+ type: "tuple",
141
+ components: [
142
+ {
143
+ name: "token",
144
+ type: "address"
145
+ },
146
+ {
147
+ name: "maxBaseFeePerGas",
148
+ type: "uint256"
149
+ },
150
+ {
151
+ name: "maxPriorityFeePerGas",
152
+ type: "uint256"
153
+ },
154
+ {
155
+ name: "executionFee",
156
+ type: "uint256"
157
+ }
158
+ ]
756
159
  };
757
-
758
- // src/instructions/contracts/schemas/eip-712/actions/sweep.json
759
- var sweep_default = {
760
- types: {
761
- Instruction: [
762
- { name: "salt", type: "uint256" },
763
- { name: "maxExecutions", type: "uint256" },
764
- { name: "action", type: "address" },
765
- { name: "sweep", type: "Sweep" }
766
- ],
767
- Sweep: [
768
- { name: "target", type: "address" },
769
- { name: "threshold", type: "uint256" },
770
- { name: "endBalance", type: "uint256" },
771
- { name: "gasLimit", type: "uint256" },
772
- { name: "fee", type: "Fee" }
773
- ],
774
- Fee: [
775
- { name: "token", type: "address" },
776
- { name: "maxBaseFeePerGas", type: "uint256" },
777
- { name: "maxPriorityFeePerGas", type: "uint256" },
778
- { name: "executionFee", type: "uint256" }
779
- ]
780
- }
781
- };
782
-
783
- // src/instructions/contracts/schemas/eip-712/actions/transfer-erc20.json
784
- var transfer_erc20_default = {
785
- types: {
786
- Instruction: [
787
- { name: "salt", type: "uint256" },
788
- { name: "maxExecutions", type: "uint256" },
789
- { name: "action", type: "address" },
790
- { name: "transferERC20", type: "TransferERC20" }
791
- ],
792
- TransferERC20: [
793
- { name: "token", type: "address" },
794
- { name: "target", type: "address" },
795
- { name: "value", type: "uint256" },
796
- { name: "schedule", type: "Schedule" },
797
- { name: "fee", type: "Fee" }
798
- ],
799
- Schedule: [
800
- { name: "startAt", type: "uint256" },
801
- { name: "startBy", type: "uint256" },
802
- { name: "interval", type: "uint256" },
803
- { name: "timeout", type: "uint256" }
804
- ],
805
- Fee: [
806
- { name: "token", type: "address" },
807
- { name: "maxBaseFeePerGas", type: "uint256" },
808
- { name: "maxPriorityFeePerGas", type: "uint256" },
809
- { name: "executionFee", type: "uint256" }
810
- ]
811
- }
812
- };
813
-
814
- // src/instructions/contracts/schemas/eip-712/actions/transfer.json
815
- var transfer_default = {
816
- types: {
817
- Instruction: [
818
- { name: "salt", type: "uint256" },
819
- { name: "maxExecutions", type: "uint256" },
820
- { name: "action", type: "address" },
821
- { name: "transfer", type: "Transfer" }
822
- ],
823
- Transfer: [
824
- { name: "target", type: "address" },
825
- { name: "value", type: "uint256" },
826
- { name: "gasLimit", type: "uint256" },
827
- { name: "schedule", type: "Schedule" },
828
- { name: "fee", type: "Fee" }
829
- ],
830
- Schedule: [
831
- { name: "startAt", type: "uint256" },
832
- { name: "startBy", type: "uint256" },
833
- { name: "interval", type: "uint256" },
834
- { name: "timeout", type: "uint256" }
835
- ],
836
- Fee: [
837
- { name: "token", type: "address" },
838
- { name: "maxBaseFeePerGas", type: "uint256" },
839
- { name: "maxPriorityFeePerGas", type: "uint256" },
840
- { name: "executionFee", type: "uint256" }
841
- ]
842
- }
843
- };
844
-
845
- // src/instructions/contracts/schemas/eip-712/actions/uniswap-v3-exact-input.json
846
- var uniswap_v3_exact_input_default = {
847
- types: {
848
- Instruction: [
849
- { name: "salt", type: "uint256" },
850
- { name: "maxExecutions", type: "uint256" },
851
- { name: "action", type: "address" },
852
- { name: "uniswapV3ExactInput", type: "UniswapV3ExactInput" }
853
- ],
854
- UniswapV3ExactInput: [
855
- { name: "recipient", type: "address" },
856
- { name: "tokenIn", type: "address" },
857
- { name: "tokenOut", type: "address" },
858
- { name: "feeTier", type: "uint24" },
859
- { name: "amountIn", type: "uint256" },
860
- { name: "floorAmountOut", type: "uint256" },
861
- { name: "meanPriceLookBack", type: "uint32" },
862
- { name: "maxPriceDeviationBPS", type: "uint32" },
863
- { name: "schedule", type: "Schedule" },
864
- { name: "fee", type: "Fee" }
865
- ],
866
- Schedule: [
867
- { name: "startAt", type: "uint256" },
868
- { name: "startBy", type: "uint256" },
869
- { name: "interval", type: "uint256" },
870
- { name: "timeout", type: "uint256" }
871
- ],
872
- Fee: [
873
- { name: "token", type: "address" },
874
- { name: "maxBaseFeePerGas", type: "uint256" },
875
- { name: "maxPriorityFeePerGas", type: "uint256" },
876
- { name: "executionFee", type: "uint256" }
877
- ]
878
- }
879
- };
880
-
881
- // src/instructions/types.ts
882
- var eip712TypesMap = {
883
- refuel: refuel_default,
884
- refuelERC20: refuel_erc20_default,
885
- transfer: transfer_default,
886
- transferERC20: transfer_erc20_default,
887
- uniswapV3ExactInput: uniswap_v3_exact_input_default,
888
- sweep: sweep_default,
889
- sweepERC20: sweep_erc20_default,
890
- sweepCCTP: sweep_cctp_default,
891
- sweepUniswapV3: sweep_uniswap_v3_default,
892
- sweepDepositAccount: sweep_deposit_account_default,
893
- sweepDepositAccountERC20: sweep_deposit_account_erc20_default,
894
- sweepSkipCCTPDepositAccount: sweep_skip_cctp_deposit_account_default,
895
- deactivateInstruction: deactivate_instruction_default
896
- };
897
-
898
- // src/payments/instruction-registry.ts
899
- var feeAbiComponent = {
900
- name: "fee",
901
- type: "tuple",
902
- components: [
903
- { name: "token", type: "address" },
904
- { name: "maxBaseFeePerGas", type: "uint256" },
905
- { name: "maxPriorityFeePerGas", type: "uint256" },
906
- { name: "executionFee", type: "uint256" }
907
- ]
908
- };
909
- var sweepAbi = [
910
- {
911
- type: "tuple",
912
- components: [
913
- { name: "target", type: "address" },
914
- { name: "threshold", type: "uint256" },
915
- { name: "endBalance", type: "uint256" },
916
- { name: "gasLimit", type: "uint256" },
917
- feeAbiComponent
918
- ]
919
- }
920
- ];
921
- var sweepERC20Abi = [
922
- {
923
- type: "tuple",
924
- components: [
925
- { name: "token", type: "address" },
926
- { name: "target", type: "address" },
927
- { name: "threshold", type: "uint256" },
928
- { name: "endBalance", type: "uint256" },
929
- feeAbiComponent
930
- ]
931
- }
932
- ];
933
- var sweepCCTPAbi = [
934
- {
935
- type: "tuple",
936
- components: [
937
- { name: "token", type: "address" },
938
- { name: "destinationDomain", type: "uint32" },
939
- { name: "destinationMintRecipient", type: "bytes32" },
940
- { name: "threshold", type: "uint256" },
941
- { name: "endBalance", type: "uint256" },
942
- feeAbiComponent
943
- ]
944
- }
945
- ];
946
- var sweepUniswapV3Abi = [
947
- {
948
- type: "tuple",
949
- components: [
950
- { name: "recipient", type: "address" },
951
- { name: "tokenIn", type: "address" },
952
- { name: "tokenOut", type: "address" },
953
- { name: "feeTier", type: "uint24" },
954
- { name: "threshold", type: "uint256" },
955
- { name: "endBalance", type: "uint256" },
956
- { name: "floorAmountOut", type: "uint256" },
957
- { name: "meanPriceLookBack", type: "uint32" },
958
- { name: "maxPriceDeviationBPS", type: "uint32" },
959
- feeAbiComponent
960
- ]
961
- }
962
- ];
963
- var sweepDepositAccountAbi = [
964
- {
965
- type: "tuple",
966
- components: [
967
- { name: "depositor", type: "address" },
968
- { name: "recipient", type: "address" },
969
- { name: "threshold", type: "uint256" },
970
- feeAbiComponent
971
- ]
972
- }
973
- ];
974
- var sweepDepositAccountERC20Abi = [
975
- {
976
- type: "tuple",
977
- components: [
978
- { name: "token", type: "address" },
979
- { name: "depositor", type: "address" },
980
- { name: "recipient", type: "address" },
981
- { name: "threshold", type: "uint256" },
982
- feeAbiComponent
983
- ]
984
- }
985
- ];
986
- var sweepSkipCCTPDepositAccountAbi = [
987
- {
988
- type: "tuple",
989
- components: [
990
- { name: "depositor", type: "address" },
991
- { name: "destinationDomain", type: "uint32" },
992
- { name: "destinationMintRecipient", type: "bytes32" },
993
- { name: "threshold", type: "uint256" },
994
- feeAbiComponent
995
- ]
996
- }
997
- ];
998
- var actionAbiMap = {
999
- sweep: sweepAbi,
1000
- sweepERC20: sweepERC20Abi,
1001
- sweepCCTP: sweepCCTPAbi,
1002
- sweepUniswapV3: sweepUniswapV3Abi,
1003
- sweepDepositAccount: sweepDepositAccountAbi,
1004
- sweepDepositAccountERC20: sweepDepositAccountERC20Abi,
1005
- sweepSkipCCTPDepositAccount: sweepSkipCCTPDepositAccountAbi
160
+ const sweepAbi = [{
161
+ type: "tuple",
162
+ components: [
163
+ {
164
+ name: "target",
165
+ type: "address"
166
+ },
167
+ {
168
+ name: "threshold",
169
+ type: "uint256"
170
+ },
171
+ {
172
+ name: "endBalance",
173
+ type: "uint256"
174
+ },
175
+ {
176
+ name: "gasLimit",
177
+ type: "uint256"
178
+ },
179
+ feeAbiComponent
180
+ ]
181
+ }];
182
+ const sweepERC20Abi = [{
183
+ type: "tuple",
184
+ components: [
185
+ {
186
+ name: "token",
187
+ type: "address"
188
+ },
189
+ {
190
+ name: "target",
191
+ type: "address"
192
+ },
193
+ {
194
+ name: "threshold",
195
+ type: "uint256"
196
+ },
197
+ {
198
+ name: "endBalance",
199
+ type: "uint256"
200
+ },
201
+ feeAbiComponent
202
+ ]
203
+ }];
204
+ const sweepCCTPAbi = [{
205
+ type: "tuple",
206
+ components: [
207
+ {
208
+ name: "token",
209
+ type: "address"
210
+ },
211
+ {
212
+ name: "destinationDomain",
213
+ type: "uint32"
214
+ },
215
+ {
216
+ name: "destinationMintRecipient",
217
+ type: "bytes32"
218
+ },
219
+ {
220
+ name: "threshold",
221
+ type: "uint256"
222
+ },
223
+ {
224
+ name: "endBalance",
225
+ type: "uint256"
226
+ },
227
+ feeAbiComponent
228
+ ]
229
+ }];
230
+ const sweepUniswapV3Abi = [{
231
+ type: "tuple",
232
+ components: [
233
+ {
234
+ name: "recipient",
235
+ type: "address"
236
+ },
237
+ {
238
+ name: "tokenIn",
239
+ type: "address"
240
+ },
241
+ {
242
+ name: "tokenOut",
243
+ type: "address"
244
+ },
245
+ {
246
+ name: "feeTier",
247
+ type: "uint24"
248
+ },
249
+ {
250
+ name: "threshold",
251
+ type: "uint256"
252
+ },
253
+ {
254
+ name: "endBalance",
255
+ type: "uint256"
256
+ },
257
+ {
258
+ name: "floorAmountOut",
259
+ type: "uint256"
260
+ },
261
+ {
262
+ name: "meanPriceLookBack",
263
+ type: "uint32"
264
+ },
265
+ {
266
+ name: "maxPriceDeviationBPS",
267
+ type: "uint32"
268
+ },
269
+ feeAbiComponent
270
+ ]
271
+ }];
272
+ const sweepSkipCCTPDepositAccountAbi = [{
273
+ type: "tuple",
274
+ components: [
275
+ {
276
+ name: "depositor",
277
+ type: "address"
278
+ },
279
+ {
280
+ name: "destinationDomain",
281
+ type: "uint32"
282
+ },
283
+ {
284
+ name: "destinationMintRecipient",
285
+ type: "bytes32"
286
+ },
287
+ {
288
+ name: "threshold",
289
+ type: "uint256"
290
+ },
291
+ feeAbiComponent
292
+ ]
293
+ }];
294
+ const sweepDepositERC4626Abi = [{
295
+ type: "tuple",
296
+ components: [
297
+ {
298
+ name: "vault",
299
+ type: "address"
300
+ },
301
+ {
302
+ name: "recipient",
303
+ type: "address"
304
+ },
305
+ {
306
+ name: "threshold",
307
+ type: "uint256"
308
+ },
309
+ {
310
+ name: "endBalance",
311
+ type: "uint256"
312
+ },
313
+ {
314
+ name: "minDeposit",
315
+ type: "uint256"
316
+ },
317
+ {
318
+ name: "minTotalShares",
319
+ type: "uint256"
320
+ },
321
+ feeAbiComponent
322
+ ]
323
+ }];
324
+ const sweepWithdrawERC4626Abi = [{
325
+ type: "tuple",
326
+ components: [
327
+ {
328
+ name: "vault",
329
+ type: "address"
330
+ },
331
+ {
332
+ name: "recipient",
333
+ type: "address"
334
+ },
335
+ {
336
+ name: "threshold",
337
+ type: "uint256"
338
+ },
339
+ {
340
+ name: "endBalance",
341
+ type: "uint256"
342
+ },
343
+ {
344
+ name: "minWithdraw",
345
+ type: "uint256"
346
+ },
347
+ feeAbiComponent
348
+ ]
349
+ }];
350
+ const actionAbiMap = {
351
+ [InstructionAction.Sweep]: sweepAbi,
352
+ [InstructionAction.SweepERC20]: sweepERC20Abi,
353
+ [InstructionAction.SweepCCTP]: sweepCCTPAbi,
354
+ [InstructionAction.SweepUniswapV3]: sweepUniswapV3Abi,
355
+ [InstructionAction.SweepSkipCCTPDepositAccount]: sweepSkipCCTPDepositAccountAbi,
356
+ [InstructionAction.SweepDepositERC4626]: sweepDepositERC4626Abi,
357
+ [InstructionAction.SweepWithdrawERC4626]: sweepWithdrawERC4626Abi
1006
358
  };
1007
359
  var InstructionTypeRegistry = class {
1008
- constructor() {
1009
- __publicField(this, "registry", /* @__PURE__ */ new Map());
1010
- this.initializeDefaultTypes();
1011
- }
1012
- register(actionName, definition) {
1013
- this.registry.set(actionName, definition);
1014
- }
1015
- get(actionName) {
1016
- const definition = this.registry.get(actionName);
1017
- if (!definition) {
1018
- throw this.createUnsupportedTypeError(actionName);
1019
- }
1020
- return definition;
1021
- }
1022
- has(actionName) {
1023
- return this.registry.has(actionName);
1024
- }
1025
- getAvailableTypes() {
1026
- return Array.from(this.registry.keys());
1027
- }
1028
- initializeDefaultTypes() {
1029
- const actionNames = Object.keys(actionAbiMap);
1030
- for (const actionName of actionNames) {
1031
- const abi = actionAbiMap[actionName];
1032
- const eip712Types = eip712TypesMap[actionName];
1033
- if (abi && eip712Types) {
1034
- this.register(actionName, { abi, eip712Types });
1035
- }
1036
- }
1037
- }
1038
- createUnsupportedTypeError(actionName) {
1039
- const availableTypes = this.getAvailableTypes().join(", ");
1040
- return new Error(
1041
- `Unsupported instruction type: ${actionName}. Available: ${availableTypes}`
1042
- );
1043
- }
360
+ constructor() {
361
+ _defineProperty(this, "registry", /* @__PURE__ */ new Map());
362
+ this.initializeDefaultTypes();
363
+ }
364
+ register(actionName, definition) {
365
+ this.registry.set(actionName, definition);
366
+ }
367
+ get(actionName) {
368
+ const definition = this.registry.get(actionName);
369
+ if (!definition) throw this.createUnsupportedTypeError(actionName);
370
+ return definition;
371
+ }
372
+ has(actionName) {
373
+ return this.registry.has(actionName);
374
+ }
375
+ getAvailableTypes() {
376
+ return Array.from(this.registry.keys());
377
+ }
378
+ initializeDefaultTypes() {
379
+ const actionNames = Object.keys(actionAbiMap);
380
+ for (const actionName of actionNames) {
381
+ const abi = actionAbiMap[actionName];
382
+ const eip712Types = eip712TypesMap[actionName];
383
+ if (abi && eip712Types) this.register(actionName, {
384
+ abi,
385
+ eip712Types
386
+ });
387
+ }
388
+ }
389
+ createUnsupportedTypeError(actionName) {
390
+ const availableTypes = this.getAvailableTypes().join(", ");
391
+ return /* @__PURE__ */ new Error(`Unsupported instruction type: ${actionName}. Available: ${availableTypes}`);
392
+ }
1044
393
  };
1045
- var instructionRegistry = new InstructionTypeRegistry();
394
+ const instructionRegistry = new InstructionTypeRegistry();
1046
395
 
1047
- // src/payments/action-names.ts
396
+ //#endregion
397
+ //#region src/payments/action-names.ts
1048
398
  function addActionNamesToInstructions(buildResponse, actionNames) {
1049
- const completionInstructionCount = buildResponse.completionInstructions.length;
1050
- return {
1051
- ...buildResponse,
1052
- completionInstructions: buildResponse.completionInstructions.map(
1053
- (instruction, index) => ({
1054
- ...instruction,
1055
- actionName: actionNames[index]
1056
- })
1057
- ),
1058
- instructions: buildResponse.instructions.map((instruction, index) => ({
1059
- ...instruction,
1060
- actionName: actionNames[completionInstructionCount + index]
1061
- }))
1062
- };
399
+ const completionInstructionCount = buildResponse.completionInstructions.length;
400
+ return {
401
+ ...buildResponse,
402
+ completionInstructions: buildResponse.completionInstructions.map((instruction, index) => ({
403
+ ...instruction,
404
+ actionName: actionNames[index]
405
+ })),
406
+ instructions: buildResponse.instructions.map((instruction, index) => ({
407
+ ...instruction,
408
+ actionName: actionNames[completionInstructionCount + index]
409
+ }))
410
+ };
1063
411
  }
1064
412
  function extractActionNamesMap(completionInstructions, instructions = []) {
1065
- const allInstructions = [...completionInstructions, ...instructions];
1066
- return allInstructions.reduce(
1067
- (actionNamesMap, instruction, index) => {
1068
- const actionName = getFirstActionArgumentKey(instruction.actionArguments);
1069
- if (actionName) {
1070
- actionNamesMap[index] = actionName;
1071
- }
1072
- return actionNamesMap;
1073
- },
1074
- {}
1075
- );
413
+ return [...completionInstructions, ...instructions].reduce((actionNamesMap, instruction, index) => {
414
+ const actionName = getFirstActionArgumentKey(instruction.actionArguments);
415
+ if (actionName) actionNamesMap[index] = actionName;
416
+ return actionNamesMap;
417
+ }, {});
1076
418
  }
1077
419
  function getFirstActionArgumentKey(actionArguments) {
1078
- const keys = Object.keys(actionArguments);
1079
- return keys[0];
420
+ return Object.keys(actionArguments)[0];
1080
421
  }
1081
422
 
1082
- // src/payments/validation.ts
423
+ //#endregion
424
+ //#region src/payments/validation.ts
1083
425
  var SignatureValidator = class {
1084
- static assertExactCount(context) {
1085
- if (context.received !== context.expected) {
1086
- throw new Error(
1087
- `Signature count mismatch: expected ${context.expected}, received ${context.received}`
1088
- );
1089
- }
1090
- }
1091
- static assertMinimumCount(context) {
1092
- if (context.received < context.expected) {
1093
- throw new Error(
1094
- `Insufficient signatures: expected at least ${context.expected}, received ${context.received}`
1095
- );
1096
- }
1097
- }
426
+ static assertExactCount(context) {
427
+ if (context.received !== context.expected) throw new Error(`Signature count mismatch: expected ${context.expected}, received ${context.received}`);
428
+ }
429
+ static assertMinimumCount(context) {
430
+ if (context.received < context.expected) throw new Error(`Insufficient signatures: expected at least ${context.expected}, received ${context.received}`);
431
+ }
1098
432
  };
1099
433
  function assertSignatureCount(signatures, expectedCount) {
1100
- SignatureValidator.assertExactCount({
1101
- expected: expectedCount,
1102
- received: signatures.length
1103
- });
434
+ SignatureValidator.assertExactCount({
435
+ expected: expectedCount,
436
+ received: signatures.length
437
+ });
1104
438
  }
1105
439
  function assertMinimumSignatures(signatures, minimumCount) {
1106
- SignatureValidator.assertMinimumCount({
1107
- expected: minimumCount,
1108
- received: signatures.length
1109
- });
440
+ SignatureValidator.assertMinimumCount({
441
+ expected: minimumCount,
442
+ received: signatures.length
443
+ });
1110
444
  }
1111
445
 
1112
- // src/payments/chain-token-config-builder.ts
446
+ //#endregion
447
+ //#region src/payments/chain-token-config-builder.ts
1113
448
  function createChainTokenConfigs(tokens) {
1114
- const tokensByChain = groupTokensByChainId(tokens);
1115
- return convertToChainConfigs(tokensByChain);
449
+ return convertToChainConfigs(groupTokensByChainId(tokens));
1116
450
  }
1117
451
  function groupTokensByChainId(tokens) {
1118
- const grouped = /* @__PURE__ */ new Map();
1119
- for (const token of tokens) {
1120
- const chainTokens = grouped.get(token.chainId) ?? [];
1121
- chainTokens.push(token);
1122
- grouped.set(token.chainId, chainTokens);
1123
- }
1124
- return grouped;
452
+ const grouped = /* @__PURE__ */ new Map();
453
+ for (const token of tokens) {
454
+ const chainTokens = grouped.get(token.chainId) ?? [];
455
+ chainTokens.push(token);
456
+ grouped.set(token.chainId, chainTokens);
457
+ }
458
+ return grouped;
1125
459
  }
1126
460
  function convertToChainConfigs(tokensByChain) {
1127
- return Array.from(tokensByChain.entries()).map(([chainId, tokens]) => ({
1128
- chainId,
1129
- tokens: tokens.map((token) => ({
1130
- symbol: token.symbol,
1131
- address: token.address,
1132
- decimals: token.decimals
1133
- }))
1134
- }));
1135
- }
1136
-
1137
- // src/payments/payment-request-token-resolver.ts
461
+ return Array.from(tokensByChain.entries()).map(([chainId, tokens]) => ({
462
+ chainId,
463
+ tokens: tokens.map((token) => ({
464
+ symbol: token.symbol,
465
+ address: token.address,
466
+ decimals: token.decimals
467
+ }))
468
+ }));
469
+ }
470
+
471
+ //#endregion
472
+ //#region src/payments/payment-request-token-resolver.ts
1138
473
  function isNativeToken(token) {
1139
- if (!token) {
1140
- return false;
1141
- }
1142
- return token.symbol === "ETH" || token.address.toLowerCase() === DEFAULT_ADDRESS.toLowerCase();
1143
- }
1144
- function resolvePreferredStablecoin({
1145
- preferredToken,
1146
- getStablecoinBySymbol
1147
- }) {
1148
- const stablecoin = getValidStablecoin(preferredToken);
1149
- if (stablecoin) {
1150
- return stablecoin;
1151
- }
1152
- return getDefaultStablecoin(getStablecoinBySymbol);
1153
- }
1154
- function getValidStablecoin(token) {
1155
- if (!token || isNativeToken(token) || !isStablecoin(token.symbol)) {
1156
- return null;
1157
- }
1158
- return token;
1159
- }
1160
- function getDefaultStablecoin(getStablecoinBySymbol) {
1161
- const usdc = getStablecoinBySymbol("USDC");
1162
- if (usdc) {
1163
- return usdc;
1164
- }
1165
- const usdt = getStablecoinBySymbol("USDT");
1166
- if (usdt) {
1167
- return usdt;
1168
- }
1169
- return null;
474
+ if (!token) return false;
475
+ return token.symbol === "ETH" || token.address.toLowerCase() === DEFAULT_ADDRESS.toLowerCase();
1170
476
  }
1171
477
  function createTokenIdentifier(chainId, tokenAddress) {
1172
- return `${chainId}:${tokenAddress}`;
1173
- }
1174
-
1175
- // src/payments/payment-metadata-builder.ts
1176
- var DEFAULT_CURRENCY = "USD";
1177
- function isValidAmount(value) {
1178
- return isNumber(value) && Number.isFinite(value);
1179
- }
478
+ return `${chainId}:${tokenAddress}`;
479
+ }
480
+
481
+ //#endregion
482
+ //#region src/payments/payment-metadata-builder.ts
483
+ const DEFAULT_CURRENCY = "USD";
484
+ const DEFAULT_SOURCE = "Manual";
485
+ /**
486
+ * Formats a date to NaiveDateTime format expected by Rust backend.
487
+ * Converts ISO 8601 strings like "2025-01-15T00:00:00.000Z" to "2025-01-15T00:00:00".
488
+ *
489
+ * Rust's chrono::NaiveDateTime expects format without timezone suffix.
490
+ *
491
+ * @param dateInput - Date string or Date object to format
492
+ * @returns Formatted NaiveDateTime string
493
+ * @throws Error if date is invalid
494
+ */
495
+ function formatToNaiveDateTime(dateInput) {
496
+ const date = typeof dateInput === "string" ? new Date(dateInput) : dateInput;
497
+ if (!isValidDate(date)) throw new Error(`Invalid date provided: ${String(dateInput)}`);
498
+ return `${date.getUTCFullYear()}-${String(date.getUTCMonth() + 1).padStart(2, "0")}-${String(date.getUTCDate()).padStart(2, "0")}T${String(date.getUTCHours()).padStart(2, "0")}:${String(date.getUTCMinutes()).padStart(2, "0")}:${String(date.getUTCSeconds()).padStart(2, "0")}`;
499
+ }
500
+ /**
501
+ * Formats a numeric amount to a decimal string with 2 decimal places.
502
+ * Ensures consistent formatting for monetary values.
503
+ *
504
+ * @param amount - Numeric amount to format
505
+ * @returns Formatted amount string (e.g., "150.00")
506
+ */
507
+ function formatAmount(amount) {
508
+ return amount.toFixed(2);
509
+ }
510
+ /**
511
+ * Validates that a value is a safe, finite number suitable for monetary amounts.
512
+ * Excludes NaN and Infinity which could cause calculation errors downstream.
513
+ *
514
+ * @param value - Value to validate
515
+ * @returns True if value is a valid monetary amount
516
+ */
517
+ function isValidMonetaryAmount(value) {
518
+ return isNumber(value) && Number.isFinite(value);
519
+ }
520
+ /**
521
+ * Constructs payment metadata for manually created payment requests.
522
+ * Pure function with explicit input/output contract.
523
+ *
524
+ * @param params - Configuration for manual payment request
525
+ * @returns Immutable PaymentRequestMetadata object
526
+ */
1180
527
  function buildPaymentMetadata(params) {
1181
- const {
1182
- note,
1183
- tokenSymbol,
1184
- dueDate,
1185
- amountInUSD,
1186
- hasInvoiceMetadata = false,
1187
- fromAccountAddress
1188
- } = params;
1189
- const metadata = {
1190
- token: tokenSymbol
1191
- };
1192
- if (!hasInvoiceMetadata) {
1193
- if (isValidAmount(amountInUSD)) {
1194
- metadata.amountDue = amountInUSD.toFixed(2);
1195
- }
1196
- metadata.currency = DEFAULT_CURRENCY;
1197
- }
1198
- if (dueDate) {
1199
- metadata.dueDate = dueDate;
1200
- }
1201
- if (note) {
1202
- metadata.note = note;
1203
- }
1204
- if (fromAccountAddress) {
1205
- metadata.fromAccountAddress = fromAccountAddress;
1206
- }
1207
- return metadata;
1208
- }
528
+ const { tokenSymbol, note, dueDate, amountInUSD, fromAccountAddress, payer, source = DEFAULT_SOURCE } = params;
529
+ const baseMetadata = {
530
+ type: OrchestrationType.PaymentRequest,
531
+ token: tokenSymbol,
532
+ amountDue: formatAmount(amountInUSD),
533
+ currency: DEFAULT_CURRENCY,
534
+ dueDate: formatToNaiveDateTime(dueDate),
535
+ fromAccountAddress,
536
+ payer,
537
+ source
538
+ };
539
+ if (note !== void 0 && note !== "") return {
540
+ ...baseMetadata,
541
+ note
542
+ };
543
+ return baseMetadata;
544
+ }
545
+ /**
546
+ * Constructs payment metadata from invoice integration data.
547
+ * Invoice fields are authoritative and override any defaults.
548
+ * Pure function ensuring consistent metadata structure for integrations.
549
+ *
550
+ * @param params - Invoice and account configuration
551
+ * @returns Immutable PaymentRequestMetadata object
552
+ */
553
+ function buildPaymentMetadataFromInvoice(params) {
554
+ const { tokenSymbol, fromAccountAddress, payer, invoiceMetadata } = params;
555
+ const baseMetadata = {
556
+ type: OrchestrationType.PaymentRequest,
557
+ token: tokenSymbol,
558
+ amountDue: formatAmount(Number(invoiceMetadata.amount)),
559
+ currency: invoiceMetadata.currency,
560
+ dueDate: formatToNaiveDateTime(invoiceMetadata.dueDate),
561
+ fromAccountAddress,
562
+ payer,
563
+ source: invoiceMetadata.source,
564
+ invoiceId: invoiceMetadata.invoiceId,
565
+ invoiceNumber: invoiceMetadata.invoiceNumber
566
+ };
567
+ const optionalFields = {
568
+ ...invoiceMetadata.description && { note: invoiceMetadata.description },
569
+ ...invoiceMetadata.attachmentUrl && { attachmentUrl: invoiceMetadata.attachmentUrl },
570
+ ...invoiceMetadata.attachmentName && { attachmentName: invoiceMetadata.attachmentName }
571
+ };
572
+ return {
573
+ ...baseMetadata,
574
+ ...optionalFields
575
+ };
576
+ }
577
+ /**
578
+ * Merges invoice data from external integrations with base payment metadata.
579
+ * Invoice fields override manual entries to ensure accuracy and maintain
580
+ * audit trail through source/invoiceId tracking.
581
+ *
582
+ * @param params - Invoice and base metadata configuration
583
+ * @returns Immutable PaymentRequestMetadata with merged fields
584
+ */
1209
585
  function buildInvoiceMetadata(params) {
1210
- const { invoiceMetadata, baseMetadata } = params;
1211
- return {
1212
- ...baseMetadata,
1213
- /**
1214
- * Invoice amounts/dates are authoritative - they override any manually
1215
- * entered values to prevent sync issues with external systems
1216
- */
1217
- amountDue: Number(invoiceMetadata.amount).toFixed(2),
1218
- currency: invoiceMetadata.currency,
1219
- dueDate: invoiceMetadata.dueDate,
1220
- /** Preserve user's manual note if invoice doesn't provide one */
1221
- note: invoiceMetadata.description ?? baseMetadata.note,
1222
- /** Track integration source for reconciliation and debugging */
1223
- source: invoiceMetadata.source,
1224
- invoiceId: invoiceMetadata.invoiceId,
1225
- invoiceNumber: invoiceMetadata.invoiceNumber
1226
- };
1227
- }
586
+ const { invoiceMetadata, baseMetadata } = params;
587
+ const mergedMetadata = {
588
+ ...baseMetadata,
589
+ amountDue: formatAmount(Number(invoiceMetadata.amount)),
590
+ currency: invoiceMetadata.currency,
591
+ dueDate: formatToNaiveDateTime(invoiceMetadata.dueDate),
592
+ note: invoiceMetadata.description ?? baseMetadata.note,
593
+ source: invoiceMetadata.source,
594
+ invoiceId: invoiceMetadata.invoiceId,
595
+ invoiceNumber: invoiceMetadata.invoiceNumber
596
+ };
597
+ const attachmentFields = {
598
+ ...invoiceMetadata.attachmentUrl && { attachmentUrl: invoiceMetadata.attachmentUrl },
599
+ ...invoiceMetadata.attachmentName && { attachmentName: invoiceMetadata.attachmentName }
600
+ };
601
+ return {
602
+ ...mergedMetadata,
603
+ ...attachmentFields
604
+ };
605
+ }
606
+ /**
607
+ * Validates payment metadata structure before sending to backend API.
608
+ * Catches type mismatches and invalid values that would cause payment
609
+ * creation failures or blockchain transaction errors.
610
+ *
611
+ * Pure function returning immutable result object.
612
+ *
613
+ * @param metadata - Metadata to validate
614
+ * @returns Validation result with explicit errors array
615
+ */
1228
616
  function validatePaymentMetadata(metadata) {
1229
- const errors = [];
1230
- const token = metadata["token"];
1231
- if (!token || typeof token !== "string") {
1232
- errors.push("Token symbol is required");
1233
- }
1234
- const amountDue = metadata["amountDue"];
1235
- if (amountDue !== void 0 && amountDue !== null) {
1236
- const amount = typeof amountDue === "string" ? parseFloat(amountDue) : Number(amountDue);
1237
- if (!isValidAmount(amount) || amount < 0) {
1238
- errors.push("Amount must be a valid positive number");
1239
- }
1240
- }
1241
- const dueDate = metadata["dueDate"];
1242
- if (dueDate !== void 0 && dueDate !== null) {
1243
- if (typeof dueDate !== "string") {
1244
- errors.push("Due date must be a string");
1245
- } else {
1246
- const date = new Date(dueDate);
1247
- if (!isValidDate(date)) {
1248
- errors.push("Due date must be a valid ISO date string");
1249
- }
1250
- }
1251
- }
1252
- return {
1253
- isValid: errors.length === 0,
1254
- errors
1255
- };
1256
- }
1257
- export {
1258
- DefaultCCTPConfig,
1259
- PaymentAction,
1260
- SignatureValidator,
1261
- UniswapV3FeeTier,
1262
- addActionNamesToInstructions,
1263
- assertMinimumSignatures,
1264
- assertSignatureCount,
1265
- buildInvoiceMetadata,
1266
- buildPaymentMetadata,
1267
- createChainTokenConfigs,
1268
- createComprehensivePaymentRequest,
1269
- createDefaultFee,
1270
- createFeeWithToken,
1271
- createPaymentRequestBuildPayload,
1272
- createSweepActionArguments,
1273
- createSweepCCTPActionArguments,
1274
- createSweepERC20ActionArguments,
1275
- createSweepUniswapV3ActionArguments,
1276
- createTokenIdentifier,
1277
- defaultCCTPConfig,
1278
- extractActionNamesMap,
1279
- getRecommendedFeeTier,
1280
- instructionRegistry,
1281
- isNativeToken,
1282
- resolvePreferredStablecoin,
1283
- validatePaymentMetadata
1284
- };
1285
- //# sourceMappingURL=index.mjs.map
617
+ const errors = [];
618
+ if (metadata.type !== OrchestrationType.PaymentRequest) errors.push(`Metadata type must be '${OrchestrationType.PaymentRequest}', got '${String(metadata.type)}'`);
619
+ if (!metadata.token || typeof metadata.token !== "string") errors.push("Token symbol is required and must be a string");
620
+ if (!metadata.amountDue || typeof metadata.amountDue !== "string") errors.push("Amount due is required and must be a string");
621
+ else {
622
+ const amount = parseFloat(metadata.amountDue);
623
+ if (!isValidMonetaryAmount(amount) || amount < 0) errors.push(`Amount must be a valid non-negative number, got '${metadata.amountDue}'`);
624
+ }
625
+ if (!metadata.currency || typeof metadata.currency !== "string") errors.push("Currency is required and must be a string");
626
+ if (!metadata.dueDate || typeof metadata.dueDate !== "string") errors.push("Due date is required and must be a string");
627
+ else if (!isValidDate(new Date(metadata.dueDate))) errors.push(`Due date must be a valid date string, got '${metadata.dueDate}'`);
628
+ if (!metadata.fromAccountAddress || typeof metadata.fromAccountAddress !== "string") errors.push("From account address is required and must be a string");
629
+ if (!metadata.payer) errors.push("Payer information is required");
630
+ else {
631
+ if (typeof metadata.payer.name !== "string") errors.push("Payer name must be a string");
632
+ if (!metadata.payer.address || typeof metadata.payer.address !== "string") errors.push("Payer address is required and must be a string");
633
+ }
634
+ if (!metadata.source || typeof metadata.source !== "string") errors.push("Source is required and must be a string");
635
+ return {
636
+ isValid: errors.length === 0,
637
+ errors
638
+ };
639
+ }
640
+
641
+ //#endregion
642
+ export { DefaultCCTPConfig, OrchestrationType, PaymentAction, SignatureValidator, UniswapV3FeeTier, addActionNamesToInstructions, assertMinimumSignatures, assertSignatureCount, buildInvoiceMetadata, buildPaymentMetadata, buildPaymentMetadataFromInvoice, createChainTokenConfigs, createDefaultFee, createFeeWithToken, createPaymentRequestBuildPayload, createTokenIdentifier, defaultCCTPConfig, extractActionNamesMap, getRecommendedFeeTier, instructionRegistry, isNativeToken, validatePaymentMetadata };
643
+ //# sourceMappingURL=index.mjs.map