@oobe-protocol-labs/synapse-sap-sdk 0.13.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (418) hide show
  1. package/dist/cjs/accounts/index.js +286 -0
  2. package/dist/cjs/accounts/index.js.map +1 -0
  3. package/dist/cjs/client.js +125 -0
  4. package/dist/cjs/client.js.map +1 -0
  5. package/dist/cjs/constants/seeds.js +9 -9
  6. package/dist/cjs/constants/seeds.js.map +1 -1
  7. package/dist/cjs/constants.js +66 -0
  8. package/dist/cjs/constants.js.map +1 -0
  9. package/dist/cjs/errors.js +260 -0
  10. package/dist/cjs/errors.js.map +1 -0
  11. package/dist/cjs/events/index.js +37 -123
  12. package/dist/cjs/events/index.js.map +1 -1
  13. package/dist/cjs/idlTypes.js +4 -0
  14. package/dist/cjs/idlTypes.js.map +1 -0
  15. package/dist/cjs/index.js +75 -241
  16. package/dist/cjs/index.js.map +1 -1
  17. package/dist/cjs/instructions/agent.js +90 -0
  18. package/dist/cjs/instructions/agent.js.map +1 -0
  19. package/dist/cjs/instructions/attestation.js +113 -0
  20. package/dist/cjs/instructions/attestation.js.map +1 -0
  21. package/dist/cjs/instructions/digest.js +29 -0
  22. package/dist/cjs/instructions/digest.js.map +1 -0
  23. package/dist/cjs/instructions/dispute.js +117 -0
  24. package/dist/cjs/instructions/dispute.js.map +1 -0
  25. package/dist/cjs/instructions/escrow.js +102 -0
  26. package/dist/cjs/instructions/escrow.js.map +1 -0
  27. package/dist/cjs/instructions/global.js +29 -0
  28. package/dist/cjs/instructions/global.js.map +1 -0
  29. package/dist/cjs/instructions/index.js +31 -0
  30. package/dist/cjs/instructions/index.js.map +1 -0
  31. package/dist/cjs/instructions/indexing.js +222 -0
  32. package/dist/cjs/instructions/indexing.js.map +1 -0
  33. package/dist/cjs/instructions/misc.js +74 -0
  34. package/dist/cjs/instructions/misc.js.map +1 -0
  35. package/dist/cjs/instructions/session.js +90 -0
  36. package/dist/cjs/instructions/session.js.map +1 -0
  37. package/dist/cjs/instructions/staking.js +133 -0
  38. package/dist/cjs/instructions/staking.js.map +1 -0
  39. package/dist/cjs/instructions/subscription.js +81 -0
  40. package/dist/cjs/instructions/subscription.js.map +1 -0
  41. package/dist/cjs/instructions/tools.js +110 -0
  42. package/dist/cjs/instructions/tools.js.map +1 -0
  43. package/dist/cjs/instructions/vault.js +107 -0
  44. package/dist/cjs/instructions/vault.js.map +1 -0
  45. package/dist/cjs/pdas/index.js +120 -0
  46. package/dist/cjs/pdas/index.js.map +1 -0
  47. package/dist/cjs/registries/fairscale.js +1 -1
  48. package/dist/cjs/registries/fairscale.js.map +1 -1
  49. package/dist/cjs/registries/metaplex-bridge.js +1 -1
  50. package/dist/cjs/registries/metaplex-bridge.js.map +1 -1
  51. package/dist/cjs/types.js +45 -0
  52. package/dist/cjs/types.js.map +1 -0
  53. package/dist/cjs/utils/escrow-validation.js +1 -1
  54. package/dist/cjs/utils/escrow-validation.js.map +1 -1
  55. package/dist/cjs/utils/index.js +32 -83
  56. package/dist/cjs/utils/index.js.map +1 -1
  57. package/dist/cjs/utils/merchant-validator.js +5 -5
  58. package/dist/cjs/utils/merchant-validator.js.map +1 -1
  59. package/dist/cjs/utils/validate.js +236 -0
  60. package/dist/cjs/utils/validate.js.map +1 -0
  61. package/dist/cjs/utils/volume-curve.js +1 -1
  62. package/dist/cjs/utils/volume-curve.js.map +1 -1
  63. package/dist/esm/accounts/index.d.ts +11 -0
  64. package/dist/esm/accounts/index.d.ts.map +1 -0
  65. package/dist/esm/accounts/index.js +273 -0
  66. package/dist/esm/accounts/index.js.map +1 -0
  67. package/dist/esm/client.d.ts +55 -0
  68. package/dist/esm/client.d.ts.map +1 -0
  69. package/dist/esm/client.js +87 -0
  70. package/dist/esm/client.js.map +1 -0
  71. package/dist/esm/constants/addresses.d.ts +117 -0
  72. package/dist/esm/constants/addresses.d.ts.map +1 -0
  73. package/dist/esm/constants/index.d.ts +31 -0
  74. package/dist/esm/constants/index.d.ts.map +1 -0
  75. package/dist/esm/constants/limits.d.ts +149 -0
  76. package/dist/esm/constants/limits.d.ts.map +1 -0
  77. package/{src/constants/network.ts → dist/esm/constants/network.d.ts} +23 -31
  78. package/dist/esm/constants/network.d.ts.map +1 -0
  79. package/{src/constants/payments.ts → dist/esm/constants/payments.d.ts} +11 -35
  80. package/dist/esm/constants/payments.d.ts.map +1 -0
  81. package/{src/constants/programs.ts → dist/esm/constants/programs.d.ts} +6 -20
  82. package/dist/esm/constants/programs.d.ts.map +1 -0
  83. package/dist/esm/constants/seeds.d.ts +80 -0
  84. package/dist/esm/constants/seeds.d.ts.map +1 -0
  85. package/dist/esm/constants/seeds.js +9 -9
  86. package/dist/esm/constants/seeds.js.map +1 -1
  87. package/dist/esm/constants.d.ts +39 -0
  88. package/dist/esm/constants.d.ts.map +1 -0
  89. package/dist/esm/constants.js +41 -0
  90. package/dist/esm/constants.js.map +1 -0
  91. package/dist/esm/core/client.d.ts +452 -0
  92. package/dist/esm/core/client.d.ts.map +1 -0
  93. package/dist/esm/core/connection.d.ts +305 -0
  94. package/dist/esm/core/connection.d.ts.map +1 -0
  95. package/{src/core/index.ts → dist/esm/core/index.d.ts} +1 -1
  96. package/dist/esm/core/index.d.ts.map +1 -0
  97. package/dist/esm/errors/index.d.ts +276 -0
  98. package/dist/esm/errors/index.d.ts.map +1 -0
  99. package/dist/esm/errors.d.ts +119 -0
  100. package/dist/esm/errors.d.ts.map +1 -0
  101. package/dist/esm/errors.js +252 -0
  102. package/dist/esm/errors.js.map +1 -0
  103. package/dist/esm/events/geyser.d.ts +150 -0
  104. package/dist/esm/events/geyser.d.ts.map +1 -0
  105. package/dist/esm/events/index.d.ts +17 -0
  106. package/dist/esm/events/index.d.ts.map +1 -0
  107. package/dist/esm/events/index.js +34 -122
  108. package/dist/esm/events/index.js.map +1 -1
  109. package/{src/idl/index.ts → dist/esm/idl/index.d.ts} +9 -15
  110. package/dist/esm/idl/index.d.ts.map +1 -0
  111. package/dist/esm/idlTypes.d.ts +925 -0
  112. package/dist/esm/idlTypes.d.ts.map +1 -0
  113. package/dist/esm/idlTypes.js +3 -0
  114. package/dist/esm/idlTypes.js.map +1 -0
  115. package/dist/esm/index.d.ts +12 -0
  116. package/dist/esm/index.d.ts.map +1 -0
  117. package/dist/esm/index.js +15 -88
  118. package/dist/esm/index.js.map +1 -1
  119. package/dist/esm/instructions/agent.d.ts +71 -0
  120. package/dist/esm/instructions/agent.d.ts.map +1 -0
  121. package/dist/esm/instructions/agent.js +86 -0
  122. package/dist/esm/instructions/agent.js.map +1 -0
  123. package/dist/esm/instructions/attestation.d.ts +76 -0
  124. package/dist/esm/instructions/attestation.d.ts.map +1 -0
  125. package/dist/esm/instructions/attestation.js +109 -0
  126. package/dist/esm/instructions/attestation.js.map +1 -0
  127. package/dist/esm/instructions/digest.d.ts +20 -0
  128. package/dist/esm/instructions/digest.d.ts.map +1 -0
  129. package/dist/esm/instructions/digest.js +25 -0
  130. package/dist/esm/instructions/digest.js.map +1 -0
  131. package/dist/esm/instructions/dispute.d.ts +81 -0
  132. package/dist/esm/instructions/dispute.d.ts.map +1 -0
  133. package/dist/esm/instructions/dispute.js +113 -0
  134. package/dist/esm/instructions/dispute.js.map +1 -0
  135. package/dist/esm/instructions/escrow.d.ts +79 -0
  136. package/dist/esm/instructions/escrow.d.ts.map +1 -0
  137. package/dist/esm/instructions/escrow.js +98 -0
  138. package/dist/esm/instructions/escrow.js.map +1 -0
  139. package/dist/esm/instructions/global.d.ts +14 -0
  140. package/dist/esm/instructions/global.d.ts.map +1 -0
  141. package/dist/esm/instructions/global.js +25 -0
  142. package/dist/esm/instructions/global.js.map +1 -0
  143. package/dist/esm/instructions/index.d.ts +14 -0
  144. package/dist/esm/instructions/index.d.ts.map +1 -0
  145. package/dist/esm/instructions/index.js +15 -0
  146. package/dist/esm/instructions/index.js.map +1 -0
  147. package/dist/esm/instructions/indexing.d.ts +150 -0
  148. package/dist/esm/instructions/indexing.d.ts.map +1 -0
  149. package/dist/esm/instructions/indexing.js +218 -0
  150. package/dist/esm/instructions/indexing.js.map +1 -0
  151. package/dist/esm/instructions/memory.d.ts +8 -0
  152. package/dist/esm/instructions/memory.d.ts.map +1 -0
  153. package/dist/esm/instructions/memory.js +234 -0
  154. package/dist/esm/instructions/memory.js.map +1 -0
  155. package/dist/esm/instructions/misc.d.ts +50 -0
  156. package/dist/esm/instructions/misc.d.ts.map +1 -0
  157. package/dist/esm/instructions/misc.js +70 -0
  158. package/dist/esm/instructions/misc.js.map +1 -0
  159. package/dist/esm/instructions/session.d.ts +57 -0
  160. package/dist/esm/instructions/session.d.ts.map +1 -0
  161. package/dist/esm/instructions/session.js +86 -0
  162. package/dist/esm/instructions/session.js.map +1 -0
  163. package/dist/esm/instructions/staking.d.ts +85 -0
  164. package/dist/esm/instructions/staking.d.ts.map +1 -0
  165. package/dist/esm/instructions/staking.js +129 -0
  166. package/dist/esm/instructions/staking.js.map +1 -0
  167. package/dist/esm/instructions/subscription.d.ts +50 -0
  168. package/dist/esm/instructions/subscription.d.ts.map +1 -0
  169. package/dist/esm/instructions/subscription.js +77 -0
  170. package/dist/esm/instructions/subscription.js.map +1 -0
  171. package/dist/esm/instructions/tools.d.ts +88 -0
  172. package/dist/esm/instructions/tools.d.ts.map +1 -0
  173. package/dist/esm/instructions/tools.js +106 -0
  174. package/dist/esm/instructions/tools.js.map +1 -0
  175. package/dist/esm/instructions/vault.d.ts +84 -0
  176. package/dist/esm/instructions/vault.d.ts.map +1 -0
  177. package/dist/esm/instructions/vault.js +103 -0
  178. package/dist/esm/instructions/vault.js.map +1 -0
  179. package/dist/esm/modules/agent.d.ts +166 -0
  180. package/dist/esm/modules/agent.d.ts.map +1 -0
  181. package/dist/esm/modules/attestation.d.ts +96 -0
  182. package/dist/esm/modules/attestation.d.ts.map +1 -0
  183. package/dist/esm/modules/base.d.ts +161 -0
  184. package/dist/esm/modules/base.d.ts.map +1 -0
  185. package/dist/esm/modules/escrow-v2.d.ts +169 -0
  186. package/dist/esm/modules/escrow-v2.d.ts.map +1 -0
  187. package/dist/esm/modules/feedback.d.ts +105 -0
  188. package/dist/esm/modules/feedback.d.ts.map +1 -0
  189. package/{src/modules/index.ts → dist/esm/modules/index.d.ts} +1 -1
  190. package/dist/esm/modules/index.d.ts.map +1 -0
  191. package/dist/esm/modules/indexing.d.ts +200 -0
  192. package/dist/esm/modules/indexing.d.ts.map +1 -0
  193. package/dist/esm/modules/ledger.d.ts +150 -0
  194. package/dist/esm/modules/ledger.d.ts.map +1 -0
  195. package/dist/esm/modules/receipt.d.ts +77 -0
  196. package/dist/esm/modules/receipt.d.ts.map +1 -0
  197. package/dist/esm/modules/staking.d.ts +51 -0
  198. package/dist/esm/modules/staking.d.ts.map +1 -0
  199. package/dist/esm/modules/subscription.d.ts +33 -0
  200. package/dist/esm/modules/subscription.d.ts.map +1 -0
  201. package/dist/esm/modules/tools.d.ts +182 -0
  202. package/dist/esm/modules/tools.d.ts.map +1 -0
  203. package/dist/esm/modules/vault.d.ts +240 -0
  204. package/dist/esm/modules/vault.d.ts.map +1 -0
  205. package/dist/esm/parser/client.d.ts +123 -0
  206. package/dist/esm/parser/client.d.ts.map +1 -0
  207. package/dist/esm/parser/complete.d.ts +90 -0
  208. package/dist/esm/parser/complete.d.ts.map +1 -0
  209. package/{src/parser/index.ts → dist/esm/parser/index.d.ts} +6 -37
  210. package/dist/esm/parser/index.d.ts.map +1 -0
  211. package/dist/esm/parser/inner.d.ts +114 -0
  212. package/dist/esm/parser/inner.d.ts.map +1 -0
  213. package/{src/parser/instructions.ts → dist/esm/parser/instructions.d.ts} +4 -63
  214. package/dist/esm/parser/instructions.d.ts.map +1 -0
  215. package/dist/esm/parser/transaction.d.ts +77 -0
  216. package/dist/esm/parser/transaction.d.ts.map +1 -0
  217. package/dist/esm/parser/types.d.ts +154 -0
  218. package/dist/esm/parser/types.d.ts.map +1 -0
  219. package/{src/pda/index.ts → dist/esm/pda/index.d.ts} +33 -442
  220. package/dist/esm/pda/index.d.ts.map +1 -0
  221. package/dist/esm/pdas/index.d.ts +37 -0
  222. package/dist/esm/pdas/index.d.ts.map +1 -0
  223. package/dist/esm/pdas/index.js +101 -0
  224. package/dist/esm/pdas/index.js.map +1 -0
  225. package/dist/esm/plugin/index.d.ts +171 -0
  226. package/dist/esm/plugin/index.d.ts.map +1 -0
  227. package/dist/esm/plugin/protocols.d.ts +152 -0
  228. package/dist/esm/plugin/protocols.d.ts.map +1 -0
  229. package/dist/esm/plugin/schemas.d.ts +829 -0
  230. package/dist/esm/plugin/schemas.d.ts.map +1 -0
  231. package/dist/esm/postgres/adapter.d.ts +355 -0
  232. package/dist/esm/postgres/adapter.d.ts.map +1 -0
  233. package/dist/esm/postgres/index.d.ts +24 -0
  234. package/dist/esm/postgres/index.d.ts.map +1 -0
  235. package/dist/esm/postgres/serializers.d.ts +30 -0
  236. package/dist/esm/postgres/serializers.d.ts.map +1 -0
  237. package/dist/esm/postgres/sync.d.ts +156 -0
  238. package/dist/esm/postgres/sync.d.ts.map +1 -0
  239. package/dist/esm/postgres/types.d.ts +167 -0
  240. package/dist/esm/postgres/types.d.ts.map +1 -0
  241. package/dist/esm/registries/builder.d.ts +340 -0
  242. package/dist/esm/registries/builder.d.ts.map +1 -0
  243. package/dist/esm/registries/discovery.d.ts +333 -0
  244. package/dist/esm/registries/discovery.d.ts.map +1 -0
  245. package/dist/esm/registries/fairscale.d.ts +680 -0
  246. package/dist/esm/registries/fairscale.d.ts.map +1 -0
  247. package/dist/esm/registries/fairscale.js +1 -1
  248. package/dist/esm/registries/fairscale.js.map +1 -1
  249. package/dist/esm/registries/index.d.ts +52 -0
  250. package/dist/esm/registries/index.d.ts.map +1 -0
  251. package/dist/esm/registries/metaplex-bridge.d.ts +489 -0
  252. package/dist/esm/registries/metaplex-bridge.d.ts.map +1 -0
  253. package/dist/esm/registries/metaplex-bridge.js +1 -1
  254. package/dist/esm/registries/metaplex-bridge.js.map +1 -1
  255. package/dist/esm/registries/session.d.ts +323 -0
  256. package/dist/esm/registries/session.d.ts.map +1 -0
  257. package/dist/esm/registries/x402.d.ts +530 -0
  258. package/dist/esm/registries/x402.d.ts.map +1 -0
  259. package/dist/esm/types/accounts.d.ts +765 -0
  260. package/dist/esm/types/accounts.d.ts.map +1 -0
  261. package/dist/esm/types/common.d.ts +166 -0
  262. package/dist/esm/types/common.d.ts.map +1 -0
  263. package/dist/esm/types/endpoint.d.ts +161 -0
  264. package/dist/esm/types/endpoint.d.ts.map +1 -0
  265. package/dist/esm/types/enums.d.ts +353 -0
  266. package/dist/esm/types/enums.d.ts.map +1 -0
  267. package/dist/esm/types/index.d.ts +29 -0
  268. package/dist/esm/types/index.d.ts.map +1 -0
  269. package/dist/esm/types/instructions.d.ts +400 -0
  270. package/dist/esm/types/instructions.d.ts.map +1 -0
  271. package/dist/esm/types.d.ts +236 -0
  272. package/dist/esm/types.d.ts.map +1 -0
  273. package/dist/esm/types.js +40 -0
  274. package/dist/esm/types.js.map +1 -0
  275. package/dist/esm/utils/anchor-errors.d.ts +61 -0
  276. package/dist/esm/utils/anchor-errors.d.ts.map +1 -0
  277. package/dist/esm/utils/endpoint-validator.d.ts +110 -0
  278. package/dist/esm/utils/endpoint-validator.d.ts.map +1 -0
  279. package/dist/esm/utils/escrow-validation.d.ts +145 -0
  280. package/dist/esm/utils/escrow-validation.d.ts.map +1 -0
  281. package/dist/esm/utils/escrow-validation.js +1 -1
  282. package/dist/esm/utils/escrow-validation.js.map +1 -1
  283. package/{src/utils/hash.ts → dist/esm/utils/hash.d.ts} +4 -42
  284. package/dist/esm/utils/hash.d.ts.map +1 -0
  285. package/dist/esm/utils/index.d.ts +6 -0
  286. package/dist/esm/utils/index.d.ts.map +1 -0
  287. package/dist/esm/utils/index.js +16 -33
  288. package/dist/esm/utils/index.js.map +1 -1
  289. package/dist/esm/utils/merchant-validator.d.ts +176 -0
  290. package/dist/esm/utils/merchant-validator.d.ts.map +1 -0
  291. package/dist/esm/utils/merchant-validator.js +1 -1
  292. package/dist/esm/utils/merchant-validator.js.map +1 -1
  293. package/dist/esm/utils/network-normalizer.d.ts +120 -0
  294. package/dist/esm/utils/network-normalizer.d.ts.map +1 -0
  295. package/dist/esm/utils/priority-fee.d.ts +205 -0
  296. package/dist/esm/utils/priority-fee.d.ts.map +1 -0
  297. package/dist/esm/utils/rpc-strategy.d.ts +172 -0
  298. package/dist/esm/utils/rpc-strategy.d.ts.map +1 -0
  299. package/dist/esm/utils/schemas.d.ts +351 -0
  300. package/dist/esm/utils/schemas.d.ts.map +1 -0
  301. package/{src/utils/serialization.ts → dist/esm/utils/serialization.d.ts} +3 -32
  302. package/dist/esm/utils/serialization.d.ts.map +1 -0
  303. package/dist/esm/utils/validate.d.ts +66 -0
  304. package/dist/esm/utils/validate.d.ts.map +1 -0
  305. package/dist/esm/utils/validate.js +221 -0
  306. package/dist/esm/utils/validate.js.map +1 -0
  307. package/{src/utils/validation.ts → dist/esm/utils/validation.d.ts} +2 -9
  308. package/dist/esm/utils/validation.d.ts.map +1 -0
  309. package/{src/utils/volume-curve.ts → dist/esm/utils/volume-curve.d.ts} +2 -73
  310. package/dist/esm/utils/volume-curve.d.ts.map +1 -0
  311. package/dist/esm/utils/volume-curve.js +1 -1
  312. package/dist/esm/utils/volume-curve.js.map +1 -1
  313. package/dist/esm/utils/x402-direct.d.ts +114 -0
  314. package/dist/esm/utils/x402-direct.d.ts.map +1 -0
  315. package/dist/types/constants/seeds.d.ts +2 -0
  316. package/dist/types/constants/seeds.d.ts.map +1 -1
  317. package/dist/types/core/client.d.ts +21 -6
  318. package/dist/types/core/client.d.ts.map +1 -1
  319. package/dist/types/errors/index.d.ts +59 -0
  320. package/dist/types/errors/index.d.ts.map +1 -1
  321. package/dist/types/index.d.ts +3 -2
  322. package/dist/types/index.d.ts.map +1 -1
  323. package/dist/types/modules/agent.d.ts +9 -19
  324. package/dist/types/modules/agent.d.ts.map +1 -1
  325. package/dist/types/modules/attestation.d.ts.map +1 -1
  326. package/dist/types/modules/base.d.ts +54 -0
  327. package/dist/types/modules/base.d.ts.map +1 -1
  328. package/dist/types/modules/escrow-v2.d.ts +117 -1
  329. package/dist/types/modules/escrow-v2.d.ts.map +1 -1
  330. package/dist/types/modules/index.d.ts +1 -2
  331. package/dist/types/modules/index.d.ts.map +1 -1
  332. package/dist/types/modules/receipt.d.ts +14 -0
  333. package/dist/types/modules/receipt.d.ts.map +1 -1
  334. package/dist/types/modules/subscription.d.ts.map +1 -1
  335. package/dist/types/modules/tools.d.ts +0 -10
  336. package/dist/types/modules/tools.d.ts.map +1 -1
  337. package/dist/types/modules/vault.d.ts.map +1 -1
  338. package/dist/types/pda/index.d.ts +17 -0
  339. package/dist/types/pda/index.d.ts.map +1 -1
  340. package/dist/types/plugin/index.d.ts.map +1 -1
  341. package/dist/types/registries/builder.d.ts +2 -9
  342. package/dist/types/registries/builder.d.ts.map +1 -1
  343. package/dist/types/registries/metaplex-bridge.d.ts.map +1 -1
  344. package/dist/types/registries/session.d.ts +3 -9
  345. package/dist/types/registries/session.d.ts.map +1 -1
  346. package/dist/types/registries/x402.d.ts +2 -9
  347. package/dist/types/registries/x402.d.ts.map +1 -1
  348. package/dist/types/types/accounts.d.ts +52 -0
  349. package/dist/types/types/accounts.d.ts.map +1 -1
  350. package/dist/types/types/index.d.ts +1 -1
  351. package/dist/types/types/index.d.ts.map +1 -1
  352. package/dist/types/utils/rpc-strategy.d.ts +7 -0
  353. package/dist/types/utils/rpc-strategy.d.ts.map +1 -1
  354. package/package.json +59 -183
  355. package/src/constants/addresses.ts +0 -162
  356. package/src/constants/index.ts +0 -69
  357. package/src/constants/limits.ts +0 -165
  358. package/src/constants/seeds.ts +0 -85
  359. package/src/core/client.ts +0 -583
  360. package/src/core/connection.ts +0 -461
  361. package/src/errors/index.ts +0 -346
  362. package/src/events/geyser.ts +0 -384
  363. package/src/events/index.ts +0 -335
  364. package/src/events/yellowstone.d.ts +0 -7
  365. package/src/idl/synapse_agent_sap.json +0 -14595
  366. package/src/index.ts +0 -421
  367. package/src/modules/agent.ts +0 -319
  368. package/src/modules/attestation.ts +0 -168
  369. package/src/modules/base.ts +0 -247
  370. package/src/modules/escrow-v2.ts +0 -871
  371. package/src/modules/escrow.ts +0 -439
  372. package/src/modules/feedback.ts +0 -186
  373. package/src/modules/indexing.ts +0 -444
  374. package/src/modules/ledger.ts +0 -262
  375. package/src/modules/receipt.ts +0 -212
  376. package/src/modules/staking.ts +0 -223
  377. package/src/modules/subscription.ts +0 -147
  378. package/src/modules/tools.ts +0 -454
  379. package/src/modules/vault.ts +0 -558
  380. package/src/parser/client.ts +0 -211
  381. package/src/parser/complete.ts +0 -232
  382. package/src/parser/inner.ts +0 -255
  383. package/src/parser/transaction.ts +0 -200
  384. package/src/parser/types.ts +0 -182
  385. package/src/plugin/index.ts +0 -1224
  386. package/src/plugin/protocols.ts +0 -404
  387. package/src/plugin/schemas.ts +0 -941
  388. package/src/postgres/adapter.ts +0 -904
  389. package/src/postgres/index.ts +0 -59
  390. package/src/postgres/schema.sql +0 -683
  391. package/src/postgres/serializers.ts +0 -485
  392. package/src/postgres/sync.ts +0 -340
  393. package/src/postgres/types.ts +0 -245
  394. package/src/registries/builder.ts +0 -607
  395. package/src/registries/discovery.ts +0 -572
  396. package/src/registries/fairscale.ts +0 -1278
  397. package/src/registries/index.ts +0 -143
  398. package/src/registries/metaplex-bridge.ts +0 -1199
  399. package/src/registries/session.ts +0 -613
  400. package/src/registries/x402.ts +0 -1048
  401. package/src/types/accounts.ts +0 -858
  402. package/src/types/common.ts +0 -187
  403. package/src/types/endpoint.ts +0 -181
  404. package/src/types/enums.ts +0 -333
  405. package/src/types/index.ts +0 -121
  406. package/src/types/instructions.ts +0 -453
  407. package/src/utils/anchor-errors.ts +0 -461
  408. package/src/utils/endpoint-validator.ts +0 -300
  409. package/src/utils/escrow-validation.ts +0 -301
  410. package/src/utils/index.ts +0 -118
  411. package/src/utils/merchant-validator.ts +0 -359
  412. package/src/utils/network-normalizer.ts +0 -240
  413. package/src/utils/priority-fee.ts +0 -325
  414. package/src/utils/rpc-strategy.ts +0 -322
  415. package/src/utils/schemas.ts +0 -359
  416. package/src/utils/x402-direct.ts +0 -370
  417. /package/dist/{types → esm}/modules/escrow.d.ts +0 -0
  418. /package/dist/{types → esm}/modules/escrow.d.ts.map +0 -0
@@ -0,0 +1,172 @@
1
+ /**
2
+ * @module utils/rpc-strategy
3
+ * @description Dual-connection RPC strategy and idempotent ATA creation.
4
+ *
5
+ * Solves two interoperability problems:
6
+ *
7
+ * 1. **WebSocket 400 loop**: Some authenticated RPCs reject WebSocket
8
+ * connections for SPL token operations. This module exposes a
9
+ * dual-connection strategy: primary RPC for SAP program calls,
10
+ * fallback public RPC for token operations.
11
+ *
12
+ * 2. **Idempotent ATA creation**: Wraps `getOrCreateAssociatedTokenAccount`
13
+ * with retries so "account already exists" doesn't surface as a
14
+ * hard error.
15
+ *
16
+ * @category Utils
17
+ * @since v0.6.0
18
+ */
19
+ import { Connection, type Commitment, PublicKey, type TransactionSignature } from "@solana/web3.js";
20
+ /**
21
+ * @interface RpcConfig
22
+ * @description Configuration for dual-connection RPC strategy.
23
+ * @category Utils
24
+ * @since v0.6.0
25
+ */
26
+ export interface RpcConfig {
27
+ /** Primary RPC URL (for SAP program calls). */
28
+ readonly primaryUrl: string;
29
+ /** Fallback RPC URL (for SPL token ops, public RPCs). */
30
+ readonly fallbackUrl?: string;
31
+ /** Commitment level. */
32
+ readonly commitment?: Commitment;
33
+ }
34
+ /**
35
+ * @interface DualConnection
36
+ * @description Dual RPC connections: primary for SAP, fallback for tokens.
37
+ * @category Utils
38
+ * @since v0.6.0
39
+ */
40
+ export interface DualConnection {
41
+ /** Primary connection for SAP program calls. */
42
+ readonly primary: Connection;
43
+ /** Fallback connection for SPL token operations. */
44
+ readonly fallback: Connection;
45
+ }
46
+ /**
47
+ * @name getRpcUrl
48
+ * @description Get the primary RPC URL from environment or config.
49
+ *
50
+ * Resolution order:
51
+ * 1. Explicit `config.primaryUrl`
52
+ * 2. `SOLANA_RPC_URL` env var
53
+ * 3. Cluster-appropriate public RPC
54
+ *
55
+ * @param config - Optional RPC configuration.
56
+ * @param cluster - Cluster hint (defaults to "mainnet-beta").
57
+ * @returns The resolved primary RPC URL.
58
+ *
59
+ * @category Utils
60
+ * @since v0.6.0
61
+ */
62
+ export declare function getRpcUrl(config?: Partial<RpcConfig>, cluster?: string): string;
63
+ /**
64
+ * @name getFallbackRpcUrl
65
+ * @description Get the fallback RPC URL for SPL token operations.
66
+ *
67
+ * This avoids the WebSocket-400 loop when the primary RPC is
68
+ * an authenticated endpoint that rejects token-related WebSocket
69
+ * subscriptions.
70
+ *
71
+ * @param config - Optional RPC configuration.
72
+ * @param cluster - Cluster hint (defaults to "mainnet-beta").
73
+ * @returns The resolved fallback RPC URL.
74
+ *
75
+ * @category Utils
76
+ * @since v0.6.0
77
+ */
78
+ export declare function getFallbackRpcUrl(config?: Partial<RpcConfig>, cluster?: string): string;
79
+ /**
80
+ * @name createDualConnection
81
+ * @description Create a dual-connection pair: primary for SAP program calls,
82
+ * fallback for SPL token operations.
83
+ *
84
+ * @param config - RPC configuration.
85
+ * @param cluster - Cluster hint.
86
+ * @returns A {@link DualConnection} with both connections.
87
+ *
88
+ * @category Utils
89
+ * @since v0.6.0
90
+ *
91
+ * @example
92
+ * ```ts
93
+ * const { primary, fallback } = createDualConnection({
94
+ * primaryUrl: "https://my-rpc.example.com",
95
+ * }, "mainnet-beta");
96
+ *
97
+ * // Use primary for SAP calls
98
+ * const provider = new AnchorProvider(primary, wallet, {});
99
+ *
100
+ * // Use fallback for SPL token account creation
101
+ * const ata = await getOrCreateATA(fallback, mint, owner);
102
+ * ```
103
+ */
104
+ export declare function createDualConnection(config: Partial<RpcConfig>, cluster?: string): DualConnection;
105
+ /**
106
+ * @interface AtaResult
107
+ * @description Result of idempotent ATA creation attempt.
108
+ * @category Utils
109
+ * @since v0.6.0
110
+ */
111
+ export interface AtaResult {
112
+ /** The ATA public key (exists or newly created). */
113
+ readonly address: PublicKey;
114
+ /** Whether the ATA already existed. */
115
+ readonly existed: boolean;
116
+ /** Transaction signature (only if newly created). */
117
+ readonly txSignature?: TransactionSignature;
118
+ }
119
+ /**
120
+ * @name findATA
121
+ * @description Derive the Associated Token Account address.
122
+ * Uses the standard ATA PDA derivation without importing the full
123
+ * `@solana/spl-token` package.
124
+ *
125
+ * @param owner - The token account owner.
126
+ * @param mint - The token mint.
127
+ * @param programId - Token program ID (defaults to TOKEN_PROGRAM_ID).
128
+ * @returns The derived ATA public key.
129
+ *
130
+ * @category Utils
131
+ * @since v0.6.0
132
+ */
133
+ export declare function findATA(owner: PublicKey, mint: PublicKey, programId?: PublicKey): PublicKey;
134
+ /**
135
+ * @name classifyAnchorError
136
+ * @description Convert an Anchor error code into a friendly, actionable message.
137
+ *
138
+ * @param errorCode - The numeric Anchor error code.
139
+ * @returns A human-readable error message, or a generic message for unknown codes.
140
+ *
141
+ * @category Utils
142
+ * @since v0.6.0
143
+ *
144
+ * @example
145
+ * ```ts
146
+ * try {
147
+ * await client.escrow.create(...);
148
+ * } catch (err) {
149
+ * const code = extractAnchorErrorCode(err);
150
+ * if (code !== null) {
151
+ * console.error(classifyAnchorError(code));
152
+ * }
153
+ * }
154
+ * ```
155
+ */
156
+ export declare function classifyAnchorError(errorCode: number): string;
157
+ /**
158
+ * @name extractAnchorErrorCode
159
+ * @description Attempt to extract an Anchor error code from an Error object.
160
+ *
161
+ * Anchor errors typically have the structure `{ code: number, msg: string }`.
162
+ * This function handles both the direct `error.code` pattern and the
163
+ * `error.error.errorCode.number` nested pattern.
164
+ *
165
+ * @param err - The caught error object.
166
+ * @returns The numeric error code, or `null` if not an Anchor error.
167
+ *
168
+ * @category Utils
169
+ * @since v0.6.0
170
+ */
171
+ export declare function extractAnchorErrorCode(err: unknown): number | null;
172
+ //# sourceMappingURL=rpc-strategy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc-strategy.d.ts","sourceRoot":"","sources":["../../../src/utils/rpc-strategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EACL,UAAU,EACV,KAAK,UAAU,EACf,SAAS,EACT,KAAK,oBAAoB,EAC1B,MAAM,iBAAiB,CAAC;AAMzB;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,+CAA+C;IAC/C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,yDAAyD;IACzD,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,wBAAwB;IACxB,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;CAClC;AAED;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,gDAAgD;IAChD,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,oDAAoD;IACpD,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;CAC/B;AAiBD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,SAAS,CACvB,MAAM,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,EAC3B,OAAO,GAAE,MAAuB,GAC/B,MAAM,CASR;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,CAAC,EAAE,OAAO,CAAC,SAAS,CAAC,EAC3B,OAAO,GAAE,MAAuB,GAC/B,MAAM,CAWR;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,EAC1B,OAAO,GAAE,MAAuB,GAC/B,cAAc,CAShB;AAMD;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,oDAAoD;IACpD,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,uCAAuC;IACvC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,qDAAqD;IACrD,QAAQ,CAAC,WAAW,CAAC,EAAE,oBAAoB,CAAC;CAC7C;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CACrB,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,SAAS,EACf,SAAS,GAAE,SAAwE,GAClF,SAAS,CAUX;AAiCD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAK7D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAyBlE"}
@@ -0,0 +1,351 @@
1
+ /**
2
+ * @module utils/schemas
3
+ * @description Zod schemas for runtime validation of environment variables,
4
+ * tool arguments, agent manifests, and x402 payment parameters.
5
+ *
6
+ * These schemas enforce correctness at the boundary: CLI scripts refuse
7
+ * to run if required fields are missing or mis-typed, and SDK methods
8
+ * validate inputs before hitting the chain.
9
+ *
10
+ * Zod is a peer dependency — these schemas are tree-shaken if not imported.
11
+ *
12
+ * @category Utils
13
+ * @since v0.6.0
14
+ */
15
+ /**
16
+ * @name createEnvSchema
17
+ * @description Create a Zod schema for SAP SDK environment variables.
18
+ * Validates that all required env vars are present and correctly typed.
19
+ *
20
+ * @returns A Zod schema object for env validation.
21
+ *
22
+ * @category Utils
23
+ * @since v0.6.0
24
+ *
25
+ * @example
26
+ * ```ts
27
+ * import { createEnvSchema } from "@synapse-sap/sdk";
28
+ *
29
+ * const schema = createEnvSchema();
30
+ * const env = schema.parse(process.env);
31
+ * // env.SOLANA_CLUSTER is typed as "mainnet-beta" | "devnet" | "localnet"
32
+ * ```
33
+ */
34
+ export declare function createEnvSchema(): import("zod").ZodObject<{
35
+ SOLANA_CLUSTER: import("zod").ZodDefault<import("zod").ZodEnum<{
36
+ "mainnet-beta": "mainnet-beta";
37
+ devnet: "devnet";
38
+ localnet: "localnet";
39
+ }>>;
40
+ SOLANA_RPC_URL: import("zod").ZodOptional<import("zod").ZodString>;
41
+ SOLANA_FALLBACK_RPC_URL: import("zod").ZodOptional<import("zod").ZodString>;
42
+ SOLANA_WS_URL: import("zod").ZodOptional<import("zod").ZodString>;
43
+ WALLET_KEYPAIR_PATH: import("zod").ZodOptional<import("zod").ZodString>;
44
+ WALLET_PRIVATE_KEY: import("zod").ZodOptional<import("zod").ZodString>;
45
+ SAP_PROGRAM_ID: import("zod").ZodOptional<import("zod").ZodString>;
46
+ DATABASE_URL: import("zod").ZodOptional<import("zod").ZodString>;
47
+ LOG_LEVEL: import("zod").ZodDefault<import("zod").ZodEnum<{
48
+ error: "error";
49
+ info: "info";
50
+ debug: "debug";
51
+ warn: "warn";
52
+ }>>;
53
+ X402_ENDPOINT: import("zod").ZodOptional<import("zod").ZodString>;
54
+ AGENT_URI: import("zod").ZodOptional<import("zod").ZodString>;
55
+ }, import("zod/v4/core").$strip>;
56
+ /**
57
+ * @name createEndpointDescriptorSchema
58
+ * @description Zod schema for {@link EndpointDescriptor}.
59
+ * @returns A Zod schema for endpoint descriptor validation.
60
+ * @category Utils
61
+ * @since v0.6.0
62
+ */
63
+ export declare function createEndpointDescriptorSchema(): import("zod").ZodObject<{
64
+ url: import("zod").ZodString;
65
+ method: import("zod").ZodDefault<import("zod").ZodEnum<{
66
+ GET: "GET";
67
+ POST: "POST";
68
+ PUT: "PUT";
69
+ DELETE: "DELETE";
70
+ }>>;
71
+ contentType: import("zod").ZodDefault<import("zod").ZodString>;
72
+ requiresAuth: import("zod").ZodDefault<import("zod").ZodBoolean>;
73
+ authType: import("zod").ZodOptional<import("zod").ZodEnum<{
74
+ bearer: "bearer";
75
+ "api-key": "api-key";
76
+ x402: "x402";
77
+ none: "none";
78
+ }>>;
79
+ requiresCSRF: import("zod").ZodDefault<import("zod").ZodBoolean>;
80
+ requiresCookies: import("zod").ZodDefault<import("zod").ZodBoolean>;
81
+ corsOrigins: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
82
+ requiredHeaders: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
83
+ }, import("zod/v4/core").$strip>;
84
+ /**
85
+ * @name createHealthCheckSchema
86
+ * @description Zod schema for {@link HealthCheckDescriptor}.
87
+ * @returns A Zod schema for health check validation.
88
+ * @category Utils
89
+ * @since v0.6.0
90
+ */
91
+ export declare function createHealthCheckSchema(): import("zod").ZodObject<{
92
+ url: import("zod").ZodString;
93
+ expectedStatus: import("zod").ZodDefault<import("zod").ZodNumber>;
94
+ timeoutMs: import("zod").ZodDefault<import("zod").ZodNumber>;
95
+ method: import("zod").ZodDefault<import("zod").ZodEnum<{
96
+ GET: "GET";
97
+ HEAD: "HEAD";
98
+ }>>;
99
+ }, import("zod/v4/core").$strip>;
100
+ /**
101
+ * @name createToolManifestEntrySchema
102
+ * @description Zod schema for a single tool in an agent manifest.
103
+ * @returns A Zod schema for tool manifest entry validation.
104
+ * @category Utils
105
+ * @since v0.6.0
106
+ */
107
+ export declare function createToolManifestEntrySchema(): import("zod").ZodObject<{
108
+ name: import("zod").ZodString;
109
+ description: import("zod").ZodString;
110
+ protocol: import("zod").ZodString;
111
+ category: import("zod").ZodString;
112
+ inputSchema: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>;
113
+ outputSchema: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>;
114
+ httpMethod: import("zod").ZodDefault<import("zod").ZodEnum<{
115
+ GET: "GET";
116
+ POST: "POST";
117
+ PUT: "PUT";
118
+ DELETE: "DELETE";
119
+ COMPOUND: "COMPOUND";
120
+ }>>;
121
+ paymentMode: import("zod").ZodDefault<import("zod").ZodEnum<{
122
+ subscription: "subscription";
123
+ x402: "x402";
124
+ free: "free";
125
+ prepaid: "prepaid";
126
+ }>>;
127
+ pricePerCall: import("zod").ZodDefault<import("zod").ZodNumber>;
128
+ requiredArgs: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
129
+ prerequisites: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
130
+ endpointOverride: import("zod").ZodOptional<import("zod").ZodObject<{
131
+ url: import("zod").ZodString;
132
+ method: import("zod").ZodDefault<import("zod").ZodEnum<{
133
+ GET: "GET";
134
+ POST: "POST";
135
+ PUT: "PUT";
136
+ DELETE: "DELETE";
137
+ }>>;
138
+ contentType: import("zod").ZodDefault<import("zod").ZodString>;
139
+ requiresAuth: import("zod").ZodDefault<import("zod").ZodBoolean>;
140
+ authType: import("zod").ZodOptional<import("zod").ZodEnum<{
141
+ bearer: "bearer";
142
+ "api-key": "api-key";
143
+ x402: "x402";
144
+ none: "none";
145
+ }>>;
146
+ requiresCSRF: import("zod").ZodDefault<import("zod").ZodBoolean>;
147
+ requiresCookies: import("zod").ZodDefault<import("zod").ZodBoolean>;
148
+ corsOrigins: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
149
+ requiredHeaders: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
150
+ }, import("zod/v4/core").$strip>>;
151
+ }, import("zod/v4/core").$strip>;
152
+ /**
153
+ * @name createAgentManifestSchema
154
+ * @description Zod schema for a complete agent manifest.
155
+ * @returns A Zod schema for manifest validation.
156
+ * @category Utils
157
+ * @since v0.6.0
158
+ *
159
+ * @example
160
+ * ```ts
161
+ * import { createAgentManifestSchema } from "@synapse-sap/sdk";
162
+ *
163
+ * const schema = createAgentManifestSchema();
164
+ * const manifest = schema.parse(JSON.parse(fs.readFileSync("manifest.json", "utf-8")));
165
+ * ```
166
+ */
167
+ export declare function createAgentManifestSchema(): import("zod").ZodObject<{
168
+ version: import("zod").ZodLiteral<"1.0.0">;
169
+ wallet: import("zod").ZodString;
170
+ name: import("zod").ZodString;
171
+ description: import("zod").ZodString;
172
+ endpoint: import("zod").ZodObject<{
173
+ url: import("zod").ZodString;
174
+ method: import("zod").ZodDefault<import("zod").ZodEnum<{
175
+ GET: "GET";
176
+ POST: "POST";
177
+ PUT: "PUT";
178
+ DELETE: "DELETE";
179
+ }>>;
180
+ contentType: import("zod").ZodDefault<import("zod").ZodString>;
181
+ requiresAuth: import("zod").ZodDefault<import("zod").ZodBoolean>;
182
+ authType: import("zod").ZodOptional<import("zod").ZodEnum<{
183
+ bearer: "bearer";
184
+ "api-key": "api-key";
185
+ x402: "x402";
186
+ none: "none";
187
+ }>>;
188
+ requiresCSRF: import("zod").ZodDefault<import("zod").ZodBoolean>;
189
+ requiresCookies: import("zod").ZodDefault<import("zod").ZodBoolean>;
190
+ corsOrigins: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
191
+ requiredHeaders: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
192
+ }, import("zod/v4/core").$strip>;
193
+ healthCheck: import("zod").ZodOptional<import("zod").ZodObject<{
194
+ url: import("zod").ZodString;
195
+ expectedStatus: import("zod").ZodDefault<import("zod").ZodNumber>;
196
+ timeoutMs: import("zod").ZodDefault<import("zod").ZodNumber>;
197
+ method: import("zod").ZodDefault<import("zod").ZodEnum<{
198
+ GET: "GET";
199
+ HEAD: "HEAD";
200
+ }>>;
201
+ }, import("zod/v4/core").$strip>>;
202
+ tools: import("zod").ZodArray<import("zod").ZodObject<{
203
+ name: import("zod").ZodString;
204
+ description: import("zod").ZodString;
205
+ protocol: import("zod").ZodString;
206
+ category: import("zod").ZodString;
207
+ inputSchema: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>;
208
+ outputSchema: import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>;
209
+ httpMethod: import("zod").ZodDefault<import("zod").ZodEnum<{
210
+ GET: "GET";
211
+ POST: "POST";
212
+ PUT: "PUT";
213
+ DELETE: "DELETE";
214
+ COMPOUND: "COMPOUND";
215
+ }>>;
216
+ paymentMode: import("zod").ZodDefault<import("zod").ZodEnum<{
217
+ subscription: "subscription";
218
+ x402: "x402";
219
+ free: "free";
220
+ prepaid: "prepaid";
221
+ }>>;
222
+ pricePerCall: import("zod").ZodDefault<import("zod").ZodNumber>;
223
+ requiredArgs: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
224
+ prerequisites: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
225
+ endpointOverride: import("zod").ZodOptional<import("zod").ZodObject<{
226
+ url: import("zod").ZodString;
227
+ method: import("zod").ZodDefault<import("zod").ZodEnum<{
228
+ GET: "GET";
229
+ POST: "POST";
230
+ PUT: "PUT";
231
+ DELETE: "DELETE";
232
+ }>>;
233
+ contentType: import("zod").ZodDefault<import("zod").ZodString>;
234
+ requiresAuth: import("zod").ZodDefault<import("zod").ZodBoolean>;
235
+ authType: import("zod").ZodOptional<import("zod").ZodEnum<{
236
+ bearer: "bearer";
237
+ "api-key": "api-key";
238
+ x402: "x402";
239
+ none: "none";
240
+ }>>;
241
+ requiresCSRF: import("zod").ZodDefault<import("zod").ZodBoolean>;
242
+ requiresCookies: import("zod").ZodDefault<import("zod").ZodBoolean>;
243
+ corsOrigins: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
244
+ requiredHeaders: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
245
+ }, import("zod/v4/core").$strip>>;
246
+ }, import("zod/v4/core").$strip>>;
247
+ supportedNetworks: import("zod").ZodArray<import("zod").ZodString>;
248
+ generatedAt: import("zod").ZodString;
249
+ }, import("zod/v4/core").$strip>;
250
+ /**
251
+ * @name createPreparePaymentSchema
252
+ * @description Zod schema for x402 payment preparation parameters.
253
+ * @returns A Zod schema for payment option validation.
254
+ * @category Utils
255
+ * @since v0.6.0
256
+ */
257
+ export declare function createPreparePaymentSchema(): import("zod").ZodObject<{
258
+ pricePerCall: import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodBigInt]>;
259
+ maxCalls: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodBigInt]>>;
260
+ deposit: import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodBigInt]>;
261
+ expiresAt: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodBigInt]>>;
262
+ volumeCurve: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
263
+ afterCalls: import("zod").ZodNumber;
264
+ pricePerCall: import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodBigInt]>;
265
+ }, import("zod/v4/core").$strip>>>;
266
+ tokenMint: import("zod").ZodOptional<import("zod").ZodString>;
267
+ tokenDecimals: import("zod").ZodDefault<import("zod").ZodNumber>;
268
+ networkIdentifier: import("zod").ZodOptional<import("zod").ZodString>;
269
+ }, import("zod/v4/core").$strip>;
270
+ /**
271
+ * @name createRegisterAgentSchema
272
+ * @description Zod schema for agent registration arguments.
273
+ * @returns A Zod schema for registration validation.
274
+ * @category Utils
275
+ * @since v0.6.0
276
+ */
277
+ export declare function createRegisterAgentSchema(): import("zod").ZodObject<{
278
+ name: import("zod").ZodString;
279
+ description: import("zod").ZodString;
280
+ agentId: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodString>>;
281
+ agentUri: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodString>>;
282
+ x402Endpoint: import("zod").ZodNullable<import("zod").ZodOptional<import("zod").ZodString>>;
283
+ capabilities: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodObject<{
284
+ id: import("zod").ZodString;
285
+ description: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
286
+ protocolId: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
287
+ version: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
288
+ }, import("zod/v4/core").$strip>>>;
289
+ protocols: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
290
+ pricing: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodObject<{
291
+ tierId: import("zod").ZodString;
292
+ pricePerCall: import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString]>;
293
+ rateLimit: import("zod").ZodNumber;
294
+ tokenType: import("zod").ZodDefault<import("zod").ZodEnum<{
295
+ sol: "sol";
296
+ usdc: "usdc";
297
+ spl: "spl";
298
+ }>>;
299
+ settlementMode: import("zod").ZodDefault<import("zod").ZodEnum<{
300
+ escrow: "escrow";
301
+ x402: "x402";
302
+ instant: "instant";
303
+ batched: "batched";
304
+ }>>;
305
+ }, import("zod/v4/core").$strip>>>;
306
+ }, import("zod/v4/core").$strip>;
307
+ /**
308
+ * @name createCallArgsSchema
309
+ * @description Zod schema for `npm run call` script arguments.
310
+ * Ensures all required fields are present before executing an x402 call.
311
+ *
312
+ * @returns A Zod schema for call argument validation.
313
+ * @category Utils
314
+ * @since v0.6.0
315
+ */
316
+ export declare function createCallArgsSchema(): import("zod").ZodObject<{
317
+ agentWallet: import("zod").ZodString;
318
+ tool: import("zod").ZodString;
319
+ args: import("zod").ZodDefault<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
320
+ endpoint: import("zod").ZodOptional<import("zod").ZodString>;
321
+ network: import("zod").ZodOptional<import("zod").ZodString>;
322
+ maxRetries: import("zod").ZodDefault<import("zod").ZodNumber>;
323
+ timeoutMs: import("zod").ZodDefault<import("zod").ZodNumber>;
324
+ }, import("zod/v4/core").$strip>;
325
+ /**
326
+ * @name validateOrThrow
327
+ * @description Validate a value against a Zod schema, throwing a SapValidationError
328
+ * with a friendly message if validation fails.
329
+ *
330
+ * @param schema - A Zod schema.
331
+ * @param value - The value to validate.
332
+ * @param label - A label for error messages (e.g. "environment", "call args").
333
+ * @returns The parsed and typed value.
334
+ * @throws {Error} With formatted validation errors.
335
+ *
336
+ * @category Utils
337
+ * @since v0.6.0
338
+ */
339
+ export declare function validateOrThrow<T>(schema: {
340
+ parse: (v: unknown) => T;
341
+ safeParse: (v: unknown) => {
342
+ success: boolean;
343
+ error?: {
344
+ issues: Array<{
345
+ path: Array<string | number>;
346
+ message: string;
347
+ }>;
348
+ };
349
+ };
350
+ }, value: unknown, label: string): T;
351
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/utils/schemas.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AA2BH;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,eAAe;;;;;;;;;;;;;;;;;;;;;iCAsD9B;AAMD;;;;;;GAMG;AACH,wBAAgB,8BAA8B;;;;;;;;;;;;;;;;;;;;iCAc7C;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB;;;;;;;;iCAStC;AAMD;;;;;;GAMG;AACH,wBAAgB,6BAA6B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAiB5C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAcxC;AAMD;;;;;;GAMG;AACH,wBAAgB,0BAA0B;;;;;;;;;;;;iCAoBzC;AAMD;;;;;;GAMG;AACH,wBAAgB,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iCAkCxC;AAMD;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB;;;;;;;;iCAYnC;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAC/B,MAAM,EAAE;IAAE,KAAK,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,CAAC,CAAC;IAAC,SAAS,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE;YAAE,MAAM,EAAE,KAAK,CAAC;gBAAE,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;gBAAC,OAAO,EAAE,MAAM,CAAA;aAAE,CAAC,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,EACnK,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,GACZ,CAAC,CAYH"}
@@ -18,10 +18,6 @@
18
18
  * // { authority: "GBL...", totalCalls: "42", ... }
19
19
  * ```
20
20
  */
21
-
22
- import { PublicKey } from "@solana/web3.js";
23
- import BN from "bn.js";
24
-
25
21
  /**
26
22
  * Recursively convert a single value for JSON serialization.
27
23
  *
@@ -46,21 +42,7 @@ import BN from "bn.js";
46
42
  * serializeValue(new BN(42)); // "42"
47
43
  * ```
48
44
  */
49
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
- export function serializeValue(value: unknown): any {
51
- if (value === null || value === undefined) return null;
52
- if (value instanceof PublicKey) return value.toBase58();
53
- if (BN.isBN(value)) return value.toString();
54
- if (value instanceof Uint8Array || Buffer.isBuffer(value))
55
- return Buffer.from(value).toString("hex");
56
- if (Array.isArray(value)) return value.map(serializeValue);
57
- if (typeof value === "object") {
58
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
- return serializeAccount(value as Record<string, any>);
60
- }
61
- return value;
62
- }
63
-
45
+ export declare function serializeValue(value: unknown): any;
64
46
  /**
65
47
  * Serialize an entire on-chain account object to a JSON-safe shape.
66
48
  *
@@ -83,16 +65,5 @@ export function serializeValue(value: unknown): any {
83
65
  * console.log(JSON.stringify(safe));
84
66
  * ```
85
67
  */
86
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
87
- export function serializeAccount(
88
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
89
- obj: Record<string, any>,
90
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
91
- ): Record<string, any> {
92
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
93
- const result: Record<string, any> = {};
94
- for (const [key, value] of Object.entries(obj)) {
95
- result[key] = serializeValue(value);
96
- }
97
- return result;
98
- }
68
+ export declare function serializeAccount(obj: Record<string, any>): Record<string, any>;
69
+ //# sourceMappingURL=serialization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../src/utils/serialization.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAKH;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,CAYlD;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,wBAAgB,gBAAgB,CAE9B,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAEvB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAOrB"}
@@ -0,0 +1,66 @@
1
+ import BN from "bn.js";
2
+ import { PublicKey } from "@solana/web3.js";
3
+ import { SettlementSecurity, VolumeCurvePoint, BillingInterval } from "../types";
4
+ export interface ValidationResult {
5
+ ok: boolean;
6
+ errors: string[];
7
+ }
8
+ /** Validate agent creation parameters */
9
+ export declare function validateAgentInput(params: {
10
+ name: string;
11
+ endpointUri: string;
12
+ }): ValidationResult;
13
+ /** Compute max_obligation for an escrow (must match on-chain logic) */
14
+ export declare function computeEscrowMaxObligation(pricePerCall: BN, maxCalls: BN, initialDeposit: BN): BN;
15
+ /** Validate escrow V2 creation parameters (mirrors create_escrow_v2 on-chain checks) */
16
+ export declare function validateEscrowCreate(params: {
17
+ pricePerCall: BN;
18
+ basePrice: BN;
19
+ maxCalls: BN;
20
+ initialDeposit: BN;
21
+ expiresAt: BN;
22
+ settlementSecurity: SettlementSecurity;
23
+ coSigner: PublicKey | null;
24
+ arbiter: PublicKey | null;
25
+ disputeWindowSlots: number;
26
+ volumeCurve: VolumeCurvePoint[];
27
+ agentWallet: PublicKey;
28
+ }): ValidationResult;
29
+ /** Validate deposit parameters */
30
+ export declare function validateEscrowDeposit(params: {
31
+ amount: BN;
32
+ escrowMaxObligation: BN;
33
+ escrowBalance: BN;
34
+ escrowPendingAmount: BN;
35
+ }): ValidationResult;
36
+ /** Validate settle_calls_v2 parameters (pre-computation) */
37
+ export declare function validateEscrowSettle(params: {
38
+ callsToSettle: number;
39
+ escrowBalance: BN;
40
+ escrowPendingAmount: BN;
41
+ escrowTotalCallsSettled: BN;
42
+ escrowPendingCalls: BN;
43
+ escrowMaxCalls: BN;
44
+ pricePerCall: BN;
45
+ basePrice?: BN;
46
+ volumeCurve?: VolumeCurvePoint[];
47
+ }): {
48
+ ok: boolean;
49
+ errors: string[];
50
+ amount: BN;
51
+ };
52
+ /** Client-side mirror of on-chain calculate_settle_amount (v0.13) */
53
+ export declare function calculateSettleAmount(pricePerCall: BN, basePrice: BN, volumeCurve: VolumeCurvePoint[], calls: number): BN;
54
+ /** Validate receipt proof submission (C4 bounds check) */
55
+ export declare function validateReceiptProof(receiptHashes: Uint8Array[], merkleProofs: Uint8Array[][]): ValidationResult;
56
+ /** Validate subscription parameters */
57
+ export declare function validateSubscriptionCreate(params: {
58
+ billingInterval: BillingInterval;
59
+ pricePerInterval: BN;
60
+ durationIntervals: number;
61
+ }): ValidationResult;
62
+ /** Validate close_escrow_v2 can proceed (H8 check) */
63
+ export declare function validateEscrowClose(pendingSettlementCount: number, balance: BN, pendingAmount: BN): ValidationResult;
64
+ /** Validate agent close (stake + active_escrows) */
65
+ export declare function validateAgentClose(stakedAmount: BN, activeEscrows: number, unstakeAvailableAt: BN): ValidationResult;
66
+ //# sourceMappingURL=validate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/utils/validate.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,MAAM,OAAO,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAYjF,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAUD,yCAAyC;AACzC,wBAAgB,kBAAkB,CAAC,MAAM,EAAE;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,gBAAgB,CAMnB;AAED,uEAAuE;AACvE,wBAAgB,0BAA0B,CACxC,YAAY,EAAE,EAAE,EAChB,QAAQ,EAAE,EAAE,EACZ,cAAc,EAAE,EAAE,GACjB,EAAE,CAQJ;AAED,wFAAwF;AACxF,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,YAAY,EAAE,EAAE,CAAC;IACjB,SAAS,EAAE,EAAE,CAAC;IACd,QAAQ,EAAE,EAAE,CAAC;IACb,cAAc,EAAE,EAAE,CAAC;IACnB,SAAS,EAAE,EAAE,CAAC;IACd,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,SAAS,GAAG,IAAI,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,gBAAgB,EAAE,CAAC;IAChC,WAAW,EAAE,SAAS,CAAC;CACxB,GAAG,gBAAgB,CAqDnB;AAED,kCAAkC;AAClC,wBAAgB,qBAAqB,CAAC,MAAM,EAAE;IAC5C,MAAM,EAAE,EAAE,CAAC;IACX,mBAAmB,EAAE,EAAE,CAAC;IACxB,aAAa,EAAE,EAAE,CAAC;IAClB,mBAAmB,EAAE,EAAE,CAAC;CACzB,GAAG,gBAAgB,CAcnB;AAED,4DAA4D;AAC5D,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAC3C,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,EAAE,CAAC;IAClB,mBAAmB,EAAE,EAAE,CAAC;IACxB,uBAAuB,EAAE,EAAE,CAAC;IAC5B,kBAAkB,EAAE,EAAE,CAAC;IACvB,cAAc,EAAE,EAAE,CAAC;IACnB,YAAY,EAAE,EAAE,CAAC;IACjB,SAAS,CAAC,EAAE,EAAE,CAAC;IACf,WAAW,CAAC,EAAE,gBAAgB,EAAE,CAAC;CAClC,GAAG;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,EAAE,EAAE,CAAA;CAAE,CAqChD;AAED,qEAAqE;AACrE,wBAAgB,qBAAqB,CACnC,YAAY,EAAE,EAAE,EAChB,SAAS,EAAE,EAAE,EACb,WAAW,EAAE,gBAAgB,EAAE,EAC/B,KAAK,EAAE,MAAM,GACZ,EAAE,CAqCJ;AAED,0DAA0D;AAC1D,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,UAAU,EAAE,EAC3B,YAAY,EAAE,UAAU,EAAE,EAAE,GAC3B,gBAAgB,CAkBlB;AAED,uCAAuC;AACvC,wBAAgB,0BAA0B,CAAC,MAAM,EAAE;IACjD,eAAe,EAAE,eAAe,CAAC;IACjC,gBAAgB,EAAE,EAAE,CAAC;IACrB,iBAAiB,EAAE,MAAM,CAAC;CAC3B,GAAG,gBAAgB,CAcnB;AAED,sDAAsD;AACtD,wBAAgB,mBAAmB,CACjC,sBAAsB,EAAE,MAAM,EAC9B,OAAO,EAAE,EAAE,EACX,aAAa,EAAE,EAAE,GAChB,gBAAgB,CAYlB;AAED,oDAAoD;AACpD,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,EAAE,EAChB,aAAa,EAAE,MAAM,EACrB,kBAAkB,EAAE,EAAE,GACrB,gBAAgB,CAmBlB"}