@oobe-protocol-labs/synapse-sap-sdk 0.12.9 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (640) hide show
  1. package/dist/cjs/accounts/index.js +286 -0
  2. package/dist/cjs/accounts/index.js.map +1 -0
  3. package/dist/cjs/client.js +108 -0
  4. package/dist/cjs/client.js.map +1 -0
  5. package/dist/cjs/constants.js +59 -0
  6. package/dist/cjs/constants.js.map +1 -0
  7. package/dist/cjs/errors.js +250 -0
  8. package/dist/cjs/errors.js.map +1 -0
  9. package/dist/cjs/events/index.js +38 -130
  10. package/dist/cjs/events/index.js.map +1 -1
  11. package/dist/cjs/idlTypes.js +4 -0
  12. package/dist/cjs/idlTypes.js.map +1 -0
  13. package/dist/cjs/index.js +75 -241
  14. package/dist/cjs/index.js.map +1 -1
  15. package/dist/cjs/instructions/agent.js +89 -0
  16. package/dist/cjs/instructions/agent.js.map +1 -0
  17. package/dist/cjs/instructions/attestation.js +112 -0
  18. package/dist/cjs/instructions/attestation.js.map +1 -0
  19. package/dist/cjs/instructions/digest.js +28 -0
  20. package/dist/cjs/instructions/digest.js.map +1 -0
  21. package/dist/cjs/instructions/dispute.js +116 -0
  22. package/dist/cjs/instructions/dispute.js.map +1 -0
  23. package/dist/cjs/instructions/escrow.js +101 -0
  24. package/dist/cjs/instructions/escrow.js.map +1 -0
  25. package/dist/cjs/instructions/global.js +28 -0
  26. package/dist/cjs/instructions/global.js.map +1 -0
  27. package/dist/cjs/instructions/index.js +31 -0
  28. package/dist/cjs/instructions/index.js.map +1 -0
  29. package/dist/cjs/instructions/indexing.js +221 -0
  30. package/dist/cjs/instructions/indexing.js.map +1 -0
  31. package/dist/cjs/instructions/misc.js +73 -0
  32. package/dist/cjs/instructions/misc.js.map +1 -0
  33. package/dist/cjs/instructions/session.js +89 -0
  34. package/dist/cjs/instructions/session.js.map +1 -0
  35. package/dist/cjs/instructions/staking.js +132 -0
  36. package/dist/cjs/instructions/staking.js.map +1 -0
  37. package/dist/cjs/instructions/subscription.js +80 -0
  38. package/dist/cjs/instructions/subscription.js.map +1 -0
  39. package/dist/cjs/instructions/tools.js +109 -0
  40. package/dist/cjs/instructions/tools.js.map +1 -0
  41. package/dist/cjs/instructions/vault.js +106 -0
  42. package/dist/cjs/instructions/vault.js.map +1 -0
  43. package/dist/cjs/pdas/index.js +120 -0
  44. package/dist/cjs/pdas/index.js.map +1 -0
  45. package/dist/cjs/types.js +42 -0
  46. package/dist/cjs/types.js.map +1 -0
  47. package/dist/cjs/utils/index.js +29 -75
  48. package/dist/cjs/utils/index.js.map +1 -1
  49. package/dist/cjs/utils/validate.js +236 -0
  50. package/dist/cjs/utils/validate.js.map +1 -0
  51. package/dist/esm/accounts/index.d.ts +11 -0
  52. package/dist/esm/accounts/index.d.ts.map +1 -0
  53. package/dist/esm/accounts/index.js +273 -0
  54. package/dist/esm/accounts/index.js.map +1 -0
  55. package/dist/esm/client.d.ts +55 -0
  56. package/dist/esm/client.d.ts.map +1 -0
  57. package/dist/esm/client.js +70 -0
  58. package/dist/esm/client.js.map +1 -0
  59. package/dist/esm/constants.d.ts +52 -0
  60. package/dist/esm/constants.d.ts.map +1 -0
  61. package/dist/esm/constants.js +56 -0
  62. package/dist/esm/constants.js.map +1 -0
  63. package/dist/esm/errors.d.ts +111 -0
  64. package/dist/esm/errors.d.ts.map +1 -0
  65. package/dist/esm/errors.js +244 -0
  66. package/dist/esm/errors.js.map +1 -0
  67. package/dist/esm/events/index.d.ts +13 -0
  68. package/dist/esm/events/index.d.ts.map +1 -0
  69. package/dist/esm/events/index.js +36 -128
  70. package/dist/esm/events/index.js.map +1 -1
  71. package/dist/esm/idlTypes.d.ts +925 -0
  72. package/dist/esm/idlTypes.d.ts.map +1 -0
  73. package/dist/esm/idlTypes.js +3 -0
  74. package/dist/esm/idlTypes.js.map +1 -0
  75. package/dist/esm/index.d.ts +12 -0
  76. package/dist/esm/index.d.ts.map +1 -0
  77. package/dist/esm/index.js +15 -88
  78. package/dist/esm/index.js.map +1 -1
  79. package/dist/esm/instructions/agent.d.ts +71 -0
  80. package/dist/esm/instructions/agent.d.ts.map +1 -0
  81. package/dist/esm/instructions/agent.js +85 -0
  82. package/dist/esm/instructions/agent.js.map +1 -0
  83. package/dist/esm/instructions/attestation.d.ts +76 -0
  84. package/dist/esm/instructions/attestation.d.ts.map +1 -0
  85. package/dist/esm/instructions/attestation.js +108 -0
  86. package/dist/esm/instructions/attestation.js.map +1 -0
  87. package/dist/esm/instructions/digest.d.ts +20 -0
  88. package/dist/esm/instructions/digest.d.ts.map +1 -0
  89. package/dist/esm/instructions/digest.js +24 -0
  90. package/dist/esm/instructions/digest.js.map +1 -0
  91. package/dist/esm/instructions/dispute.d.ts +81 -0
  92. package/dist/esm/instructions/dispute.d.ts.map +1 -0
  93. package/dist/esm/instructions/dispute.js +112 -0
  94. package/dist/esm/instructions/dispute.js.map +1 -0
  95. package/dist/esm/instructions/escrow.d.ts +79 -0
  96. package/dist/esm/instructions/escrow.d.ts.map +1 -0
  97. package/dist/esm/instructions/escrow.js +97 -0
  98. package/dist/esm/instructions/escrow.js.map +1 -0
  99. package/dist/esm/instructions/global.d.ts +14 -0
  100. package/dist/esm/instructions/global.d.ts.map +1 -0
  101. package/dist/esm/instructions/global.js +24 -0
  102. package/dist/esm/instructions/global.js.map +1 -0
  103. package/dist/esm/instructions/index.d.ts +14 -0
  104. package/dist/esm/instructions/index.d.ts.map +1 -0
  105. package/dist/esm/instructions/index.js +15 -0
  106. package/dist/esm/instructions/index.js.map +1 -0
  107. package/dist/esm/instructions/indexing.d.ts +150 -0
  108. package/dist/esm/instructions/indexing.d.ts.map +1 -0
  109. package/dist/esm/instructions/indexing.js +217 -0
  110. package/dist/esm/instructions/indexing.js.map +1 -0
  111. package/dist/esm/instructions/memory.d.ts +8 -0
  112. package/dist/esm/instructions/memory.d.ts.map +1 -0
  113. package/dist/esm/instructions/memory.js +234 -0
  114. package/dist/esm/instructions/memory.js.map +1 -0
  115. package/dist/esm/instructions/misc.d.ts +50 -0
  116. package/dist/esm/instructions/misc.d.ts.map +1 -0
  117. package/dist/esm/instructions/misc.js +69 -0
  118. package/dist/esm/instructions/misc.js.map +1 -0
  119. package/dist/esm/instructions/session.d.ts +57 -0
  120. package/dist/esm/instructions/session.d.ts.map +1 -0
  121. package/dist/esm/instructions/session.js +85 -0
  122. package/dist/esm/instructions/session.js.map +1 -0
  123. package/dist/esm/instructions/staking.d.ts +85 -0
  124. package/dist/esm/instructions/staking.d.ts.map +1 -0
  125. package/dist/esm/instructions/staking.js +128 -0
  126. package/dist/esm/instructions/staking.js.map +1 -0
  127. package/dist/esm/instructions/subscription.d.ts +50 -0
  128. package/dist/esm/instructions/subscription.d.ts.map +1 -0
  129. package/dist/esm/instructions/subscription.js +76 -0
  130. package/dist/esm/instructions/subscription.js.map +1 -0
  131. package/dist/esm/instructions/tools.d.ts +88 -0
  132. package/dist/esm/instructions/tools.d.ts.map +1 -0
  133. package/dist/esm/instructions/tools.js +105 -0
  134. package/dist/esm/instructions/tools.js.map +1 -0
  135. package/dist/esm/instructions/vault.d.ts +84 -0
  136. package/dist/esm/instructions/vault.d.ts.map +1 -0
  137. package/dist/esm/instructions/vault.js +102 -0
  138. package/dist/esm/instructions/vault.js.map +1 -0
  139. package/dist/esm/pdas/index.d.ts +37 -0
  140. package/dist/esm/pdas/index.d.ts.map +1 -0
  141. package/dist/esm/pdas/index.js +101 -0
  142. package/dist/esm/pdas/index.js.map +1 -0
  143. package/dist/esm/types.d.ts +208 -0
  144. package/dist/esm/types.d.ts.map +1 -0
  145. package/dist/esm/types.js +39 -0
  146. package/dist/esm/types.js.map +1 -0
  147. package/dist/esm/utils/index.d.ts +4 -0
  148. package/dist/esm/utils/index.d.ts.map +1 -0
  149. package/dist/esm/utils/index.js +13 -29
  150. package/dist/esm/utils/index.js.map +1 -1
  151. package/dist/esm/utils/validate.d.ts +66 -0
  152. package/dist/esm/utils/validate.d.ts.map +1 -0
  153. package/dist/esm/utils/validate.js +221 -0
  154. package/dist/esm/utils/validate.js.map +1 -0
  155. package/package.json +59 -183
  156. package/LICENSE +0 -21
  157. package/README.md +0 -986
  158. package/dist/cjs/constants/addresses.js +0 -143
  159. package/dist/cjs/constants/addresses.js.map +0 -1
  160. package/dist/cjs/constants/index.js +0 -64
  161. package/dist/cjs/constants/index.js.map +0 -1
  162. package/dist/cjs/constants/limits.js +0 -161
  163. package/dist/cjs/constants/limits.js.map +0 -1
  164. package/dist/cjs/constants/network.js +0 -81
  165. package/dist/cjs/constants/network.js.map +0 -1
  166. package/dist/cjs/constants/payments.js +0 -137
  167. package/dist/cjs/constants/payments.js.map +0 -1
  168. package/dist/cjs/constants/programs.js +0 -78
  169. package/dist/cjs/constants/programs.js.map +0 -1
  170. package/dist/cjs/constants/seeds.js +0 -76
  171. package/dist/cjs/constants/seeds.js.map +0 -1
  172. package/dist/cjs/core/client.js +0 -546
  173. package/dist/cjs/core/client.js.map +0 -1
  174. package/dist/cjs/core/connection.js +0 -350
  175. package/dist/cjs/core/connection.js.map +0 -1
  176. package/dist/cjs/core/index.js +0 -25
  177. package/dist/cjs/core/index.js.map +0 -1
  178. package/dist/cjs/errors/index.js +0 -334
  179. package/dist/cjs/errors/index.js.map +0 -1
  180. package/dist/cjs/events/geyser.js +0 -295
  181. package/dist/cjs/events/geyser.js.map +0 -1
  182. package/dist/cjs/idl/index.js +0 -63
  183. package/dist/cjs/idl/index.js.map +0 -1
  184. package/dist/cjs/idl/synapse_agent_sap.json +0 -14595
  185. package/dist/cjs/modules/agent.js +0 -272
  186. package/dist/cjs/modules/agent.js.map +0 -1
  187. package/dist/cjs/modules/attestation.js +0 -147
  188. package/dist/cjs/modules/attestation.js.map +0 -1
  189. package/dist/cjs/modules/base.js +0 -128
  190. package/dist/cjs/modules/base.js.map +0 -1
  191. package/dist/cjs/modules/escrow-v2.js +0 -454
  192. package/dist/cjs/modules/escrow-v2.js.map +0 -1
  193. package/dist/cjs/modules/escrow.js +0 -300
  194. package/dist/cjs/modules/escrow.js.map +0 -1
  195. package/dist/cjs/modules/feedback.js +0 -166
  196. package/dist/cjs/modules/feedback.js.map +0 -1
  197. package/dist/cjs/modules/index.js +0 -43
  198. package/dist/cjs/modules/index.js.map +0 -1
  199. package/dist/cjs/modules/indexing.js +0 -375
  200. package/dist/cjs/modules/indexing.js.map +0 -1
  201. package/dist/cjs/modules/ledger.js +0 -234
  202. package/dist/cjs/modules/ledger.js.map +0 -1
  203. package/dist/cjs/modules/receipt.js +0 -148
  204. package/dist/cjs/modules/receipt.js.map +0 -1
  205. package/dist/cjs/modules/staking.js +0 -124
  206. package/dist/cjs/modules/staking.js.map +0 -1
  207. package/dist/cjs/modules/subscription.js +0 -96
  208. package/dist/cjs/modules/subscription.js.map +0 -1
  209. package/dist/cjs/modules/tools.js +0 -319
  210. package/dist/cjs/modules/tools.js.map +0 -1
  211. package/dist/cjs/modules/vault.js +0 -410
  212. package/dist/cjs/modules/vault.js.map +0 -1
  213. package/dist/cjs/parser/client.js +0 -146
  214. package/dist/cjs/parser/client.js.map +0 -1
  215. package/dist/cjs/parser/complete.js +0 -177
  216. package/dist/cjs/parser/complete.js.map +0 -1
  217. package/dist/cjs/parser/index.js +0 -57
  218. package/dist/cjs/parser/index.js.map +0 -1
  219. package/dist/cjs/parser/inner.js +0 -185
  220. package/dist/cjs/parser/inner.js.map +0 -1
  221. package/dist/cjs/parser/instructions.js +0 -114
  222. package/dist/cjs/parser/instructions.js.map +0 -1
  223. package/dist/cjs/parser/transaction.js +0 -153
  224. package/dist/cjs/parser/transaction.js.map +0 -1
  225. package/dist/cjs/parser/types.js +0 -14
  226. package/dist/cjs/parser/types.js.map +0 -1
  227. package/dist/cjs/pda/index.js +0 -672
  228. package/dist/cjs/pda/index.js.map +0 -1
  229. package/dist/cjs/plugin/index.js +0 -952
  230. package/dist/cjs/plugin/index.js.map +0 -1
  231. package/dist/cjs/plugin/protocols.js +0 -282
  232. package/dist/cjs/plugin/protocols.js.map +0 -1
  233. package/dist/cjs/plugin/schemas.js +0 -863
  234. package/dist/cjs/plugin/schemas.js.map +0 -1
  235. package/dist/cjs/postgres/adapter.js +0 -715
  236. package/dist/cjs/postgres/adapter.js.map +0 -1
  237. package/dist/cjs/postgres/index.js +0 -50
  238. package/dist/cjs/postgres/index.js.map +0 -1
  239. package/dist/cjs/postgres/serializers.js +0 -381
  240. package/dist/cjs/postgres/serializers.js.map +0 -1
  241. package/dist/cjs/postgres/sync.js +0 -289
  242. package/dist/cjs/postgres/sync.js.map +0 -1
  243. package/dist/cjs/postgres/types.js +0 -44
  244. package/dist/cjs/postgres/types.js.map +0 -1
  245. package/dist/cjs/registries/builder.js +0 -414
  246. package/dist/cjs/registries/builder.js.map +0 -1
  247. package/dist/cjs/registries/discovery.js +0 -362
  248. package/dist/cjs/registries/discovery.js.map +0 -1
  249. package/dist/cjs/registries/fairscale.js +0 -639
  250. package/dist/cjs/registries/fairscale.js.map +0 -1
  251. package/dist/cjs/registries/index.js +0 -58
  252. package/dist/cjs/registries/index.js.map +0 -1
  253. package/dist/cjs/registries/metaplex-bridge.js +0 -743
  254. package/dist/cjs/registries/metaplex-bridge.js.map +0 -1
  255. package/dist/cjs/registries/session.js +0 -433
  256. package/dist/cjs/registries/session.js.map +0 -1
  257. package/dist/cjs/registries/x402.js +0 -668
  258. package/dist/cjs/registries/x402.js.map +0 -1
  259. package/dist/cjs/types/accounts.js +0 -13
  260. package/dist/cjs/types/accounts.js.map +0 -1
  261. package/dist/cjs/types/common.js +0 -13
  262. package/dist/cjs/types/common.js.map +0 -1
  263. package/dist/cjs/types/endpoint.js +0 -15
  264. package/dist/cjs/types/endpoint.js.map +0 -1
  265. package/dist/cjs/types/enums.js +0 -269
  266. package/dist/cjs/types/enums.js.map +0 -1
  267. package/dist/cjs/types/index.js +0 -41
  268. package/dist/cjs/types/index.js.map +0 -1
  269. package/dist/cjs/types/instructions.js +0 -92
  270. package/dist/cjs/types/instructions.js.map +0 -1
  271. package/dist/cjs/utils/endpoint-validator.js +0 -232
  272. package/dist/cjs/utils/endpoint-validator.js.map +0 -1
  273. package/dist/cjs/utils/escrow-validation.js +0 -219
  274. package/dist/cjs/utils/escrow-validation.js.map +0 -1
  275. package/dist/cjs/utils/hash.js +0 -109
  276. package/dist/cjs/utils/hash.js.map +0 -1
  277. package/dist/cjs/utils/merchant-validator.js +0 -246
  278. package/dist/cjs/utils/merchant-validator.js.map +0 -1
  279. package/dist/cjs/utils/network-normalizer.js +0 -236
  280. package/dist/cjs/utils/network-normalizer.js.map +0 -1
  281. package/dist/cjs/utils/priority-fee.js +0 -215
  282. package/dist/cjs/utils/priority-fee.js.map +0 -1
  283. package/dist/cjs/utils/rpc-strategy.js +0 -239
  284. package/dist/cjs/utils/rpc-strategy.js.map +0 -1
  285. package/dist/cjs/utils/schemas.js +0 -331
  286. package/dist/cjs/utils/schemas.js.map +0 -1
  287. package/dist/cjs/utils/serialization.js +0 -105
  288. package/dist/cjs/utils/serialization.js.map +0 -1
  289. package/dist/cjs/utils/validation.js +0 -36
  290. package/dist/cjs/utils/validation.js.map +0 -1
  291. package/dist/cjs/utils/x402-direct.js +0 -231
  292. package/dist/cjs/utils/x402-direct.js.map +0 -1
  293. package/dist/esm/constants/addresses.js +0 -140
  294. package/dist/esm/constants/addresses.js.map +0 -1
  295. package/dist/esm/constants/index.js +0 -35
  296. package/dist/esm/constants/index.js.map +0 -1
  297. package/dist/esm/constants/limits.js +0 -158
  298. package/dist/esm/constants/limits.js.map +0 -1
  299. package/dist/esm/constants/network.js +0 -78
  300. package/dist/esm/constants/network.js.map +0 -1
  301. package/dist/esm/constants/payments.js +0 -131
  302. package/dist/esm/constants/payments.js.map +0 -1
  303. package/dist/esm/constants/programs.js +0 -75
  304. package/dist/esm/constants/programs.js.map +0 -1
  305. package/dist/esm/constants/seeds.js +0 -73
  306. package/dist/esm/constants/seeds.js.map +0 -1
  307. package/dist/esm/core/client.js +0 -539
  308. package/dist/esm/core/client.js.map +0 -1
  309. package/dist/esm/core/connection.js +0 -345
  310. package/dist/esm/core/connection.js.map +0 -1
  311. package/dist/esm/core/index.js +0 -19
  312. package/dist/esm/core/index.js.map +0 -1
  313. package/dist/esm/errors/index.js +0 -325
  314. package/dist/esm/errors/index.js.map +0 -1
  315. package/dist/esm/events/geyser.js +0 -258
  316. package/dist/esm/events/geyser.js.map +0 -1
  317. package/dist/esm/idl/index.js +0 -57
  318. package/dist/esm/idl/index.js.map +0 -1
  319. package/dist/esm/idl/synapse_agent_sap.json +0 -14595
  320. package/dist/esm/modules/agent.js +0 -268
  321. package/dist/esm/modules/agent.js.map +0 -1
  322. package/dist/esm/modules/attestation.js +0 -143
  323. package/dist/esm/modules/attestation.js.map +0 -1
  324. package/dist/esm/modules/base.js +0 -124
  325. package/dist/esm/modules/base.js.map +0 -1
  326. package/dist/esm/modules/escrow-v2.js +0 -450
  327. package/dist/esm/modules/escrow-v2.js.map +0 -1
  328. package/dist/esm/modules/escrow.js +0 -296
  329. package/dist/esm/modules/escrow.js.map +0 -1
  330. package/dist/esm/modules/feedback.js +0 -162
  331. package/dist/esm/modules/feedback.js.map +0 -1
  332. package/dist/esm/modules/index.js +0 -27
  333. package/dist/esm/modules/index.js.map +0 -1
  334. package/dist/esm/modules/indexing.js +0 -371
  335. package/dist/esm/modules/indexing.js.map +0 -1
  336. package/dist/esm/modules/ledger.js +0 -230
  337. package/dist/esm/modules/ledger.js.map +0 -1
  338. package/dist/esm/modules/receipt.js +0 -144
  339. package/dist/esm/modules/receipt.js.map +0 -1
  340. package/dist/esm/modules/staking.js +0 -120
  341. package/dist/esm/modules/staking.js.map +0 -1
  342. package/dist/esm/modules/subscription.js +0 -92
  343. package/dist/esm/modules/subscription.js.map +0 -1
  344. package/dist/esm/modules/tools.js +0 -315
  345. package/dist/esm/modules/tools.js.map +0 -1
  346. package/dist/esm/modules/vault.js +0 -406
  347. package/dist/esm/modules/vault.js.map +0 -1
  348. package/dist/esm/parser/client.js +0 -142
  349. package/dist/esm/parser/client.js.map +0 -1
  350. package/dist/esm/parser/complete.js +0 -173
  351. package/dist/esm/parser/complete.js.map +0 -1
  352. package/dist/esm/parser/index.js +0 -43
  353. package/dist/esm/parser/index.js.map +0 -1
  354. package/dist/esm/parser/inner.js +0 -180
  355. package/dist/esm/parser/inner.js.map +0 -1
  356. package/dist/esm/parser/instructions.js +0 -109
  357. package/dist/esm/parser/instructions.js.map +0 -1
  358. package/dist/esm/parser/transaction.js +0 -149
  359. package/dist/esm/parser/transaction.js.map +0 -1
  360. package/dist/esm/parser/types.js +0 -13
  361. package/dist/esm/parser/types.js.map +0 -1
  362. package/dist/esm/pda/index.js +0 -638
  363. package/dist/esm/pda/index.js.map +0 -1
  364. package/dist/esm/plugin/index.js +0 -945
  365. package/dist/esm/plugin/index.js.map +0 -1
  366. package/dist/esm/plugin/protocols.js +0 -279
  367. package/dist/esm/plugin/protocols.js.map +0 -1
  368. package/dist/esm/plugin/schemas.js +0 -860
  369. package/dist/esm/plugin/schemas.js.map +0 -1
  370. package/dist/esm/postgres/adapter.js +0 -678
  371. package/dist/esm/postgres/adapter.js.map +0 -1
  372. package/dist/esm/postgres/index.js +0 -27
  373. package/dist/esm/postgres/index.js.map +0 -1
  374. package/dist/esm/postgres/serializers.js +0 -362
  375. package/dist/esm/postgres/serializers.js.map +0 -1
  376. package/dist/esm/postgres/sync.js +0 -285
  377. package/dist/esm/postgres/sync.js.map +0 -1
  378. package/dist/esm/postgres/types.js +0 -41
  379. package/dist/esm/postgres/types.js.map +0 -1
  380. package/dist/esm/registries/builder.js +0 -410
  381. package/dist/esm/registries/builder.js.map +0 -1
  382. package/dist/esm/registries/discovery.js +0 -358
  383. package/dist/esm/registries/discovery.js.map +0 -1
  384. package/dist/esm/registries/fairscale.js +0 -633
  385. package/dist/esm/registries/fairscale.js.map +0 -1
  386. package/dist/esm/registries/index.js +0 -46
  387. package/dist/esm/registries/index.js.map +0 -1
  388. package/dist/esm/registries/metaplex-bridge.js +0 -706
  389. package/dist/esm/registries/metaplex-bridge.js.map +0 -1
  390. package/dist/esm/registries/session.js +0 -429
  391. package/dist/esm/registries/session.js.map +0 -1
  392. package/dist/esm/registries/x402.js +0 -664
  393. package/dist/esm/registries/x402.js.map +0 -1
  394. package/dist/esm/types/accounts.js +0 -12
  395. package/dist/esm/types/accounts.js.map +0 -1
  396. package/dist/esm/types/common.js +0 -12
  397. package/dist/esm/types/common.js.map +0 -1
  398. package/dist/esm/types/endpoint.js +0 -14
  399. package/dist/esm/types/endpoint.js.map +0 -1
  400. package/dist/esm/types/enums.js +0 -266
  401. package/dist/esm/types/enums.js.map +0 -1
  402. package/dist/esm/types/index.js +0 -25
  403. package/dist/esm/types/index.js.map +0 -1
  404. package/dist/esm/types/instructions.js +0 -89
  405. package/dist/esm/types/instructions.js.map +0 -1
  406. package/dist/esm/utils/endpoint-validator.js +0 -226
  407. package/dist/esm/utils/endpoint-validator.js.map +0 -1
  408. package/dist/esm/utils/escrow-validation.js +0 -212
  409. package/dist/esm/utils/escrow-validation.js.map +0 -1
  410. package/dist/esm/utils/hash.js +0 -103
  411. package/dist/esm/utils/hash.js.map +0 -1
  412. package/dist/esm/utils/merchant-validator.js +0 -241
  413. package/dist/esm/utils/merchant-validator.js.map +0 -1
  414. package/dist/esm/utils/network-normalizer.js +0 -229
  415. package/dist/esm/utils/network-normalizer.js.map +0 -1
  416. package/dist/esm/utils/priority-fee.js +0 -209
  417. package/dist/esm/utils/priority-fee.js.map +0 -1
  418. package/dist/esm/utils/rpc-strategy.js +0 -231
  419. package/dist/esm/utils/rpc-strategy.js.map +0 -1
  420. package/dist/esm/utils/schemas.js +0 -320
  421. package/dist/esm/utils/schemas.js.map +0 -1
  422. package/dist/esm/utils/serialization.js +0 -98
  423. package/dist/esm/utils/serialization.js.map +0 -1
  424. package/dist/esm/utils/validation.js +0 -33
  425. package/dist/esm/utils/validation.js.map +0 -1
  426. package/dist/esm/utils/x402-direct.js +0 -228
  427. package/dist/esm/utils/x402-direct.js.map +0 -1
  428. package/dist/types/constants/addresses.d.ts +0 -117
  429. package/dist/types/constants/addresses.d.ts.map +0 -1
  430. package/dist/types/constants/index.d.ts +0 -31
  431. package/dist/types/constants/index.d.ts.map +0 -1
  432. package/dist/types/constants/limits.d.ts +0 -149
  433. package/dist/types/constants/limits.d.ts.map +0 -1
  434. package/dist/types/constants/network.d.ts +0 -81
  435. package/dist/types/constants/network.d.ts.map +0 -1
  436. package/dist/types/constants/payments.d.ts +0 -121
  437. package/dist/types/constants/payments.d.ts.map +0 -1
  438. package/dist/types/constants/programs.d.ts +0 -69
  439. package/dist/types/constants/programs.d.ts.map +0 -1
  440. package/dist/types/constants/seeds.d.ts +0 -80
  441. package/dist/types/constants/seeds.d.ts.map +0 -1
  442. package/dist/types/core/client.d.ts +0 -452
  443. package/dist/types/core/client.d.ts.map +0 -1
  444. package/dist/types/core/connection.d.ts +0 -305
  445. package/dist/types/core/connection.d.ts.map +0 -1
  446. package/dist/types/core/index.d.ts +0 -20
  447. package/dist/types/core/index.d.ts.map +0 -1
  448. package/dist/types/errors/index.d.ts +0 -276
  449. package/dist/types/errors/index.d.ts.map +0 -1
  450. package/dist/types/events/geyser.d.ts +0 -150
  451. package/dist/types/events/geyser.d.ts.map +0 -1
  452. package/dist/types/events/index.d.ts +0 -248
  453. package/dist/types/events/index.d.ts.map +0 -1
  454. package/dist/types/idl/index.d.ts +0 -70
  455. package/dist/types/idl/index.d.ts.map +0 -1
  456. package/dist/types/index.d.ts +0 -85
  457. package/dist/types/index.d.ts.map +0 -1
  458. package/dist/types/modules/agent.d.ts +0 -166
  459. package/dist/types/modules/agent.d.ts.map +0 -1
  460. package/dist/types/modules/attestation.d.ts +0 -96
  461. package/dist/types/modules/attestation.d.ts.map +0 -1
  462. package/dist/types/modules/base.d.ts +0 -126
  463. package/dist/types/modules/base.d.ts.map +0 -1
  464. package/dist/types/modules/escrow-v2.d.ts +0 -100
  465. package/dist/types/modules/escrow-v2.d.ts.map +0 -1
  466. package/dist/types/modules/escrow.d.ts +0 -168
  467. package/dist/types/modules/escrow.d.ts.map +0 -1
  468. package/dist/types/modules/feedback.d.ts +0 -105
  469. package/dist/types/modules/feedback.d.ts.map +0 -1
  470. package/dist/types/modules/index.d.ts +0 -28
  471. package/dist/types/modules/index.d.ts.map +0 -1
  472. package/dist/types/modules/indexing.d.ts +0 -200
  473. package/dist/types/modules/indexing.d.ts.map +0 -1
  474. package/dist/types/modules/ledger.d.ts +0 -150
  475. package/dist/types/modules/ledger.d.ts.map +0 -1
  476. package/dist/types/modules/receipt.d.ts +0 -77
  477. package/dist/types/modules/receipt.d.ts.map +0 -1
  478. package/dist/types/modules/staking.d.ts +0 -51
  479. package/dist/types/modules/staking.d.ts.map +0 -1
  480. package/dist/types/modules/subscription.d.ts +0 -33
  481. package/dist/types/modules/subscription.d.ts.map +0 -1
  482. package/dist/types/modules/tools.d.ts +0 -182
  483. package/dist/types/modules/tools.d.ts.map +0 -1
  484. package/dist/types/modules/vault.d.ts +0 -240
  485. package/dist/types/modules/vault.d.ts.map +0 -1
  486. package/dist/types/parser/client.d.ts +0 -123
  487. package/dist/types/parser/client.d.ts.map +0 -1
  488. package/dist/types/parser/complete.d.ts +0 -90
  489. package/dist/types/parser/complete.d.ts.map +0 -1
  490. package/dist/types/parser/index.d.ts +0 -40
  491. package/dist/types/parser/index.d.ts.map +0 -1
  492. package/dist/types/parser/inner.d.ts +0 -114
  493. package/dist/types/parser/inner.d.ts.map +0 -1
  494. package/dist/types/parser/instructions.d.ts +0 -76
  495. package/dist/types/parser/instructions.d.ts.map +0 -1
  496. package/dist/types/parser/transaction.d.ts +0 -77
  497. package/dist/types/parser/transaction.d.ts.map +0 -1
  498. package/dist/types/parser/types.d.ts +0 -154
  499. package/dist/types/parser/types.d.ts.map +0 -1
  500. package/dist/types/pda/index.d.ts +0 -510
  501. package/dist/types/pda/index.d.ts.map +0 -1
  502. package/dist/types/plugin/index.d.ts +0 -171
  503. package/dist/types/plugin/index.d.ts.map +0 -1
  504. package/dist/types/plugin/protocols.d.ts +0 -152
  505. package/dist/types/plugin/protocols.d.ts.map +0 -1
  506. package/dist/types/plugin/schemas.d.ts +0 -829
  507. package/dist/types/plugin/schemas.d.ts.map +0 -1
  508. package/dist/types/postgres/adapter.d.ts +0 -355
  509. package/dist/types/postgres/adapter.d.ts.map +0 -1
  510. package/dist/types/postgres/index.d.ts +0 -24
  511. package/dist/types/postgres/index.d.ts.map +0 -1
  512. package/dist/types/postgres/serializers.d.ts +0 -30
  513. package/dist/types/postgres/serializers.d.ts.map +0 -1
  514. package/dist/types/postgres/sync.d.ts +0 -156
  515. package/dist/types/postgres/sync.d.ts.map +0 -1
  516. package/dist/types/postgres/types.d.ts +0 -167
  517. package/dist/types/postgres/types.d.ts.map +0 -1
  518. package/dist/types/registries/builder.d.ts +0 -340
  519. package/dist/types/registries/builder.d.ts.map +0 -1
  520. package/dist/types/registries/discovery.d.ts +0 -333
  521. package/dist/types/registries/discovery.d.ts.map +0 -1
  522. package/dist/types/registries/fairscale.d.ts +0 -680
  523. package/dist/types/registries/fairscale.d.ts.map +0 -1
  524. package/dist/types/registries/index.d.ts +0 -52
  525. package/dist/types/registries/index.d.ts.map +0 -1
  526. package/dist/types/registries/metaplex-bridge.d.ts +0 -488
  527. package/dist/types/registries/metaplex-bridge.d.ts.map +0 -1
  528. package/dist/types/registries/session.d.ts +0 -323
  529. package/dist/types/registries/session.d.ts.map +0 -1
  530. package/dist/types/registries/x402.d.ts +0 -530
  531. package/dist/types/registries/x402.d.ts.map +0 -1
  532. package/dist/types/types/accounts.d.ts +0 -765
  533. package/dist/types/types/accounts.d.ts.map +0 -1
  534. package/dist/types/types/common.d.ts +0 -166
  535. package/dist/types/types/common.d.ts.map +0 -1
  536. package/dist/types/types/endpoint.d.ts +0 -161
  537. package/dist/types/types/endpoint.d.ts.map +0 -1
  538. package/dist/types/types/enums.d.ts +0 -353
  539. package/dist/types/types/enums.d.ts.map +0 -1
  540. package/dist/types/types/index.d.ts +0 -29
  541. package/dist/types/types/index.d.ts.map +0 -1
  542. package/dist/types/types/instructions.d.ts +0 -400
  543. package/dist/types/types/instructions.d.ts.map +0 -1
  544. package/dist/types/utils/endpoint-validator.d.ts +0 -110
  545. package/dist/types/utils/endpoint-validator.d.ts.map +0 -1
  546. package/dist/types/utils/escrow-validation.d.ts +0 -145
  547. package/dist/types/utils/escrow-validation.d.ts.map +0 -1
  548. package/dist/types/utils/hash.d.ts +0 -75
  549. package/dist/types/utils/hash.d.ts.map +0 -1
  550. package/dist/types/utils/index.d.ts +0 -33
  551. package/dist/types/utils/index.d.ts.map +0 -1
  552. package/dist/types/utils/merchant-validator.d.ts +0 -176
  553. package/dist/types/utils/merchant-validator.d.ts.map +0 -1
  554. package/dist/types/utils/network-normalizer.d.ts +0 -120
  555. package/dist/types/utils/network-normalizer.d.ts.map +0 -1
  556. package/dist/types/utils/priority-fee.d.ts +0 -205
  557. package/dist/types/utils/priority-fee.d.ts.map +0 -1
  558. package/dist/types/utils/rpc-strategy.d.ts +0 -172
  559. package/dist/types/utils/rpc-strategy.d.ts.map +0 -1
  560. package/dist/types/utils/schemas.d.ts +0 -351
  561. package/dist/types/utils/schemas.d.ts.map +0 -1
  562. package/dist/types/utils/serialization.d.ts +0 -69
  563. package/dist/types/utils/serialization.d.ts.map +0 -1
  564. package/dist/types/utils/validation.d.ts +0 -29
  565. package/dist/types/utils/validation.d.ts.map +0 -1
  566. package/dist/types/utils/x402-direct.d.ts +0 -114
  567. package/dist/types/utils/x402-direct.d.ts.map +0 -1
  568. package/src/constants/addresses.ts +0 -162
  569. package/src/constants/index.ts +0 -69
  570. package/src/constants/limits.ts +0 -165
  571. package/src/constants/network.ts +0 -89
  572. package/src/constants/payments.ts +0 -145
  573. package/src/constants/programs.ts +0 -83
  574. package/src/constants/seeds.ts +0 -85
  575. package/src/core/client.ts +0 -583
  576. package/src/core/connection.ts +0 -461
  577. package/src/core/index.ts +0 -20
  578. package/src/errors/index.ts +0 -346
  579. package/src/events/geyser.ts +0 -384
  580. package/src/events/index.ts +0 -335
  581. package/src/events/yellowstone.d.ts +0 -7
  582. package/src/idl/index.ts +0 -76
  583. package/src/idl/synapse_agent_sap.json +0 -14595
  584. package/src/index.ts +0 -421
  585. package/src/modules/agent.ts +0 -319
  586. package/src/modules/attestation.ts +0 -168
  587. package/src/modules/base.ts +0 -158
  588. package/src/modules/escrow-v2.ts +0 -658
  589. package/src/modules/escrow.ts +0 -383
  590. package/src/modules/feedback.ts +0 -186
  591. package/src/modules/index.ts +0 -28
  592. package/src/modules/indexing.ts +0 -444
  593. package/src/modules/ledger.ts +0 -262
  594. package/src/modules/receipt.ts +0 -212
  595. package/src/modules/staking.ts +0 -157
  596. package/src/modules/subscription.ts +0 -147
  597. package/src/modules/tools.ts +0 -411
  598. package/src/modules/vault.ts +0 -533
  599. package/src/parser/client.ts +0 -211
  600. package/src/parser/complete.ts +0 -232
  601. package/src/parser/index.ts +0 -71
  602. package/src/parser/inner.ts +0 -255
  603. package/src/parser/instructions.ts +0 -135
  604. package/src/parser/transaction.ts +0 -200
  605. package/src/parser/types.ts +0 -182
  606. package/src/pda/index.ts +0 -919
  607. package/src/plugin/index.ts +0 -1224
  608. package/src/plugin/protocols.ts +0 -404
  609. package/src/plugin/schemas.ts +0 -941
  610. package/src/postgres/adapter.ts +0 -904
  611. package/src/postgres/index.ts +0 -59
  612. package/src/postgres/schema.sql +0 -683
  613. package/src/postgres/serializers.ts +0 -485
  614. package/src/postgres/sync.ts +0 -340
  615. package/src/postgres/types.ts +0 -245
  616. package/src/registries/builder.ts +0 -607
  617. package/src/registries/discovery.ts +0 -572
  618. package/src/registries/fairscale.ts +0 -1278
  619. package/src/registries/index.ts +0 -143
  620. package/src/registries/metaplex-bridge.ts +0 -1199
  621. package/src/registries/session.ts +0 -613
  622. package/src/registries/x402.ts +0 -1048
  623. package/src/types/accounts.ts +0 -858
  624. package/src/types/common.ts +0 -187
  625. package/src/types/endpoint.ts +0 -181
  626. package/src/types/enums.ts +0 -333
  627. package/src/types/index.ts +0 -121
  628. package/src/types/instructions.ts +0 -453
  629. package/src/utils/endpoint-validator.ts +0 -300
  630. package/src/utils/escrow-validation.ts +0 -301
  631. package/src/utils/hash.ts +0 -113
  632. package/src/utils/index.ts +0 -102
  633. package/src/utils/merchant-validator.ts +0 -359
  634. package/src/utils/network-normalizer.ts +0 -240
  635. package/src/utils/priority-fee.ts +0 -325
  636. package/src/utils/rpc-strategy.ts +0 -322
  637. package/src/utils/schemas.ts +0 -359
  638. package/src/utils/serialization.ts +0 -98
  639. package/src/utils/validation.ts +0 -36
  640. package/src/utils/x402-direct.ts +0 -370
@@ -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
- }