@oobe-protocol-labs/synapse-sap-sdk 0.14.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 (651) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +986 -0
  3. package/dist/cjs/client.js +30 -13
  4. package/dist/cjs/client.js.map +1 -1
  5. package/dist/cjs/constants/addresses.js +143 -0
  6. package/dist/cjs/constants/addresses.js.map +1 -0
  7. package/dist/cjs/constants/index.js +64 -0
  8. package/dist/cjs/constants/index.js.map +1 -0
  9. package/dist/cjs/constants/limits.js +161 -0
  10. package/dist/cjs/constants/limits.js.map +1 -0
  11. package/dist/cjs/constants/network.js +81 -0
  12. package/dist/cjs/constants/network.js.map +1 -0
  13. package/dist/cjs/constants/payments.js +137 -0
  14. package/dist/cjs/constants/payments.js.map +1 -0
  15. package/dist/cjs/constants/programs.js +78 -0
  16. package/dist/cjs/constants/programs.js.map +1 -0
  17. package/dist/cjs/constants/seeds.js +76 -0
  18. package/dist/cjs/constants/seeds.js.map +1 -0
  19. package/dist/cjs/constants.js +39 -32
  20. package/dist/cjs/constants.js.map +1 -1
  21. package/dist/cjs/core/client.js +546 -0
  22. package/dist/cjs/core/client.js.map +1 -0
  23. package/dist/cjs/core/connection.js +350 -0
  24. package/dist/cjs/core/connection.js.map +1 -0
  25. package/dist/cjs/core/index.js +25 -0
  26. package/dist/cjs/core/index.js.map +1 -0
  27. package/dist/cjs/errors/index.js +334 -0
  28. package/dist/cjs/errors/index.js.map +1 -0
  29. package/dist/cjs/errors.js +15 -5
  30. package/dist/cjs/errors.js.map +1 -1
  31. package/dist/cjs/events/geyser.js +295 -0
  32. package/dist/cjs/events/geyser.js.map +1 -0
  33. package/dist/cjs/events/index.js +32 -26
  34. package/dist/cjs/events/index.js.map +1 -1
  35. package/dist/cjs/idl/index.js +63 -0
  36. package/dist/cjs/idl/index.js.map +1 -0
  37. package/dist/cjs/idl/synapse_agent_sap.json +14595 -0
  38. package/dist/cjs/instructions/agent.js +1 -0
  39. package/dist/cjs/instructions/agent.js.map +1 -1
  40. package/dist/cjs/instructions/attestation.js +1 -0
  41. package/dist/cjs/instructions/attestation.js.map +1 -1
  42. package/dist/cjs/instructions/digest.js +1 -0
  43. package/dist/cjs/instructions/digest.js.map +1 -1
  44. package/dist/cjs/instructions/dispute.js +1 -0
  45. package/dist/cjs/instructions/dispute.js.map +1 -1
  46. package/dist/cjs/instructions/escrow.js +1 -0
  47. package/dist/cjs/instructions/escrow.js.map +1 -1
  48. package/dist/cjs/instructions/global.js +1 -0
  49. package/dist/cjs/instructions/global.js.map +1 -1
  50. package/dist/cjs/instructions/indexing.js +1 -0
  51. package/dist/cjs/instructions/indexing.js.map +1 -1
  52. package/dist/cjs/instructions/misc.js +1 -0
  53. package/dist/cjs/instructions/misc.js.map +1 -1
  54. package/dist/cjs/instructions/session.js +1 -0
  55. package/dist/cjs/instructions/session.js.map +1 -1
  56. package/dist/cjs/instructions/staking.js +1 -0
  57. package/dist/cjs/instructions/staking.js.map +1 -1
  58. package/dist/cjs/instructions/subscription.js +1 -0
  59. package/dist/cjs/instructions/subscription.js.map +1 -1
  60. package/dist/cjs/instructions/tools.js +1 -0
  61. package/dist/cjs/instructions/tools.js.map +1 -1
  62. package/dist/cjs/instructions/vault.js +1 -0
  63. package/dist/cjs/instructions/vault.js.map +1 -1
  64. package/dist/cjs/modules/agent.js +272 -0
  65. package/dist/cjs/modules/agent.js.map +1 -0
  66. package/dist/cjs/modules/attestation.js +147 -0
  67. package/dist/cjs/modules/attestation.js.map +1 -0
  68. package/dist/cjs/modules/base.js +189 -0
  69. package/dist/cjs/modules/base.js.map +1 -0
  70. package/dist/cjs/modules/escrow-v2.js +607 -0
  71. package/dist/cjs/modules/escrow-v2.js.map +1 -0
  72. package/dist/cjs/modules/escrow.js +336 -0
  73. package/dist/cjs/modules/escrow.js.map +1 -0
  74. package/dist/cjs/modules/feedback.js +166 -0
  75. package/dist/cjs/modules/feedback.js.map +1 -0
  76. package/dist/cjs/modules/index.js +43 -0
  77. package/dist/cjs/modules/index.js.map +1 -0
  78. package/dist/cjs/modules/indexing.js +375 -0
  79. package/dist/cjs/modules/indexing.js.map +1 -0
  80. package/dist/cjs/modules/ledger.js +234 -0
  81. package/dist/cjs/modules/ledger.js.map +1 -0
  82. package/dist/cjs/modules/receipt.js +148 -0
  83. package/dist/cjs/modules/receipt.js.map +1 -0
  84. package/dist/cjs/modules/staking.js +159 -0
  85. package/dist/cjs/modules/staking.js.map +1 -0
  86. package/dist/cjs/modules/subscription.js +96 -0
  87. package/dist/cjs/modules/subscription.js.map +1 -0
  88. package/dist/cjs/modules/tools.js +345 -0
  89. package/dist/cjs/modules/tools.js.map +1 -0
  90. package/dist/cjs/modules/vault.js +427 -0
  91. package/dist/cjs/modules/vault.js.map +1 -0
  92. package/dist/cjs/parser/client.js +146 -0
  93. package/dist/cjs/parser/client.js.map +1 -0
  94. package/dist/cjs/parser/complete.js +177 -0
  95. package/dist/cjs/parser/complete.js.map +1 -0
  96. package/dist/cjs/parser/index.js +57 -0
  97. package/dist/cjs/parser/index.js.map +1 -0
  98. package/dist/cjs/parser/inner.js +185 -0
  99. package/dist/cjs/parser/inner.js.map +1 -0
  100. package/dist/cjs/parser/instructions.js +114 -0
  101. package/dist/cjs/parser/instructions.js.map +1 -0
  102. package/dist/cjs/parser/transaction.js +153 -0
  103. package/dist/cjs/parser/transaction.js.map +1 -0
  104. package/dist/cjs/parser/types.js +14 -0
  105. package/dist/cjs/parser/types.js.map +1 -0
  106. package/dist/cjs/pda/index.js +672 -0
  107. package/dist/cjs/pda/index.js.map +1 -0
  108. package/dist/cjs/plugin/index.js +952 -0
  109. package/dist/cjs/plugin/index.js.map +1 -0
  110. package/dist/cjs/plugin/protocols.js +282 -0
  111. package/dist/cjs/plugin/protocols.js.map +1 -0
  112. package/dist/cjs/plugin/schemas.js +863 -0
  113. package/dist/cjs/plugin/schemas.js.map +1 -0
  114. package/dist/cjs/postgres/adapter.js +715 -0
  115. package/dist/cjs/postgres/adapter.js.map +1 -0
  116. package/dist/cjs/postgres/index.js +50 -0
  117. package/dist/cjs/postgres/index.js.map +1 -0
  118. package/dist/cjs/postgres/serializers.js +381 -0
  119. package/dist/cjs/postgres/serializers.js.map +1 -0
  120. package/dist/cjs/postgres/sync.js +289 -0
  121. package/dist/cjs/postgres/sync.js.map +1 -0
  122. package/dist/cjs/postgres/types.js +44 -0
  123. package/dist/cjs/postgres/types.js.map +1 -0
  124. package/dist/cjs/registries/builder.js +414 -0
  125. package/dist/cjs/registries/builder.js.map +1 -0
  126. package/dist/cjs/registries/discovery.js +362 -0
  127. package/dist/cjs/registries/discovery.js.map +1 -0
  128. package/dist/cjs/registries/fairscale.js +639 -0
  129. package/dist/cjs/registries/fairscale.js.map +1 -0
  130. package/dist/cjs/registries/index.js +58 -0
  131. package/dist/cjs/registries/index.js.map +1 -0
  132. package/dist/cjs/registries/metaplex-bridge.js +743 -0
  133. package/dist/cjs/registries/metaplex-bridge.js.map +1 -0
  134. package/dist/cjs/registries/session.js +433 -0
  135. package/dist/cjs/registries/session.js.map +1 -0
  136. package/dist/cjs/registries/x402.js +668 -0
  137. package/dist/cjs/registries/x402.js.map +1 -0
  138. package/dist/cjs/types/accounts.js +13 -0
  139. package/dist/cjs/types/accounts.js.map +1 -0
  140. package/dist/cjs/types/common.js +13 -0
  141. package/dist/cjs/types/common.js.map +1 -0
  142. package/dist/cjs/types/endpoint.js +15 -0
  143. package/dist/cjs/types/endpoint.js.map +1 -0
  144. package/dist/cjs/types/enums.js +269 -0
  145. package/dist/cjs/types/enums.js.map +1 -0
  146. package/dist/cjs/types/index.js +41 -0
  147. package/dist/cjs/types/index.js.map +1 -0
  148. package/dist/cjs/types/instructions.js +92 -0
  149. package/dist/cjs/types/instructions.js.map +1 -0
  150. package/dist/cjs/types.js +4 -1
  151. package/dist/cjs/types.js.map +1 -1
  152. package/dist/cjs/utils/anchor-errors.js +453 -0
  153. package/dist/cjs/utils/anchor-errors.js.map +1 -0
  154. package/dist/cjs/utils/endpoint-validator.js +232 -0
  155. package/dist/cjs/utils/endpoint-validator.js.map +1 -0
  156. package/dist/cjs/utils/escrow-validation.js +219 -0
  157. package/dist/cjs/utils/escrow-validation.js.map +1 -0
  158. package/dist/cjs/utils/hash.js +109 -0
  159. package/dist/cjs/utils/hash.js.map +1 -0
  160. package/dist/cjs/utils/index.js +10 -4
  161. package/dist/cjs/utils/index.js.map +1 -1
  162. package/dist/cjs/utils/merchant-validator.js +246 -0
  163. package/dist/cjs/utils/merchant-validator.js.map +1 -0
  164. package/dist/cjs/utils/network-normalizer.js +236 -0
  165. package/dist/cjs/utils/network-normalizer.js.map +1 -0
  166. package/dist/cjs/utils/priority-fee.js +215 -0
  167. package/dist/cjs/utils/priority-fee.js.map +1 -0
  168. package/dist/cjs/utils/rpc-strategy.js +239 -0
  169. package/dist/cjs/utils/rpc-strategy.js.map +1 -0
  170. package/dist/cjs/utils/schemas.js +331 -0
  171. package/dist/cjs/utils/schemas.js.map +1 -0
  172. package/dist/cjs/utils/serialization.js +105 -0
  173. package/dist/cjs/utils/serialization.js.map +1 -0
  174. package/dist/cjs/utils/validate.js +1 -1
  175. package/dist/cjs/utils/validate.js.map +1 -1
  176. package/dist/cjs/utils/validation.js +36 -0
  177. package/dist/cjs/utils/validation.js.map +1 -0
  178. package/dist/cjs/utils/volume-curve.js +117 -0
  179. package/dist/cjs/utils/volume-curve.js.map +1 -0
  180. package/dist/cjs/utils/x402-direct.js +231 -0
  181. package/dist/cjs/utils/x402-direct.js.map +1 -0
  182. package/dist/esm/client.js +30 -13
  183. package/dist/esm/client.js.map +1 -1
  184. package/dist/esm/constants/addresses.d.ts +117 -0
  185. package/dist/esm/constants/addresses.d.ts.map +1 -0
  186. package/dist/esm/constants/addresses.js +140 -0
  187. package/dist/esm/constants/addresses.js.map +1 -0
  188. package/dist/esm/constants/index.d.ts +31 -0
  189. package/dist/esm/constants/index.d.ts.map +1 -0
  190. package/dist/esm/constants/index.js +35 -0
  191. package/dist/esm/constants/index.js.map +1 -0
  192. package/dist/esm/constants/limits.d.ts +149 -0
  193. package/dist/esm/constants/limits.d.ts.map +1 -0
  194. package/dist/esm/constants/limits.js +158 -0
  195. package/dist/esm/constants/limits.js.map +1 -0
  196. package/dist/esm/constants/network.d.ts +81 -0
  197. package/dist/esm/constants/network.d.ts.map +1 -0
  198. package/dist/esm/constants/network.js +78 -0
  199. package/dist/esm/constants/network.js.map +1 -0
  200. package/dist/esm/constants/payments.d.ts +121 -0
  201. package/dist/esm/constants/payments.d.ts.map +1 -0
  202. package/dist/esm/constants/payments.js +131 -0
  203. package/dist/esm/constants/payments.js.map +1 -0
  204. package/dist/esm/constants/programs.d.ts +69 -0
  205. package/dist/esm/constants/programs.d.ts.map +1 -0
  206. package/dist/esm/constants/programs.js +75 -0
  207. package/dist/esm/constants/programs.js.map +1 -0
  208. package/dist/esm/constants/seeds.d.ts +80 -0
  209. package/dist/esm/constants/seeds.d.ts.map +1 -0
  210. package/dist/esm/constants/seeds.js +73 -0
  211. package/dist/esm/constants/seeds.js.map +1 -0
  212. package/dist/esm/constants.d.ts +14 -27
  213. package/dist/esm/constants.d.ts.map +1 -1
  214. package/dist/esm/constants.js +16 -31
  215. package/dist/esm/constants.js.map +1 -1
  216. package/dist/esm/core/client.d.ts +452 -0
  217. package/dist/esm/core/client.d.ts.map +1 -0
  218. package/dist/esm/core/client.js +539 -0
  219. package/dist/esm/core/client.js.map +1 -0
  220. package/dist/esm/core/connection.d.ts +305 -0
  221. package/dist/esm/core/connection.d.ts.map +1 -0
  222. package/dist/esm/core/connection.js +345 -0
  223. package/dist/esm/core/connection.js.map +1 -0
  224. package/dist/esm/core/index.d.ts +20 -0
  225. package/dist/esm/core/index.d.ts.map +1 -0
  226. package/dist/esm/core/index.js +19 -0
  227. package/dist/esm/core/index.js.map +1 -0
  228. package/dist/esm/errors/index.d.ts +276 -0
  229. package/dist/esm/errors/index.d.ts.map +1 -0
  230. package/dist/esm/errors/index.js +325 -0
  231. package/dist/esm/errors/index.js.map +1 -0
  232. package/dist/esm/errors.d.ts +8 -0
  233. package/dist/esm/errors.d.ts.map +1 -1
  234. package/dist/esm/errors.js +8 -0
  235. package/dist/esm/errors.js.map +1 -1
  236. package/dist/esm/events/geyser.d.ts +150 -0
  237. package/dist/esm/events/geyser.d.ts.map +1 -0
  238. package/dist/esm/events/geyser.js +258 -0
  239. package/dist/esm/events/geyser.js.map +1 -0
  240. package/dist/esm/events/index.d.ts +11 -7
  241. package/dist/esm/events/index.d.ts.map +1 -1
  242. package/dist/esm/events/index.js +30 -26
  243. package/dist/esm/events/index.js.map +1 -1
  244. package/dist/esm/idl/index.d.ts +70 -0
  245. package/dist/esm/idl/index.d.ts.map +1 -0
  246. package/dist/esm/idl/index.js +57 -0
  247. package/dist/esm/idl/index.js.map +1 -0
  248. package/dist/esm/idl/synapse_agent_sap.json +14595 -0
  249. package/dist/esm/instructions/agent.js +1 -0
  250. package/dist/esm/instructions/agent.js.map +1 -1
  251. package/dist/esm/instructions/attestation.js +1 -0
  252. package/dist/esm/instructions/attestation.js.map +1 -1
  253. package/dist/esm/instructions/digest.js +1 -0
  254. package/dist/esm/instructions/digest.js.map +1 -1
  255. package/dist/esm/instructions/dispute.js +1 -0
  256. package/dist/esm/instructions/dispute.js.map +1 -1
  257. package/dist/esm/instructions/escrow.js +1 -0
  258. package/dist/esm/instructions/escrow.js.map +1 -1
  259. package/dist/esm/instructions/global.js +1 -0
  260. package/dist/esm/instructions/global.js.map +1 -1
  261. package/dist/esm/instructions/indexing.js +1 -0
  262. package/dist/esm/instructions/indexing.js.map +1 -1
  263. package/dist/esm/instructions/misc.js +1 -0
  264. package/dist/esm/instructions/misc.js.map +1 -1
  265. package/dist/esm/instructions/session.js +1 -0
  266. package/dist/esm/instructions/session.js.map +1 -1
  267. package/dist/esm/instructions/staking.js +1 -0
  268. package/dist/esm/instructions/staking.js.map +1 -1
  269. package/dist/esm/instructions/subscription.js +1 -0
  270. package/dist/esm/instructions/subscription.js.map +1 -1
  271. package/dist/esm/instructions/tools.js +1 -0
  272. package/dist/esm/instructions/tools.js.map +1 -1
  273. package/dist/esm/instructions/vault.js +1 -0
  274. package/dist/esm/instructions/vault.js.map +1 -1
  275. package/dist/esm/modules/agent.d.ts +166 -0
  276. package/dist/esm/modules/agent.d.ts.map +1 -0
  277. package/dist/esm/modules/agent.js +268 -0
  278. package/dist/esm/modules/agent.js.map +1 -0
  279. package/dist/esm/modules/attestation.d.ts +96 -0
  280. package/dist/esm/modules/attestation.d.ts.map +1 -0
  281. package/dist/esm/modules/attestation.js +143 -0
  282. package/dist/esm/modules/attestation.js.map +1 -0
  283. package/dist/esm/modules/base.d.ts +161 -0
  284. package/dist/esm/modules/base.d.ts.map +1 -0
  285. package/dist/esm/modules/base.js +185 -0
  286. package/dist/esm/modules/base.js.map +1 -0
  287. package/dist/esm/modules/escrow-v2.d.ts +169 -0
  288. package/dist/esm/modules/escrow-v2.d.ts.map +1 -0
  289. package/dist/esm/modules/escrow-v2.js +603 -0
  290. package/dist/esm/modules/escrow-v2.js.map +1 -0
  291. package/dist/esm/modules/escrow.d.ts +168 -0
  292. package/dist/esm/modules/escrow.d.ts.map +1 -0
  293. package/dist/esm/modules/escrow.js +332 -0
  294. package/dist/esm/modules/escrow.js.map +1 -0
  295. package/dist/esm/modules/feedback.d.ts +105 -0
  296. package/dist/esm/modules/feedback.d.ts.map +1 -0
  297. package/dist/esm/modules/feedback.js +162 -0
  298. package/dist/esm/modules/feedback.js.map +1 -0
  299. package/dist/esm/modules/index.d.ts +28 -0
  300. package/dist/esm/modules/index.d.ts.map +1 -0
  301. package/dist/esm/modules/index.js +27 -0
  302. package/dist/esm/modules/index.js.map +1 -0
  303. package/dist/esm/modules/indexing.d.ts +200 -0
  304. package/dist/esm/modules/indexing.d.ts.map +1 -0
  305. package/dist/esm/modules/indexing.js +371 -0
  306. package/dist/esm/modules/indexing.js.map +1 -0
  307. package/dist/esm/modules/ledger.d.ts +150 -0
  308. package/dist/esm/modules/ledger.d.ts.map +1 -0
  309. package/dist/esm/modules/ledger.js +230 -0
  310. package/dist/esm/modules/ledger.js.map +1 -0
  311. package/dist/esm/modules/receipt.d.ts +77 -0
  312. package/dist/esm/modules/receipt.d.ts.map +1 -0
  313. package/dist/esm/modules/receipt.js +144 -0
  314. package/dist/esm/modules/receipt.js.map +1 -0
  315. package/dist/esm/modules/staking.d.ts +51 -0
  316. package/dist/esm/modules/staking.d.ts.map +1 -0
  317. package/dist/esm/modules/staking.js +155 -0
  318. package/dist/esm/modules/staking.js.map +1 -0
  319. package/dist/esm/modules/subscription.d.ts +33 -0
  320. package/dist/esm/modules/subscription.d.ts.map +1 -0
  321. package/dist/esm/modules/subscription.js +92 -0
  322. package/dist/esm/modules/subscription.js.map +1 -0
  323. package/dist/esm/modules/tools.d.ts +182 -0
  324. package/dist/esm/modules/tools.d.ts.map +1 -0
  325. package/dist/esm/modules/tools.js +341 -0
  326. package/dist/esm/modules/tools.js.map +1 -0
  327. package/dist/esm/modules/vault.d.ts +240 -0
  328. package/dist/esm/modules/vault.d.ts.map +1 -0
  329. package/dist/esm/modules/vault.js +423 -0
  330. package/dist/esm/modules/vault.js.map +1 -0
  331. package/dist/esm/parser/client.d.ts +123 -0
  332. package/dist/esm/parser/client.d.ts.map +1 -0
  333. package/dist/esm/parser/client.js +142 -0
  334. package/dist/esm/parser/client.js.map +1 -0
  335. package/dist/esm/parser/complete.d.ts +90 -0
  336. package/dist/esm/parser/complete.d.ts.map +1 -0
  337. package/dist/esm/parser/complete.js +173 -0
  338. package/dist/esm/parser/complete.js.map +1 -0
  339. package/dist/esm/parser/index.d.ts +40 -0
  340. package/dist/esm/parser/index.d.ts.map +1 -0
  341. package/dist/esm/parser/index.js +43 -0
  342. package/dist/esm/parser/index.js.map +1 -0
  343. package/dist/esm/parser/inner.d.ts +114 -0
  344. package/dist/esm/parser/inner.d.ts.map +1 -0
  345. package/dist/esm/parser/inner.js +180 -0
  346. package/dist/esm/parser/inner.js.map +1 -0
  347. package/dist/esm/parser/instructions.d.ts +76 -0
  348. package/dist/esm/parser/instructions.d.ts.map +1 -0
  349. package/dist/esm/parser/instructions.js +109 -0
  350. package/dist/esm/parser/instructions.js.map +1 -0
  351. package/dist/esm/parser/transaction.d.ts +77 -0
  352. package/dist/esm/parser/transaction.d.ts.map +1 -0
  353. package/dist/esm/parser/transaction.js +149 -0
  354. package/dist/esm/parser/transaction.js.map +1 -0
  355. package/dist/esm/parser/types.d.ts +154 -0
  356. package/dist/esm/parser/types.d.ts.map +1 -0
  357. package/dist/esm/parser/types.js +13 -0
  358. package/dist/esm/parser/types.js.map +1 -0
  359. package/dist/esm/pda/index.d.ts +510 -0
  360. package/dist/esm/pda/index.d.ts.map +1 -0
  361. package/dist/esm/pda/index.js +638 -0
  362. package/dist/esm/pda/index.js.map +1 -0
  363. package/dist/esm/plugin/index.d.ts +171 -0
  364. package/dist/esm/plugin/index.d.ts.map +1 -0
  365. package/dist/esm/plugin/index.js +945 -0
  366. package/dist/esm/plugin/index.js.map +1 -0
  367. package/dist/esm/plugin/protocols.d.ts +152 -0
  368. package/dist/esm/plugin/protocols.d.ts.map +1 -0
  369. package/dist/esm/plugin/protocols.js +279 -0
  370. package/dist/esm/plugin/protocols.js.map +1 -0
  371. package/dist/esm/plugin/schemas.d.ts +829 -0
  372. package/dist/esm/plugin/schemas.d.ts.map +1 -0
  373. package/dist/esm/plugin/schemas.js +860 -0
  374. package/dist/esm/plugin/schemas.js.map +1 -0
  375. package/dist/esm/postgres/adapter.d.ts +355 -0
  376. package/dist/esm/postgres/adapter.d.ts.map +1 -0
  377. package/dist/esm/postgres/adapter.js +678 -0
  378. package/dist/esm/postgres/adapter.js.map +1 -0
  379. package/dist/esm/postgres/index.d.ts +24 -0
  380. package/dist/esm/postgres/index.d.ts.map +1 -0
  381. package/dist/esm/postgres/index.js +27 -0
  382. package/dist/esm/postgres/index.js.map +1 -0
  383. package/dist/esm/postgres/serializers.d.ts +30 -0
  384. package/dist/esm/postgres/serializers.d.ts.map +1 -0
  385. package/dist/esm/postgres/serializers.js +362 -0
  386. package/dist/esm/postgres/serializers.js.map +1 -0
  387. package/dist/esm/postgres/sync.d.ts +156 -0
  388. package/dist/esm/postgres/sync.d.ts.map +1 -0
  389. package/dist/esm/postgres/sync.js +285 -0
  390. package/dist/esm/postgres/sync.js.map +1 -0
  391. package/dist/esm/postgres/types.d.ts +167 -0
  392. package/dist/esm/postgres/types.d.ts.map +1 -0
  393. package/dist/esm/postgres/types.js +41 -0
  394. package/dist/esm/postgres/types.js.map +1 -0
  395. package/dist/esm/registries/builder.d.ts +340 -0
  396. package/dist/esm/registries/builder.d.ts.map +1 -0
  397. package/dist/esm/registries/builder.js +410 -0
  398. package/dist/esm/registries/builder.js.map +1 -0
  399. package/dist/esm/registries/discovery.d.ts +333 -0
  400. package/dist/esm/registries/discovery.d.ts.map +1 -0
  401. package/dist/esm/registries/discovery.js +358 -0
  402. package/dist/esm/registries/discovery.js.map +1 -0
  403. package/dist/esm/registries/fairscale.d.ts +680 -0
  404. package/dist/esm/registries/fairscale.d.ts.map +1 -0
  405. package/dist/esm/registries/fairscale.js +633 -0
  406. package/dist/esm/registries/fairscale.js.map +1 -0
  407. package/dist/esm/registries/index.d.ts +52 -0
  408. package/dist/esm/registries/index.d.ts.map +1 -0
  409. package/dist/esm/registries/index.js +46 -0
  410. package/dist/esm/registries/index.js.map +1 -0
  411. package/dist/esm/registries/metaplex-bridge.d.ts +489 -0
  412. package/dist/esm/registries/metaplex-bridge.d.ts.map +1 -0
  413. package/dist/esm/registries/metaplex-bridge.js +706 -0
  414. package/dist/esm/registries/metaplex-bridge.js.map +1 -0
  415. package/dist/esm/registries/session.d.ts +323 -0
  416. package/dist/esm/registries/session.d.ts.map +1 -0
  417. package/dist/esm/registries/session.js +429 -0
  418. package/dist/esm/registries/session.js.map +1 -0
  419. package/dist/esm/registries/x402.d.ts +530 -0
  420. package/dist/esm/registries/x402.d.ts.map +1 -0
  421. package/dist/esm/registries/x402.js +664 -0
  422. package/dist/esm/registries/x402.js.map +1 -0
  423. package/dist/esm/types/accounts.d.ts +765 -0
  424. package/dist/esm/types/accounts.d.ts.map +1 -0
  425. package/dist/esm/types/accounts.js +12 -0
  426. package/dist/esm/types/accounts.js.map +1 -0
  427. package/dist/esm/types/common.d.ts +166 -0
  428. package/dist/esm/types/common.d.ts.map +1 -0
  429. package/dist/esm/types/common.js +12 -0
  430. package/dist/esm/types/common.js.map +1 -0
  431. package/dist/esm/types/endpoint.d.ts +161 -0
  432. package/dist/esm/types/endpoint.d.ts.map +1 -0
  433. package/dist/esm/types/endpoint.js +14 -0
  434. package/dist/esm/types/endpoint.js.map +1 -0
  435. package/dist/esm/types/enums.d.ts +353 -0
  436. package/dist/esm/types/enums.d.ts.map +1 -0
  437. package/dist/esm/types/enums.js +266 -0
  438. package/dist/esm/types/enums.js.map +1 -0
  439. package/dist/esm/types/index.d.ts +29 -0
  440. package/dist/esm/types/index.d.ts.map +1 -0
  441. package/dist/esm/types/index.js +25 -0
  442. package/dist/esm/types/index.js.map +1 -0
  443. package/dist/esm/types/instructions.d.ts +400 -0
  444. package/dist/esm/types/instructions.d.ts.map +1 -0
  445. package/dist/esm/types/instructions.js +89 -0
  446. package/dist/esm/types/instructions.js.map +1 -0
  447. package/dist/esm/types.d.ts +28 -0
  448. package/dist/esm/types.d.ts.map +1 -1
  449. package/dist/esm/types.js +1 -0
  450. package/dist/esm/types.js.map +1 -1
  451. package/dist/esm/utils/anchor-errors.d.ts +61 -0
  452. package/dist/esm/utils/anchor-errors.d.ts.map +1 -0
  453. package/dist/esm/utils/anchor-errors.js +447 -0
  454. package/dist/esm/utils/anchor-errors.js.map +1 -0
  455. package/dist/esm/utils/endpoint-validator.d.ts +110 -0
  456. package/dist/esm/utils/endpoint-validator.d.ts.map +1 -0
  457. package/dist/esm/utils/endpoint-validator.js +226 -0
  458. package/dist/esm/utils/endpoint-validator.js.map +1 -0
  459. package/dist/esm/utils/escrow-validation.d.ts +145 -0
  460. package/dist/esm/utils/escrow-validation.d.ts.map +1 -0
  461. package/dist/esm/utils/escrow-validation.js +212 -0
  462. package/dist/esm/utils/escrow-validation.js.map +1 -0
  463. package/dist/esm/utils/hash.d.ts +75 -0
  464. package/dist/esm/utils/hash.d.ts.map +1 -0
  465. package/dist/esm/utils/hash.js +103 -0
  466. package/dist/esm/utils/hash.js.map +1 -0
  467. package/dist/esm/utils/index.d.ts +3 -1
  468. package/dist/esm/utils/index.d.ts.map +1 -1
  469. package/dist/esm/utils/index.js +6 -3
  470. package/dist/esm/utils/index.js.map +1 -1
  471. package/dist/esm/utils/merchant-validator.d.ts +176 -0
  472. package/dist/esm/utils/merchant-validator.d.ts.map +1 -0
  473. package/dist/esm/utils/merchant-validator.js +241 -0
  474. package/dist/esm/utils/merchant-validator.js.map +1 -0
  475. package/dist/esm/utils/network-normalizer.d.ts +120 -0
  476. package/dist/esm/utils/network-normalizer.d.ts.map +1 -0
  477. package/dist/esm/utils/network-normalizer.js +229 -0
  478. package/dist/esm/utils/network-normalizer.js.map +1 -0
  479. package/dist/esm/utils/priority-fee.d.ts +205 -0
  480. package/dist/esm/utils/priority-fee.d.ts.map +1 -0
  481. package/dist/esm/utils/priority-fee.js +209 -0
  482. package/dist/esm/utils/priority-fee.js.map +1 -0
  483. package/dist/esm/utils/rpc-strategy.d.ts +172 -0
  484. package/dist/esm/utils/rpc-strategy.d.ts.map +1 -0
  485. package/dist/esm/utils/rpc-strategy.js +231 -0
  486. package/dist/esm/utils/rpc-strategy.js.map +1 -0
  487. package/dist/esm/utils/schemas.d.ts +351 -0
  488. package/dist/esm/utils/schemas.d.ts.map +1 -0
  489. package/dist/esm/utils/schemas.js +320 -0
  490. package/dist/esm/utils/schemas.js.map +1 -0
  491. package/dist/esm/utils/serialization.d.ts +69 -0
  492. package/dist/esm/utils/serialization.d.ts.map +1 -0
  493. package/dist/esm/utils/serialization.js +98 -0
  494. package/dist/esm/utils/serialization.js.map +1 -0
  495. package/dist/esm/utils/validate.js +1 -1
  496. package/dist/esm/utils/validate.js.map +1 -1
  497. package/dist/esm/utils/validation.d.ts +29 -0
  498. package/dist/esm/utils/validation.d.ts.map +1 -0
  499. package/dist/esm/utils/validation.js +33 -0
  500. package/dist/esm/utils/validation.js.map +1 -0
  501. package/dist/esm/utils/volume-curve.d.ts +60 -0
  502. package/dist/esm/utils/volume-curve.d.ts.map +1 -0
  503. package/dist/esm/utils/volume-curve.js +114 -0
  504. package/dist/esm/utils/volume-curve.js.map +1 -0
  505. package/dist/esm/utils/x402-direct.d.ts +114 -0
  506. package/dist/esm/utils/x402-direct.d.ts.map +1 -0
  507. package/dist/esm/utils/x402-direct.js +228 -0
  508. package/dist/esm/utils/x402-direct.js.map +1 -0
  509. package/dist/types/constants/addresses.d.ts +117 -0
  510. package/dist/types/constants/addresses.d.ts.map +1 -0
  511. package/dist/types/constants/index.d.ts +31 -0
  512. package/dist/types/constants/index.d.ts.map +1 -0
  513. package/dist/types/constants/limits.d.ts +149 -0
  514. package/dist/types/constants/limits.d.ts.map +1 -0
  515. package/dist/types/constants/network.d.ts +81 -0
  516. package/dist/types/constants/network.d.ts.map +1 -0
  517. package/dist/types/constants/payments.d.ts +121 -0
  518. package/dist/types/constants/payments.d.ts.map +1 -0
  519. package/dist/types/constants/programs.d.ts +69 -0
  520. package/dist/types/constants/programs.d.ts.map +1 -0
  521. package/dist/types/constants/seeds.d.ts +82 -0
  522. package/dist/types/constants/seeds.d.ts.map +1 -0
  523. package/dist/types/core/client.d.ts +467 -0
  524. package/dist/types/core/client.d.ts.map +1 -0
  525. package/dist/types/core/connection.d.ts +305 -0
  526. package/dist/types/core/connection.d.ts.map +1 -0
  527. package/dist/types/core/index.d.ts +20 -0
  528. package/dist/types/core/index.d.ts.map +1 -0
  529. package/dist/types/errors/index.d.ts +335 -0
  530. package/dist/types/errors/index.d.ts.map +1 -0
  531. package/dist/types/events/geyser.d.ts +150 -0
  532. package/dist/types/events/geyser.d.ts.map +1 -0
  533. package/dist/types/events/index.d.ts +248 -0
  534. package/dist/types/events/index.d.ts.map +1 -0
  535. package/dist/types/idl/index.d.ts +70 -0
  536. package/dist/types/idl/index.d.ts.map +1 -0
  537. package/dist/types/index.d.ts +86 -0
  538. package/dist/types/index.d.ts.map +1 -0
  539. package/dist/types/modules/agent.d.ts +156 -0
  540. package/dist/types/modules/agent.d.ts.map +1 -0
  541. package/dist/types/modules/attestation.d.ts +96 -0
  542. package/dist/types/modules/attestation.d.ts.map +1 -0
  543. package/dist/types/modules/base.d.ts +215 -0
  544. package/dist/types/modules/base.d.ts.map +1 -0
  545. package/dist/types/modules/escrow-v2.d.ts +285 -0
  546. package/dist/types/modules/escrow-v2.d.ts.map +1 -0
  547. package/dist/types/modules/feedback.d.ts +105 -0
  548. package/dist/types/modules/feedback.d.ts.map +1 -0
  549. package/dist/types/modules/index.d.ts +27 -0
  550. package/dist/types/modules/index.d.ts.map +1 -0
  551. package/dist/types/modules/indexing.d.ts +200 -0
  552. package/dist/types/modules/indexing.d.ts.map +1 -0
  553. package/dist/types/modules/ledger.d.ts +150 -0
  554. package/dist/types/modules/ledger.d.ts.map +1 -0
  555. package/dist/types/modules/receipt.d.ts +91 -0
  556. package/dist/types/modules/receipt.d.ts.map +1 -0
  557. package/dist/types/modules/staking.d.ts +51 -0
  558. package/dist/types/modules/staking.d.ts.map +1 -0
  559. package/dist/types/modules/subscription.d.ts +33 -0
  560. package/dist/types/modules/subscription.d.ts.map +1 -0
  561. package/dist/types/modules/tools.d.ts +172 -0
  562. package/dist/types/modules/tools.d.ts.map +1 -0
  563. package/dist/types/modules/vault.d.ts +240 -0
  564. package/dist/types/modules/vault.d.ts.map +1 -0
  565. package/dist/types/parser/client.d.ts +123 -0
  566. package/dist/types/parser/client.d.ts.map +1 -0
  567. package/dist/types/parser/complete.d.ts +90 -0
  568. package/dist/types/parser/complete.d.ts.map +1 -0
  569. package/dist/types/parser/index.d.ts +40 -0
  570. package/dist/types/parser/index.d.ts.map +1 -0
  571. package/dist/types/parser/inner.d.ts +114 -0
  572. package/dist/types/parser/inner.d.ts.map +1 -0
  573. package/dist/types/parser/instructions.d.ts +76 -0
  574. package/dist/types/parser/instructions.d.ts.map +1 -0
  575. package/dist/types/parser/transaction.d.ts +77 -0
  576. package/dist/types/parser/transaction.d.ts.map +1 -0
  577. package/dist/types/parser/types.d.ts +154 -0
  578. package/dist/types/parser/types.d.ts.map +1 -0
  579. package/dist/types/pda/index.d.ts +527 -0
  580. package/dist/types/pda/index.d.ts.map +1 -0
  581. package/dist/types/plugin/index.d.ts +171 -0
  582. package/dist/types/plugin/index.d.ts.map +1 -0
  583. package/dist/types/plugin/protocols.d.ts +152 -0
  584. package/dist/types/plugin/protocols.d.ts.map +1 -0
  585. package/dist/types/plugin/schemas.d.ts +829 -0
  586. package/dist/types/plugin/schemas.d.ts.map +1 -0
  587. package/dist/types/postgres/adapter.d.ts +355 -0
  588. package/dist/types/postgres/adapter.d.ts.map +1 -0
  589. package/dist/types/postgres/index.d.ts +24 -0
  590. package/dist/types/postgres/index.d.ts.map +1 -0
  591. package/dist/types/postgres/serializers.d.ts +30 -0
  592. package/dist/types/postgres/serializers.d.ts.map +1 -0
  593. package/dist/types/postgres/sync.d.ts +156 -0
  594. package/dist/types/postgres/sync.d.ts.map +1 -0
  595. package/dist/types/postgres/types.d.ts +167 -0
  596. package/dist/types/postgres/types.d.ts.map +1 -0
  597. package/dist/types/registries/builder.d.ts +333 -0
  598. package/dist/types/registries/builder.d.ts.map +1 -0
  599. package/dist/types/registries/discovery.d.ts +333 -0
  600. package/dist/types/registries/discovery.d.ts.map +1 -0
  601. package/dist/types/registries/fairscale.d.ts +680 -0
  602. package/dist/types/registries/fairscale.d.ts.map +1 -0
  603. package/dist/types/registries/index.d.ts +52 -0
  604. package/dist/types/registries/index.d.ts.map +1 -0
  605. package/dist/types/registries/metaplex-bridge.d.ts +488 -0
  606. package/dist/types/registries/metaplex-bridge.d.ts.map +1 -0
  607. package/dist/types/registries/session.d.ts +317 -0
  608. package/dist/types/registries/session.d.ts.map +1 -0
  609. package/dist/types/registries/x402.d.ts +523 -0
  610. package/dist/types/registries/x402.d.ts.map +1 -0
  611. package/dist/types/types/accounts.d.ts +817 -0
  612. package/dist/types/types/accounts.d.ts.map +1 -0
  613. package/dist/types/types/common.d.ts +166 -0
  614. package/dist/types/types/common.d.ts.map +1 -0
  615. package/dist/types/types/endpoint.d.ts +161 -0
  616. package/dist/types/types/endpoint.d.ts.map +1 -0
  617. package/dist/types/types/enums.d.ts +353 -0
  618. package/dist/types/types/enums.d.ts.map +1 -0
  619. package/dist/types/types/index.d.ts +29 -0
  620. package/dist/types/types/index.d.ts.map +1 -0
  621. package/dist/types/types/instructions.d.ts +400 -0
  622. package/dist/types/types/instructions.d.ts.map +1 -0
  623. package/dist/types/utils/anchor-errors.d.ts +61 -0
  624. package/dist/types/utils/anchor-errors.d.ts.map +1 -0
  625. package/dist/types/utils/endpoint-validator.d.ts +110 -0
  626. package/dist/types/utils/endpoint-validator.d.ts.map +1 -0
  627. package/dist/types/utils/escrow-validation.d.ts +145 -0
  628. package/dist/types/utils/escrow-validation.d.ts.map +1 -0
  629. package/dist/types/utils/hash.d.ts +75 -0
  630. package/dist/types/utils/hash.d.ts.map +1 -0
  631. package/dist/types/utils/index.d.ts +36 -0
  632. package/dist/types/utils/index.d.ts.map +1 -0
  633. package/dist/types/utils/merchant-validator.d.ts +176 -0
  634. package/dist/types/utils/merchant-validator.d.ts.map +1 -0
  635. package/dist/types/utils/network-normalizer.d.ts +120 -0
  636. package/dist/types/utils/network-normalizer.d.ts.map +1 -0
  637. package/dist/types/utils/priority-fee.d.ts +205 -0
  638. package/dist/types/utils/priority-fee.d.ts.map +1 -0
  639. package/dist/types/utils/rpc-strategy.d.ts +179 -0
  640. package/dist/types/utils/rpc-strategy.d.ts.map +1 -0
  641. package/dist/types/utils/schemas.d.ts +351 -0
  642. package/dist/types/utils/schemas.d.ts.map +1 -0
  643. package/dist/types/utils/serialization.d.ts +69 -0
  644. package/dist/types/utils/serialization.d.ts.map +1 -0
  645. package/dist/types/utils/validation.d.ts +29 -0
  646. package/dist/types/utils/validation.d.ts.map +1 -0
  647. package/dist/types/utils/volume-curve.d.ts +60 -0
  648. package/dist/types/utils/volume-curve.d.ts.map +1 -0
  649. package/dist/types/utils/x402-direct.d.ts +114 -0
  650. package/dist/types/utils/x402-direct.d.ts.map +1 -0
  651. package/package.json +2 -2
@@ -0,0 +1,743 @@
1
+ "use strict";
2
+ /**
3
+ * @module registries/metaplex-bridge
4
+ * @description Bridge between Synapse Agent Protocol (SAP) and Metaplex
5
+ * Core's `AgentIdentity` external plugin adapter (mpl-core ≥ 1.9.0).
6
+ *
7
+ * ## Why this design (verified against mpl-core PR #258, v1.9.0)
8
+ *
9
+ * The MPL Core `AgentIdentity` plugin has exactly one field:
10
+ *
11
+ * ```ts
12
+ * type AgentIdentity = { uri: string };
13
+ * ```
14
+ *
15
+ * The URI must point to an **EIP-8004** agent registration JSON. There is
16
+ * no on-chain executive list, no `addExecutive` / `delegateExecutionV1`
17
+ * instruction. Capabilities, services, executives, and reputation live
18
+ * off-chain in that JSON. The plugin only hooks the `Execute` lifecycle
19
+ * event, allowing the URI's authority to gate execution.
20
+ *
21
+ * The most efficient SAP × MPL integration therefore is:
22
+ *
23
+ * 1. SAP serves a **live EIP-8004 JSON** at a deterministic URL derived
24
+ * from the SAP `AgentAccount` PDA (e.g.
25
+ * `https://explorer.oobeprotocol.ai/agents/<sapAgentPda>/eip-8004.json`).
26
+ * 2. The MPL Core asset attaches an `AgentIdentity` adapter whose `uri`
27
+ * points to that URL.
28
+ * 3. Every SAP write (capability change, vault delegate add/revoke, x402
29
+ * tier update) is reflected in the JSON automatically — **no second
30
+ * transaction required, on either chain or for any wallet.**
31
+ *
32
+ * One SAP transaction = both protocols updated. That is the efficiency
33
+ * win that motivated the Phase 1 redesign on 2026-04-22.
34
+ *
35
+ * @category Registries
36
+ * @since v0.9.0
37
+ * @see https://github.com/metaplex-foundation/mpl-core/pull/258
38
+ * @see https://eips.ethereum.org/EIPS/eip-8004
39
+ */
40
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
41
+ if (k2 === undefined) k2 = k;
42
+ var desc = Object.getOwnPropertyDescriptor(m, k);
43
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
44
+ desc = { enumerable: true, get: function() { return m[k]; } };
45
+ }
46
+ Object.defineProperty(o, k2, desc);
47
+ }) : (function(o, m, k, k2) {
48
+ if (k2 === undefined) k2 = k;
49
+ o[k2] = m[k];
50
+ }));
51
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
52
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
53
+ }) : function(o, v) {
54
+ o["default"] = v;
55
+ });
56
+ var __importStar = (this && this.__importStar) || (function () {
57
+ var ownKeys = function(o) {
58
+ ownKeys = Object.getOwnPropertyNames || function (o) {
59
+ var ar = [];
60
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
61
+ return ar;
62
+ };
63
+ return ownKeys(o);
64
+ };
65
+ return function (mod) {
66
+ if (mod && mod.__esModule) return mod;
67
+ var result = {};
68
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
69
+ __setModuleDefault(result, mod);
70
+ return result;
71
+ };
72
+ })();
73
+ Object.defineProperty(exports, "__esModule", { value: true });
74
+ exports.MetaplexBridge = void 0;
75
+ const web3_js_1 = require("@solana/web3.js");
76
+ const pda_1 = require("../pda");
77
+ // ═══════════════════════════════════════════════════════════════════
78
+ // Lazy peer-dep loader
79
+ // ═══════════════════════════════════════════════════════════════════
80
+ const PEER_DEP_INSTALL_HINT = "MetaplexBridge requires @metaplex-foundation/mpl-core (>=1.9.0) and " +
81
+ "@metaplex-foundation/umi-bundle-defaults. " +
82
+ "Install: npm i @metaplex-foundation/mpl-core @metaplex-foundation/umi-bundle-defaults";
83
+ let cachedRuntime = null;
84
+ async function loadMplCore() {
85
+ if (cachedRuntime)
86
+ return cachedRuntime;
87
+ try {
88
+ const [mplCore, umiBundle, umiCore] = await Promise.all([
89
+ Promise.resolve().then(() => __importStar(require("@metaplex-foundation/mpl-core"))),
90
+ Promise.resolve().then(() => __importStar(require("@metaplex-foundation/umi-bundle-defaults"))),
91
+ Promise.resolve().then(() => __importStar(require("@metaplex-foundation/umi"))),
92
+ ]);
93
+ cachedRuntime = { mplCore, umiBundle, umiCore };
94
+ return cachedRuntime;
95
+ }
96
+ catch (cause) {
97
+ throw Object.assign(new Error(PEER_DEP_INSTALL_HINT), { cause });
98
+ }
99
+ }
100
+ // ═══════════════════════════════════════════════════════════════════
101
+ // MetaplexBridge
102
+ // ═══════════════════════════════════════════════════════════════════
103
+ /**
104
+ * @name MetaplexBridge
105
+ * @description Read-side merger and write-side instruction composer for
106
+ * SAP × Metaplex Core `AgentIdentity` integration.
107
+ *
108
+ * Linking is **single-transaction**: the MPL `addExternalPluginAdapterV1`
109
+ * instruction sets a URI that points at SAP's live registration host.
110
+ * Subsequent SAP state changes propagate automatically — no extra MPL
111
+ * transaction required.
112
+ *
113
+ * @category Registries
114
+ * @since v0.9.0
115
+ */
116
+ class MetaplexBridge {
117
+ program;
118
+ constructor(program) {
119
+ this.program = program;
120
+ }
121
+ // ─────────────────────────────────────────────────────
122
+ // Pure helpers
123
+ // ─────────────────────────────────────────────────────
124
+ /**
125
+ * @name deriveRegistrationUrl
126
+ * @description Compute the deterministic EIP-8004 registration URL for
127
+ * a SAP agent. Hosts MUST serve the JSON at exactly this path so that
128
+ * {@link MetaplexBridge.verifyLink} validates without external config.
129
+ *
130
+ * @since v0.9.0
131
+ */
132
+ deriveRegistrationUrl(sapAgentPda, baseUrl) {
133
+ const trimmed = baseUrl.replace(/\/+$/, "");
134
+ return `${trimmed}/agents/${sapAgentPda.toBase58()}/eip-8004.json`;
135
+ }
136
+ /**
137
+ * @name buildEip8004Registration
138
+ * @description Build a canonical EIP-8004 JSON document for a SAP agent.
139
+ * Designed to be called server-side by a registry host.
140
+ *
141
+ * @since v0.9.0
142
+ */
143
+ async buildEip8004Registration(args) {
144
+ const [sapPda] = (0, pda_1.deriveAgent)(args.sapAgentOwner);
145
+ const identity = await this.fetchAgentNullable(sapPda);
146
+ if (!identity) {
147
+ throw new Error(`buildEip8004Registration: SAP agent not found for owner ${args.sapAgentOwner.toBase58()}`);
148
+ }
149
+ const delegates = await this.fetchActiveVaultDelegates(sapPda);
150
+ return {
151
+ version: "0.1",
152
+ name: this.readString(identity, "name") ?? "Synapse Agent",
153
+ description: this.readString(identity, "description") ?? undefined,
154
+ synapseAgent: sapPda.toBase58(),
155
+ authority: args.sapAgentOwner.toBase58(),
156
+ capabilities: this.readCapabilities(identity),
157
+ services: args.services ?? [],
158
+ executives: delegates,
159
+ updatedAt: new Date().toISOString(),
160
+ extra: args.extra,
161
+ };
162
+ }
163
+ // ─────────────────────────────────────────────────────
164
+ // Write side — build MPL instructions only
165
+ // ─────────────────────────────────────────────────────
166
+ /**
167
+ * @name buildAttachAgentIdentityIx
168
+ * @description Build the MPL Core `addExternalPluginAdapterV1`
169
+ * `TransactionInstruction` that attaches an `AgentIdentity` plugin
170
+ * pointing at SAP's live EIP-8004 registration URL.
171
+ *
172
+ * @since v0.9.0
173
+ */
174
+ async buildAttachAgentIdentityIx(opts) {
175
+ const [sapPda] = (0, pda_1.deriveAgent)(opts.sapAgentOwner);
176
+ const uri = this.deriveRegistrationUrl(sapPda, opts.registrationBaseUrl);
177
+ return this.buildAddExternalPluginIx({
178
+ asset: opts.asset,
179
+ authority: opts.authority,
180
+ payer: opts.payer ?? opts.authority,
181
+ uri,
182
+ rpcUrl: opts.rpcUrl,
183
+ });
184
+ }
185
+ /**
186
+ * @name buildUpdateAgentIdentityUriIx
187
+ * @description Build the MPL Core `updateExternalPluginAdapterV1`
188
+ * instruction that re-points an existing `AgentIdentity` plugin.
189
+ *
190
+ * @since v0.9.0
191
+ */
192
+ async buildUpdateAgentIdentityUriIx(opts) {
193
+ const { mplCore, umiBundle, umiCore } = await loadMplCore();
194
+ const umi = umiBundle.createUmi(opts.rpcUrl).use(mplCore.mplCore());
195
+ const authority = umiCore.createNoopSigner(umiCore.publicKey(opts.authority.toBase58()));
196
+ const payer = umiCore.createNoopSigner(umiCore.publicKey((opts.payer ?? opts.authority).toBase58()));
197
+ const builder = mplCore.updateExternalPluginAdapterV1(umi, {
198
+ asset: umiCore.publicKey(opts.asset.toBase58()),
199
+ authority,
200
+ payer,
201
+ key: { __kind: "AgentIdentity" },
202
+ updateInfo: {
203
+ __kind: "AgentIdentity",
204
+ fields: [
205
+ {
206
+ uri: opts.newUri,
207
+ lifecycleChecks: null,
208
+ },
209
+ ],
210
+ },
211
+ });
212
+ return this.firstWeb3Ix(builder, "updateExternalPluginAdapterV1");
213
+ }
214
+ // ─────────────────────────────────────────────────────
215
+ // Write side — combined SAP × MPL register flows (v0.9.3)
216
+ // ─────────────────────────────────────────────────────
217
+ /**
218
+ * @name buildMintAndAttachIxs
219
+ * @description Build the two MPL Core instructions needed to mint a new
220
+ * asset for an existing SAP agent and immediately bind it via the
221
+ * `AgentIdentity` plugin (URI = canonical EIP-8004 URL).
222
+ *
223
+ * Flow:
224
+ * 1. Generate a fresh asset keypair (returned as `assetSecretKey`).
225
+ * 2. Build `mpl_core::create` with the new asset as signer.
226
+ * 3. Build `addExternalPluginAdapterV1` for the AgentIdentity URI.
227
+ *
228
+ * The returned `instructions` are deterministic order. The caller
229
+ * partial-signs the assembled transaction with `assetSecretKey` and the
230
+ * authority/payer wallet.
231
+ *
232
+ * @since v0.9.3
233
+ */
234
+ async buildMintAndAttachIxs(opts) {
235
+ const { mplCore, umiBundle, umiCore } = await loadMplCore();
236
+ const umi = umiBundle.createUmi(opts.rpcUrl).use(mplCore.mplCore());
237
+ const [sapPda] = (0, pda_1.deriveAgent)(opts.sapAgentOwner);
238
+ const registrationUrl = this.deriveRegistrationUrl(sapPda, opts.registrationBaseUrl);
239
+ const assetUmiSigner = umiCore.generateSigner(umi);
240
+ const assetAddress = new web3_js_1.PublicKey(assetUmiSigner.publicKey.toString());
241
+ const assetSecretKey = assetUmiSigner.secretKey;
242
+ const authority = umiCore.createNoopSigner(umiCore.publicKey(opts.authority.toBase58()));
243
+ const payer = umiCore.createNoopSigner(umiCore.publicKey((opts.payer ?? opts.authority).toBase58()));
244
+ const ownerUmi = opts.owner
245
+ ? umiCore.publicKey(opts.owner.toBase58())
246
+ : umiCore.publicKey(opts.authority.toBase58());
247
+ const createBuilder = mplCore.create(umi, {
248
+ asset: assetUmiSigner,
249
+ collection: opts.collection
250
+ ? { publicKey: umiCore.publicKey(opts.collection.toBase58()) }
251
+ : undefined,
252
+ authority,
253
+ payer,
254
+ owner: ownerUmi,
255
+ name: opts.name,
256
+ uri: opts.metadataUri,
257
+ });
258
+ const mintIx = await this.firstWeb3Ix(createBuilder, "mpl_core::create");
259
+ const attachIx = await this.buildAddExternalPluginIx({
260
+ asset: assetAddress,
261
+ authority: opts.authority,
262
+ payer: opts.payer ?? opts.authority,
263
+ uri: registrationUrl,
264
+ rpcUrl: opts.rpcUrl,
265
+ });
266
+ return {
267
+ assetAddress,
268
+ assetSecretKey,
269
+ registrationUrl,
270
+ instructions: [mintIx, attachIx],
271
+ };
272
+ }
273
+ /**
274
+ * @name buildRegisterSapForMplOwnerIx
275
+ * @description Given an existing MPL Core asset, resolve its on-chain
276
+ * owner and build the SAP `registerAgent` instruction the owner must
277
+ * sign. Idempotent: if a SAP agent already exists for that owner the
278
+ * method returns `instruction: null` with `alreadyRegistered: true`.
279
+ *
280
+ * Use after a wallet has minted (or holds) an MPL Core agent NFT and
281
+ * wants to back-fill a SAP identity at the canonical PDA so the bridge's
282
+ * EIP-8004 URL becomes resolvable.
283
+ *
284
+ * @since v0.9.3
285
+ */
286
+ async buildRegisterSapForMplOwnerIx(opts) {
287
+ const snap = await this.fetchMplSnapshot(opts.asset, opts.rpcUrl);
288
+ if (!snap) {
289
+ throw new Error(`buildRegisterSapForMplOwnerIx: MPL Core asset ${opts.asset.toBase58()} not readable`);
290
+ }
291
+ const [sapPda] = (0, pda_1.deriveAgent)(snap.owner);
292
+ const existing = await this.fetchAgentNullable(sapPda);
293
+ if (existing) {
294
+ return {
295
+ assetOwner: snap.owner,
296
+ sapAgentPda: sapPda,
297
+ alreadyRegistered: true,
298
+ currentAgentIdentityUri: snap.agentIdentityUri,
299
+ instruction: null,
300
+ };
301
+ }
302
+ const ix = await this.buildRegisterAgentIx({
303
+ wallet: snap.owner,
304
+ args: opts.registerArgs,
305
+ });
306
+ return {
307
+ assetOwner: snap.owner,
308
+ sapAgentPda: sapPda,
309
+ alreadyRegistered: false,
310
+ currentAgentIdentityUri: snap.agentIdentityUri,
311
+ instruction: ix,
312
+ };
313
+ }
314
+ /**
315
+ * @name buildRegisterBothIxs
316
+ * @description Atomic 3-instruction bundle for a wallet that owns
317
+ * neither side: `[SAP registerAgent, MPL Core create, MPL AgentIdentity attach]`.
318
+ * Single transaction, single user signature (plus the ephemeral asset
319
+ * keypair returned in `assetSecretKey`).
320
+ *
321
+ * Throws if a SAP agent already exists for `wallet` — callers should
322
+ * fall through to {@link MetaplexBridge.buildMintAndAttachIxs} instead.
323
+ *
324
+ * @since v0.9.3
325
+ */
326
+ async buildRegisterBothIxs(opts) {
327
+ const [sapPda] = (0, pda_1.deriveAgent)(opts.wallet);
328
+ const existing = await this.fetchAgentNullable(sapPda);
329
+ if (existing) {
330
+ throw new Error(`buildRegisterBothIxs: SAP agent already exists at ${sapPda.toBase58()}; ` +
331
+ `use buildMintAndAttachIxs instead`);
332
+ }
333
+ const sapIx = await this.buildRegisterAgentIx({
334
+ wallet: opts.wallet,
335
+ args: opts.registerArgs,
336
+ });
337
+ const mint = await this.buildMintAndAttachIxs({
338
+ sapAgentOwner: opts.wallet,
339
+ authority: opts.wallet,
340
+ payer: opts.payer ?? opts.wallet,
341
+ owner: opts.wallet,
342
+ name: opts.mintName,
343
+ metadataUri: opts.mintMetadataUri,
344
+ registrationBaseUrl: opts.registrationBaseUrl,
345
+ rpcUrl: opts.rpcUrl,
346
+ collection: opts.collection,
347
+ });
348
+ return {
349
+ sapAgentPda: sapPda,
350
+ assetAddress: mint.assetAddress,
351
+ assetSecretKey: mint.assetSecretKey,
352
+ registrationUrl: mint.registrationUrl,
353
+ instructions: [sapIx, ...mint.instructions],
354
+ };
355
+ }
356
+ // ─────────────────────────────────────────────────────
357
+ // Read side
358
+ // ─────────────────────────────────────────────────────
359
+ /**
360
+ * @name getUnifiedProfile
361
+ * @description Fetch a merged view of an agent across SAP and Metaplex.
362
+ * Provide `wallet` (SAP-first) or `asset` (MPL-first), or both.
363
+ *
364
+ * @since v0.9.0
365
+ */
366
+ async getUnifiedProfile(input) {
367
+ if (!input.wallet && !input.asset) {
368
+ throw new Error("getUnifiedProfile: provide `wallet` or `asset`");
369
+ }
370
+ let sapPda = null;
371
+ let identity = null;
372
+ let stats = null;
373
+ if (input.wallet) {
374
+ [sapPda] = (0, pda_1.deriveAgent)(input.wallet);
375
+ identity = await this.fetchAgentNullable(sapPda);
376
+ stats = await this.fetchStatsNullable(sapPda);
377
+ }
378
+ let mpl = null;
379
+ if (input.asset) {
380
+ mpl = await this.fetchMplSnapshot(input.asset, input.rpcUrl, input.rpcHeaders);
381
+ if (!sapPda && mpl?.registration?.synapseAgent) {
382
+ try {
383
+ sapPda = new web3_js_1.PublicKey(mpl.registration.synapseAgent);
384
+ identity = await this.fetchAgentNullable(sapPda);
385
+ stats = await this.fetchStatsNullable(sapPda);
386
+ }
387
+ catch {
388
+ /* invalid PDA in JSON */
389
+ }
390
+ }
391
+ }
392
+ if (!sapPda) {
393
+ throw new Error("getUnifiedProfile: failed to resolve SAP agent PDA");
394
+ }
395
+ return {
396
+ sap: { pda: sapPda, identity, stats },
397
+ mpl,
398
+ linked: this.detectLink(sapPda, mpl),
399
+ };
400
+ }
401
+ /**
402
+ * @name resolveAgentIdentifier
403
+ * @description Resolve a generic agent identifier to canonical SAP routing
404
+ * keys. Useful when callers may receive either owner wallets or Metaplex
405
+ * Core asset IDs (e.g. metaplex.com/agents/<core-asset-id>).
406
+ *
407
+ * Resolution order:
408
+ * 1) Treat input as wallet and check if a SAP agent exists.
409
+ * 2) If not found, treat input as MPL Core asset and resolve owner wallet.
410
+ *
411
+ * @since v0.9.2
412
+ */
413
+ async resolveAgentIdentifier(input) {
414
+ let asPubkey;
415
+ try {
416
+ asPubkey = new web3_js_1.PublicKey(input.identifier);
417
+ }
418
+ catch {
419
+ return {
420
+ input: input.identifier,
421
+ kind: "unknown",
422
+ wallet: null,
423
+ sapAgentPda: null,
424
+ asset: null,
425
+ hasSapAgent: false,
426
+ error: "Invalid public key",
427
+ };
428
+ }
429
+ // 1) Wallet-first resolution (SAP-native)
430
+ const [walletSapPda] = (0, pda_1.deriveAgent)(asPubkey);
431
+ const walletIdentity = await this.fetchAgentNullable(walletSapPda);
432
+ if (walletIdentity) {
433
+ return {
434
+ input: input.identifier,
435
+ kind: "wallet",
436
+ wallet: asPubkey,
437
+ sapAgentPda: walletSapPda,
438
+ asset: null,
439
+ hasSapAgent: true,
440
+ error: null,
441
+ };
442
+ }
443
+ // 2) MPL Core asset resolution
444
+ const mpl = await this.fetchMplSnapshot(asPubkey, input.rpcUrl, input.rpcHeaders);
445
+ if (!mpl) {
446
+ return {
447
+ input: input.identifier,
448
+ kind: "unknown",
449
+ wallet: null,
450
+ sapAgentPda: null,
451
+ asset: null,
452
+ hasSapAgent: false,
453
+ error: "Not a SAP wallet and not a readable MPL Core asset",
454
+ };
455
+ }
456
+ const [sapPdaFromOwner] = (0, pda_1.deriveAgent)(mpl.owner);
457
+ const ownerIdentity = await this.fetchAgentNullable(sapPdaFromOwner);
458
+ return {
459
+ input: input.identifier,
460
+ kind: "core-asset",
461
+ wallet: mpl.owner,
462
+ sapAgentPda: sapPdaFromOwner,
463
+ asset: asPubkey,
464
+ hasSapAgent: !!ownerIdentity,
465
+ error: ownerIdentity ? null : "Core asset owner has no SAP agent profile",
466
+ };
467
+ }
468
+ /**
469
+ * @name verifyLink
470
+ * @description Verify the bidirectional link between an MPL Core asset
471
+ * and a SAP agent. Returns `true` only when both URL and JSON sides
472
+ * reference the SAP agent PDA.
473
+ *
474
+ * @since v0.9.0
475
+ */
476
+ async verifyLink(args) {
477
+ const snap = await this.fetchMplSnapshot(args.asset, args.rpcUrl, args.rpcHeaders);
478
+ if (!snap?.agentIdentityUri || !snap.registration)
479
+ return false;
480
+ const expectedSuffix = `/agents/${args.sapAgentPda.toBase58()}/eip-8004.json`;
481
+ if (!snap.agentIdentityUri.endsWith(expectedSuffix))
482
+ return false;
483
+ return snap.registration.synapseAgent === args.sapAgentPda.toBase58();
484
+ }
485
+ /**
486
+ * @name tripleCheckLink
487
+ * @description Explicit 3-layer verification for explorer/host badges.
488
+ * Returns one struct enumerating each check independently so UIs can
489
+ * present partial trust states (e.g. "MPL plugin present, JSON pending").
490
+ *
491
+ * Layers:
492
+ * 1. **mplOnChain** — Asset + AgentIdentity URI fetched on-chain.
493
+ * 2. **eip8004Json** — JSON fetched and `synapseAgent` matches PDA.
494
+ * 3. **sapOnChain** — `AgentAccount` PDA exists on the SAP program.
495
+ *
496
+ * @since v0.9.3
497
+ */
498
+ async tripleCheckLink(args) {
499
+ const snap = await this.fetchMplSnapshot(args.asset, args.rpcUrl, args.rpcHeaders);
500
+ if (!snap) {
501
+ const fallbackPda = args.expectedOwner
502
+ ? (0, pda_1.deriveAgent)(args.expectedOwner)[0]
503
+ : args.asset;
504
+ return {
505
+ asset: args.asset,
506
+ sapAgentPda: fallbackPda,
507
+ mplOnChain: false,
508
+ eip8004Json: false,
509
+ sapOnChain: false,
510
+ linked: false,
511
+ agentIdentityUri: null,
512
+ registration: null,
513
+ identity: null,
514
+ error: "MPL Core asset not readable on-chain",
515
+ };
516
+ }
517
+ const owner = args.expectedOwner ?? snap.owner;
518
+ const [sapPda] = (0, pda_1.deriveAgent)(owner);
519
+ const expectedSuffix = `/agents/${sapPda.toBase58()}/eip-8004.json`;
520
+ const mplOnChain = !!snap.agentIdentityUri;
521
+ const eip8004Json = !!snap.registration &&
522
+ !!snap.agentIdentityUri &&
523
+ snap.agentIdentityUri.endsWith(expectedSuffix) &&
524
+ snap.registration.synapseAgent === sapPda.toBase58();
525
+ const identity = await this.fetchAgentNullable(sapPda);
526
+ const sapOnChain = !!identity;
527
+ return {
528
+ asset: args.asset,
529
+ sapAgentPda: sapPda,
530
+ mplOnChain,
531
+ eip8004Json,
532
+ sapOnChain,
533
+ linked: mplOnChain && eip8004Json && sapOnChain,
534
+ agentIdentityUri: snap.agentIdentityUri,
535
+ registration: snap.registration,
536
+ identity,
537
+ error: null,
538
+ };
539
+ }
540
+ // ═════════════════════════════════════════════════════
541
+ // Private — SAP fetching
542
+ // ═════════════════════════════════════════════════════
543
+ get accounts() {
544
+ return this.program.account;
545
+ }
546
+ async fetchAgentNullable(pda) {
547
+ try {
548
+ return await this.accounts.agentAccount.fetch(pda);
549
+ }
550
+ catch {
551
+ return null;
552
+ }
553
+ }
554
+ async fetchStatsNullable(agentPda) {
555
+ try {
556
+ const [statsPda] = (0, pda_1.deriveAgentStats)(agentPda);
557
+ return await this.accounts.agentStats.fetch(statsPda);
558
+ }
559
+ catch {
560
+ return null;
561
+ }
562
+ }
563
+ async fetchActiveVaultDelegates(agentPda) {
564
+ try {
565
+ const [vaultPda] = (0, pda_1.deriveVault)(agentPda);
566
+ // VaultDelegate layout: [discriminator(8) | bump(1) | vault(32) | ...]
567
+ const all = await this.accounts.vaultDelegate.all([
568
+ { memcmp: { offset: 8 + 1, bytes: vaultPda.toBase58() } },
569
+ ]);
570
+ const now = Math.floor(Date.now() / 1000);
571
+ return all
572
+ .map(({ account }) => {
573
+ const expiresRaw = account.expiresAt.toString();
574
+ const expiresAt = expiresRaw === "0" ? null : expiresRaw;
575
+ return { wallet: account.delegate.toBase58(), expiresAt };
576
+ })
577
+ .filter((d) => d.expiresAt === null || Number(d.expiresAt) > now);
578
+ }
579
+ catch {
580
+ return [];
581
+ }
582
+ }
583
+ // ═════════════════════════════════════════════════════
584
+ // Private — MPL fetching
585
+ // ═════════════════════════════════════════════════════
586
+ async buildUmi(rpcUrl, rpcHeaders) {
587
+ const { mplCore, umiBundle } = await loadMplCore();
588
+ // umi-bundle-defaults.createUmi accepts an options object with httpHeaders
589
+ // since umi 1.x — required for gated providers like Synapse RPC that
590
+ // enforce `x-api-key`. Without it `getAccountInfo` returns 401 silently.
591
+ const umi = umiBundle.createUmi(rpcUrl, rpcHeaders ? { httpHeaders: rpcHeaders } : undefined).use(mplCore.mplCore());
592
+ return umi;
593
+ }
594
+ async fetchMplSnapshot(asset, rpcUrl, rpcHeaders) {
595
+ const { mplCore, umiCore } = await loadMplCore();
596
+ const umi = await this.buildUmi(rpcUrl, rpcHeaders);
597
+ try {
598
+ const fetched = await mplCore.fetchAsset(umi, umiCore.publicKey(asset.toBase58()));
599
+ const owner = new web3_js_1.PublicKey(fetched.owner.toString());
600
+ const uri = this.extractAgentIdentityUri(fetched);
601
+ const registration = uri ? await this.fetchEip8004Safe(uri) : null;
602
+ return {
603
+ asset,
604
+ owner,
605
+ name: fetched.name ?? null,
606
+ agentIdentityUri: uri,
607
+ registration,
608
+ };
609
+ }
610
+ catch {
611
+ return null;
612
+ }
613
+ }
614
+ extractAgentIdentityUri(asset) {
615
+ const adapters = asset.agentIdentities;
616
+ if (!adapters || adapters.length === 0)
617
+ return null;
618
+ const first = adapters[0];
619
+ if (!first)
620
+ return null;
621
+ return typeof first.uri === "string" ? first.uri : null;
622
+ }
623
+ async fetchEip8004Safe(uri) {
624
+ try {
625
+ const res = await fetch(uri, { method: "GET" });
626
+ if (!res.ok)
627
+ return null;
628
+ const json = (await res.json());
629
+ if (typeof json.synapseAgent !== "string" ||
630
+ typeof json.authority !== "string") {
631
+ return null;
632
+ }
633
+ return {
634
+ version: json.version ?? "0.1",
635
+ name: json.name ?? "",
636
+ description: json.description,
637
+ synapseAgent: json.synapseAgent,
638
+ authority: json.authority,
639
+ capabilities: Array.isArray(json.capabilities) ? json.capabilities : [],
640
+ services: Array.isArray(json.services) ? json.services : [],
641
+ executives: Array.isArray(json.executives) ? json.executives : [],
642
+ updatedAt: json.updatedAt ?? "",
643
+ extra: json.extra,
644
+ };
645
+ }
646
+ catch {
647
+ return null;
648
+ }
649
+ }
650
+ // ═════════════════════════════════════════════════════
651
+ // Private — MPL instruction building
652
+ // ═════════════════════════════════════════════════════
653
+ async buildAddExternalPluginIx(args) {
654
+ const { mplCore, umiBundle, umiCore } = await loadMplCore();
655
+ const umi = umiBundle.createUmi(args.rpcUrl).use(mplCore.mplCore());
656
+ const authority = umiCore.createNoopSigner(umiCore.publicKey(args.authority.toBase58()));
657
+ const payer = umiCore.createNoopSigner(umiCore.publicKey(args.payer.toBase58()));
658
+ // HookableLifecycleEvent.Execute = 4; ExternalCheckResult { flags: 1 } = CanApprove
659
+ const ExecuteEvent = mplCore.HookableLifecycleEvent.Execute;
660
+ const builder = mplCore.addExternalPluginAdapterV1(umi, {
661
+ asset: umiCore.publicKey(args.asset.toBase58()),
662
+ authority,
663
+ payer,
664
+ initInfo: {
665
+ __kind: "AgentIdentity",
666
+ fields: [
667
+ {
668
+ uri: args.uri,
669
+ initPluginAuthority: { __kind: "UpdateAuthority" },
670
+ lifecycleChecks: [[ExecuteEvent, { flags: 1 }]],
671
+ },
672
+ ],
673
+ },
674
+ });
675
+ return this.firstWeb3Ix(builder, "addExternalPluginAdapterV1");
676
+ }
677
+ // ═════════════════════════════════════════════════════
678
+ // Private — SAP instruction building (v0.9.3)
679
+ // ═════════════════════════════════════════════════════
680
+ async buildRegisterAgentIx(args) {
681
+ // Lazy import to avoid a hard cycle with `pda/index.ts`.
682
+ const { deriveGlobalRegistry } = await Promise.resolve().then(() => __importStar(require("../pda")));
683
+ const { SystemProgram } = await Promise.resolve().then(() => __importStar(require("@solana/web3.js")));
684
+ const [agentPda] = (0, pda_1.deriveAgent)(args.wallet);
685
+ const [statsPda] = (0, pda_1.deriveAgentStats)(agentPda);
686
+ const [globalPda] = deriveGlobalRegistry();
687
+ const a = args.args;
688
+ // Cast to `any` to sidestep Anchor's deep generic IDL inference, which
689
+ // otherwise blows TS recursion budget here. Same pattern as BaseModule.
690
+ const methods = this.program.methods;
691
+ return await methods
692
+ .registerAgent(a.name, a.description, a.capabilities, a.pricing, a.protocols, a.agentId ?? null, a.agentUri ?? null, a.x402Endpoint ?? null)
693
+ .accounts({
694
+ wallet: args.wallet,
695
+ agent: agentPda,
696
+ agentStats: statsPda,
697
+ globalRegistry: globalPda,
698
+ systemProgram: SystemProgram.programId,
699
+ })
700
+ .instruction();
701
+ }
702
+ async firstWeb3Ix(builder, name) {
703
+ const items = builder.getInstructions();
704
+ const first = items[0];
705
+ if (!first) {
706
+ throw new Error(`MetaplexBridge: ${name} produced no instructions`);
707
+ }
708
+ return this.umiIxToWeb3(first);
709
+ }
710
+ umiIxToWeb3(ix) {
711
+ return {
712
+ programId: new web3_js_1.PublicKey(ix.programId.toString()),
713
+ keys: ix.keys.map((k) => ({
714
+ pubkey: new web3_js_1.PublicKey(k.pubkey.toString()),
715
+ isSigner: k.isSigner,
716
+ isWritable: k.isWritable,
717
+ })),
718
+ data: Buffer.from(ix.data),
719
+ };
720
+ }
721
+ // ═════════════════════════════════════════════════════
722
+ // Private — link detection + duck-typed readers
723
+ // ═════════════════════════════════════════════════════
724
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
725
+ detectLink(sapPda, mpl) {
726
+ if (!mpl?.agentIdentityUri || !mpl.registration)
727
+ return false;
728
+ const expectedSuffix = `/agents/${sapPda.toBase58()}/eip-8004.json`;
729
+ if (!mpl.agentIdentityUri.endsWith(expectedSuffix))
730
+ return false;
731
+ return mpl.registration.synapseAgent === sapPda.toBase58();
732
+ }
733
+ readString(identity, key) {
734
+ const value = identity[key];
735
+ return typeof value === "string" ? value : null;
736
+ }
737
+ readCapabilities(identity) {
738
+ const caps = identity.capabilities ?? [];
739
+ return caps.map((c) => c.id).filter((s) => typeof s === "string");
740
+ }
741
+ }
742
+ exports.MetaplexBridge = MetaplexBridge;
743
+ //# sourceMappingURL=metaplex-bridge.js.map