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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (418) hide show
  1. package/dist/cjs/accounts/index.js +286 -0
  2. package/dist/cjs/accounts/index.js.map +1 -0
  3. package/dist/cjs/client.js +125 -0
  4. package/dist/cjs/client.js.map +1 -0
  5. package/dist/cjs/constants/seeds.js +9 -9
  6. package/dist/cjs/constants/seeds.js.map +1 -1
  7. package/dist/cjs/constants.js +66 -0
  8. package/dist/cjs/constants.js.map +1 -0
  9. package/dist/cjs/errors.js +260 -0
  10. package/dist/cjs/errors.js.map +1 -0
  11. package/dist/cjs/events/index.js +37 -123
  12. package/dist/cjs/events/index.js.map +1 -1
  13. package/dist/cjs/idlTypes.js +4 -0
  14. package/dist/cjs/idlTypes.js.map +1 -0
  15. package/dist/cjs/index.js +75 -241
  16. package/dist/cjs/index.js.map +1 -1
  17. package/dist/cjs/instructions/agent.js +90 -0
  18. package/dist/cjs/instructions/agent.js.map +1 -0
  19. package/dist/cjs/instructions/attestation.js +113 -0
  20. package/dist/cjs/instructions/attestation.js.map +1 -0
  21. package/dist/cjs/instructions/digest.js +29 -0
  22. package/dist/cjs/instructions/digest.js.map +1 -0
  23. package/dist/cjs/instructions/dispute.js +117 -0
  24. package/dist/cjs/instructions/dispute.js.map +1 -0
  25. package/dist/cjs/instructions/escrow.js +102 -0
  26. package/dist/cjs/instructions/escrow.js.map +1 -0
  27. package/dist/cjs/instructions/global.js +29 -0
  28. package/dist/cjs/instructions/global.js.map +1 -0
  29. package/dist/cjs/instructions/index.js +31 -0
  30. package/dist/cjs/instructions/index.js.map +1 -0
  31. package/dist/cjs/instructions/indexing.js +222 -0
  32. package/dist/cjs/instructions/indexing.js.map +1 -0
  33. package/dist/cjs/instructions/misc.js +74 -0
  34. package/dist/cjs/instructions/misc.js.map +1 -0
  35. package/dist/cjs/instructions/session.js +90 -0
  36. package/dist/cjs/instructions/session.js.map +1 -0
  37. package/dist/cjs/instructions/staking.js +133 -0
  38. package/dist/cjs/instructions/staking.js.map +1 -0
  39. package/dist/cjs/instructions/subscription.js +81 -0
  40. package/dist/cjs/instructions/subscription.js.map +1 -0
  41. package/dist/cjs/instructions/tools.js +110 -0
  42. package/dist/cjs/instructions/tools.js.map +1 -0
  43. package/dist/cjs/instructions/vault.js +107 -0
  44. package/dist/cjs/instructions/vault.js.map +1 -0
  45. package/dist/cjs/pdas/index.js +120 -0
  46. package/dist/cjs/pdas/index.js.map +1 -0
  47. package/dist/cjs/registries/fairscale.js +1 -1
  48. package/dist/cjs/registries/fairscale.js.map +1 -1
  49. package/dist/cjs/registries/metaplex-bridge.js +1 -1
  50. package/dist/cjs/registries/metaplex-bridge.js.map +1 -1
  51. package/dist/cjs/types.js +45 -0
  52. package/dist/cjs/types.js.map +1 -0
  53. package/dist/cjs/utils/escrow-validation.js +1 -1
  54. package/dist/cjs/utils/escrow-validation.js.map +1 -1
  55. package/dist/cjs/utils/index.js +32 -83
  56. package/dist/cjs/utils/index.js.map +1 -1
  57. package/dist/cjs/utils/merchant-validator.js +5 -5
  58. package/dist/cjs/utils/merchant-validator.js.map +1 -1
  59. package/dist/cjs/utils/validate.js +236 -0
  60. package/dist/cjs/utils/validate.js.map +1 -0
  61. package/dist/cjs/utils/volume-curve.js +1 -1
  62. package/dist/cjs/utils/volume-curve.js.map +1 -1
  63. package/dist/esm/accounts/index.d.ts +11 -0
  64. package/dist/esm/accounts/index.d.ts.map +1 -0
  65. package/dist/esm/accounts/index.js +273 -0
  66. package/dist/esm/accounts/index.js.map +1 -0
  67. package/dist/esm/client.d.ts +55 -0
  68. package/dist/esm/client.d.ts.map +1 -0
  69. package/dist/esm/client.js +87 -0
  70. package/dist/esm/client.js.map +1 -0
  71. package/dist/esm/constants/addresses.d.ts +117 -0
  72. package/dist/esm/constants/addresses.d.ts.map +1 -0
  73. package/dist/esm/constants/index.d.ts +31 -0
  74. package/dist/esm/constants/index.d.ts.map +1 -0
  75. package/dist/esm/constants/limits.d.ts +149 -0
  76. package/dist/esm/constants/limits.d.ts.map +1 -0
  77. package/{src/constants/network.ts → dist/esm/constants/network.d.ts} +23 -31
  78. package/dist/esm/constants/network.d.ts.map +1 -0
  79. package/{src/constants/payments.ts → dist/esm/constants/payments.d.ts} +11 -35
  80. package/dist/esm/constants/payments.d.ts.map +1 -0
  81. package/{src/constants/programs.ts → dist/esm/constants/programs.d.ts} +6 -20
  82. package/dist/esm/constants/programs.d.ts.map +1 -0
  83. package/dist/esm/constants/seeds.d.ts +80 -0
  84. package/dist/esm/constants/seeds.d.ts.map +1 -0
  85. package/dist/esm/constants/seeds.js +9 -9
  86. package/dist/esm/constants/seeds.js.map +1 -1
  87. package/dist/esm/constants.d.ts +39 -0
  88. package/dist/esm/constants.d.ts.map +1 -0
  89. package/dist/esm/constants.js +41 -0
  90. package/dist/esm/constants.js.map +1 -0
  91. package/dist/esm/core/client.d.ts +452 -0
  92. package/dist/esm/core/client.d.ts.map +1 -0
  93. package/dist/esm/core/connection.d.ts +305 -0
  94. package/dist/esm/core/connection.d.ts.map +1 -0
  95. package/{src/core/index.ts → dist/esm/core/index.d.ts} +1 -1
  96. package/dist/esm/core/index.d.ts.map +1 -0
  97. package/dist/esm/errors/index.d.ts +276 -0
  98. package/dist/esm/errors/index.d.ts.map +1 -0
  99. package/dist/esm/errors.d.ts +119 -0
  100. package/dist/esm/errors.d.ts.map +1 -0
  101. package/dist/esm/errors.js +252 -0
  102. package/dist/esm/errors.js.map +1 -0
  103. package/dist/esm/events/geyser.d.ts +150 -0
  104. package/dist/esm/events/geyser.d.ts.map +1 -0
  105. package/dist/esm/events/index.d.ts +17 -0
  106. package/dist/esm/events/index.d.ts.map +1 -0
  107. package/dist/esm/events/index.js +34 -122
  108. package/dist/esm/events/index.js.map +1 -1
  109. package/{src/idl/index.ts → dist/esm/idl/index.d.ts} +9 -15
  110. package/dist/esm/idl/index.d.ts.map +1 -0
  111. package/dist/esm/idlTypes.d.ts +925 -0
  112. package/dist/esm/idlTypes.d.ts.map +1 -0
  113. package/dist/esm/idlTypes.js +3 -0
  114. package/dist/esm/idlTypes.js.map +1 -0
  115. package/dist/esm/index.d.ts +12 -0
  116. package/dist/esm/index.d.ts.map +1 -0
  117. package/dist/esm/index.js +15 -88
  118. package/dist/esm/index.js.map +1 -1
  119. package/dist/esm/instructions/agent.d.ts +71 -0
  120. package/dist/esm/instructions/agent.d.ts.map +1 -0
  121. package/dist/esm/instructions/agent.js +86 -0
  122. package/dist/esm/instructions/agent.js.map +1 -0
  123. package/dist/esm/instructions/attestation.d.ts +76 -0
  124. package/dist/esm/instructions/attestation.d.ts.map +1 -0
  125. package/dist/esm/instructions/attestation.js +109 -0
  126. package/dist/esm/instructions/attestation.js.map +1 -0
  127. package/dist/esm/instructions/digest.d.ts +20 -0
  128. package/dist/esm/instructions/digest.d.ts.map +1 -0
  129. package/dist/esm/instructions/digest.js +25 -0
  130. package/dist/esm/instructions/digest.js.map +1 -0
  131. package/dist/esm/instructions/dispute.d.ts +81 -0
  132. package/dist/esm/instructions/dispute.d.ts.map +1 -0
  133. package/dist/esm/instructions/dispute.js +113 -0
  134. package/dist/esm/instructions/dispute.js.map +1 -0
  135. package/dist/esm/instructions/escrow.d.ts +79 -0
  136. package/dist/esm/instructions/escrow.d.ts.map +1 -0
  137. package/dist/esm/instructions/escrow.js +98 -0
  138. package/dist/esm/instructions/escrow.js.map +1 -0
  139. package/dist/esm/instructions/global.d.ts +14 -0
  140. package/dist/esm/instructions/global.d.ts.map +1 -0
  141. package/dist/esm/instructions/global.js +25 -0
  142. package/dist/esm/instructions/global.js.map +1 -0
  143. package/dist/esm/instructions/index.d.ts +14 -0
  144. package/dist/esm/instructions/index.d.ts.map +1 -0
  145. package/dist/esm/instructions/index.js +15 -0
  146. package/dist/esm/instructions/index.js.map +1 -0
  147. package/dist/esm/instructions/indexing.d.ts +150 -0
  148. package/dist/esm/instructions/indexing.d.ts.map +1 -0
  149. package/dist/esm/instructions/indexing.js +218 -0
  150. package/dist/esm/instructions/indexing.js.map +1 -0
  151. package/dist/esm/instructions/memory.d.ts +8 -0
  152. package/dist/esm/instructions/memory.d.ts.map +1 -0
  153. package/dist/esm/instructions/memory.js +234 -0
  154. package/dist/esm/instructions/memory.js.map +1 -0
  155. package/dist/esm/instructions/misc.d.ts +50 -0
  156. package/dist/esm/instructions/misc.d.ts.map +1 -0
  157. package/dist/esm/instructions/misc.js +70 -0
  158. package/dist/esm/instructions/misc.js.map +1 -0
  159. package/dist/esm/instructions/session.d.ts +57 -0
  160. package/dist/esm/instructions/session.d.ts.map +1 -0
  161. package/dist/esm/instructions/session.js +86 -0
  162. package/dist/esm/instructions/session.js.map +1 -0
  163. package/dist/esm/instructions/staking.d.ts +85 -0
  164. package/dist/esm/instructions/staking.d.ts.map +1 -0
  165. package/dist/esm/instructions/staking.js +129 -0
  166. package/dist/esm/instructions/staking.js.map +1 -0
  167. package/dist/esm/instructions/subscription.d.ts +50 -0
  168. package/dist/esm/instructions/subscription.d.ts.map +1 -0
  169. package/dist/esm/instructions/subscription.js +77 -0
  170. package/dist/esm/instructions/subscription.js.map +1 -0
  171. package/dist/esm/instructions/tools.d.ts +88 -0
  172. package/dist/esm/instructions/tools.d.ts.map +1 -0
  173. package/dist/esm/instructions/tools.js +106 -0
  174. package/dist/esm/instructions/tools.js.map +1 -0
  175. package/dist/esm/instructions/vault.d.ts +84 -0
  176. package/dist/esm/instructions/vault.d.ts.map +1 -0
  177. package/dist/esm/instructions/vault.js +103 -0
  178. package/dist/esm/instructions/vault.js.map +1 -0
  179. package/dist/esm/modules/agent.d.ts +166 -0
  180. package/dist/esm/modules/agent.d.ts.map +1 -0
  181. package/dist/esm/modules/attestation.d.ts +96 -0
  182. package/dist/esm/modules/attestation.d.ts.map +1 -0
  183. package/dist/esm/modules/base.d.ts +161 -0
  184. package/dist/esm/modules/base.d.ts.map +1 -0
  185. package/dist/esm/modules/escrow-v2.d.ts +169 -0
  186. package/dist/esm/modules/escrow-v2.d.ts.map +1 -0
  187. package/dist/esm/modules/feedback.d.ts +105 -0
  188. package/dist/esm/modules/feedback.d.ts.map +1 -0
  189. package/{src/modules/index.ts → dist/esm/modules/index.d.ts} +1 -1
  190. package/dist/esm/modules/index.d.ts.map +1 -0
  191. package/dist/esm/modules/indexing.d.ts +200 -0
  192. package/dist/esm/modules/indexing.d.ts.map +1 -0
  193. package/dist/esm/modules/ledger.d.ts +150 -0
  194. package/dist/esm/modules/ledger.d.ts.map +1 -0
  195. package/dist/esm/modules/receipt.d.ts +77 -0
  196. package/dist/esm/modules/receipt.d.ts.map +1 -0
  197. package/dist/esm/modules/staking.d.ts +51 -0
  198. package/dist/esm/modules/staking.d.ts.map +1 -0
  199. package/dist/esm/modules/subscription.d.ts +33 -0
  200. package/dist/esm/modules/subscription.d.ts.map +1 -0
  201. package/dist/esm/modules/tools.d.ts +182 -0
  202. package/dist/esm/modules/tools.d.ts.map +1 -0
  203. package/dist/esm/modules/vault.d.ts +240 -0
  204. package/dist/esm/modules/vault.d.ts.map +1 -0
  205. package/dist/esm/parser/client.d.ts +123 -0
  206. package/dist/esm/parser/client.d.ts.map +1 -0
  207. package/dist/esm/parser/complete.d.ts +90 -0
  208. package/dist/esm/parser/complete.d.ts.map +1 -0
  209. package/{src/parser/index.ts → dist/esm/parser/index.d.ts} +6 -37
  210. package/dist/esm/parser/index.d.ts.map +1 -0
  211. package/dist/esm/parser/inner.d.ts +114 -0
  212. package/dist/esm/parser/inner.d.ts.map +1 -0
  213. package/{src/parser/instructions.ts → dist/esm/parser/instructions.d.ts} +4 -63
  214. package/dist/esm/parser/instructions.d.ts.map +1 -0
  215. package/dist/esm/parser/transaction.d.ts +77 -0
  216. package/dist/esm/parser/transaction.d.ts.map +1 -0
  217. package/dist/esm/parser/types.d.ts +154 -0
  218. package/dist/esm/parser/types.d.ts.map +1 -0
  219. package/{src/pda/index.ts → dist/esm/pda/index.d.ts} +33 -442
  220. package/dist/esm/pda/index.d.ts.map +1 -0
  221. package/dist/esm/pdas/index.d.ts +37 -0
  222. package/dist/esm/pdas/index.d.ts.map +1 -0
  223. package/dist/esm/pdas/index.js +101 -0
  224. package/dist/esm/pdas/index.js.map +1 -0
  225. package/dist/esm/plugin/index.d.ts +171 -0
  226. package/dist/esm/plugin/index.d.ts.map +1 -0
  227. package/dist/esm/plugin/protocols.d.ts +152 -0
  228. package/dist/esm/plugin/protocols.d.ts.map +1 -0
  229. package/dist/esm/plugin/schemas.d.ts +829 -0
  230. package/dist/esm/plugin/schemas.d.ts.map +1 -0
  231. package/dist/esm/postgres/adapter.d.ts +355 -0
  232. package/dist/esm/postgres/adapter.d.ts.map +1 -0
  233. package/dist/esm/postgres/index.d.ts +24 -0
  234. package/dist/esm/postgres/index.d.ts.map +1 -0
  235. package/dist/esm/postgres/serializers.d.ts +30 -0
  236. package/dist/esm/postgres/serializers.d.ts.map +1 -0
  237. package/dist/esm/postgres/sync.d.ts +156 -0
  238. package/dist/esm/postgres/sync.d.ts.map +1 -0
  239. package/dist/esm/postgres/types.d.ts +167 -0
  240. package/dist/esm/postgres/types.d.ts.map +1 -0
  241. package/dist/esm/registries/builder.d.ts +340 -0
  242. package/dist/esm/registries/builder.d.ts.map +1 -0
  243. package/dist/esm/registries/discovery.d.ts +333 -0
  244. package/dist/esm/registries/discovery.d.ts.map +1 -0
  245. package/dist/esm/registries/fairscale.d.ts +680 -0
  246. package/dist/esm/registries/fairscale.d.ts.map +1 -0
  247. package/dist/esm/registries/fairscale.js +1 -1
  248. package/dist/esm/registries/fairscale.js.map +1 -1
  249. package/dist/esm/registries/index.d.ts +52 -0
  250. package/dist/esm/registries/index.d.ts.map +1 -0
  251. package/dist/esm/registries/metaplex-bridge.d.ts +489 -0
  252. package/dist/esm/registries/metaplex-bridge.d.ts.map +1 -0
  253. package/dist/esm/registries/metaplex-bridge.js +1 -1
  254. package/dist/esm/registries/metaplex-bridge.js.map +1 -1
  255. package/dist/esm/registries/session.d.ts +323 -0
  256. package/dist/esm/registries/session.d.ts.map +1 -0
  257. package/dist/esm/registries/x402.d.ts +530 -0
  258. package/dist/esm/registries/x402.d.ts.map +1 -0
  259. package/dist/esm/types/accounts.d.ts +765 -0
  260. package/dist/esm/types/accounts.d.ts.map +1 -0
  261. package/dist/esm/types/common.d.ts +166 -0
  262. package/dist/esm/types/common.d.ts.map +1 -0
  263. package/dist/esm/types/endpoint.d.ts +161 -0
  264. package/dist/esm/types/endpoint.d.ts.map +1 -0
  265. package/dist/esm/types/enums.d.ts +353 -0
  266. package/dist/esm/types/enums.d.ts.map +1 -0
  267. package/dist/esm/types/index.d.ts +29 -0
  268. package/dist/esm/types/index.d.ts.map +1 -0
  269. package/dist/esm/types/instructions.d.ts +400 -0
  270. package/dist/esm/types/instructions.d.ts.map +1 -0
  271. package/dist/esm/types.d.ts +236 -0
  272. package/dist/esm/types.d.ts.map +1 -0
  273. package/dist/esm/types.js +40 -0
  274. package/dist/esm/types.js.map +1 -0
  275. package/dist/esm/utils/anchor-errors.d.ts +61 -0
  276. package/dist/esm/utils/anchor-errors.d.ts.map +1 -0
  277. package/dist/esm/utils/endpoint-validator.d.ts +110 -0
  278. package/dist/esm/utils/endpoint-validator.d.ts.map +1 -0
  279. package/dist/esm/utils/escrow-validation.d.ts +145 -0
  280. package/dist/esm/utils/escrow-validation.d.ts.map +1 -0
  281. package/dist/esm/utils/escrow-validation.js +1 -1
  282. package/dist/esm/utils/escrow-validation.js.map +1 -1
  283. package/{src/utils/hash.ts → dist/esm/utils/hash.d.ts} +4 -42
  284. package/dist/esm/utils/hash.d.ts.map +1 -0
  285. package/dist/esm/utils/index.d.ts +6 -0
  286. package/dist/esm/utils/index.d.ts.map +1 -0
  287. package/dist/esm/utils/index.js +16 -33
  288. package/dist/esm/utils/index.js.map +1 -1
  289. package/dist/esm/utils/merchant-validator.d.ts +176 -0
  290. package/dist/esm/utils/merchant-validator.d.ts.map +1 -0
  291. package/dist/esm/utils/merchant-validator.js +1 -1
  292. package/dist/esm/utils/merchant-validator.js.map +1 -1
  293. package/dist/esm/utils/network-normalizer.d.ts +120 -0
  294. package/dist/esm/utils/network-normalizer.d.ts.map +1 -0
  295. package/dist/esm/utils/priority-fee.d.ts +205 -0
  296. package/dist/esm/utils/priority-fee.d.ts.map +1 -0
  297. package/dist/esm/utils/rpc-strategy.d.ts +172 -0
  298. package/dist/esm/utils/rpc-strategy.d.ts.map +1 -0
  299. package/dist/esm/utils/schemas.d.ts +351 -0
  300. package/dist/esm/utils/schemas.d.ts.map +1 -0
  301. package/{src/utils/serialization.ts → dist/esm/utils/serialization.d.ts} +3 -32
  302. package/dist/esm/utils/serialization.d.ts.map +1 -0
  303. package/dist/esm/utils/validate.d.ts +66 -0
  304. package/dist/esm/utils/validate.d.ts.map +1 -0
  305. package/dist/esm/utils/validate.js +221 -0
  306. package/dist/esm/utils/validate.js.map +1 -0
  307. package/{src/utils/validation.ts → dist/esm/utils/validation.d.ts} +2 -9
  308. package/dist/esm/utils/validation.d.ts.map +1 -0
  309. package/{src/utils/volume-curve.ts → dist/esm/utils/volume-curve.d.ts} +2 -73
  310. package/dist/esm/utils/volume-curve.d.ts.map +1 -0
  311. package/dist/esm/utils/volume-curve.js +1 -1
  312. package/dist/esm/utils/volume-curve.js.map +1 -1
  313. package/dist/esm/utils/x402-direct.d.ts +114 -0
  314. package/dist/esm/utils/x402-direct.d.ts.map +1 -0
  315. package/dist/types/constants/seeds.d.ts +2 -0
  316. package/dist/types/constants/seeds.d.ts.map +1 -1
  317. package/dist/types/core/client.d.ts +21 -6
  318. package/dist/types/core/client.d.ts.map +1 -1
  319. package/dist/types/errors/index.d.ts +59 -0
  320. package/dist/types/errors/index.d.ts.map +1 -1
  321. package/dist/types/index.d.ts +3 -2
  322. package/dist/types/index.d.ts.map +1 -1
  323. package/dist/types/modules/agent.d.ts +9 -19
  324. package/dist/types/modules/agent.d.ts.map +1 -1
  325. package/dist/types/modules/attestation.d.ts.map +1 -1
  326. package/dist/types/modules/base.d.ts +54 -0
  327. package/dist/types/modules/base.d.ts.map +1 -1
  328. package/dist/types/modules/escrow-v2.d.ts +117 -1
  329. package/dist/types/modules/escrow-v2.d.ts.map +1 -1
  330. package/dist/types/modules/index.d.ts +1 -2
  331. package/dist/types/modules/index.d.ts.map +1 -1
  332. package/dist/types/modules/receipt.d.ts +14 -0
  333. package/dist/types/modules/receipt.d.ts.map +1 -1
  334. package/dist/types/modules/subscription.d.ts.map +1 -1
  335. package/dist/types/modules/tools.d.ts +0 -10
  336. package/dist/types/modules/tools.d.ts.map +1 -1
  337. package/dist/types/modules/vault.d.ts.map +1 -1
  338. package/dist/types/pda/index.d.ts +17 -0
  339. package/dist/types/pda/index.d.ts.map +1 -1
  340. package/dist/types/plugin/index.d.ts.map +1 -1
  341. package/dist/types/registries/builder.d.ts +2 -9
  342. package/dist/types/registries/builder.d.ts.map +1 -1
  343. package/dist/types/registries/metaplex-bridge.d.ts.map +1 -1
  344. package/dist/types/registries/session.d.ts +3 -9
  345. package/dist/types/registries/session.d.ts.map +1 -1
  346. package/dist/types/registries/x402.d.ts +2 -9
  347. package/dist/types/registries/x402.d.ts.map +1 -1
  348. package/dist/types/types/accounts.d.ts +52 -0
  349. package/dist/types/types/accounts.d.ts.map +1 -1
  350. package/dist/types/types/index.d.ts +1 -1
  351. package/dist/types/types/index.d.ts.map +1 -1
  352. package/dist/types/utils/rpc-strategy.d.ts +7 -0
  353. package/dist/types/utils/rpc-strategy.d.ts.map +1 -1
  354. package/package.json +59 -183
  355. package/src/constants/addresses.ts +0 -162
  356. package/src/constants/index.ts +0 -69
  357. package/src/constants/limits.ts +0 -165
  358. package/src/constants/seeds.ts +0 -85
  359. package/src/core/client.ts +0 -583
  360. package/src/core/connection.ts +0 -461
  361. package/src/errors/index.ts +0 -346
  362. package/src/events/geyser.ts +0 -384
  363. package/src/events/index.ts +0 -335
  364. package/src/events/yellowstone.d.ts +0 -7
  365. package/src/idl/synapse_agent_sap.json +0 -14595
  366. package/src/index.ts +0 -421
  367. package/src/modules/agent.ts +0 -319
  368. package/src/modules/attestation.ts +0 -168
  369. package/src/modules/base.ts +0 -247
  370. package/src/modules/escrow-v2.ts +0 -871
  371. package/src/modules/escrow.ts +0 -439
  372. package/src/modules/feedback.ts +0 -186
  373. package/src/modules/indexing.ts +0 -444
  374. package/src/modules/ledger.ts +0 -262
  375. package/src/modules/receipt.ts +0 -212
  376. package/src/modules/staking.ts +0 -223
  377. package/src/modules/subscription.ts +0 -147
  378. package/src/modules/tools.ts +0 -454
  379. package/src/modules/vault.ts +0 -558
  380. package/src/parser/client.ts +0 -211
  381. package/src/parser/complete.ts +0 -232
  382. package/src/parser/inner.ts +0 -255
  383. package/src/parser/transaction.ts +0 -200
  384. package/src/parser/types.ts +0 -182
  385. package/src/plugin/index.ts +0 -1224
  386. package/src/plugin/protocols.ts +0 -404
  387. package/src/plugin/schemas.ts +0 -941
  388. package/src/postgres/adapter.ts +0 -904
  389. package/src/postgres/index.ts +0 -59
  390. package/src/postgres/schema.sql +0 -683
  391. package/src/postgres/serializers.ts +0 -485
  392. package/src/postgres/sync.ts +0 -340
  393. package/src/postgres/types.ts +0 -245
  394. package/src/registries/builder.ts +0 -607
  395. package/src/registries/discovery.ts +0 -572
  396. package/src/registries/fairscale.ts +0 -1278
  397. package/src/registries/index.ts +0 -143
  398. package/src/registries/metaplex-bridge.ts +0 -1199
  399. package/src/registries/session.ts +0 -613
  400. package/src/registries/x402.ts +0 -1048
  401. package/src/types/accounts.ts +0 -858
  402. package/src/types/common.ts +0 -187
  403. package/src/types/endpoint.ts +0 -181
  404. package/src/types/enums.ts +0 -333
  405. package/src/types/index.ts +0 -121
  406. package/src/types/instructions.ts +0 -453
  407. package/src/utils/anchor-errors.ts +0 -461
  408. package/src/utils/endpoint-validator.ts +0 -300
  409. package/src/utils/escrow-validation.ts +0 -301
  410. package/src/utils/index.ts +0 -118
  411. package/src/utils/merchant-validator.ts +0 -359
  412. package/src/utils/network-normalizer.ts +0 -240
  413. package/src/utils/priority-fee.ts +0 -325
  414. package/src/utils/rpc-strategy.ts +0 -322
  415. package/src/utils/schemas.ts +0 -359
  416. package/src/utils/x402-direct.ts +0 -370
  417. /package/dist/{types → esm}/modules/escrow.d.ts +0 -0
  418. /package/dist/{types → esm}/modules/escrow.d.ts.map +0 -0
@@ -1,211 +0,0 @@
1
- /**
2
- * @module parser/client
3
- * @description Object-oriented wrapper for transaction parsing.
4
- *
5
- * Binds the Anchor `Program` reference so callers do not need to
6
- * pass it on every call. Designed as a lazy singleton accessible
7
- * from {@link SapClient.parser}.
8
- *
9
- * @category Parser
10
- * @since v0.5.0
11
- *
12
- * @example
13
- * ```ts
14
- * const client = SapClient.from(provider);
15
- *
16
- * // Parse a full transaction
17
- * const parsed = client.parser.parseTransaction(txResponse);
18
- *
19
- * // Quick instruction names
20
- * const names = client.parser.instructionNames(txResponse);
21
- *
22
- * // From pre-built instructions
23
- * const decoded = client.parser.fromInstructions(ixList);
24
- * ```
25
- */
26
-
27
- import type { Program } from "@coral-xyz/anchor";
28
- import type {
29
- PublicKey,
30
- TransactionInstruction,
31
- TransactionResponse,
32
- VersionedTransactionResponse,
33
- } from "@solana/web3.js";
34
- import { AddressLookupTableAccount } from "@solana/web3.js";
35
-
36
- import type {
37
- DecodedSapInstruction,
38
- ParsedSapTransaction,
39
- ParseFilterOptions,
40
- SapInstructionCoder,
41
- } from "./types";
42
- import { parseSapInstructionsFromTransaction } from "./transaction";
43
- import { parseSapInstructionsFromList, containsSapInstruction } from "./instructions";
44
- import { parseSapTransactionComplete, parseSapTransactionBatch } from "./complete";
45
- import {
46
- decodeInnerInstructions,
47
- extractAccountKeys,
48
- type InnerInstructionGroup,
49
- } from "./inner";
50
-
51
- /**
52
- * Stateful transaction parser bound to a specific Anchor `Program`.
53
- *
54
- * Stores the program reference, instruction coder, and program ID
55
- * internally so that repeated parse calls require only the
56
- * transaction data as input.
57
- *
58
- * @name TransactionParser
59
- * @category Parser
60
- * @since v0.5.0
61
- */
62
- export class TransactionParser {
63
- private readonly coder: SapInstructionCoder;
64
- private readonly programId: PublicKey;
65
-
66
- /**
67
- * Create a new TransactionParser.
68
- *
69
- * @param program - An Anchor `Program` built from the SAP IDL.
70
- */
71
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
72
- constructor(private readonly program: Program<any>) {
73
- this.coder = program.coder.instruction as unknown as SapInstructionCoder;
74
- this.programId = program.programId;
75
- }
76
-
77
- /**
78
- * Full parse: instructions + inner calls + events.
79
- *
80
- * @param tx - Raw transaction response from `connection.getTransaction`.
81
- * @param options - Optional filters for instructions, events, and inner calls.
82
- * @param addressLookupTables - Resolved lookup tables for v0 transactions.
83
- * @returns Complete parsed transaction, or `null` if the input is nullish.
84
- *
85
- * @since v0.5.0
86
- */
87
- parseTransaction(
88
- tx: TransactionResponse | VersionedTransactionResponse | null | undefined,
89
- options?: ParseFilterOptions,
90
- addressLookupTables?: AddressLookupTableAccount[],
91
- ): ParsedSapTransaction | null {
92
- return parseSapTransactionComplete(
93
- tx,
94
- this.program,
95
- this.programId,
96
- options,
97
- addressLookupTables,
98
- );
99
- }
100
-
101
- /**
102
- * Parse a batch of transactions.
103
- *
104
- * @param txs - Array of transaction responses (may contain `null` entries).
105
- * @param options - Optional parse filters.
106
- * @param addressLookupTables - Resolved lookup tables for v0 transactions.
107
- * @returns Non-null parsed transactions.
108
- *
109
- * @since v0.5.0
110
- */
111
- parseBatch(
112
- txs: (TransactionResponse | VersionedTransactionResponse | null | undefined)[],
113
- options?: ParseFilterOptions,
114
- addressLookupTables?: AddressLookupTableAccount[],
115
- ): ParsedSapTransaction[] {
116
- return parseSapTransactionBatch(
117
- txs,
118
- this.program,
119
- this.programId,
120
- options,
121
- addressLookupTables,
122
- );
123
- }
124
-
125
- /**
126
- * Decode top-level SAP instructions from a transaction response.
127
- *
128
- * @param tx - Raw transaction response.
129
- * @param addressLookupTables - Resolved lookup tables for v0 transactions.
130
- * @returns Decoded SAP instructions.
131
- *
132
- * @since v0.5.0
133
- */
134
- instructionsFromTransaction(
135
- tx: TransactionResponse | VersionedTransactionResponse,
136
- addressLookupTables?: AddressLookupTableAccount[],
137
- ): DecodedSapInstruction[] {
138
- return parseSapInstructionsFromTransaction(
139
- tx,
140
- this.coder,
141
- this.programId,
142
- addressLookupTables,
143
- );
144
- }
145
-
146
- /**
147
- * Extract only the instruction names from a transaction response.
148
- *
149
- * @param tx - Raw transaction response.
150
- * @param addressLookupTables - Resolved lookup tables for v0 transactions.
151
- * @returns Instruction name strings.
152
- *
153
- * @since v0.5.0
154
- */
155
- instructionNames(
156
- tx: TransactionResponse | VersionedTransactionResponse,
157
- addressLookupTables?: AddressLookupTableAccount[],
158
- ): string[] {
159
- return this.instructionsFromTransaction(tx, addressLookupTables).map(
160
- (ix) => ix.name,
161
- );
162
- }
163
-
164
- /**
165
- * Decode SAP instructions from a pre-built instruction array.
166
- *
167
- * @param instructions - The instruction list to decode.
168
- * @returns Decoded SAP instructions.
169
- *
170
- * @since v0.5.0
171
- */
172
- fromInstructions(
173
- instructions: TransactionInstruction[],
174
- ): DecodedSapInstruction[] {
175
- return parseSapInstructionsFromList(instructions, this.coder, this.programId);
176
- }
177
-
178
- /**
179
- * Check if any instruction in the list targets the SAP program.
180
- *
181
- * @param instructions - The instruction array to inspect.
182
- * @returns `true` if at least one instruction targets SAP.
183
- *
184
- * @since v0.5.0
185
- */
186
- isSapTransaction(instructions: TransactionInstruction[]): boolean {
187
- return containsSapInstruction(instructions, this.programId);
188
- }
189
-
190
- /**
191
- * Decode inner (CPI) instructions from transaction metadata.
192
- *
193
- * @param innerGroups - The `tx.meta.innerInstructions` array.
194
- * @param tx - The transaction response (for account key resolution).
195
- * @returns Decoded inner instructions.
196
- *
197
- * @since v0.5.0
198
- */
199
- decodeInner(
200
- innerGroups: InnerInstructionGroup[],
201
- tx: TransactionResponse | VersionedTransactionResponse,
202
- ) {
203
- const accountKeys = extractAccountKeys(tx);
204
- return decodeInnerInstructions(
205
- innerGroups,
206
- accountKeys,
207
- this.coder,
208
- this.programId,
209
- );
210
- }
211
- }
@@ -1,232 +0,0 @@
1
- /**
2
- * @module parser/complete
3
- * @description Full SAP transaction parser: instructions + args + accounts + events.
4
- *
5
- * This is "Case 2 Complete": given a raw transaction response, produce a
6
- * single {@link ParsedSapTransaction} containing every decoded instruction,
7
- * all inner (CPI) calls, and all SAP events extracted from the logs.
8
- *
9
- * Designed for indexer pipelines where the decode step must be pure,
10
- * deterministic, and fully testable without an RPC connection.
11
- *
12
- * @category Parser
13
- * @since v0.5.0
14
- *
15
- * @example
16
- * ```ts
17
- * import { parseSapTransactionComplete } from "@synapse-sap/sdk/parser";
18
- * import { SAP_PROGRAM_ID, SAP_IDL } from "@synapse-sap/sdk";
19
- * import { Program } from "\@coral-xyz/anchor";
20
- *
21
- * const program = new Program(SAP_IDL, provider);
22
- * const tx = await connection.getTransaction(sig, {
23
- * commitment: "confirmed",
24
- * maxSupportedTransactionVersion: 0,
25
- * });
26
- *
27
- * const parsed = parseSapTransactionComplete(tx, program, SAP_PROGRAM_ID);
28
- * console.log(parsed.instructions.map(i => i.name));
29
- * console.log(parsed.events.map(e => e.name));
30
- * ```
31
- */
32
-
33
- import {
34
- AddressLookupTableAccount,
35
- type PublicKey,
36
- type TransactionResponse,
37
- type VersionedTransactionResponse,
38
- } from "@solana/web3.js";
39
- import type { Program } from "@coral-xyz/anchor";
40
-
41
- import type {
42
- ParsedSapTransaction,
43
- ParseFilterOptions,
44
- DecodedInnerInstruction,
45
- SapInstructionCoder,
46
- } from "./types";
47
- import type { ParsedEvent } from "../events";
48
- import { EventParser } from "../events";
49
- import { parseSapInstructionsFromTransaction } from "./transaction";
50
- import {
51
- decodeInnerInstructions,
52
- extractAccountKeys,
53
- type InnerInstructionGroup,
54
- } from "./inner";
55
-
56
- // ================================================================
57
- // Public API
58
- // ================================================================
59
-
60
- /**
61
- * Parse a complete SAP transaction into a unified result.
62
- *
63
- * Combines three stages:
64
- * 1. **Instruction decode** - top-level SAP instructions with args and accounts
65
- * 2. **Inner instruction decode** - CPI calls with full account reconstruction
66
- * 3. **Event extraction** - SAP events decoded from the transaction logs
67
- *
68
- * All three stages are safe: malformed data produces `null` fields
69
- * rather than exceptions. This makes the function suitable for
70
- * batch-processing in indexer workers where a single bad transaction
71
- * must not halt the pipeline.
72
- *
73
- * @param tx - The raw transaction response from `connection.getTransaction`.
74
- * @param program - An Anchor `Program` instance built from the SAP IDL.
75
- * The coder and program ID are extracted automatically.
76
- * @param sapProgramId - The SAP program public key. Passed explicitly so
77
- * callers can target devnet/localnet deployments independently.
78
- * @param options - Optional filters for instructions, events, and inner calls.
79
- * @param addressLookupTables - Resolved lookup table accounts for v0 transactions.
80
- * @returns A fully parsed transaction, or `null` if the input is `null`/`undefined`.
81
- *
82
- * @category Parser
83
- * @since v0.5.0
84
- */
85
- export function parseSapTransactionComplete(
86
- tx: TransactionResponse | VersionedTransactionResponse | null | undefined,
87
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
88
- program: Program<any>,
89
- sapProgramId: PublicKey,
90
- options?: ParseFilterOptions,
91
- addressLookupTables?: AddressLookupTableAccount[],
92
- ): ParsedSapTransaction | null {
93
- if (!tx) return null;
94
-
95
- const opts: Required<ParseFilterOptions> = {
96
- includeInner: options?.includeInner ?? false,
97
- includeEvents: options?.includeEvents ?? true,
98
- instructionFilter: options?.instructionFilter ?? [],
99
- eventFilter: options?.eventFilter ?? [],
100
- };
101
-
102
- // Extract coder from the program
103
- const coder = program.coder.instruction as unknown as SapInstructionCoder;
104
-
105
- // 1. Top-level instructions
106
- let instructions = parseSapInstructionsFromTransaction(
107
- tx,
108
- coder,
109
- sapProgramId,
110
- addressLookupTables,
111
- );
112
-
113
- if (opts.instructionFilter.length > 0) {
114
- const filterSet = new Set(opts.instructionFilter);
115
- instructions = instructions.filter((ix) => filterSet.has(ix.name));
116
- }
117
-
118
- // 2. Inner (CPI) instructions
119
- let innerInstructions: DecodedInnerInstruction[] = [];
120
- if (opts.includeInner && tx.meta?.innerInstructions) {
121
- const accountKeys = extractAccountKeys(tx);
122
- innerInstructions = decodeInnerInstructions(
123
- tx.meta.innerInstructions as unknown as InnerInstructionGroup[],
124
- accountKeys,
125
- coder,
126
- sapProgramId,
127
- );
128
- }
129
-
130
- // 3. Events from logs
131
- let events: ParsedEvent[] = [];
132
- const logs = tx.meta?.logMessages ?? [];
133
-
134
- if (opts.includeEvents && logs.length > 0) {
135
- const eventParser = new EventParser(program);
136
- events = eventParser.parseLogs(logs);
137
-
138
- if (opts.eventFilter.length > 0) {
139
- const filterSet = new Set(opts.eventFilter);
140
- events = events.filter((e) => filterSet.has(e.name as never));
141
- }
142
- }
143
-
144
- // 4. Metadata
145
- const signature = extractSignature(tx);
146
- const slot = tx.slot ?? null;
147
- const blockTime = tx.blockTime ?? null;
148
- const success = tx.meta?.err === null || tx.meta?.err === undefined;
149
-
150
- return {
151
- signature,
152
- slot,
153
- blockTime,
154
- success,
155
- instructions,
156
- innerInstructions,
157
- events,
158
- logs,
159
- };
160
- }
161
-
162
- /**
163
- * Parse multiple transactions in batch.
164
- *
165
- * Convenience wrapper for indexer pipelines that process pages of
166
- * transactions. Skips `null` entries and failed decodes silently.
167
- *
168
- * @param txs - Array of transaction responses (may contain `null` entries).
169
- * @param program - The Anchor SAP program instance.
170
- * @param sapProgramId - The SAP program public key.
171
- * @param options - Optional parse filters applied to every transaction.
172
- * @param addressLookupTables - Lookup tables for v0 transactions.
173
- * @returns An array of non-null parsed transactions.
174
- *
175
- * @category Parser
176
- * @since v0.5.0
177
- *
178
- * @example
179
- * ```ts
180
- * const signatures = await connection.getSignaturesForAddress(agentPda);
181
- * const txs = await Promise.all(
182
- * signatures.map(s => connection.getTransaction(s.signature, { ... }))
183
- * );
184
- * const parsed = parseSapTransactionBatch(txs, program, SAP_PROGRAM_ID, {
185
- * includeEvents: true,
186
- * includeInner: true,
187
- * });
188
- * ```
189
- */
190
- export function parseSapTransactionBatch(
191
- txs: (TransactionResponse | VersionedTransactionResponse | null | undefined)[],
192
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
193
- program: Program<any>,
194
- sapProgramId: PublicKey,
195
- options?: ParseFilterOptions,
196
- addressLookupTables?: AddressLookupTableAccount[],
197
- ): ParsedSapTransaction[] {
198
- const results: ParsedSapTransaction[] = [];
199
- for (const tx of txs) {
200
- const parsed = parseSapTransactionComplete(
201
- tx,
202
- program,
203
- sapProgramId,
204
- options,
205
- addressLookupTables,
206
- );
207
- if (parsed) results.push(parsed);
208
- }
209
- return results;
210
- }
211
-
212
- // ================================================================
213
- // Internal
214
- // ================================================================
215
-
216
- /**
217
- * Extract the transaction signature from the response.
218
- * Different RPC clients expose it in different locations.
219
- *
220
- * @internal
221
- */
222
- function extractSignature(
223
- tx: TransactionResponse | VersionedTransactionResponse,
224
- ): string | null {
225
- // Some clients expose signatures on the transaction object
226
- const txObj = tx.transaction;
227
- if ("signatures" in txObj && Array.isArray(txObj.signatures) && txObj.signatures.length > 0) {
228
- const first = txObj.signatures[0];
229
- if (typeof first === "string") return first;
230
- }
231
- return null;
232
- }
@@ -1,255 +0,0 @@
1
- /**
2
- * @module parser/inner
3
- * @description Decode inner (CPI) instructions from transaction metadata.
4
- *
5
- * When a SAP instruction triggers cross-program invocations, the
6
- * resulting inner instructions appear in `tx.meta.innerInstructions`.
7
- * These are stored in a "compiled" format that references account
8
- * indices rather than full public keys.
9
- *
10
- * This module reconstructs the full account keys from the transaction
11
- * message's account list and decodes any inner calls that target the
12
- * SAP program.
13
- *
14
- * @category Parser
15
- * @since v0.5.0
16
- *
17
- * @example
18
- * ```ts
19
- * import { decodeInnerInstructions } from "@synapse-sap/sdk/parser";
20
- *
21
- * const inner = decodeInnerInstructions(
22
- * tx.meta?.innerInstructions ?? [],
23
- * accountKeys,
24
- * program.coder.instruction,
25
- * SAP_PROGRAM_ID,
26
- * );
27
- * for (const cpi of inner) {
28
- * if (cpi.name) console.log("SAP CPI:", cpi.name);
29
- * }
30
- * ```
31
- */
32
-
33
- import { PublicKey } from "@solana/web3.js";
34
- import { utils } from "@coral-xyz/anchor";
35
- import type { DecodedInnerInstruction, SapInstructionCoder } from "./types";
36
-
37
- // ================================================================
38
- // Types matching Solana RPC response shapes
39
- // ================================================================
40
-
41
- /**
42
- * Shape of a single compiled inner instruction from `tx.meta.innerInstructions`.
43
- * Mirrors the Solana RPC `CompiledInnerInstruction` format.
44
- *
45
- * @interface CompiledInner
46
- * @category Parser
47
- * @since v0.5.0
48
- */
49
- export interface CompiledInner {
50
- readonly programIdIndex: number;
51
- readonly accounts: number[];
52
- readonly data: string;
53
- }
54
-
55
- /**
56
- * Top-level inner instruction group from the transaction metadata.
57
- * Each group corresponds to one outer instruction by `index`.
58
- *
59
- * @interface InnerInstructionGroup
60
- * @category Parser
61
- * @since v0.5.0
62
- */
63
- export interface InnerInstructionGroup {
64
- readonly index: number;
65
- readonly instructions: CompiledInner[];
66
- }
67
-
68
- // ================================================================
69
- // Public API
70
- // ================================================================
71
-
72
- /**
73
- * Decode inner (CPI) instructions from transaction metadata.
74
- *
75
- * Reconstructs full public keys from the compiled account indices
76
- * and attempts to decode each inner instruction that targets the
77
- * SAP program. Non-SAP inner instructions are included in the
78
- * result with `name: null` and `args: null`.
79
- *
80
- * @param innerInstructionGroups - The `tx.meta.innerInstructions` array.
81
- * @param accountKeys - Ordered list of all account public keys from the
82
- * transaction message (`staticAccountKeys` for versioned, or
83
- * `accountKeys` for legacy).
84
- * @param coder - An Anchor instruction coder built from the SAP IDL.
85
- * @param sapProgramId - The SAP program public key.
86
- * @returns An array of decoded inner instructions.
87
- *
88
- * @category Parser
89
- * @since v0.5.0
90
- */
91
- export function decodeInnerInstructions(
92
- innerInstructionGroups: InnerInstructionGroup[],
93
- accountKeys: PublicKey[],
94
- coder: SapInstructionCoder,
95
- sapProgramId: PublicKey,
96
- ): DecodedInnerInstruction[] {
97
- const results: DecodedInnerInstruction[] = [];
98
-
99
- for (const group of innerInstructionGroups) {
100
- for (let innerIdx = 0; innerIdx < group.instructions.length; innerIdx++) {
101
- const compiled = group.instructions[innerIdx];
102
- if (!compiled) continue;
103
-
104
- const programId = resolveAccountKey(
105
- accountKeys,
106
- compiled.programIdIndex,
107
- );
108
- const accounts = compiled.accounts.map((idx) =>
109
- resolveAccountKey(accountKeys, idx),
110
- );
111
-
112
- let name: string | null = null;
113
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
114
- let args: Record<string, any> | null = null;
115
-
116
- if (programId.equals(sapProgramId)) {
117
- const decoded = safeDecodeInstruction(coder, compiled.data);
118
- if (decoded) {
119
- name = decoded.name;
120
- args = decoded.data;
121
- }
122
- }
123
-
124
- results.push({
125
- outerIndex: group.index,
126
- innerIndex: innerIdx,
127
- name,
128
- args,
129
- accounts,
130
- programId,
131
- });
132
- }
133
- }
134
-
135
- return results;
136
- }
137
-
138
- /**
139
- * Filter decoded inner instructions to only those targeting the SAP program.
140
- *
141
- * @param inner - The full inner instruction list from {@link decodeInnerInstructions}.
142
- * @returns Only inner instructions where `name` is not `null`.
143
- *
144
- * @category Parser
145
- * @since v0.5.0
146
- */
147
- export function filterSapInnerInstructions(
148
- inner: DecodedInnerInstruction[],
149
- ): DecodedInnerInstruction[] {
150
- return inner.filter((i) => i.name !== null);
151
- }
152
-
153
- // ================================================================
154
- // Helpers: extract account keys from various tx formats
155
- // ================================================================
156
-
157
- /**
158
- * Extract the full ordered list of account keys from a transaction
159
- * response, handling both legacy and versioned formats.
160
- *
161
- * For versioned transactions that include loaded addresses (from
162
- * address lookup tables), these are appended after the static keys
163
- * in the order: static, writable loaded, readonly loaded.
164
- *
165
- * @param tx - The raw transaction response from RPC.
166
- * @returns An ordered array of all account public keys.
167
- *
168
- * @category Parser
169
- * @since v0.5.0
170
- */
171
- export function extractAccountKeys(
172
- tx: {
173
- transaction: {
174
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
175
- message: any;
176
- };
177
- meta?: {
178
- loadedAddresses?: {
179
- writable: PublicKey[];
180
- readonly: PublicKey[];
181
- } | null;
182
- } | null;
183
- },
184
- ): PublicKey[] {
185
- const message = tx.transaction.message;
186
-
187
- // Versioned messages expose `staticAccountKeys`
188
- if ("staticAccountKeys" in message && Array.isArray(message.staticAccountKeys)) {
189
- const staticKeys: PublicKey[] = message.staticAccountKeys.map(toPubkey);
190
- const loaded = tx.meta?.loadedAddresses;
191
- if (loaded) {
192
- return [
193
- ...staticKeys,
194
- ...loaded.writable.map(toPubkey),
195
- ...loaded.readonly.map(toPubkey),
196
- ];
197
- }
198
- return staticKeys;
199
- }
200
-
201
- // Legacy messages expose `accountKeys`
202
- if ("accountKeys" in message && Array.isArray(message.accountKeys)) {
203
- return message.accountKeys.map(toPubkey);
204
- }
205
-
206
- return [];
207
- }
208
-
209
- // ================================================================
210
- // Internal
211
- // ================================================================
212
-
213
- /**
214
- * Safely resolve an account index to a public key, returning
215
- * `PublicKey.default` for out-of-bounds indices instead of throwing.
216
- *
217
- * @internal
218
- */
219
- function resolveAccountKey(keys: PublicKey[], index: number): PublicKey {
220
- const key = keys[index];
221
- return key ?? PublicKey.default;
222
- }
223
-
224
- /**
225
- * Coerce a value to PublicKey. Handles both string base58 and
226
- * PublicKey instances returned by different RPC client versions.
227
- *
228
- * @internal
229
- */
230
- function toPubkey(value: string | PublicKey): PublicKey {
231
- if (typeof value === "string") return new PublicKey(value);
232
- return value;
233
- }
234
-
235
- /**
236
- * @internal
237
- */
238
- function safeDecodeInstruction(
239
- coder: SapInstructionCoder,
240
- data: string,
241
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
242
- ): { name: string; data: Record<string, any> } | null {
243
- try {
244
- // Inner instruction data from RPC is base58-encoded
245
- const buffer = Buffer.from(utils.bytes.bs58.decode(data));
246
- return coder.decode(buffer);
247
- } catch {
248
- // Fallback: try base64 encoding (some RPC responses use base64)
249
- try {
250
- return coder.decode(Buffer.from(data, "base64"));
251
- } catch {
252
- return null;
253
- }
254
- }
255
- }