@oobe-protocol-labs/synapse-sap-sdk 0.13.0 → 0.14.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 (654) 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 +108 -0
  4. package/dist/cjs/client.js.map +1 -0
  5. package/dist/cjs/constants.js +59 -0
  6. package/dist/cjs/constants.js.map +1 -0
  7. package/dist/cjs/errors.js +250 -0
  8. package/dist/cjs/errors.js.map +1 -0
  9. package/dist/cjs/events/index.js +38 -130
  10. package/dist/cjs/events/index.js.map +1 -1
  11. package/dist/cjs/idlTypes.js +4 -0
  12. package/dist/cjs/idlTypes.js.map +1 -0
  13. package/dist/cjs/index.js +75 -241
  14. package/dist/cjs/index.js.map +1 -1
  15. package/dist/cjs/instructions/agent.js +89 -0
  16. package/dist/cjs/instructions/agent.js.map +1 -0
  17. package/dist/cjs/instructions/attestation.js +112 -0
  18. package/dist/cjs/instructions/attestation.js.map +1 -0
  19. package/dist/cjs/instructions/digest.js +28 -0
  20. package/dist/cjs/instructions/digest.js.map +1 -0
  21. package/dist/cjs/instructions/dispute.js +116 -0
  22. package/dist/cjs/instructions/dispute.js.map +1 -0
  23. package/dist/cjs/instructions/escrow.js +101 -0
  24. package/dist/cjs/instructions/escrow.js.map +1 -0
  25. package/dist/cjs/instructions/global.js +28 -0
  26. package/dist/cjs/instructions/global.js.map +1 -0
  27. package/dist/cjs/instructions/index.js +31 -0
  28. package/dist/cjs/instructions/index.js.map +1 -0
  29. package/dist/cjs/instructions/indexing.js +221 -0
  30. package/dist/cjs/instructions/indexing.js.map +1 -0
  31. package/dist/cjs/instructions/misc.js +73 -0
  32. package/dist/cjs/instructions/misc.js.map +1 -0
  33. package/dist/cjs/instructions/session.js +89 -0
  34. package/dist/cjs/instructions/session.js.map +1 -0
  35. package/dist/cjs/instructions/staking.js +132 -0
  36. package/dist/cjs/instructions/staking.js.map +1 -0
  37. package/dist/cjs/instructions/subscription.js +80 -0
  38. package/dist/cjs/instructions/subscription.js.map +1 -0
  39. package/dist/cjs/instructions/tools.js +109 -0
  40. package/dist/cjs/instructions/tools.js.map +1 -0
  41. package/dist/cjs/instructions/vault.js +106 -0
  42. package/dist/cjs/instructions/vault.js.map +1 -0
  43. package/dist/cjs/pdas/index.js +120 -0
  44. package/dist/cjs/pdas/index.js.map +1 -0
  45. package/dist/cjs/types.js +42 -0
  46. package/dist/cjs/types.js.map +1 -0
  47. package/dist/cjs/utils/index.js +29 -86
  48. package/dist/cjs/utils/index.js.map +1 -1
  49. package/dist/cjs/utils/validate.js +236 -0
  50. package/dist/cjs/utils/validate.js.map +1 -0
  51. package/dist/esm/accounts/index.d.ts +11 -0
  52. package/dist/esm/accounts/index.d.ts.map +1 -0
  53. package/dist/esm/accounts/index.js +273 -0
  54. package/dist/esm/accounts/index.js.map +1 -0
  55. package/dist/esm/client.d.ts +55 -0
  56. package/dist/esm/client.d.ts.map +1 -0
  57. package/dist/esm/client.js +70 -0
  58. package/dist/esm/client.js.map +1 -0
  59. package/dist/esm/constants.d.ts +52 -0
  60. package/dist/esm/constants.d.ts.map +1 -0
  61. package/dist/esm/constants.js +56 -0
  62. package/dist/esm/constants.js.map +1 -0
  63. package/dist/esm/errors.d.ts +111 -0
  64. package/dist/esm/errors.d.ts.map +1 -0
  65. package/dist/esm/errors.js +244 -0
  66. package/dist/esm/errors.js.map +1 -0
  67. package/dist/esm/events/index.d.ts +13 -0
  68. package/dist/esm/events/index.d.ts.map +1 -0
  69. package/dist/esm/events/index.js +36 -128
  70. package/dist/esm/events/index.js.map +1 -1
  71. package/dist/esm/idlTypes.d.ts +925 -0
  72. package/dist/esm/idlTypes.d.ts.map +1 -0
  73. package/dist/esm/idlTypes.js +3 -0
  74. package/dist/esm/idlTypes.js.map +1 -0
  75. package/dist/esm/index.d.ts +12 -0
  76. package/dist/esm/index.d.ts.map +1 -0
  77. package/dist/esm/index.js +15 -88
  78. package/dist/esm/index.js.map +1 -1
  79. package/dist/esm/instructions/agent.d.ts +71 -0
  80. package/dist/esm/instructions/agent.d.ts.map +1 -0
  81. package/dist/esm/instructions/agent.js +85 -0
  82. package/dist/esm/instructions/agent.js.map +1 -0
  83. package/dist/esm/instructions/attestation.d.ts +76 -0
  84. package/dist/esm/instructions/attestation.d.ts.map +1 -0
  85. package/dist/esm/instructions/attestation.js +108 -0
  86. package/dist/esm/instructions/attestation.js.map +1 -0
  87. package/dist/esm/instructions/digest.d.ts +20 -0
  88. package/dist/esm/instructions/digest.d.ts.map +1 -0
  89. package/dist/esm/instructions/digest.js +24 -0
  90. package/dist/esm/instructions/digest.js.map +1 -0
  91. package/dist/esm/instructions/dispute.d.ts +81 -0
  92. package/dist/esm/instructions/dispute.d.ts.map +1 -0
  93. package/dist/esm/instructions/dispute.js +112 -0
  94. package/dist/esm/instructions/dispute.js.map +1 -0
  95. package/dist/esm/instructions/escrow.d.ts +79 -0
  96. package/dist/esm/instructions/escrow.d.ts.map +1 -0
  97. package/dist/esm/instructions/escrow.js +97 -0
  98. package/dist/esm/instructions/escrow.js.map +1 -0
  99. package/dist/esm/instructions/global.d.ts +14 -0
  100. package/dist/esm/instructions/global.d.ts.map +1 -0
  101. package/dist/esm/instructions/global.js +24 -0
  102. package/dist/esm/instructions/global.js.map +1 -0
  103. package/dist/esm/instructions/index.d.ts +14 -0
  104. package/dist/esm/instructions/index.d.ts.map +1 -0
  105. package/dist/esm/instructions/index.js +15 -0
  106. package/dist/esm/instructions/index.js.map +1 -0
  107. package/dist/esm/instructions/indexing.d.ts +150 -0
  108. package/dist/esm/instructions/indexing.d.ts.map +1 -0
  109. package/dist/esm/instructions/indexing.js +217 -0
  110. package/dist/esm/instructions/indexing.js.map +1 -0
  111. package/dist/esm/instructions/memory.d.ts +8 -0
  112. package/dist/esm/instructions/memory.d.ts.map +1 -0
  113. package/dist/esm/instructions/memory.js +234 -0
  114. package/dist/esm/instructions/memory.js.map +1 -0
  115. package/dist/esm/instructions/misc.d.ts +50 -0
  116. package/dist/esm/instructions/misc.d.ts.map +1 -0
  117. package/dist/esm/instructions/misc.js +69 -0
  118. package/dist/esm/instructions/misc.js.map +1 -0
  119. package/dist/esm/instructions/session.d.ts +57 -0
  120. package/dist/esm/instructions/session.d.ts.map +1 -0
  121. package/dist/esm/instructions/session.js +85 -0
  122. package/dist/esm/instructions/session.js.map +1 -0
  123. package/dist/esm/instructions/staking.d.ts +85 -0
  124. package/dist/esm/instructions/staking.d.ts.map +1 -0
  125. package/dist/esm/instructions/staking.js +128 -0
  126. package/dist/esm/instructions/staking.js.map +1 -0
  127. package/dist/esm/instructions/subscription.d.ts +50 -0
  128. package/dist/esm/instructions/subscription.d.ts.map +1 -0
  129. package/dist/esm/instructions/subscription.js +76 -0
  130. package/dist/esm/instructions/subscription.js.map +1 -0
  131. package/dist/esm/instructions/tools.d.ts +88 -0
  132. package/dist/esm/instructions/tools.d.ts.map +1 -0
  133. package/dist/esm/instructions/tools.js +105 -0
  134. package/dist/esm/instructions/tools.js.map +1 -0
  135. package/dist/esm/instructions/vault.d.ts +84 -0
  136. package/dist/esm/instructions/vault.d.ts.map +1 -0
  137. package/dist/esm/instructions/vault.js +102 -0
  138. package/dist/esm/instructions/vault.js.map +1 -0
  139. package/dist/esm/pdas/index.d.ts +37 -0
  140. package/dist/esm/pdas/index.d.ts.map +1 -0
  141. package/dist/esm/pdas/index.js +101 -0
  142. package/dist/esm/pdas/index.js.map +1 -0
  143. package/dist/esm/types.d.ts +208 -0
  144. package/dist/esm/types.d.ts.map +1 -0
  145. package/dist/esm/types.js +39 -0
  146. package/dist/esm/types.js.map +1 -0
  147. package/dist/esm/utils/index.d.ts +4 -0
  148. package/dist/esm/utils/index.d.ts.map +1 -0
  149. package/dist/esm/utils/index.js +13 -33
  150. package/dist/esm/utils/index.js.map +1 -1
  151. package/dist/esm/utils/validate.d.ts +66 -0
  152. package/dist/esm/utils/validate.d.ts.map +1 -0
  153. package/dist/esm/utils/validate.js +221 -0
  154. package/dist/esm/utils/validate.js.map +1 -0
  155. package/package.json +59 -183
  156. package/LICENSE +0 -21
  157. package/README.md +0 -986
  158. package/dist/cjs/constants/addresses.js +0 -143
  159. package/dist/cjs/constants/addresses.js.map +0 -1
  160. package/dist/cjs/constants/index.js +0 -64
  161. package/dist/cjs/constants/index.js.map +0 -1
  162. package/dist/cjs/constants/limits.js +0 -161
  163. package/dist/cjs/constants/limits.js.map +0 -1
  164. package/dist/cjs/constants/network.js +0 -81
  165. package/dist/cjs/constants/network.js.map +0 -1
  166. package/dist/cjs/constants/payments.js +0 -137
  167. package/dist/cjs/constants/payments.js.map +0 -1
  168. package/dist/cjs/constants/programs.js +0 -78
  169. package/dist/cjs/constants/programs.js.map +0 -1
  170. package/dist/cjs/constants/seeds.js +0 -76
  171. package/dist/cjs/constants/seeds.js.map +0 -1
  172. package/dist/cjs/core/client.js +0 -546
  173. package/dist/cjs/core/client.js.map +0 -1
  174. package/dist/cjs/core/connection.js +0 -350
  175. package/dist/cjs/core/connection.js.map +0 -1
  176. package/dist/cjs/core/index.js +0 -25
  177. package/dist/cjs/core/index.js.map +0 -1
  178. package/dist/cjs/errors/index.js +0 -334
  179. package/dist/cjs/errors/index.js.map +0 -1
  180. package/dist/cjs/events/geyser.js +0 -295
  181. package/dist/cjs/events/geyser.js.map +0 -1
  182. package/dist/cjs/idl/index.js +0 -63
  183. package/dist/cjs/idl/index.js.map +0 -1
  184. package/dist/cjs/idl/synapse_agent_sap.json +0 -14595
  185. package/dist/cjs/modules/agent.js +0 -272
  186. package/dist/cjs/modules/agent.js.map +0 -1
  187. package/dist/cjs/modules/attestation.js +0 -147
  188. package/dist/cjs/modules/attestation.js.map +0 -1
  189. package/dist/cjs/modules/base.js +0 -189
  190. package/dist/cjs/modules/base.js.map +0 -1
  191. package/dist/cjs/modules/escrow-v2.js +0 -607
  192. package/dist/cjs/modules/escrow-v2.js.map +0 -1
  193. package/dist/cjs/modules/escrow.js +0 -336
  194. package/dist/cjs/modules/escrow.js.map +0 -1
  195. package/dist/cjs/modules/feedback.js +0 -166
  196. package/dist/cjs/modules/feedback.js.map +0 -1
  197. package/dist/cjs/modules/index.js +0 -43
  198. package/dist/cjs/modules/index.js.map +0 -1
  199. package/dist/cjs/modules/indexing.js +0 -375
  200. package/dist/cjs/modules/indexing.js.map +0 -1
  201. package/dist/cjs/modules/ledger.js +0 -234
  202. package/dist/cjs/modules/ledger.js.map +0 -1
  203. package/dist/cjs/modules/receipt.js +0 -148
  204. package/dist/cjs/modules/receipt.js.map +0 -1
  205. package/dist/cjs/modules/staking.js +0 -159
  206. package/dist/cjs/modules/staking.js.map +0 -1
  207. package/dist/cjs/modules/subscription.js +0 -96
  208. package/dist/cjs/modules/subscription.js.map +0 -1
  209. package/dist/cjs/modules/tools.js +0 -345
  210. package/dist/cjs/modules/tools.js.map +0 -1
  211. package/dist/cjs/modules/vault.js +0 -427
  212. package/dist/cjs/modules/vault.js.map +0 -1
  213. package/dist/cjs/parser/client.js +0 -146
  214. package/dist/cjs/parser/client.js.map +0 -1
  215. package/dist/cjs/parser/complete.js +0 -177
  216. package/dist/cjs/parser/complete.js.map +0 -1
  217. package/dist/cjs/parser/index.js +0 -57
  218. package/dist/cjs/parser/index.js.map +0 -1
  219. package/dist/cjs/parser/inner.js +0 -185
  220. package/dist/cjs/parser/inner.js.map +0 -1
  221. package/dist/cjs/parser/instructions.js +0 -114
  222. package/dist/cjs/parser/instructions.js.map +0 -1
  223. package/dist/cjs/parser/transaction.js +0 -153
  224. package/dist/cjs/parser/transaction.js.map +0 -1
  225. package/dist/cjs/parser/types.js +0 -14
  226. package/dist/cjs/parser/types.js.map +0 -1
  227. package/dist/cjs/pda/index.js +0 -672
  228. package/dist/cjs/pda/index.js.map +0 -1
  229. package/dist/cjs/plugin/index.js +0 -952
  230. package/dist/cjs/plugin/index.js.map +0 -1
  231. package/dist/cjs/plugin/protocols.js +0 -282
  232. package/dist/cjs/plugin/protocols.js.map +0 -1
  233. package/dist/cjs/plugin/schemas.js +0 -863
  234. package/dist/cjs/plugin/schemas.js.map +0 -1
  235. package/dist/cjs/postgres/adapter.js +0 -715
  236. package/dist/cjs/postgres/adapter.js.map +0 -1
  237. package/dist/cjs/postgres/index.js +0 -50
  238. package/dist/cjs/postgres/index.js.map +0 -1
  239. package/dist/cjs/postgres/serializers.js +0 -381
  240. package/dist/cjs/postgres/serializers.js.map +0 -1
  241. package/dist/cjs/postgres/sync.js +0 -289
  242. package/dist/cjs/postgres/sync.js.map +0 -1
  243. package/dist/cjs/postgres/types.js +0 -44
  244. package/dist/cjs/postgres/types.js.map +0 -1
  245. package/dist/cjs/registries/builder.js +0 -414
  246. package/dist/cjs/registries/builder.js.map +0 -1
  247. package/dist/cjs/registries/discovery.js +0 -362
  248. package/dist/cjs/registries/discovery.js.map +0 -1
  249. package/dist/cjs/registries/fairscale.js +0 -639
  250. package/dist/cjs/registries/fairscale.js.map +0 -1
  251. package/dist/cjs/registries/index.js +0 -58
  252. package/dist/cjs/registries/index.js.map +0 -1
  253. package/dist/cjs/registries/metaplex-bridge.js +0 -743
  254. package/dist/cjs/registries/metaplex-bridge.js.map +0 -1
  255. package/dist/cjs/registries/session.js +0 -433
  256. package/dist/cjs/registries/session.js.map +0 -1
  257. package/dist/cjs/registries/x402.js +0 -668
  258. package/dist/cjs/registries/x402.js.map +0 -1
  259. package/dist/cjs/types/accounts.js +0 -13
  260. package/dist/cjs/types/accounts.js.map +0 -1
  261. package/dist/cjs/types/common.js +0 -13
  262. package/dist/cjs/types/common.js.map +0 -1
  263. package/dist/cjs/types/endpoint.js +0 -15
  264. package/dist/cjs/types/endpoint.js.map +0 -1
  265. package/dist/cjs/types/enums.js +0 -269
  266. package/dist/cjs/types/enums.js.map +0 -1
  267. package/dist/cjs/types/index.js +0 -41
  268. package/dist/cjs/types/index.js.map +0 -1
  269. package/dist/cjs/types/instructions.js +0 -92
  270. package/dist/cjs/types/instructions.js.map +0 -1
  271. package/dist/cjs/utils/anchor-errors.js +0 -453
  272. package/dist/cjs/utils/anchor-errors.js.map +0 -1
  273. package/dist/cjs/utils/endpoint-validator.js +0 -232
  274. package/dist/cjs/utils/endpoint-validator.js.map +0 -1
  275. package/dist/cjs/utils/escrow-validation.js +0 -219
  276. package/dist/cjs/utils/escrow-validation.js.map +0 -1
  277. package/dist/cjs/utils/hash.js +0 -109
  278. package/dist/cjs/utils/hash.js.map +0 -1
  279. package/dist/cjs/utils/merchant-validator.js +0 -246
  280. package/dist/cjs/utils/merchant-validator.js.map +0 -1
  281. package/dist/cjs/utils/network-normalizer.js +0 -236
  282. package/dist/cjs/utils/network-normalizer.js.map +0 -1
  283. package/dist/cjs/utils/priority-fee.js +0 -215
  284. package/dist/cjs/utils/priority-fee.js.map +0 -1
  285. package/dist/cjs/utils/rpc-strategy.js +0 -239
  286. package/dist/cjs/utils/rpc-strategy.js.map +0 -1
  287. package/dist/cjs/utils/schemas.js +0 -331
  288. package/dist/cjs/utils/schemas.js.map +0 -1
  289. package/dist/cjs/utils/serialization.js +0 -105
  290. package/dist/cjs/utils/serialization.js.map +0 -1
  291. package/dist/cjs/utils/validation.js +0 -36
  292. package/dist/cjs/utils/validation.js.map +0 -1
  293. package/dist/cjs/utils/volume-curve.js +0 -117
  294. package/dist/cjs/utils/volume-curve.js.map +0 -1
  295. package/dist/cjs/utils/x402-direct.js +0 -231
  296. package/dist/cjs/utils/x402-direct.js.map +0 -1
  297. package/dist/esm/constants/addresses.js +0 -140
  298. package/dist/esm/constants/addresses.js.map +0 -1
  299. package/dist/esm/constants/index.js +0 -35
  300. package/dist/esm/constants/index.js.map +0 -1
  301. package/dist/esm/constants/limits.js +0 -158
  302. package/dist/esm/constants/limits.js.map +0 -1
  303. package/dist/esm/constants/network.js +0 -78
  304. package/dist/esm/constants/network.js.map +0 -1
  305. package/dist/esm/constants/payments.js +0 -131
  306. package/dist/esm/constants/payments.js.map +0 -1
  307. package/dist/esm/constants/programs.js +0 -75
  308. package/dist/esm/constants/programs.js.map +0 -1
  309. package/dist/esm/constants/seeds.js +0 -73
  310. package/dist/esm/constants/seeds.js.map +0 -1
  311. package/dist/esm/core/client.js +0 -539
  312. package/dist/esm/core/client.js.map +0 -1
  313. package/dist/esm/core/connection.js +0 -345
  314. package/dist/esm/core/connection.js.map +0 -1
  315. package/dist/esm/core/index.js +0 -19
  316. package/dist/esm/core/index.js.map +0 -1
  317. package/dist/esm/errors/index.js +0 -325
  318. package/dist/esm/errors/index.js.map +0 -1
  319. package/dist/esm/events/geyser.js +0 -258
  320. package/dist/esm/events/geyser.js.map +0 -1
  321. package/dist/esm/idl/index.js +0 -57
  322. package/dist/esm/idl/index.js.map +0 -1
  323. package/dist/esm/idl/synapse_agent_sap.json +0 -14595
  324. package/dist/esm/modules/agent.js +0 -268
  325. package/dist/esm/modules/agent.js.map +0 -1
  326. package/dist/esm/modules/attestation.js +0 -143
  327. package/dist/esm/modules/attestation.js.map +0 -1
  328. package/dist/esm/modules/base.js +0 -185
  329. package/dist/esm/modules/base.js.map +0 -1
  330. package/dist/esm/modules/escrow-v2.js +0 -603
  331. package/dist/esm/modules/escrow-v2.js.map +0 -1
  332. package/dist/esm/modules/escrow.js +0 -332
  333. package/dist/esm/modules/escrow.js.map +0 -1
  334. package/dist/esm/modules/feedback.js +0 -162
  335. package/dist/esm/modules/feedback.js.map +0 -1
  336. package/dist/esm/modules/index.js +0 -27
  337. package/dist/esm/modules/index.js.map +0 -1
  338. package/dist/esm/modules/indexing.js +0 -371
  339. package/dist/esm/modules/indexing.js.map +0 -1
  340. package/dist/esm/modules/ledger.js +0 -230
  341. package/dist/esm/modules/ledger.js.map +0 -1
  342. package/dist/esm/modules/receipt.js +0 -144
  343. package/dist/esm/modules/receipt.js.map +0 -1
  344. package/dist/esm/modules/staking.js +0 -155
  345. package/dist/esm/modules/staking.js.map +0 -1
  346. package/dist/esm/modules/subscription.js +0 -92
  347. package/dist/esm/modules/subscription.js.map +0 -1
  348. package/dist/esm/modules/tools.js +0 -341
  349. package/dist/esm/modules/tools.js.map +0 -1
  350. package/dist/esm/modules/vault.js +0 -423
  351. package/dist/esm/modules/vault.js.map +0 -1
  352. package/dist/esm/parser/client.js +0 -142
  353. package/dist/esm/parser/client.js.map +0 -1
  354. package/dist/esm/parser/complete.js +0 -173
  355. package/dist/esm/parser/complete.js.map +0 -1
  356. package/dist/esm/parser/index.js +0 -43
  357. package/dist/esm/parser/index.js.map +0 -1
  358. package/dist/esm/parser/inner.js +0 -180
  359. package/dist/esm/parser/inner.js.map +0 -1
  360. package/dist/esm/parser/instructions.js +0 -109
  361. package/dist/esm/parser/instructions.js.map +0 -1
  362. package/dist/esm/parser/transaction.js +0 -149
  363. package/dist/esm/parser/transaction.js.map +0 -1
  364. package/dist/esm/parser/types.js +0 -13
  365. package/dist/esm/parser/types.js.map +0 -1
  366. package/dist/esm/pda/index.js +0 -638
  367. package/dist/esm/pda/index.js.map +0 -1
  368. package/dist/esm/plugin/index.js +0 -945
  369. package/dist/esm/plugin/index.js.map +0 -1
  370. package/dist/esm/plugin/protocols.js +0 -279
  371. package/dist/esm/plugin/protocols.js.map +0 -1
  372. package/dist/esm/plugin/schemas.js +0 -860
  373. package/dist/esm/plugin/schemas.js.map +0 -1
  374. package/dist/esm/postgres/adapter.js +0 -678
  375. package/dist/esm/postgres/adapter.js.map +0 -1
  376. package/dist/esm/postgres/index.js +0 -27
  377. package/dist/esm/postgres/index.js.map +0 -1
  378. package/dist/esm/postgres/serializers.js +0 -362
  379. package/dist/esm/postgres/serializers.js.map +0 -1
  380. package/dist/esm/postgres/sync.js +0 -285
  381. package/dist/esm/postgres/sync.js.map +0 -1
  382. package/dist/esm/postgres/types.js +0 -41
  383. package/dist/esm/postgres/types.js.map +0 -1
  384. package/dist/esm/registries/builder.js +0 -410
  385. package/dist/esm/registries/builder.js.map +0 -1
  386. package/dist/esm/registries/discovery.js +0 -358
  387. package/dist/esm/registries/discovery.js.map +0 -1
  388. package/dist/esm/registries/fairscale.js +0 -633
  389. package/dist/esm/registries/fairscale.js.map +0 -1
  390. package/dist/esm/registries/index.js +0 -46
  391. package/dist/esm/registries/index.js.map +0 -1
  392. package/dist/esm/registries/metaplex-bridge.js +0 -706
  393. package/dist/esm/registries/metaplex-bridge.js.map +0 -1
  394. package/dist/esm/registries/session.js +0 -429
  395. package/dist/esm/registries/session.js.map +0 -1
  396. package/dist/esm/registries/x402.js +0 -664
  397. package/dist/esm/registries/x402.js.map +0 -1
  398. package/dist/esm/types/accounts.js +0 -12
  399. package/dist/esm/types/accounts.js.map +0 -1
  400. package/dist/esm/types/common.js +0 -12
  401. package/dist/esm/types/common.js.map +0 -1
  402. package/dist/esm/types/endpoint.js +0 -14
  403. package/dist/esm/types/endpoint.js.map +0 -1
  404. package/dist/esm/types/enums.js +0 -266
  405. package/dist/esm/types/enums.js.map +0 -1
  406. package/dist/esm/types/index.js +0 -25
  407. package/dist/esm/types/index.js.map +0 -1
  408. package/dist/esm/types/instructions.js +0 -89
  409. package/dist/esm/types/instructions.js.map +0 -1
  410. package/dist/esm/utils/anchor-errors.js +0 -447
  411. package/dist/esm/utils/anchor-errors.js.map +0 -1
  412. package/dist/esm/utils/endpoint-validator.js +0 -226
  413. package/dist/esm/utils/endpoint-validator.js.map +0 -1
  414. package/dist/esm/utils/escrow-validation.js +0 -212
  415. package/dist/esm/utils/escrow-validation.js.map +0 -1
  416. package/dist/esm/utils/hash.js +0 -103
  417. package/dist/esm/utils/hash.js.map +0 -1
  418. package/dist/esm/utils/merchant-validator.js +0 -241
  419. package/dist/esm/utils/merchant-validator.js.map +0 -1
  420. package/dist/esm/utils/network-normalizer.js +0 -229
  421. package/dist/esm/utils/network-normalizer.js.map +0 -1
  422. package/dist/esm/utils/priority-fee.js +0 -209
  423. package/dist/esm/utils/priority-fee.js.map +0 -1
  424. package/dist/esm/utils/rpc-strategy.js +0 -231
  425. package/dist/esm/utils/rpc-strategy.js.map +0 -1
  426. package/dist/esm/utils/schemas.js +0 -320
  427. package/dist/esm/utils/schemas.js.map +0 -1
  428. package/dist/esm/utils/serialization.js +0 -98
  429. package/dist/esm/utils/serialization.js.map +0 -1
  430. package/dist/esm/utils/validation.js +0 -33
  431. package/dist/esm/utils/validation.js.map +0 -1
  432. package/dist/esm/utils/volume-curve.js +0 -114
  433. package/dist/esm/utils/volume-curve.js.map +0 -1
  434. package/dist/esm/utils/x402-direct.js +0 -228
  435. package/dist/esm/utils/x402-direct.js.map +0 -1
  436. package/dist/types/constants/addresses.d.ts +0 -117
  437. package/dist/types/constants/addresses.d.ts.map +0 -1
  438. package/dist/types/constants/index.d.ts +0 -31
  439. package/dist/types/constants/index.d.ts.map +0 -1
  440. package/dist/types/constants/limits.d.ts +0 -149
  441. package/dist/types/constants/limits.d.ts.map +0 -1
  442. package/dist/types/constants/network.d.ts +0 -81
  443. package/dist/types/constants/network.d.ts.map +0 -1
  444. package/dist/types/constants/payments.d.ts +0 -121
  445. package/dist/types/constants/payments.d.ts.map +0 -1
  446. package/dist/types/constants/programs.d.ts +0 -69
  447. package/dist/types/constants/programs.d.ts.map +0 -1
  448. package/dist/types/constants/seeds.d.ts +0 -80
  449. package/dist/types/constants/seeds.d.ts.map +0 -1
  450. package/dist/types/core/client.d.ts +0 -452
  451. package/dist/types/core/client.d.ts.map +0 -1
  452. package/dist/types/core/connection.d.ts +0 -305
  453. package/dist/types/core/connection.d.ts.map +0 -1
  454. package/dist/types/core/index.d.ts +0 -20
  455. package/dist/types/core/index.d.ts.map +0 -1
  456. package/dist/types/errors/index.d.ts +0 -276
  457. package/dist/types/errors/index.d.ts.map +0 -1
  458. package/dist/types/events/geyser.d.ts +0 -150
  459. package/dist/types/events/geyser.d.ts.map +0 -1
  460. package/dist/types/events/index.d.ts +0 -248
  461. package/dist/types/events/index.d.ts.map +0 -1
  462. package/dist/types/idl/index.d.ts +0 -70
  463. package/dist/types/idl/index.d.ts.map +0 -1
  464. package/dist/types/index.d.ts +0 -85
  465. package/dist/types/index.d.ts.map +0 -1
  466. package/dist/types/modules/agent.d.ts +0 -166
  467. package/dist/types/modules/agent.d.ts.map +0 -1
  468. package/dist/types/modules/attestation.d.ts +0 -96
  469. package/dist/types/modules/attestation.d.ts.map +0 -1
  470. package/dist/types/modules/base.d.ts +0 -161
  471. package/dist/types/modules/base.d.ts.map +0 -1
  472. package/dist/types/modules/escrow-v2.d.ts +0 -169
  473. package/dist/types/modules/escrow-v2.d.ts.map +0 -1
  474. package/dist/types/modules/escrow.d.ts +0 -168
  475. package/dist/types/modules/escrow.d.ts.map +0 -1
  476. package/dist/types/modules/feedback.d.ts +0 -105
  477. package/dist/types/modules/feedback.d.ts.map +0 -1
  478. package/dist/types/modules/index.d.ts +0 -28
  479. package/dist/types/modules/index.d.ts.map +0 -1
  480. package/dist/types/modules/indexing.d.ts +0 -200
  481. package/dist/types/modules/indexing.d.ts.map +0 -1
  482. package/dist/types/modules/ledger.d.ts +0 -150
  483. package/dist/types/modules/ledger.d.ts.map +0 -1
  484. package/dist/types/modules/receipt.d.ts +0 -77
  485. package/dist/types/modules/receipt.d.ts.map +0 -1
  486. package/dist/types/modules/staking.d.ts +0 -51
  487. package/dist/types/modules/staking.d.ts.map +0 -1
  488. package/dist/types/modules/subscription.d.ts +0 -33
  489. package/dist/types/modules/subscription.d.ts.map +0 -1
  490. package/dist/types/modules/tools.d.ts +0 -182
  491. package/dist/types/modules/tools.d.ts.map +0 -1
  492. package/dist/types/modules/vault.d.ts +0 -240
  493. package/dist/types/modules/vault.d.ts.map +0 -1
  494. package/dist/types/parser/client.d.ts +0 -123
  495. package/dist/types/parser/client.d.ts.map +0 -1
  496. package/dist/types/parser/complete.d.ts +0 -90
  497. package/dist/types/parser/complete.d.ts.map +0 -1
  498. package/dist/types/parser/index.d.ts +0 -40
  499. package/dist/types/parser/index.d.ts.map +0 -1
  500. package/dist/types/parser/inner.d.ts +0 -114
  501. package/dist/types/parser/inner.d.ts.map +0 -1
  502. package/dist/types/parser/instructions.d.ts +0 -76
  503. package/dist/types/parser/instructions.d.ts.map +0 -1
  504. package/dist/types/parser/transaction.d.ts +0 -77
  505. package/dist/types/parser/transaction.d.ts.map +0 -1
  506. package/dist/types/parser/types.d.ts +0 -154
  507. package/dist/types/parser/types.d.ts.map +0 -1
  508. package/dist/types/pda/index.d.ts +0 -510
  509. package/dist/types/pda/index.d.ts.map +0 -1
  510. package/dist/types/plugin/index.d.ts +0 -171
  511. package/dist/types/plugin/index.d.ts.map +0 -1
  512. package/dist/types/plugin/protocols.d.ts +0 -152
  513. package/dist/types/plugin/protocols.d.ts.map +0 -1
  514. package/dist/types/plugin/schemas.d.ts +0 -829
  515. package/dist/types/plugin/schemas.d.ts.map +0 -1
  516. package/dist/types/postgres/adapter.d.ts +0 -355
  517. package/dist/types/postgres/adapter.d.ts.map +0 -1
  518. package/dist/types/postgres/index.d.ts +0 -24
  519. package/dist/types/postgres/index.d.ts.map +0 -1
  520. package/dist/types/postgres/serializers.d.ts +0 -30
  521. package/dist/types/postgres/serializers.d.ts.map +0 -1
  522. package/dist/types/postgres/sync.d.ts +0 -156
  523. package/dist/types/postgres/sync.d.ts.map +0 -1
  524. package/dist/types/postgres/types.d.ts +0 -167
  525. package/dist/types/postgres/types.d.ts.map +0 -1
  526. package/dist/types/registries/builder.d.ts +0 -340
  527. package/dist/types/registries/builder.d.ts.map +0 -1
  528. package/dist/types/registries/discovery.d.ts +0 -333
  529. package/dist/types/registries/discovery.d.ts.map +0 -1
  530. package/dist/types/registries/fairscale.d.ts +0 -680
  531. package/dist/types/registries/fairscale.d.ts.map +0 -1
  532. package/dist/types/registries/index.d.ts +0 -52
  533. package/dist/types/registries/index.d.ts.map +0 -1
  534. package/dist/types/registries/metaplex-bridge.d.ts +0 -488
  535. package/dist/types/registries/metaplex-bridge.d.ts.map +0 -1
  536. package/dist/types/registries/session.d.ts +0 -323
  537. package/dist/types/registries/session.d.ts.map +0 -1
  538. package/dist/types/registries/x402.d.ts +0 -530
  539. package/dist/types/registries/x402.d.ts.map +0 -1
  540. package/dist/types/types/accounts.d.ts +0 -765
  541. package/dist/types/types/accounts.d.ts.map +0 -1
  542. package/dist/types/types/common.d.ts +0 -166
  543. package/dist/types/types/common.d.ts.map +0 -1
  544. package/dist/types/types/endpoint.d.ts +0 -161
  545. package/dist/types/types/endpoint.d.ts.map +0 -1
  546. package/dist/types/types/enums.d.ts +0 -353
  547. package/dist/types/types/enums.d.ts.map +0 -1
  548. package/dist/types/types/index.d.ts +0 -29
  549. package/dist/types/types/index.d.ts.map +0 -1
  550. package/dist/types/types/instructions.d.ts +0 -400
  551. package/dist/types/types/instructions.d.ts.map +0 -1
  552. package/dist/types/utils/anchor-errors.d.ts +0 -61
  553. package/dist/types/utils/anchor-errors.d.ts.map +0 -1
  554. package/dist/types/utils/endpoint-validator.d.ts +0 -110
  555. package/dist/types/utils/endpoint-validator.d.ts.map +0 -1
  556. package/dist/types/utils/escrow-validation.d.ts +0 -145
  557. package/dist/types/utils/escrow-validation.d.ts.map +0 -1
  558. package/dist/types/utils/hash.d.ts +0 -75
  559. package/dist/types/utils/hash.d.ts.map +0 -1
  560. package/dist/types/utils/index.d.ts +0 -36
  561. package/dist/types/utils/index.d.ts.map +0 -1
  562. package/dist/types/utils/merchant-validator.d.ts +0 -176
  563. package/dist/types/utils/merchant-validator.d.ts.map +0 -1
  564. package/dist/types/utils/network-normalizer.d.ts +0 -120
  565. package/dist/types/utils/network-normalizer.d.ts.map +0 -1
  566. package/dist/types/utils/priority-fee.d.ts +0 -205
  567. package/dist/types/utils/priority-fee.d.ts.map +0 -1
  568. package/dist/types/utils/rpc-strategy.d.ts +0 -172
  569. package/dist/types/utils/rpc-strategy.d.ts.map +0 -1
  570. package/dist/types/utils/schemas.d.ts +0 -351
  571. package/dist/types/utils/schemas.d.ts.map +0 -1
  572. package/dist/types/utils/serialization.d.ts +0 -69
  573. package/dist/types/utils/serialization.d.ts.map +0 -1
  574. package/dist/types/utils/validation.d.ts +0 -29
  575. package/dist/types/utils/validation.d.ts.map +0 -1
  576. package/dist/types/utils/volume-curve.d.ts +0 -60
  577. package/dist/types/utils/volume-curve.d.ts.map +0 -1
  578. package/dist/types/utils/x402-direct.d.ts +0 -114
  579. package/dist/types/utils/x402-direct.d.ts.map +0 -1
  580. package/src/constants/addresses.ts +0 -162
  581. package/src/constants/index.ts +0 -69
  582. package/src/constants/limits.ts +0 -165
  583. package/src/constants/network.ts +0 -89
  584. package/src/constants/payments.ts +0 -145
  585. package/src/constants/programs.ts +0 -83
  586. package/src/constants/seeds.ts +0 -85
  587. package/src/core/client.ts +0 -583
  588. package/src/core/connection.ts +0 -461
  589. package/src/core/index.ts +0 -20
  590. package/src/errors/index.ts +0 -346
  591. package/src/events/geyser.ts +0 -384
  592. package/src/events/index.ts +0 -335
  593. package/src/events/yellowstone.d.ts +0 -7
  594. package/src/idl/index.ts +0 -76
  595. package/src/idl/synapse_agent_sap.json +0 -14595
  596. package/src/index.ts +0 -421
  597. package/src/modules/agent.ts +0 -319
  598. package/src/modules/attestation.ts +0 -168
  599. package/src/modules/base.ts +0 -247
  600. package/src/modules/escrow-v2.ts +0 -871
  601. package/src/modules/escrow.ts +0 -439
  602. package/src/modules/feedback.ts +0 -186
  603. package/src/modules/index.ts +0 -28
  604. package/src/modules/indexing.ts +0 -444
  605. package/src/modules/ledger.ts +0 -262
  606. package/src/modules/receipt.ts +0 -212
  607. package/src/modules/staking.ts +0 -223
  608. package/src/modules/subscription.ts +0 -147
  609. package/src/modules/tools.ts +0 -454
  610. package/src/modules/vault.ts +0 -558
  611. package/src/parser/client.ts +0 -211
  612. package/src/parser/complete.ts +0 -232
  613. package/src/parser/index.ts +0 -71
  614. package/src/parser/inner.ts +0 -255
  615. package/src/parser/instructions.ts +0 -135
  616. package/src/parser/transaction.ts +0 -200
  617. package/src/parser/types.ts +0 -182
  618. package/src/pda/index.ts +0 -919
  619. package/src/plugin/index.ts +0 -1224
  620. package/src/plugin/protocols.ts +0 -404
  621. package/src/plugin/schemas.ts +0 -941
  622. package/src/postgres/adapter.ts +0 -904
  623. package/src/postgres/index.ts +0 -59
  624. package/src/postgres/schema.sql +0 -683
  625. package/src/postgres/serializers.ts +0 -485
  626. package/src/postgres/sync.ts +0 -340
  627. package/src/postgres/types.ts +0 -245
  628. package/src/registries/builder.ts +0 -607
  629. package/src/registries/discovery.ts +0 -572
  630. package/src/registries/fairscale.ts +0 -1278
  631. package/src/registries/index.ts +0 -143
  632. package/src/registries/metaplex-bridge.ts +0 -1199
  633. package/src/registries/session.ts +0 -613
  634. package/src/registries/x402.ts +0 -1048
  635. package/src/types/accounts.ts +0 -858
  636. package/src/types/common.ts +0 -187
  637. package/src/types/endpoint.ts +0 -181
  638. package/src/types/enums.ts +0 -333
  639. package/src/types/index.ts +0 -121
  640. package/src/types/instructions.ts +0 -453
  641. package/src/utils/anchor-errors.ts +0 -461
  642. package/src/utils/endpoint-validator.ts +0 -300
  643. package/src/utils/escrow-validation.ts +0 -301
  644. package/src/utils/hash.ts +0 -113
  645. package/src/utils/index.ts +0 -118
  646. package/src/utils/merchant-validator.ts +0 -359
  647. package/src/utils/network-normalizer.ts +0 -240
  648. package/src/utils/priority-fee.ts +0 -325
  649. package/src/utils/rpc-strategy.ts +0 -322
  650. package/src/utils/schemas.ts +0 -359
  651. package/src/utils/serialization.ts +0 -98
  652. package/src/utils/validation.ts +0 -36
  653. package/src/utils/volume-curve.ts +0 -131
  654. package/src/utils/x402-direct.ts +0 -370
@@ -1,240 +0,0 @@
1
- /**
2
- * @module utils/network-normalizer
3
- * @description Network identifier normalization for x402 payment headers.
4
- *
5
- * Solves the canonical-string mismatch between SAP clients and servers:
6
- * some providers accept `solana:mainnet-beta` while others require
7
- * the genesis-hash form `solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp`.
8
- *
9
- * This module provides a single source of truth for normalizing
10
- * network identifiers so that both clients and agents canonicalize
11
- * before comparing. Catches the Kamiyo "sap network mismatch" error
12
- * at the SDK level.
13
- *
14
- * @category Utils
15
- * @since v0.6.0
16
- */
17
-
18
- import { SapNetwork, type SapNetworkId } from "../constants/network";
19
-
20
- // ═══════════════════════════════════════════════════════════════════
21
- // Canonical Mapping
22
- // ═══════════════════════════════════════════════════════════════════
23
-
24
- /**
25
- * Bidirectional alias map: for every known network string, stores the
26
- * canonical SapNetworkId it resolves to, plus all known aliases.
27
- */
28
- const NETWORK_ALIASES: ReadonlyMap<string, SapNetworkId> = new Map([
29
- // ── Mainnet ───────────────────────────────
30
- // Canonical: genesis-hash form
31
- ["solana:mainnet-beta", SapNetwork.SOLANA_MAINNET],
32
- ["solana:mainnet", SapNetwork.SOLANA_MAINNET],
33
- ["mainnet-beta", SapNetwork.SOLANA_MAINNET],
34
- ["mainnet", SapNetwork.SOLANA_MAINNET],
35
- ["solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp", SapNetwork.SOLANA_MAINNET_GENESIS],
36
- ["5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp", SapNetwork.SOLANA_MAINNET_GENESIS],
37
-
38
- // ── Devnet ────────────────────────────────
39
- ["solana:devnet", SapNetwork.SOLANA_DEVNET_NAMED],
40
- ["devnet", SapNetwork.SOLANA_DEVNET_NAMED],
41
- ["solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1", SapNetwork.SOLANA_DEVNET],
42
- ["EtWTRABZaYq6iMfeYKouRu166VU2xqa1", SapNetwork.SOLANA_DEVNET],
43
- ]);
44
-
45
- /**
46
- * Mainnet equivalence set: all strings that refer to Solana mainnet-beta,
47
- * regardless of format.
48
- */
49
- const MAINNET_EQUIVALENTS = new Set<string>([
50
- SapNetwork.SOLANA_MAINNET,
51
- SapNetwork.SOLANA_MAINNET_GENESIS,
52
- "solana:mainnet",
53
- "mainnet-beta",
54
- "mainnet",
55
- "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",
56
- ]);
57
-
58
- /**
59
- * Devnet equivalence set.
60
- */
61
- const DEVNET_EQUIVALENTS = new Set<string>([
62
- SapNetwork.SOLANA_DEVNET,
63
- SapNetwork.SOLANA_DEVNET_NAMED,
64
- "devnet",
65
- "EtWTRABZaYq6iMfeYKouRu166VU2xqa1",
66
- ]);
67
-
68
- // ═══════════════════════════════════════════════════════════════════
69
- // Public API
70
- // ═══════════════════════════════════════════════════════════════════
71
-
72
- /**
73
- * @name normalizeNetworkId
74
- * @description Normalize a raw network identifier string to its canonical
75
- * {@link SapNetworkId} form.
76
- *
77
- * Handles:
78
- * - Case-insensitive matching
79
- * - Stripping whitespace
80
- * - Resolving genesis-hash vs. cluster-name aliases
81
- * - Unknown strings are returned as-is (passthrough)
82
- *
83
- * @param raw - Raw network identifier string from headers, env vars, or config.
84
- * @returns The canonical {@link SapNetworkId}, or the trimmed input if unknown.
85
- *
86
- * @category Utils
87
- * @since v0.6.0
88
- *
89
- * @example
90
- * ```ts
91
- * import { normalizeNetworkId } from "@synapse-sap/sdk";
92
- *
93
- * normalizeNetworkId("solana:mainnet-beta");
94
- * // → "solana:mainnet-beta"
95
- *
96
- * normalizeNetworkId("5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp");
97
- * // → "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
98
- *
99
- * normalizeNetworkId(" MAINNET ");
100
- * // → "solana:mainnet-beta"
101
- * ```
102
- */
103
- export function normalizeNetworkId(raw: string): SapNetworkId | string {
104
- const trimmed = raw.trim();
105
- // Exact match first
106
- const exact = NETWORK_ALIASES.get(trimmed);
107
- if (exact) return exact;
108
-
109
- // Case-insensitive lookup
110
- const lower = trimmed.toLowerCase();
111
- for (const [alias, canonical] of NETWORK_ALIASES) {
112
- if (alias.toLowerCase() === lower) return canonical;
113
- }
114
-
115
- // Passthrough for unknown networks (custom chains, etc.)
116
- return trimmed;
117
- }
118
-
119
- /**
120
- * @name isNetworkEquivalent
121
- * @description Check if two network identifier strings refer to the same network,
122
- * even if they use different formats (cluster-name vs. genesis-hash).
123
- *
124
- * This is the key function that prevents the Kamiyo "sap network mismatch"
125
- * error — instead of comparing strings literally, we compare their
126
- * canonical equivalence class.
127
- *
128
- * @param a - First network identifier.
129
- * @param b - Second network identifier.
130
- * @returns `true` if both identifiers refer to the same Solana network.
131
- *
132
- * @category Utils
133
- * @since v0.6.0
134
- *
135
- * @example
136
- * ```ts
137
- * import { isNetworkEquivalent } from "@synapse-sap/sdk";
138
- *
139
- * isNetworkEquivalent("solana:mainnet-beta", "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp");
140
- * // → true
141
- *
142
- * isNetworkEquivalent("solana:devnet", "solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1");
143
- * // → true
144
- *
145
- * isNetworkEquivalent("solana:mainnet-beta", "solana:devnet");
146
- * // → false
147
- * ```
148
- */
149
- export function isNetworkEquivalent(a: string, b: string): boolean {
150
- const normA = a.trim();
151
- const normB = b.trim();
152
-
153
- // Fast path: identical strings
154
- if (normA === normB) return true;
155
-
156
- // Check if both are in the same equivalence set
157
- if (MAINNET_EQUIVALENTS.has(normA) && MAINNET_EQUIVALENTS.has(normB)) return true;
158
- if (DEVNET_EQUIVALENTS.has(normA) && DEVNET_EQUIVALENTS.has(normB)) return true;
159
-
160
- // Case-insensitive match
161
- const lowerA = normA.toLowerCase();
162
- const lowerB = normB.toLowerCase();
163
- if (lowerA === lowerB) return true;
164
-
165
- // Resolve both to canonical and compare
166
- const canonA = normalizeNetworkId(normA);
167
- const canonB = normalizeNetworkId(normB);
168
-
169
- if (canonA === canonB) return true;
170
-
171
- // Final check: both resolve to the same equivalence set
172
- if (MAINNET_EQUIVALENTS.has(canonA) && MAINNET_EQUIVALENTS.has(canonB)) return true;
173
- if (DEVNET_EQUIVALENTS.has(canonA) && DEVNET_EQUIVALENTS.has(canonB)) return true;
174
-
175
- return false;
176
- }
177
-
178
- /**
179
- * @name getNetworkGenesisHash
180
- * @description Get the genesis-hash form of a network identifier.
181
- * Returns the genesis-hash variant for known networks, or the input as-is.
182
- *
183
- * Useful for agents that require the genesis-hash form (Kamiyo, Helius x402).
184
- *
185
- * @param networkId - Any network identifier.
186
- * @returns The genesis-hash form, or the input if unknown.
187
- *
188
- * @category Utils
189
- * @since v0.6.0
190
- */
191
- export function getNetworkGenesisHash(networkId: string): string {
192
- const norm = normalizeNetworkId(networkId);
193
- if (MAINNET_EQUIVALENTS.has(networkId) || MAINNET_EQUIVALENTS.has(norm)) {
194
- return SapNetwork.SOLANA_MAINNET_GENESIS;
195
- }
196
- if (DEVNET_EQUIVALENTS.has(networkId) || DEVNET_EQUIVALENTS.has(norm)) {
197
- return SapNetwork.SOLANA_DEVNET;
198
- }
199
- return norm;
200
- }
201
-
202
- /**
203
- * @name getNetworkClusterName
204
- * @description Get the cluster-name form of a network identifier.
205
- * Returns the human-readable cluster name for known networks.
206
- *
207
- * Useful for providers that accept cluster names (Coinbase, Phantom).
208
- *
209
- * @param networkId - Any network identifier.
210
- * @returns The cluster-name form, or the input if unknown.
211
- *
212
- * @category Utils
213
- * @since v0.6.0
214
- */
215
- export function getNetworkClusterName(networkId: string): string {
216
- const norm = normalizeNetworkId(networkId);
217
- if (MAINNET_EQUIVALENTS.has(networkId) || MAINNET_EQUIVALENTS.has(norm)) {
218
- return SapNetwork.SOLANA_MAINNET;
219
- }
220
- if (DEVNET_EQUIVALENTS.has(networkId) || DEVNET_EQUIVALENTS.has(norm)) {
221
- return SapNetwork.SOLANA_DEVNET_NAMED;
222
- }
223
- return norm;
224
- }
225
-
226
- /**
227
- * @name isKnownNetwork
228
- * @description Check if a network identifier is recognized by the SDK.
229
- *
230
- * @param networkId - The network identifier to check.
231
- * @returns `true` if the identifier maps to a known Solana network.
232
- *
233
- * @category Utils
234
- * @since v0.6.0
235
- */
236
- export function isKnownNetwork(networkId: string): boolean {
237
- const trimmed = networkId.trim();
238
- return MAINNET_EQUIVALENTS.has(trimmed) || DEVNET_EQUIVALENTS.has(trimmed) ||
239
- NETWORK_ALIASES.has(trimmed);
240
- }
@@ -1,325 +0,0 @@
1
- /**
2
- * @module utils/priority-fee
3
- * @description Compute budget and priority fee utilities for SAP transactions.
4
- *
5
- * Solana transactions that include a priority fee (via the Compute Budget program)
6
- * land faster because validators prefer higher-fee transactions. This module
7
- * provides a clean, composable API for building priority-fee instructions
8
- * that can be prepended to any Anchor method builder via `.preInstructions()`.
9
- *
10
- * Typical use: x402 settlement transactions where the receiving agent's RPC
11
- * has a short confirmation window (e.g., 30 seconds).
12
- *
13
- * @category Utils
14
- * @since v0.6.2
15
- *
16
- * @example
17
- * ```ts
18
- * import { buildPriorityFeeIxs, DEFAULT_SETTLE_PRIORITY } from "@synapse-sap/sdk";
19
- *
20
- * // Append to any Anchor method builder:
21
- * await program.methods
22
- * .settleCalls(calls, hash)
23
- * .accounts({ ... })
24
- * .preInstructions(buildPriorityFeeIxs({ priorityFeeMicroLamports: 5000 }))
25
- * .rpc({ skipPreflight: true });
26
- * ```
27
- */
28
-
29
- import {
30
- ComputeBudgetProgram,
31
- type TransactionInstruction,
32
- } from "@solana/web3.js";
33
-
34
- // ═══════════════════════════════════════════════════════════════════
35
- // Constants
36
- // ═══════════════════════════════════════════════════════════════════
37
-
38
- /**
39
- * Default priority fee for settlement transactions (in microlamports).
40
- * 5000 µL ≈ 0.0005 SOL per 200k CU — fast enough for most agent RPCs.
41
- *
42
- * @since v0.6.2
43
- */
44
- export const DEFAULT_SETTLE_PRIORITY_FEE = 5_000;
45
-
46
- /**
47
- * Default compute unit limit for settlement transactions.
48
- * `settle_calls` uses ~60k CU; 100k provides a safe margin.
49
- *
50
- * @since v0.6.2
51
- */
52
- export const DEFAULT_SETTLE_COMPUTE_UNITS = 100_000;
53
-
54
- /**
55
- * Default compute unit limit for batch settlement transactions.
56
- * `settle_batch` with 10 entries uses ~200k CU; 300k provides margin.
57
- *
58
- * @since v0.6.2
59
- */
60
- export const DEFAULT_BATCH_SETTLE_COMPUTE_UNITS = 300_000;
61
-
62
- /**
63
- * Per-settlement CU cost observed for `settle_batch` (sha256 of the
64
- * service hash, dedup scan, volume-curve math, account writes).
65
- *
66
- * @since v0.11.0
67
- * @internal
68
- */
69
- const BATCH_SETTLE_CU_PER_ENTRY = 25_000;
70
-
71
- /**
72
- * Fixed CU overhead for a `settle_batch` transaction independent of
73
- * the entry count (signature verify, account loads, transfer, event).
74
- *
75
- * @since v0.11.0
76
- * @internal
77
- */
78
- const BATCH_SETTLE_CU_BASE = 60_000;
79
-
80
- /**
81
- * Hard ceiling — Solana caps a single instruction at 1.4M CU. We
82
- * stay below that so a transaction with extra preInstructions
83
- * (priority-fee, ATA creation) still fits.
84
- *
85
- * @since v0.11.0
86
- * @internal
87
- */
88
- const BATCH_SETTLE_CU_MAX = 1_200_000;
89
-
90
- /**
91
- * @name computeBatchSettleCu
92
- * @description Compute the CU limit needed by `settle_batch` for a
93
- * given entry count. Returned value is safe to pass to
94
- * `ComputeBudgetProgram.setComputeUnitLimit`.
95
- *
96
- * Formula: `60_000 + n * 25_000`, clamped to 1.2M.
97
- *
98
- * @param entryCount - Number of settlements in the batch (1..N).
99
- * @returns CU limit suitable for `setComputeUnitLimit`.
100
- *
101
- * @example
102
- * ```ts
103
- * const cu = computeBatchSettleCu(20); // 560_000
104
- * ```
105
- *
106
- * @category Utils
107
- * @since v0.11.0
108
- */
109
- export function computeBatchSettleCu(entryCount: number): number {
110
- if (!Number.isFinite(entryCount) || entryCount <= 0) {
111
- return DEFAULT_BATCH_SETTLE_COMPUTE_UNITS;
112
- }
113
- const raw = BATCH_SETTLE_CU_BASE + Math.ceil(entryCount) * BATCH_SETTLE_CU_PER_ENTRY;
114
- return Math.min(raw, BATCH_SETTLE_CU_MAX);
115
- }
116
-
117
- // ═══════════════════════════════════════════════════════════════════
118
- // Types
119
- // ═══════════════════════════════════════════════════════════════════
120
-
121
- /**
122
- * @interface PriorityFeeConfig
123
- * @description Configuration for building compute budget instructions.
124
- * @category Utils
125
- * @since v0.6.2
126
- */
127
- export interface PriorityFeeConfig {
128
- /**
129
- * Priority fee in microlamports per compute unit.
130
- * Higher values = faster confirmation.
131
- *
132
- * Common values:
133
- * - `1000` — low priority (~0.0001 SOL)
134
- * - `5000` — medium priority (~0.0005 SOL) ← recommended for settle
135
- * - `50000` — high priority (~0.005 SOL)
136
- * - `0` — no priority fee (default Solana behavior)
137
- *
138
- * @default 0
139
- */
140
- readonly priorityFeeMicroLamports?: number;
141
-
142
- /**
143
- * Maximum compute units the transaction may consume.
144
- * Setting an explicit limit avoids overpaying for unused CU.
145
- *
146
- * @default 200_000 (Solana default)
147
- */
148
- readonly computeUnits?: number;
149
- }
150
-
151
- /**
152
- * @interface SettleOptions
153
- * @description Options for x402 settlement transactions.
154
- * Controls priority fees, compute budget, and RPC behavior
155
- * to optimize confirmation speed for time-sensitive settlements.
156
- *
157
- * @category Registries
158
- * @since v0.6.2
159
- *
160
- * @example
161
- * ```ts
162
- * // Fast settlement with priority fee
163
- * const receipt = await x402.settle(depositor, 1, "data", {
164
- * priorityFeeMicroLamports: 5000,
165
- * computeUnits: 100_000,
166
- * skipPreflight: true,
167
- * });
168
- *
169
- * // Use the convenience preset
170
- * import { FAST_SETTLE_OPTIONS } from "@synapse-sap/sdk";
171
- * const receipt = await x402.settle(depositor, 1, "data", FAST_SETTLE_OPTIONS);
172
- * ```
173
- */
174
- export interface SettleOptions extends PriorityFeeConfig {
175
- /**
176
- * Skip Solana simulation before submitting.
177
- * Saves ~400ms but loses pre-flight error detection.
178
- *
179
- * Recommended for settlements where the escrow state
180
- * has already been pre-fetched and validated.
181
- *
182
- * @default false
183
- */
184
- readonly skipPreflight?: boolean;
185
-
186
- /**
187
- * Transaction commitment level override.
188
- * Uses the provider's default when omitted.
189
- *
190
- * - `"processed"` — fastest, least reliable
191
- * - `"confirmed"` — balanced (recommended)
192
- * - `"finalized"` — slowest, most reliable
193
- */
194
- readonly commitment?: "processed" | "confirmed" | "finalized";
195
-
196
- /**
197
- * Maximum number of RPC retry attempts.
198
- * @default provider default (usually 3)
199
- */
200
- readonly maxRetries?: number;
201
- }
202
-
203
- // ═══════════════════════════════════════════════════════════════════
204
- // Presets
205
- // ═══════════════════════════════════════════════════════════════════
206
-
207
- /**
208
- * Recommended preset for fast x402 settlements.
209
- * Priority fee 5000 µL, 100k CU, skip preflight, confirmed commitment.
210
- *
211
- * @since v0.6.2
212
- */
213
- export const FAST_SETTLE_OPTIONS: Readonly<SettleOptions> = Object.freeze({
214
- priorityFeeMicroLamports: DEFAULT_SETTLE_PRIORITY_FEE,
215
- computeUnits: DEFAULT_SETTLE_COMPUTE_UNITS,
216
- skipPreflight: true,
217
- commitment: "confirmed",
218
- });
219
-
220
- /**
221
- * Recommended preset for fast batch settlements.
222
- * Priority fee 5000 µL, 300k CU, skip preflight, confirmed commitment.
223
- *
224
- * @since v0.6.2
225
- */
226
- export const FAST_BATCH_SETTLE_OPTIONS: Readonly<SettleOptions> = Object.freeze({
227
- priorityFeeMicroLamports: DEFAULT_SETTLE_PRIORITY_FEE,
228
- computeUnits: DEFAULT_BATCH_SETTLE_COMPUTE_UNITS,
229
- skipPreflight: true,
230
- commitment: "confirmed",
231
- });
232
-
233
- // ═══════════════════════════════════════════════════════════════════
234
- // Builder
235
- // ═══════════════════════════════════════════════════════════════════
236
-
237
- /**
238
- * @name buildPriorityFeeIxs
239
- * @description Build compute budget instructions for priority fee transactions.
240
- *
241
- * Returns an array of 0–2 `TransactionInstruction`s:
242
- * - `SetComputeUnitPrice` (if `priorityFeeMicroLamports > 0`)
243
- * - `SetComputeUnitLimit` (if `computeUnits` provided)
244
- *
245
- * The returned array is designed to be passed directly to
246
- * Anchor's `.preInstructions()` builder method.
247
- *
248
- * @param config - Priority fee configuration.
249
- * @returns Array of compute budget instructions (may be empty).
250
- *
251
- * @category Utils
252
- * @since v0.6.2
253
- *
254
- * @example
255
- * ```ts
256
- * const ixs = buildPriorityFeeIxs({
257
- * priorityFeeMicroLamports: 5000,
258
- * computeUnits: 100_000,
259
- * });
260
- *
261
- * await program.methods
262
- * .settleCalls(calls, hash)
263
- * .accounts({ ... })
264
- * .preInstructions(ixs)
265
- * .rpc({ skipPreflight: true });
266
- * ```
267
- */
268
- export function buildPriorityFeeIxs(
269
- config?: PriorityFeeConfig,
270
- ): TransactionInstruction[] {
271
- if (!config) return [];
272
-
273
- const ixs: TransactionInstruction[] = [];
274
-
275
- const fee = config.priorityFeeMicroLamports ?? 0;
276
- if (fee > 0) {
277
- ixs.push(
278
- ComputeBudgetProgram.setComputeUnitPrice({
279
- microLamports: fee,
280
- }),
281
- );
282
- }
283
-
284
- const cu = config.computeUnits;
285
- if (cu !== undefined && cu > 0) {
286
- ixs.push(
287
- ComputeBudgetProgram.setComputeUnitLimit({
288
- units: cu,
289
- }),
290
- );
291
- }
292
-
293
- return ixs;
294
- }
295
-
296
- /**
297
- * @name buildRpcOptions
298
- * @description Build Anchor `.rpc()` options from {@link SettleOptions}.
299
- *
300
- * @param opts - Settle options.
301
- * @returns Options object suitable for Anchor `.rpc(opts)`.
302
- *
303
- * @category Utils
304
- * @since v0.6.2
305
- * @internal
306
- */
307
- export function buildRpcOptions(
308
- opts?: SettleOptions,
309
- ): Record<string, unknown> | undefined {
310
- if (!opts) return undefined;
311
-
312
- const rpcOpts: Record<string, unknown> = {};
313
-
314
- if (opts.skipPreflight !== undefined) {
315
- rpcOpts.skipPreflight = opts.skipPreflight;
316
- }
317
- if (opts.commitment !== undefined) {
318
- rpcOpts.commitment = opts.commitment;
319
- }
320
- if (opts.maxRetries !== undefined) {
321
- rpcOpts.maxRetries = opts.maxRetries;
322
- }
323
-
324
- return Object.keys(rpcOpts).length > 0 ? rpcOpts : undefined;
325
- }