@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
@@ -1,1199 +0,0 @@
1
- /**
2
- * @module registries/metaplex-bridge
3
- * @description Bridge between Synapse Agent Protocol (SAP) and Metaplex
4
- * Core's `AgentIdentity` external plugin adapter (mpl-core ≥ 1.9.0).
5
- *
6
- * ## Why this design (verified against mpl-core PR #258, v1.9.0)
7
- *
8
- * The MPL Core `AgentIdentity` plugin has exactly one field:
9
- *
10
- * ```ts
11
- * type AgentIdentity = { uri: string };
12
- * ```
13
- *
14
- * The URI must point to an **EIP-8004** agent registration JSON. There is
15
- * no on-chain executive list, no `addExecutive` / `delegateExecutionV1`
16
- * instruction. Capabilities, services, executives, and reputation live
17
- * off-chain in that JSON. The plugin only hooks the `Execute` lifecycle
18
- * event, allowing the URI's authority to gate execution.
19
- *
20
- * The most efficient SAP × MPL integration therefore is:
21
- *
22
- * 1. SAP serves a **live EIP-8004 JSON** at a deterministic URL derived
23
- * from the SAP `AgentAccount` PDA (e.g.
24
- * `https://explorer.oobeprotocol.ai/agents/<sapAgentPda>/eip-8004.json`).
25
- * 2. The MPL Core asset attaches an `AgentIdentity` adapter whose `uri`
26
- * points to that URL.
27
- * 3. Every SAP write (capability change, vault delegate add/revoke, x402
28
- * tier update) is reflected in the JSON automatically — **no second
29
- * transaction required, on either chain or for any wallet.**
30
- *
31
- * One SAP transaction = both protocols updated. That is the efficiency
32
- * win that motivated the Phase 1 redesign on 2026-04-22.
33
- *
34
- * @category Registries
35
- * @since v0.9.0
36
- * @see https://github.com/metaplex-foundation/mpl-core/pull/258
37
- * @see https://eips.ethereum.org/EIPS/eip-8004
38
- */
39
-
40
- import {
41
- PublicKey,
42
- type TransactionInstruction,
43
- } from "@solana/web3.js";
44
- import type {
45
- AssetV1,
46
- HookableLifecycleEvent as HookableLifecycleEventEnum,
47
- } from "@metaplex-foundation/mpl-core";
48
- import type {
49
- Instruction as UmiInstruction,
50
- PublicKey as UmiPublicKey,
51
- Signer as UmiSigner,
52
- TransactionBuilder,
53
- Umi,
54
- } from "@metaplex-foundation/umi";
55
- import type { SapProgram } from "../modules/base";
56
- import { deriveAgent, deriveAgentStats, deriveVault } from "../pda";
57
- import type {
58
- AgentAccountData,
59
- AgentStatsData,
60
- Capability,
61
- VaultDelegateData,
62
- } from "../types";
63
-
64
- // ═══════════════════════════════════════════════════════════════════
65
- // Typed peer-dep handles (lazy-loaded)
66
- // ═══════════════════════════════════════════════════════════════════
67
-
68
- type MplCoreModule = typeof import("@metaplex-foundation/mpl-core");
69
- type UmiBundleModule = typeof import("@metaplex-foundation/umi-bundle-defaults");
70
- type UmiModule = typeof import("@metaplex-foundation/umi");
71
-
72
- interface MplCoreRuntime {
73
- readonly mplCore: MplCoreModule;
74
- readonly umiBundle: UmiBundleModule;
75
- readonly umiCore: UmiModule;
76
- }
77
-
78
- // ═══════════════════════════════════════════════════════════════════
79
- // Public Types
80
- // ═══════════════════════════════════════════════════════════════════
81
-
82
- /**
83
- * @interface Eip8004Service
84
- * @description One service entry in an EIP-8004 registration document.
85
- * @category Registries
86
- * @since v0.9.0
87
- */
88
- export interface Eip8004Service {
89
- readonly id: string;
90
- readonly type: string;
91
- readonly url: string;
92
- readonly priceLamports?: string;
93
- }
94
-
95
- /**
96
- * @interface Eip8004Registration
97
- * @description Subset of an EIP-8004 registration document used by the
98
- * bridge. Hosts may include additional fields; they are passed through
99
- * via `extra`.
100
- * @category Registries
101
- * @since v0.9.0
102
- */
103
- export interface Eip8004Registration {
104
- readonly version: string;
105
- readonly name: string;
106
- readonly description?: string;
107
- readonly synapseAgent: string;
108
- readonly authority: string;
109
- readonly capabilities: readonly string[];
110
- readonly services: readonly Eip8004Service[];
111
- readonly executives: readonly { wallet: string; expiresAt: string | null }[];
112
- readonly updatedAt: string;
113
- readonly extra?: Record<string, unknown>;
114
- }
115
-
116
- /**
117
- * @interface AttachAgentIdentityOpts
118
- * @description Parameters for {@link MetaplexBridge.buildAttachAgentIdentityIx}.
119
- * @category Registries
120
- * @since v0.9.0
121
- */
122
- export interface AttachAgentIdentityOpts {
123
- readonly asset: PublicKey;
124
- readonly authority: PublicKey;
125
- readonly payer?: PublicKey;
126
- readonly sapAgentOwner: PublicKey;
127
- readonly registrationBaseUrl: string;
128
- readonly rpcUrl: string;
129
- }
130
-
131
- /**
132
- * @interface UpdateAgentIdentityUriOpts
133
- * @description Parameters for {@link MetaplexBridge.buildUpdateAgentIdentityUriIx}.
134
- * @category Registries
135
- * @since v0.9.0
136
- */
137
- export interface UpdateAgentIdentityUriOpts {
138
- readonly asset: PublicKey;
139
- readonly authority: PublicKey;
140
- readonly payer?: PublicKey;
141
- readonly newUri: string;
142
- readonly rpcUrl: string;
143
- }
144
-
145
- /**
146
- * @interface MplAgentSnapshot
147
- * @description Subset of an MPL Core Asset relevant to the bridge.
148
- * @category Registries
149
- * @since v0.9.0
150
- */
151
- export interface MplAgentSnapshot {
152
- readonly asset: PublicKey;
153
- readonly owner: PublicKey;
154
- readonly name: string | null;
155
- readonly agentIdentityUri: string | null;
156
- readonly registration: Eip8004Registration | null;
157
- }
158
-
159
- /**
160
- * @interface UnifiedProfile
161
- * @description Merged read-only profile combining SAP identity and an
162
- * (optional) MPL Core asset side. The `linked` flag is `true` when the
163
- * MPL asset's `AgentIdentity.uri` references the SAP agent PDA both in
164
- * the URL path and in the `synapseAgent` JSON field.
165
- * @category Registries
166
- * @since v0.9.0
167
- */
168
- export interface UnifiedProfile {
169
- readonly sap: {
170
- readonly pda: PublicKey;
171
- readonly identity: AgentAccountData | null;
172
- readonly stats: AgentStatsData | null;
173
- };
174
- readonly mpl: MplAgentSnapshot | null;
175
- readonly linked: boolean;
176
- }
177
-
178
- /**
179
- * @interface AgentIdentifierResolution
180
- * @description Resolution result for an agent identifier that may be either
181
- * an SAP owner wallet or an MPL Core asset address.
182
- *
183
- * - `kind = "wallet"`: input is treated as owner wallet.
184
- * - `kind = "core-asset"`: input is an MPL Core asset; `wallet` is asset owner.
185
- * - `kind = "unknown"`: input is invalid or cannot be resolved.
186
- *
187
- * @category Registries
188
- * @since v0.9.2
189
- */
190
- export interface AgentIdentifierResolution {
191
- readonly input: string;
192
- readonly kind: "wallet" | "core-asset" | "unknown";
193
- readonly wallet: PublicKey | null;
194
- readonly sapAgentPda: PublicKey | null;
195
- readonly asset: PublicKey | null;
196
- readonly hasSapAgent: boolean;
197
- readonly error: string | null;
198
- }
199
-
200
- /**
201
- * @interface RegisterAgentInput
202
- * @description Minimal input set the bridge needs to construct a SAP
203
- * `registerAgent` instruction. Exposed independently so the bridge does not
204
- * import `RegisterAgentArgs` from another module (keeping the public surface flat).
205
- *
206
- * @category Registries
207
- * @since v0.9.3
208
- */
209
- export interface RegisterAgentInput {
210
- readonly name: string;
211
- readonly description: string;
212
- readonly capabilities: readonly Capability[];
213
- readonly pricing: unknown;
214
- readonly protocols: readonly number[];
215
- readonly agentId?: string | null;
216
- readonly agentUri?: string | null;
217
- readonly x402Endpoint?: string | null;
218
- }
219
-
220
- /**
221
- * @interface MintAttachOpts
222
- * @description Inputs for {@link MetaplexBridge.buildMintAndAttachIxs}.
223
- * Builds: MPL Core `create` (mint a fresh asset) + `addExternalPluginAdapterV1`
224
- * (attach AgentIdentity → SAP EIP-8004 URL) — produced as two web3.js
225
- * instructions in deterministic order.
226
- *
227
- * The caller MUST sign with the returned `assetSigner` in addition to the
228
- * wallet authority, since Core mint requires the asset keypair as a signer.
229
- *
230
- * @category Registries
231
- * @since v0.9.3
232
- */
233
- export interface MintAttachOpts {
234
- readonly sapAgentOwner: PublicKey;
235
- readonly authority: PublicKey;
236
- readonly payer?: PublicKey;
237
- readonly owner?: PublicKey;
238
- readonly name: string;
239
- readonly metadataUri: string;
240
- readonly registrationBaseUrl: string;
241
- readonly rpcUrl: string;
242
- readonly collection?: PublicKey;
243
- }
244
-
245
- /**
246
- * @interface MintAttachResult
247
- * @description Return shape of {@link MetaplexBridge.buildMintAndAttachIxs}
248
- * and the mint half of {@link MetaplexBridge.buildRegisterBothIxs}.
249
- *
250
- * `assetSecretKey` is the freshly generated asset keypair's secret. The
251
- * caller is responsible for safe handling: server-side flows should
252
- * partial-sign the assembled transaction with it and then discard.
253
- *
254
- * @category Registries
255
- * @since v0.9.3
256
- */
257
- export interface MintAttachResult {
258
- readonly assetAddress: PublicKey;
259
- readonly assetSecretKey: Uint8Array;
260
- readonly registrationUrl: string;
261
- readonly instructions: readonly TransactionInstruction[];
262
- }
263
-
264
- /**
265
- * @interface SapForMplOpts
266
- * @description Inputs for {@link MetaplexBridge.buildRegisterSapForMplOwnerIx}.
267
- * Resolves the owner of `asset`, derives that owner's SAP PDA, and (if no
268
- * agent exists yet) returns the `registerAgent` instruction the owner must sign.
269
- *
270
- * @category Registries
271
- * @since v0.9.3
272
- */
273
- export interface SapForMplOpts {
274
- readonly asset: PublicKey;
275
- readonly registerArgs: RegisterAgentInput;
276
- readonly rpcUrl: string;
277
- }
278
-
279
- /**
280
- * @interface SapForMplResult
281
- * @description Result of {@link MetaplexBridge.buildRegisterSapForMplOwnerIx}.
282
- * `instruction` is `null` when the asset owner already has a SAP agent
283
- * (idempotent: nothing to do).
284
- *
285
- * @category Registries
286
- * @since v0.9.3
287
- */
288
- export interface SapForMplResult {
289
- readonly assetOwner: PublicKey;
290
- readonly sapAgentPda: PublicKey;
291
- readonly alreadyRegistered: boolean;
292
- readonly currentAgentIdentityUri: string | null;
293
- readonly instruction: TransactionInstruction | null;
294
- }
295
-
296
- /**
297
- * @interface RegisterBothOpts
298
- * @description Inputs for {@link MetaplexBridge.buildRegisterBothIxs}.
299
- * Builds the atomic SAP `registerAgent` + MPL Core `create` + `AgentIdentity`
300
- * attach sequence for a wallet that owns neither side yet.
301
- *
302
- * @category Registries
303
- * @since v0.9.3
304
- */
305
- export interface RegisterBothOpts {
306
- readonly wallet: PublicKey;
307
- readonly payer?: PublicKey;
308
- readonly registerArgs: RegisterAgentInput;
309
- readonly mintName: string;
310
- readonly mintMetadataUri: string;
311
- readonly registrationBaseUrl: string;
312
- readonly rpcUrl: string;
313
- readonly collection?: PublicKey;
314
- }
315
-
316
- /**
317
- * @interface RegisterBothResult
318
- * @description Result of {@link MetaplexBridge.buildRegisterBothIxs}.
319
- * Instructions are ordered: `[0]` SAP `registerAgent`, `[1]` MPL Core mint,
320
- * `[2]` MPL `AgentIdentity` attach. All three execute atomically inside one
321
- * transaction signed by the wallet + `assetSecretKey`.
322
- *
323
- * @category Registries
324
- * @since v0.9.3
325
- */
326
- export interface RegisterBothResult {
327
- readonly sapAgentPda: PublicKey;
328
- readonly assetAddress: PublicKey;
329
- readonly assetSecretKey: Uint8Array;
330
- readonly registrationUrl: string;
331
- readonly instructions: readonly TransactionInstruction[];
332
- }
333
-
334
- /**
335
- * @interface TripleCheckResult
336
- * @description Result of {@link MetaplexBridge.tripleCheckLink} — the explicit
337
- * 3-layer verification used by explorer/host badges.
338
- *
339
- * - `mplOnChain`: MPL Core asset fetched on-chain via mpl-core (gRPC/RPC).
340
- * - `eip8004Json`: registration JSON fetched from `agentIdentityUri` and
341
- * its `synapseAgent` matches the SAP PDA.
342
- * - `sapOnChain`: a SAP `AgentAccount` exists on-chain at that PDA.
343
- *
344
- * `linked = true` only when **all three** layers pass.
345
- *
346
- * @category Registries
347
- * @since v0.9.3
348
- */
349
- export interface TripleCheckResult {
350
- readonly asset: PublicKey;
351
- readonly sapAgentPda: PublicKey;
352
- readonly mplOnChain: boolean;
353
- readonly eip8004Json: boolean;
354
- readonly sapOnChain: boolean;
355
- readonly linked: boolean;
356
- readonly agentIdentityUri: string | null;
357
- readonly registration: Eip8004Registration | null;
358
- readonly identity: AgentAccountData | null;
359
- readonly error: string | null;
360
- }
361
-
362
- // ═══════════════════════════════════════════════════════════════════
363
- // Lazy peer-dep loader
364
- // ═══════════════════════════════════════════════════════════════════
365
-
366
- const PEER_DEP_INSTALL_HINT =
367
- "MetaplexBridge requires @metaplex-foundation/mpl-core (>=1.9.0) and " +
368
- "@metaplex-foundation/umi-bundle-defaults. " +
369
- "Install: npm i @metaplex-foundation/mpl-core @metaplex-foundation/umi-bundle-defaults";
370
-
371
- let cachedRuntime: MplCoreRuntime | null = null;
372
-
373
- async function loadMplCore(): Promise<MplCoreRuntime> {
374
- if (cachedRuntime) return cachedRuntime;
375
- try {
376
- const [mplCore, umiBundle, umiCore] = await Promise.all([
377
- import("@metaplex-foundation/mpl-core"),
378
- import("@metaplex-foundation/umi-bundle-defaults"),
379
- import("@metaplex-foundation/umi"),
380
- ]);
381
- cachedRuntime = { mplCore, umiBundle, umiCore };
382
- return cachedRuntime;
383
- } catch (cause) {
384
- throw new Error(PEER_DEP_INSTALL_HINT, { cause: cause as Error });
385
- }
386
- }
387
-
388
- // ═══════════════════════════════════════════════════════════════════
389
- // Typed SAP account namespace (Anchor IDL is generic; this struct
390
- // pins the only three accessors this module needs.)
391
- // ═══════════════════════════════════════════════════════════════════
392
-
393
- interface AnchorAccountFetcher<T> {
394
- fetch(address: PublicKey): Promise<T>;
395
- }
396
-
397
- interface AnchorAccountList<T> {
398
- all(
399
- filters?: ReadonlyArray<{
400
- memcmp: { offset: number; bytes: string };
401
- }>,
402
- ): Promise<{ publicKey: PublicKey; account: T }[]>;
403
- }
404
-
405
- interface SapAccountNamespace {
406
- agentAccount: AnchorAccountFetcher<AgentAccountData>;
407
- agentStats: AnchorAccountFetcher<AgentStatsData>;
408
- vaultDelegate: AnchorAccountList<VaultDelegateData>;
409
- }
410
-
411
- // ═══════════════════════════════════════════════════════════════════
412
- // MetaplexBridge
413
- // ═══════════════════════════════════════════════════════════════════
414
-
415
- /**
416
- * @name MetaplexBridge
417
- * @description Read-side merger and write-side instruction composer for
418
- * SAP × Metaplex Core `AgentIdentity` integration.
419
- *
420
- * Linking is **single-transaction**: the MPL `addExternalPluginAdapterV1`
421
- * instruction sets a URI that points at SAP's live registration host.
422
- * Subsequent SAP state changes propagate automatically — no extra MPL
423
- * transaction required.
424
- *
425
- * @category Registries
426
- * @since v0.9.0
427
- */
428
- export class MetaplexBridge {
429
- constructor(private readonly program: SapProgram) {}
430
-
431
- // ─────────────────────────────────────────────────────
432
- // Pure helpers
433
- // ─────────────────────────────────────────────────────
434
-
435
- /**
436
- * @name deriveRegistrationUrl
437
- * @description Compute the deterministic EIP-8004 registration URL for
438
- * a SAP agent. Hosts MUST serve the JSON at exactly this path so that
439
- * {@link MetaplexBridge.verifyLink} validates without external config.
440
- *
441
- * @since v0.9.0
442
- */
443
- deriveRegistrationUrl(sapAgentPda: PublicKey, baseUrl: string): string {
444
- const trimmed = baseUrl.replace(/\/+$/, "");
445
- return `${trimmed}/agents/${sapAgentPda.toBase58()}/eip-8004.json`;
446
- }
447
-
448
- /**
449
- * @name buildEip8004Registration
450
- * @description Build a canonical EIP-8004 JSON document for a SAP agent.
451
- * Designed to be called server-side by a registry host.
452
- *
453
- * @since v0.9.0
454
- */
455
- async buildEip8004Registration(args: {
456
- sapAgentOwner: PublicKey;
457
- services?: readonly Eip8004Service[];
458
- extra?: Record<string, unknown>;
459
- }): Promise<Eip8004Registration> {
460
- const [sapPda] = deriveAgent(args.sapAgentOwner);
461
- const identity = await this.fetchAgentNullable(sapPda);
462
- if (!identity) {
463
- throw new Error(
464
- `buildEip8004Registration: SAP agent not found for owner ${args.sapAgentOwner.toBase58()}`,
465
- );
466
- }
467
- const delegates = await this.fetchActiveVaultDelegates(sapPda);
468
- return {
469
- version: "0.1",
470
- name: this.readString(identity, "name") ?? "Synapse Agent",
471
- description: this.readString(identity, "description") ?? undefined,
472
- synapseAgent: sapPda.toBase58(),
473
- authority: args.sapAgentOwner.toBase58(),
474
- capabilities: this.readCapabilities(identity),
475
- services: args.services ?? [],
476
- executives: delegates,
477
- updatedAt: new Date().toISOString(),
478
- extra: args.extra,
479
- };
480
- }
481
-
482
- // ─────────────────────────────────────────────────────
483
- // Write side — build MPL instructions only
484
- // ─────────────────────────────────────────────────────
485
-
486
- /**
487
- * @name buildAttachAgentIdentityIx
488
- * @description Build the MPL Core `addExternalPluginAdapterV1`
489
- * `TransactionInstruction` that attaches an `AgentIdentity` plugin
490
- * pointing at SAP's live EIP-8004 registration URL.
491
- *
492
- * @since v0.9.0
493
- */
494
- async buildAttachAgentIdentityIx(
495
- opts: AttachAgentIdentityOpts,
496
- ): Promise<TransactionInstruction> {
497
- const [sapPda] = deriveAgent(opts.sapAgentOwner);
498
- const uri = this.deriveRegistrationUrl(sapPda, opts.registrationBaseUrl);
499
- return this.buildAddExternalPluginIx({
500
- asset: opts.asset,
501
- authority: opts.authority,
502
- payer: opts.payer ?? opts.authority,
503
- uri,
504
- rpcUrl: opts.rpcUrl,
505
- });
506
- }
507
-
508
- /**
509
- * @name buildUpdateAgentIdentityUriIx
510
- * @description Build the MPL Core `updateExternalPluginAdapterV1`
511
- * instruction that re-points an existing `AgentIdentity` plugin.
512
- *
513
- * @since v0.9.0
514
- */
515
- async buildUpdateAgentIdentityUriIx(
516
- opts: UpdateAgentIdentityUriOpts,
517
- ): Promise<TransactionInstruction> {
518
- const { mplCore, umiBundle, umiCore } = await loadMplCore();
519
- const umi: Umi = umiBundle.createUmi(opts.rpcUrl).use(mplCore.mplCore());
520
- const authority: UmiSigner = umiCore.createNoopSigner(
521
- umiCore.publicKey(opts.authority.toBase58()),
522
- );
523
- const payer: UmiSigner = umiCore.createNoopSigner(
524
- umiCore.publicKey((opts.payer ?? opts.authority).toBase58()),
525
- );
526
- const builder: TransactionBuilder = mplCore.updateExternalPluginAdapterV1(
527
- umi,
528
- {
529
- asset: umiCore.publicKey(opts.asset.toBase58()),
530
- authority,
531
- payer,
532
- key: { __kind: "AgentIdentity" },
533
- updateInfo: {
534
- __kind: "AgentIdentity",
535
- fields: [
536
- {
537
- uri: opts.newUri,
538
- lifecycleChecks: null,
539
- },
540
- ],
541
- },
542
- },
543
- );
544
- return this.firstWeb3Ix(builder, "updateExternalPluginAdapterV1");
545
- }
546
-
547
- // ─────────────────────────────────────────────────────
548
- // Write side — combined SAP × MPL register flows (v0.9.3)
549
- // ─────────────────────────────────────────────────────
550
-
551
- /**
552
- * @name buildMintAndAttachIxs
553
- * @description Build the two MPL Core instructions needed to mint a new
554
- * asset for an existing SAP agent and immediately bind it via the
555
- * `AgentIdentity` plugin (URI = canonical EIP-8004 URL).
556
- *
557
- * Flow:
558
- * 1. Generate a fresh asset keypair (returned as `assetSecretKey`).
559
- * 2. Build `mpl_core::create` with the new asset as signer.
560
- * 3. Build `addExternalPluginAdapterV1` for the AgentIdentity URI.
561
- *
562
- * The returned `instructions` are deterministic order. The caller
563
- * partial-signs the assembled transaction with `assetSecretKey` and the
564
- * authority/payer wallet.
565
- *
566
- * @since v0.9.3
567
- */
568
- async buildMintAndAttachIxs(opts: MintAttachOpts): Promise<MintAttachResult> {
569
- const { mplCore, umiBundle, umiCore } = await loadMplCore();
570
- const umi: Umi = umiBundle.createUmi(opts.rpcUrl).use(mplCore.mplCore());
571
-
572
- const [sapPda] = deriveAgent(opts.sapAgentOwner);
573
- const registrationUrl = this.deriveRegistrationUrl(
574
- sapPda,
575
- opts.registrationBaseUrl,
576
- );
577
-
578
- const assetUmiSigner = umiCore.generateSigner(umi);
579
- const assetAddress = new PublicKey(assetUmiSigner.publicKey.toString());
580
- const assetSecretKey = assetUmiSigner.secretKey;
581
-
582
- const authority: UmiSigner = umiCore.createNoopSigner(
583
- umiCore.publicKey(opts.authority.toBase58()),
584
- );
585
- const payer: UmiSigner = umiCore.createNoopSigner(
586
- umiCore.publicKey((opts.payer ?? opts.authority).toBase58()),
587
- );
588
- const ownerUmi = opts.owner
589
- ? umiCore.publicKey(opts.owner.toBase58())
590
- : umiCore.publicKey(opts.authority.toBase58());
591
-
592
- const createBuilder: TransactionBuilder = mplCore.create(umi, {
593
- asset: assetUmiSigner,
594
- collection: opts.collection
595
- ? ({ publicKey: umiCore.publicKey(opts.collection.toBase58()) } as never)
596
- : undefined,
597
- authority,
598
- payer,
599
- owner: ownerUmi,
600
- name: opts.name,
601
- uri: opts.metadataUri,
602
- });
603
- const mintIx = await this.firstWeb3Ix(createBuilder, "mpl_core::create");
604
-
605
- const attachIx = await this.buildAddExternalPluginIx({
606
- asset: assetAddress,
607
- authority: opts.authority,
608
- payer: opts.payer ?? opts.authority,
609
- uri: registrationUrl,
610
- rpcUrl: opts.rpcUrl,
611
- });
612
-
613
- return {
614
- assetAddress,
615
- assetSecretKey,
616
- registrationUrl,
617
- instructions: [mintIx, attachIx],
618
- };
619
- }
620
-
621
- /**
622
- * @name buildRegisterSapForMplOwnerIx
623
- * @description Given an existing MPL Core asset, resolve its on-chain
624
- * owner and build the SAP `registerAgent` instruction the owner must
625
- * sign. Idempotent: if a SAP agent already exists for that owner the
626
- * method returns `instruction: null` with `alreadyRegistered: true`.
627
- *
628
- * Use after a wallet has minted (or holds) an MPL Core agent NFT and
629
- * wants to back-fill a SAP identity at the canonical PDA so the bridge's
630
- * EIP-8004 URL becomes resolvable.
631
- *
632
- * @since v0.9.3
633
- */
634
- async buildRegisterSapForMplOwnerIx(
635
- opts: SapForMplOpts,
636
- ): Promise<SapForMplResult> {
637
- const snap = await this.fetchMplSnapshot(opts.asset, opts.rpcUrl);
638
- if (!snap) {
639
- throw new Error(
640
- `buildRegisterSapForMplOwnerIx: MPL Core asset ${opts.asset.toBase58()} not readable`,
641
- );
642
- }
643
- const [sapPda] = deriveAgent(snap.owner);
644
- const existing = await this.fetchAgentNullable(sapPda);
645
- if (existing) {
646
- return {
647
- assetOwner: snap.owner,
648
- sapAgentPda: sapPda,
649
- alreadyRegistered: true,
650
- currentAgentIdentityUri: snap.agentIdentityUri,
651
- instruction: null,
652
- };
653
- }
654
-
655
- const ix = await this.buildRegisterAgentIx({
656
- wallet: snap.owner,
657
- args: opts.registerArgs,
658
- });
659
- return {
660
- assetOwner: snap.owner,
661
- sapAgentPda: sapPda,
662
- alreadyRegistered: false,
663
- currentAgentIdentityUri: snap.agentIdentityUri,
664
- instruction: ix,
665
- };
666
- }
667
-
668
- /**
669
- * @name buildRegisterBothIxs
670
- * @description Atomic 3-instruction bundle for a wallet that owns
671
- * neither side: `[SAP registerAgent, MPL Core create, MPL AgentIdentity attach]`.
672
- * Single transaction, single user signature (plus the ephemeral asset
673
- * keypair returned in `assetSecretKey`).
674
- *
675
- * Throws if a SAP agent already exists for `wallet` — callers should
676
- * fall through to {@link MetaplexBridge.buildMintAndAttachIxs} instead.
677
- *
678
- * @since v0.9.3
679
- */
680
- async buildRegisterBothIxs(
681
- opts: RegisterBothOpts,
682
- ): Promise<RegisterBothResult> {
683
- const [sapPda] = deriveAgent(opts.wallet);
684
- const existing = await this.fetchAgentNullable(sapPda);
685
- if (existing) {
686
- throw new Error(
687
- `buildRegisterBothIxs: SAP agent already exists at ${sapPda.toBase58()}; ` +
688
- `use buildMintAndAttachIxs instead`,
689
- );
690
- }
691
-
692
- const sapIx = await this.buildRegisterAgentIx({
693
- wallet: opts.wallet,
694
- args: opts.registerArgs,
695
- });
696
-
697
- const mint = await this.buildMintAndAttachIxs({
698
- sapAgentOwner: opts.wallet,
699
- authority: opts.wallet,
700
- payer: opts.payer ?? opts.wallet,
701
- owner: opts.wallet,
702
- name: opts.mintName,
703
- metadataUri: opts.mintMetadataUri,
704
- registrationBaseUrl: opts.registrationBaseUrl,
705
- rpcUrl: opts.rpcUrl,
706
- collection: opts.collection,
707
- });
708
-
709
- return {
710
- sapAgentPda: sapPda,
711
- assetAddress: mint.assetAddress,
712
- assetSecretKey: mint.assetSecretKey,
713
- registrationUrl: mint.registrationUrl,
714
- instructions: [sapIx, ...mint.instructions],
715
- };
716
- }
717
-
718
- // ─────────────────────────────────────────────────────
719
- // Read side
720
- // ─────────────────────────────────────────────────────
721
-
722
- /**
723
- * @name getUnifiedProfile
724
- * @description Fetch a merged view of an agent across SAP and Metaplex.
725
- * Provide `wallet` (SAP-first) or `asset` (MPL-first), or both.
726
- *
727
- * @since v0.9.0
728
- */
729
- async getUnifiedProfile(input: {
730
- wallet?: PublicKey;
731
- asset?: PublicKey;
732
- rpcUrl: string;
733
- rpcHeaders?: Record<string, string>;
734
- }): Promise<UnifiedProfile> {
735
- if (!input.wallet && !input.asset) {
736
- throw new Error("getUnifiedProfile: provide `wallet` or `asset`");
737
- }
738
-
739
- let sapPda: PublicKey | null = null;
740
- let identity: AgentAccountData | null = null;
741
- let stats: AgentStatsData | null = null;
742
-
743
- if (input.wallet) {
744
- [sapPda] = deriveAgent(input.wallet);
745
- identity = await this.fetchAgentNullable(sapPda);
746
- stats = await this.fetchStatsNullable(sapPda);
747
- }
748
-
749
- let mpl: MplAgentSnapshot | null = null;
750
- if (input.asset) {
751
- mpl = await this.fetchMplSnapshot(input.asset, input.rpcUrl, input.rpcHeaders);
752
- if (!sapPda && mpl?.registration?.synapseAgent) {
753
- try {
754
- sapPda = new PublicKey(mpl.registration.synapseAgent);
755
- identity = await this.fetchAgentNullable(sapPda);
756
- stats = await this.fetchStatsNullable(sapPda);
757
- } catch {
758
- /* invalid PDA in JSON */
759
- }
760
- }
761
- }
762
-
763
- if (!sapPda) {
764
- throw new Error("getUnifiedProfile: failed to resolve SAP agent PDA");
765
- }
766
-
767
- return {
768
- sap: { pda: sapPda, identity, stats },
769
- mpl,
770
- linked: this.detectLink(sapPda, mpl),
771
- };
772
- }
773
-
774
- /**
775
- * @name resolveAgentIdentifier
776
- * @description Resolve a generic agent identifier to canonical SAP routing
777
- * keys. Useful when callers may receive either owner wallets or Metaplex
778
- * Core asset IDs (e.g. metaplex.com/agents/<core-asset-id>).
779
- *
780
- * Resolution order:
781
- * 1) Treat input as wallet and check if a SAP agent exists.
782
- * 2) If not found, treat input as MPL Core asset and resolve owner wallet.
783
- *
784
- * @since v0.9.2
785
- */
786
- async resolveAgentIdentifier(input: {
787
- identifier: string;
788
- rpcUrl: string;
789
- rpcHeaders?: Record<string, string>;
790
- }): Promise<AgentIdentifierResolution> {
791
- let asPubkey: PublicKey;
792
- try {
793
- asPubkey = new PublicKey(input.identifier);
794
- } catch {
795
- return {
796
- input: input.identifier,
797
- kind: "unknown",
798
- wallet: null,
799
- sapAgentPda: null,
800
- asset: null,
801
- hasSapAgent: false,
802
- error: "Invalid public key",
803
- };
804
- }
805
-
806
- // 1) Wallet-first resolution (SAP-native)
807
- const [walletSapPda] = deriveAgent(asPubkey);
808
- const walletIdentity = await this.fetchAgentNullable(walletSapPda);
809
- if (walletIdentity) {
810
- return {
811
- input: input.identifier,
812
- kind: "wallet",
813
- wallet: asPubkey,
814
- sapAgentPda: walletSapPda,
815
- asset: null,
816
- hasSapAgent: true,
817
- error: null,
818
- };
819
- }
820
-
821
- // 2) MPL Core asset resolution
822
- const mpl = await this.fetchMplSnapshot(asPubkey, input.rpcUrl, input.rpcHeaders);
823
- if (!mpl) {
824
- return {
825
- input: input.identifier,
826
- kind: "unknown",
827
- wallet: null,
828
- sapAgentPda: null,
829
- asset: null,
830
- hasSapAgent: false,
831
- error: "Not a SAP wallet and not a readable MPL Core asset",
832
- };
833
- }
834
-
835
- const [sapPdaFromOwner] = deriveAgent(mpl.owner);
836
- const ownerIdentity = await this.fetchAgentNullable(sapPdaFromOwner);
837
- return {
838
- input: input.identifier,
839
- kind: "core-asset",
840
- wallet: mpl.owner,
841
- sapAgentPda: sapPdaFromOwner,
842
- asset: asPubkey,
843
- hasSapAgent: !!ownerIdentity,
844
- error: ownerIdentity ? null : "Core asset owner has no SAP agent profile",
845
- };
846
- }
847
-
848
- /**
849
- * @name verifyLink
850
- * @description Verify the bidirectional link between an MPL Core asset
851
- * and a SAP agent. Returns `true` only when both URL and JSON sides
852
- * reference the SAP agent PDA.
853
- *
854
- * @since v0.9.0
855
- */
856
- async verifyLink(args: {
857
- asset: PublicKey;
858
- sapAgentPda: PublicKey;
859
- rpcUrl: string;
860
- rpcHeaders?: Record<string, string>;
861
- }): Promise<boolean> {
862
- const snap = await this.fetchMplSnapshot(args.asset, args.rpcUrl, args.rpcHeaders);
863
- if (!snap?.agentIdentityUri || !snap.registration) return false;
864
- const expectedSuffix = `/agents/${args.sapAgentPda.toBase58()}/eip-8004.json`;
865
- if (!snap.agentIdentityUri.endsWith(expectedSuffix)) return false;
866
- return snap.registration.synapseAgent === args.sapAgentPda.toBase58();
867
- }
868
-
869
- /**
870
- * @name tripleCheckLink
871
- * @description Explicit 3-layer verification for explorer/host badges.
872
- * Returns one struct enumerating each check independently so UIs can
873
- * present partial trust states (e.g. "MPL plugin present, JSON pending").
874
- *
875
- * Layers:
876
- * 1. **mplOnChain** — Asset + AgentIdentity URI fetched on-chain.
877
- * 2. **eip8004Json** — JSON fetched and `synapseAgent` matches PDA.
878
- * 3. **sapOnChain** — `AgentAccount` PDA exists on the SAP program.
879
- *
880
- * @since v0.9.3
881
- */
882
- async tripleCheckLink(args: {
883
- asset: PublicKey;
884
- expectedOwner?: PublicKey;
885
- rpcUrl: string;
886
- rpcHeaders?: Record<string, string>;
887
- }): Promise<TripleCheckResult> {
888
- const snap = await this.fetchMplSnapshot(args.asset, args.rpcUrl, args.rpcHeaders);
889
- if (!snap) {
890
- const fallbackPda = args.expectedOwner
891
- ? deriveAgent(args.expectedOwner)[0]
892
- : args.asset;
893
- return {
894
- asset: args.asset,
895
- sapAgentPda: fallbackPda,
896
- mplOnChain: false,
897
- eip8004Json: false,
898
- sapOnChain: false,
899
- linked: false,
900
- agentIdentityUri: null,
901
- registration: null,
902
- identity: null,
903
- error: "MPL Core asset not readable on-chain",
904
- };
905
- }
906
-
907
- const owner = args.expectedOwner ?? snap.owner;
908
- const [sapPda] = deriveAgent(owner);
909
- const expectedSuffix = `/agents/${sapPda.toBase58()}/eip-8004.json`;
910
-
911
- const mplOnChain = !!snap.agentIdentityUri;
912
- const eip8004Json =
913
- !!snap.registration &&
914
- !!snap.agentIdentityUri &&
915
- snap.agentIdentityUri.endsWith(expectedSuffix) &&
916
- snap.registration.synapseAgent === sapPda.toBase58();
917
-
918
- const identity = await this.fetchAgentNullable(sapPda);
919
- const sapOnChain = !!identity;
920
-
921
- return {
922
- asset: args.asset,
923
- sapAgentPda: sapPda,
924
- mplOnChain,
925
- eip8004Json,
926
- sapOnChain,
927
- linked: mplOnChain && eip8004Json && sapOnChain,
928
- agentIdentityUri: snap.agentIdentityUri,
929
- registration: snap.registration,
930
- identity,
931
- error: null,
932
- };
933
- }
934
-
935
- // ═════════════════════════════════════════════════════
936
- // Private — SAP fetching
937
- // ═════════════════════════════════════════════════════
938
-
939
- private get accounts(): SapAccountNamespace {
940
- return this.program.account as unknown as SapAccountNamespace;
941
- }
942
-
943
- private async fetchAgentNullable(
944
- pda: PublicKey,
945
- ): Promise<AgentAccountData | null> {
946
- try {
947
- return await this.accounts.agentAccount.fetch(pda);
948
- } catch {
949
- return null;
950
- }
951
- }
952
-
953
- private async fetchStatsNullable(
954
- agentPda: PublicKey,
955
- ): Promise<AgentStatsData | null> {
956
- try {
957
- const [statsPda] = deriveAgentStats(agentPda);
958
- return await this.accounts.agentStats.fetch(statsPda);
959
- } catch {
960
- return null;
961
- }
962
- }
963
-
964
- private async fetchActiveVaultDelegates(
965
- agentPda: PublicKey,
966
- ): Promise<{ wallet: string; expiresAt: string | null }[]> {
967
- try {
968
- const [vaultPda] = deriveVault(agentPda);
969
- // VaultDelegate layout: [discriminator(8) | bump(1) | vault(32) | ...]
970
- const all = await this.accounts.vaultDelegate.all([
971
- { memcmp: { offset: 8 + 1, bytes: vaultPda.toBase58() } },
972
- ]);
973
- const now = Math.floor(Date.now() / 1000);
974
- return all
975
- .map(({ account }) => {
976
- const expiresRaw = account.expiresAt.toString();
977
- const expiresAt: string | null =
978
- expiresRaw === "0" ? null : expiresRaw;
979
- return { wallet: account.delegate.toBase58(), expiresAt };
980
- })
981
- .filter((d) => d.expiresAt === null || Number(d.expiresAt) > now);
982
- } catch {
983
- return [];
984
- }
985
- }
986
-
987
- // ═════════════════════════════════════════════════════
988
- // Private — MPL fetching
989
- // ═════════════════════════════════════════════════════
990
-
991
- private async buildUmi(
992
- rpcUrl: string,
993
- rpcHeaders?: Record<string, string>,
994
- ): Promise<Umi> {
995
- const { mplCore, umiBundle } = await loadMplCore();
996
- // umi-bundle-defaults.createUmi accepts an options object with httpHeaders
997
- // since umi 1.x — required for gated providers like Synapse RPC that
998
- // enforce `x-api-key`. Without it `getAccountInfo` returns 401 silently.
999
- const umi: Umi = (umiBundle.createUmi as unknown as (
1000
- endpoint: string,
1001
- opts?: { httpHeaders?: Record<string, string> },
1002
- ) => Umi)(rpcUrl, rpcHeaders ? { httpHeaders: rpcHeaders } : undefined).use(
1003
- mplCore.mplCore(),
1004
- );
1005
- return umi;
1006
- }
1007
-
1008
- private async fetchMplSnapshot(
1009
- asset: PublicKey,
1010
- rpcUrl: string,
1011
- rpcHeaders?: Record<string, string>,
1012
- ): Promise<MplAgentSnapshot | null> {
1013
- const { mplCore, umiCore } = await loadMplCore();
1014
- const umi: Umi = await this.buildUmi(rpcUrl, rpcHeaders);
1015
- try {
1016
- const fetched: AssetV1 = await mplCore.fetchAsset(
1017
- umi,
1018
- umiCore.publicKey(asset.toBase58()),
1019
- );
1020
- const owner = new PublicKey(fetched.owner.toString());
1021
- const uri = this.extractAgentIdentityUri(fetched);
1022
- const registration = uri ? await this.fetchEip8004Safe(uri) : null;
1023
- return {
1024
- asset,
1025
- owner,
1026
- name: fetched.name ?? null,
1027
- agentIdentityUri: uri,
1028
- registration,
1029
- };
1030
- } catch {
1031
- return null;
1032
- }
1033
- }
1034
-
1035
- private extractAgentIdentityUri(asset: AssetV1): string | null {
1036
- const adapters = asset.agentIdentities;
1037
- if (!adapters || adapters.length === 0) return null;
1038
- const first = adapters[0];
1039
- if (!first) return null;
1040
- return typeof first.uri === "string" ? first.uri : null;
1041
- }
1042
-
1043
- private async fetchEip8004Safe(
1044
- uri: string,
1045
- ): Promise<Eip8004Registration | null> {
1046
- try {
1047
- const res = await fetch(uri, { method: "GET" });
1048
- if (!res.ok) return null;
1049
- const json = (await res.json()) as Partial<Eip8004Registration>;
1050
- if (
1051
- typeof json.synapseAgent !== "string" ||
1052
- typeof json.authority !== "string"
1053
- ) {
1054
- return null;
1055
- }
1056
- return {
1057
- version: json.version ?? "0.1",
1058
- name: json.name ?? "",
1059
- description: json.description,
1060
- synapseAgent: json.synapseAgent,
1061
- authority: json.authority,
1062
- capabilities: Array.isArray(json.capabilities) ? json.capabilities : [],
1063
- services: Array.isArray(json.services) ? json.services : [],
1064
- executives: Array.isArray(json.executives) ? json.executives : [],
1065
- updatedAt: json.updatedAt ?? "",
1066
- extra: json.extra,
1067
- };
1068
- } catch {
1069
- return null;
1070
- }
1071
- }
1072
-
1073
- // ═════════════════════════════════════════════════════
1074
- // Private — MPL instruction building
1075
- // ═════════════════════════════════════════════════════
1076
-
1077
- private async buildAddExternalPluginIx(args: {
1078
- asset: PublicKey;
1079
- authority: PublicKey;
1080
- payer: PublicKey;
1081
- uri: string;
1082
- rpcUrl: string;
1083
- }): Promise<TransactionInstruction> {
1084
- const { mplCore, umiBundle, umiCore } = await loadMplCore();
1085
- const umi: Umi = umiBundle.createUmi(args.rpcUrl).use(mplCore.mplCore());
1086
- const authority: UmiSigner = umiCore.createNoopSigner(
1087
- umiCore.publicKey(args.authority.toBase58()),
1088
- );
1089
- const payer: UmiSigner = umiCore.createNoopSigner(
1090
- umiCore.publicKey(args.payer.toBase58()),
1091
- );
1092
- // HookableLifecycleEvent.Execute = 4; ExternalCheckResult { flags: 1 } = CanApprove
1093
- const ExecuteEvent = mplCore.HookableLifecycleEvent.Execute as HookableLifecycleEventEnum;
1094
- const builder: TransactionBuilder = mplCore.addExternalPluginAdapterV1(umi, {
1095
- asset: umiCore.publicKey(args.asset.toBase58()),
1096
- authority,
1097
- payer,
1098
- initInfo: {
1099
- __kind: "AgentIdentity",
1100
- fields: [
1101
- {
1102
- uri: args.uri,
1103
- initPluginAuthority: { __kind: "UpdateAuthority" },
1104
- lifecycleChecks: [[ExecuteEvent, { flags: 1 }]],
1105
- },
1106
- ],
1107
- },
1108
- });
1109
- return this.firstWeb3Ix(builder, "addExternalPluginAdapterV1");
1110
- }
1111
-
1112
- // ═════════════════════════════════════════════════════
1113
- // Private — SAP instruction building (v0.9.3)
1114
- // ═════════════════════════════════════════════════════
1115
-
1116
- private async buildRegisterAgentIx(args: {
1117
- wallet: PublicKey;
1118
- args: RegisterAgentInput;
1119
- }): Promise<TransactionInstruction> {
1120
- // Lazy import to avoid a hard cycle with `pda/index.ts`.
1121
- const { deriveGlobalRegistry } = await import("../pda");
1122
- const { SystemProgram } = await import("@solana/web3.js");
1123
- const [agentPda] = deriveAgent(args.wallet);
1124
- const [statsPda] = deriveAgentStats(agentPda);
1125
- const [globalPda] = deriveGlobalRegistry();
1126
- const a = args.args;
1127
- // Cast to `any` to sidestep Anchor's deep generic IDL inference, which
1128
- // otherwise blows TS recursion budget here. Same pattern as BaseModule.
1129
- const methods = (this.program as { methods: any }).methods;
1130
- return await methods
1131
- .registerAgent(
1132
- a.name,
1133
- a.description,
1134
- a.capabilities,
1135
- a.pricing,
1136
- a.protocols,
1137
- a.agentId ?? null,
1138
- a.agentUri ?? null,
1139
- a.x402Endpoint ?? null,
1140
- )
1141
- .accounts({
1142
- wallet: args.wallet,
1143
- agent: agentPda,
1144
- agentStats: statsPda,
1145
- globalRegistry: globalPda,
1146
- systemProgram: SystemProgram.programId,
1147
- })
1148
- .instruction();
1149
- }
1150
-
1151
- private async firstWeb3Ix(
1152
- builder: TransactionBuilder,
1153
- name: string,
1154
- ): Promise<TransactionInstruction> {
1155
- const items = builder.getInstructions();
1156
- const first = items[0];
1157
- if (!first) {
1158
- throw new Error(`MetaplexBridge: ${name} produced no instructions`);
1159
- }
1160
- return this.umiIxToWeb3(first);
1161
- }
1162
-
1163
- private umiIxToWeb3(ix: UmiInstruction): TransactionInstruction {
1164
- return {
1165
- programId: new PublicKey(ix.programId.toString()),
1166
- keys: ix.keys.map((k) => ({
1167
- pubkey: new PublicKey((k.pubkey as UmiPublicKey).toString()),
1168
- isSigner: k.isSigner,
1169
- isWritable: k.isWritable,
1170
- })),
1171
- data: Buffer.from(ix.data),
1172
- };
1173
- }
1174
-
1175
- // ═════════════════════════════════════════════════════
1176
- // Private — link detection + duck-typed readers
1177
- // ═════════════════════════════════════════════════════
1178
-
1179
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
1180
- private detectLink(
1181
- sapPda: PublicKey,
1182
- mpl: MplAgentSnapshot | null,
1183
- ): boolean {
1184
- if (!mpl?.agentIdentityUri || !mpl.registration) return false;
1185
- const expectedSuffix = `/agents/${sapPda.toBase58()}/eip-8004.json`;
1186
- if (!mpl.agentIdentityUri.endsWith(expectedSuffix)) return false;
1187
- return mpl.registration.synapseAgent === sapPda.toBase58();
1188
- }
1189
-
1190
- private readString(identity: AgentAccountData, key: keyof AgentAccountData): string | null {
1191
- const value = identity[key];
1192
- return typeof value === "string" ? value : null;
1193
- }
1194
-
1195
- private readCapabilities(identity: AgentAccountData): string[] {
1196
- const caps: ReadonlyArray<Capability> = identity.capabilities ?? [];
1197
- return caps.map((c) => c.id).filter((s): s is string => typeof s === "string");
1198
- }
1199
- }