@stellar/stellar-sdk 16.0.1 → 16.2.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 (310) hide show
  1. package/README.md +41 -2
  2. package/dist/stellar-sdk-axios.js +5401 -3690
  3. package/dist/stellar-sdk-axios.js.map +1 -1
  4. package/dist/stellar-sdk-axios.min.js +12 -11
  5. package/dist/stellar-sdk-axios.min.js.map +1 -1
  6. package/dist/stellar-sdk.js +4850 -3681
  7. package/dist/stellar-sdk.js.map +1 -1
  8. package/dist/stellar-sdk.min.js +17 -17
  9. package/dist/stellar-sdk.min.js.map +1 -1
  10. package/lib/axios/cjs/base/auth.js +147 -30
  11. package/lib/axios/cjs/base/auth.js.map +1 -1
  12. package/lib/axios/cjs/base/index.js +113 -0
  13. package/lib/axios/cjs/base/index.js.map +1 -0
  14. package/lib/axios/cjs/base/keypair.js +39 -0
  15. package/lib/axios/cjs/base/keypair.js.map +1 -1
  16. package/lib/axios/cjs/base/scval.js +34 -0
  17. package/lib/axios/cjs/base/scval.js.map +1 -1
  18. package/lib/axios/cjs/bindings/client.js +170 -0
  19. package/lib/axios/cjs/bindings/client.js.map +1 -1
  20. package/lib/axios/cjs/bindings/config.js +1 -1
  21. package/lib/axios/cjs/bindings/generator.js +45 -16
  22. package/lib/axios/cjs/bindings/generator.js.map +1 -1
  23. package/lib/axios/cjs/bindings/types.js +151 -1
  24. package/lib/axios/cjs/bindings/types.js.map +1 -1
  25. package/lib/axios/cjs/bindings/utils.js +10 -0
  26. package/lib/axios/cjs/bindings/utils.js.map +1 -1
  27. package/lib/axios/cjs/cli/index.js +19 -22
  28. package/lib/axios/cjs/cli/index.js.map +1 -1
  29. package/lib/axios/cjs/cli/util.js +1 -20
  30. package/lib/axios/cjs/cli/util.js.map +1 -1
  31. package/lib/axios/cjs/contract/assembled_transaction.js +39 -17
  32. package/lib/axios/cjs/contract/assembled_transaction.js.map +1 -1
  33. package/lib/axios/cjs/contract/basic_node_signer.js +8 -42
  34. package/lib/axios/cjs/contract/basic_node_signer.js.map +1 -1
  35. package/lib/axios/cjs/contract/client.js +56 -3
  36. package/lib/axios/cjs/contract/client.js.map +1 -1
  37. package/lib/axios/cjs/contract/event_spec.js +164 -0
  38. package/lib/axios/cjs/contract/event_spec.js.map +1 -0
  39. package/lib/axios/cjs/contract/index.js +2 -0
  40. package/lib/axios/cjs/contract/index.js.map +1 -1
  41. package/lib/axios/cjs/contract/sent_transaction.js +0 -20
  42. package/lib/axios/cjs/contract/sent_transaction.js.map +1 -1
  43. package/lib/axios/cjs/contract/signer.js +96 -0
  44. package/lib/axios/cjs/contract/signer.js.map +1 -0
  45. package/lib/axios/cjs/contract/spec.js +107 -3
  46. package/lib/axios/cjs/contract/spec.js.map +1 -1
  47. package/lib/axios/cjs/contract/types.js.map +1 -1
  48. package/lib/axios/cjs/errors/transaction_failed.js +62 -0
  49. package/lib/axios/cjs/errors/transaction_failed.js.map +1 -0
  50. package/lib/axios/cjs/errors/wrap_http_error.js +20 -0
  51. package/lib/axios/cjs/errors/wrap_http_error.js.map +1 -0
  52. package/lib/axios/cjs/federation/server.js +15 -35
  53. package/lib/axios/cjs/federation/server.js.map +1 -1
  54. package/lib/axios/cjs/horizon/account_response.js +0 -20
  55. package/lib/axios/cjs/horizon/account_response.js.map +1 -1
  56. package/lib/axios/cjs/horizon/horizon_api.js +5 -0
  57. package/lib/axios/cjs/horizon/horizon_api.js.map +1 -1
  58. package/lib/axios/cjs/horizon/horizon_axios_client.js +1 -1
  59. package/lib/axios/cjs/horizon/server.js +20 -26
  60. package/lib/axios/cjs/horizon/server.js.map +1 -1
  61. package/lib/axios/cjs/index.js +66 -65
  62. package/lib/axios/cjs/index.js.map +1 -1
  63. package/lib/axios/cjs/rpc/api.js.map +1 -1
  64. package/lib/axios/cjs/rpc/axios.js +1 -1
  65. package/lib/axios/cjs/rpc/server.js +181 -13
  66. package/lib/axios/cjs/rpc/server.js.map +1 -1
  67. package/lib/axios/cjs/rpc/transaction.js +2 -20
  68. package/lib/axios/cjs/rpc/transaction.js.map +1 -1
  69. package/lib/axios/cjs/webauth/challenge_transaction.js +7 -22
  70. package/lib/axios/cjs/webauth/challenge_transaction.js.map +1 -1
  71. package/lib/axios/cjs/webauth/utils.js +1 -20
  72. package/lib/axios/cjs/webauth/utils.js.map +1 -1
  73. package/lib/axios/esm/base/auth.d.ts +181 -13
  74. package/lib/axios/esm/base/auth.js +146 -31
  75. package/lib/axios/esm/base/auth.js.map +1 -1
  76. package/lib/axios/esm/base/index.d.ts +2 -2
  77. package/lib/axios/esm/base/index.js +44 -0
  78. package/lib/axios/esm/base/index.js.map +1 -0
  79. package/lib/axios/esm/base/keypair.d.ts +27 -0
  80. package/lib/axios/esm/base/keypair.js +39 -0
  81. package/lib/axios/esm/base/keypair.js.map +1 -1
  82. package/lib/axios/esm/base/scval.d.ts +4 -0
  83. package/lib/axios/esm/base/scval.js +34 -0
  84. package/lib/axios/esm/base/scval.js.map +1 -1
  85. package/lib/axios/esm/bindings/client.d.ts +39 -0
  86. package/lib/axios/esm/bindings/client.js +171 -1
  87. package/lib/axios/esm/bindings/client.js.map +1 -1
  88. package/lib/axios/esm/bindings/config.js +1 -1
  89. package/lib/axios/esm/bindings/generator.d.ts +34 -0
  90. package/lib/axios/esm/bindings/generator.js +45 -16
  91. package/lib/axios/esm/bindings/generator.js.map +1 -1
  92. package/lib/axios/esm/bindings/types.d.ts +42 -0
  93. package/lib/axios/esm/bindings/types.js +153 -3
  94. package/lib/axios/esm/bindings/types.js.map +1 -1
  95. package/lib/axios/esm/bindings/utils.d.ts +10 -0
  96. package/lib/axios/esm/bindings/utils.js +9 -1
  97. package/lib/axios/esm/bindings/utils.js.map +1 -1
  98. package/lib/axios/esm/cli/index.js +19 -22
  99. package/lib/axios/esm/cli/index.js.map +1 -1
  100. package/lib/axios/esm/cli/util.d.ts +1 -1
  101. package/lib/axios/esm/cli/util.js +1 -20
  102. package/lib/axios/esm/cli/util.js.map +1 -1
  103. package/lib/axios/esm/contract/assembled_transaction.d.ts +7 -5
  104. package/lib/axios/esm/contract/assembled_transaction.js +39 -17
  105. package/lib/axios/esm/contract/assembled_transaction.js.map +1 -1
  106. package/lib/axios/esm/contract/basic_node_signer.d.ts +3 -0
  107. package/lib/axios/esm/contract/basic_node_signer.js +8 -42
  108. package/lib/axios/esm/contract/basic_node_signer.js.map +1 -1
  109. package/lib/axios/esm/contract/client.d.ts +49 -3
  110. package/lib/axios/esm/contract/client.js +56 -3
  111. package/lib/axios/esm/contract/client.js.map +1 -1
  112. package/lib/axios/esm/contract/event_spec.d.ts +78 -0
  113. package/lib/axios/esm/contract/event_spec.js +159 -0
  114. package/lib/axios/esm/contract/event_spec.js.map +1 -0
  115. package/lib/axios/esm/contract/index.d.ts +3 -0
  116. package/lib/axios/esm/contract/index.js +1 -0
  117. package/lib/axios/esm/contract/index.js.map +1 -1
  118. package/lib/axios/esm/contract/sent_transaction.js +0 -20
  119. package/lib/axios/esm/contract/sent_transaction.js.map +1 -1
  120. package/lib/axios/esm/contract/signer.d.ts +104 -0
  121. package/lib/axios/esm/contract/signer.js +91 -0
  122. package/lib/axios/esm/contract/signer.js.map +1 -0
  123. package/lib/axios/esm/contract/spec.d.ts +84 -0
  124. package/lib/axios/esm/contract/spec.js +107 -3
  125. package/lib/axios/esm/contract/spec.js.map +1 -1
  126. package/lib/axios/esm/contract/types.d.ts +25 -8
  127. package/lib/axios/esm/contract/types.js.map +1 -1
  128. package/lib/axios/esm/errors/index.d.ts +1 -0
  129. package/lib/axios/esm/errors/transaction_failed.d.ts +55 -0
  130. package/lib/axios/esm/errors/transaction_failed.js +60 -0
  131. package/lib/axios/esm/errors/transaction_failed.js.map +1 -0
  132. package/lib/axios/esm/errors/wrap_http_error.d.ts +20 -0
  133. package/lib/axios/esm/errors/wrap_http_error.js +18 -0
  134. package/lib/axios/esm/errors/wrap_http_error.js.map +1 -0
  135. package/lib/axios/esm/federation/server.js +15 -35
  136. package/lib/axios/esm/federation/server.js.map +1 -1
  137. package/lib/axios/esm/horizon/account_response.js +0 -20
  138. package/lib/axios/esm/horizon/account_response.js.map +1 -1
  139. package/lib/axios/esm/horizon/horizon_api.d.ts +12 -1
  140. package/lib/axios/esm/horizon/horizon_api.js +5 -0
  141. package/lib/axios/esm/horizon/horizon_api.js.map +1 -1
  142. package/lib/axios/esm/horizon/horizon_axios_client.js +1 -1
  143. package/lib/axios/esm/horizon/server.d.ts +10 -4
  144. package/lib/axios/esm/horizon/server.js +20 -26
  145. package/lib/axios/esm/horizon/server.js.map +1 -1
  146. package/lib/axios/esm/index.js +27 -29
  147. package/lib/axios/esm/index.js.map +1 -1
  148. package/lib/axios/esm/rpc/api.d.ts +21 -0
  149. package/lib/axios/esm/rpc/api.js.map +1 -1
  150. package/lib/axios/esm/rpc/axios.js +1 -1
  151. package/lib/axios/esm/rpc/server.d.ts +115 -3
  152. package/lib/axios/esm/rpc/server.js +181 -13
  153. package/lib/axios/esm/rpc/server.js.map +1 -1
  154. package/lib/axios/esm/rpc/transaction.js +2 -20
  155. package/lib/axios/esm/rpc/transaction.js.map +1 -1
  156. package/lib/axios/esm/webauth/challenge_transaction.js +7 -22
  157. package/lib/axios/esm/webauth/challenge_transaction.js.map +1 -1
  158. package/lib/axios/esm/webauth/utils.js +1 -20
  159. package/lib/axios/esm/webauth/utils.js.map +1 -1
  160. package/lib/cjs/base/auth.js +147 -30
  161. package/lib/cjs/base/auth.js.map +1 -1
  162. package/lib/cjs/base/index.js +113 -0
  163. package/lib/cjs/base/index.js.map +1 -0
  164. package/lib/cjs/base/keypair.js +39 -0
  165. package/lib/cjs/base/keypair.js.map +1 -1
  166. package/lib/cjs/base/scval.js +34 -0
  167. package/lib/cjs/base/scval.js.map +1 -1
  168. package/lib/cjs/bindings/client.js +170 -0
  169. package/lib/cjs/bindings/client.js.map +1 -1
  170. package/lib/cjs/bindings/config.js +1 -1
  171. package/lib/cjs/bindings/generator.js +45 -16
  172. package/lib/cjs/bindings/generator.js.map +1 -1
  173. package/lib/cjs/bindings/types.js +151 -1
  174. package/lib/cjs/bindings/types.js.map +1 -1
  175. package/lib/cjs/bindings/utils.js +10 -0
  176. package/lib/cjs/bindings/utils.js.map +1 -1
  177. package/lib/cjs/cli/index.js +19 -22
  178. package/lib/cjs/cli/index.js.map +1 -1
  179. package/lib/cjs/cli/util.js +1 -20
  180. package/lib/cjs/cli/util.js.map +1 -1
  181. package/lib/cjs/contract/assembled_transaction.js +39 -17
  182. package/lib/cjs/contract/assembled_transaction.js.map +1 -1
  183. package/lib/cjs/contract/basic_node_signer.js +8 -42
  184. package/lib/cjs/contract/basic_node_signer.js.map +1 -1
  185. package/lib/cjs/contract/client.js +56 -3
  186. package/lib/cjs/contract/client.js.map +1 -1
  187. package/lib/cjs/contract/event_spec.js +164 -0
  188. package/lib/cjs/contract/event_spec.js.map +1 -0
  189. package/lib/cjs/contract/index.js +2 -0
  190. package/lib/cjs/contract/index.js.map +1 -1
  191. package/lib/cjs/contract/sent_transaction.js +0 -20
  192. package/lib/cjs/contract/sent_transaction.js.map +1 -1
  193. package/lib/cjs/contract/signer.js +96 -0
  194. package/lib/cjs/contract/signer.js.map +1 -0
  195. package/lib/cjs/contract/spec.js +107 -3
  196. package/lib/cjs/contract/spec.js.map +1 -1
  197. package/lib/cjs/contract/types.js.map +1 -1
  198. package/lib/cjs/errors/transaction_failed.js +62 -0
  199. package/lib/cjs/errors/transaction_failed.js.map +1 -0
  200. package/lib/cjs/errors/wrap_http_error.js +20 -0
  201. package/lib/cjs/errors/wrap_http_error.js.map +1 -0
  202. package/lib/cjs/federation/server.js +15 -35
  203. package/lib/cjs/federation/server.js.map +1 -1
  204. package/lib/cjs/horizon/account_response.js +0 -20
  205. package/lib/cjs/horizon/account_response.js.map +1 -1
  206. package/lib/cjs/horizon/horizon_api.js +5 -0
  207. package/lib/cjs/horizon/horizon_api.js.map +1 -1
  208. package/lib/cjs/horizon/horizon_axios_client.js +1 -1
  209. package/lib/cjs/horizon/server.js +20 -26
  210. package/lib/cjs/horizon/server.js.map +1 -1
  211. package/lib/cjs/index.js +66 -65
  212. package/lib/cjs/index.js.map +1 -1
  213. package/lib/cjs/rpc/api.js.map +1 -1
  214. package/lib/cjs/rpc/axios.js +1 -1
  215. package/lib/cjs/rpc/server.js +181 -13
  216. package/lib/cjs/rpc/server.js.map +1 -1
  217. package/lib/cjs/rpc/transaction.js +2 -20
  218. package/lib/cjs/rpc/transaction.js.map +1 -1
  219. package/lib/cjs/webauth/challenge_transaction.js +7 -22
  220. package/lib/cjs/webauth/challenge_transaction.js.map +1 -1
  221. package/lib/cjs/webauth/utils.js +1 -20
  222. package/lib/cjs/webauth/utils.js.map +1 -1
  223. package/lib/esm/base/auth.d.ts +181 -13
  224. package/lib/esm/base/auth.js +146 -31
  225. package/lib/esm/base/auth.js.map +1 -1
  226. package/lib/esm/base/index.d.ts +2 -2
  227. package/lib/esm/base/index.js +44 -0
  228. package/lib/esm/base/index.js.map +1 -0
  229. package/lib/esm/base/keypair.d.ts +27 -0
  230. package/lib/esm/base/keypair.js +39 -0
  231. package/lib/esm/base/keypair.js.map +1 -1
  232. package/lib/esm/base/scval.d.ts +4 -0
  233. package/lib/esm/base/scval.js +34 -0
  234. package/lib/esm/base/scval.js.map +1 -1
  235. package/lib/esm/bindings/client.d.ts +39 -0
  236. package/lib/esm/bindings/client.js +171 -1
  237. package/lib/esm/bindings/client.js.map +1 -1
  238. package/lib/esm/bindings/config.js +1 -1
  239. package/lib/esm/bindings/generator.d.ts +34 -0
  240. package/lib/esm/bindings/generator.js +45 -16
  241. package/lib/esm/bindings/generator.js.map +1 -1
  242. package/lib/esm/bindings/types.d.ts +42 -0
  243. package/lib/esm/bindings/types.js +153 -3
  244. package/lib/esm/bindings/types.js.map +1 -1
  245. package/lib/esm/bindings/utils.d.ts +10 -0
  246. package/lib/esm/bindings/utils.js +9 -1
  247. package/lib/esm/bindings/utils.js.map +1 -1
  248. package/lib/esm/cli/index.js +19 -22
  249. package/lib/esm/cli/index.js.map +1 -1
  250. package/lib/esm/cli/util.d.ts +1 -1
  251. package/lib/esm/cli/util.js +1 -20
  252. package/lib/esm/cli/util.js.map +1 -1
  253. package/lib/esm/contract/assembled_transaction.d.ts +7 -5
  254. package/lib/esm/contract/assembled_transaction.js +39 -17
  255. package/lib/esm/contract/assembled_transaction.js.map +1 -1
  256. package/lib/esm/contract/basic_node_signer.d.ts +3 -0
  257. package/lib/esm/contract/basic_node_signer.js +8 -42
  258. package/lib/esm/contract/basic_node_signer.js.map +1 -1
  259. package/lib/esm/contract/client.d.ts +49 -3
  260. package/lib/esm/contract/client.js +56 -3
  261. package/lib/esm/contract/client.js.map +1 -1
  262. package/lib/esm/contract/event_spec.d.ts +78 -0
  263. package/lib/esm/contract/event_spec.js +159 -0
  264. package/lib/esm/contract/event_spec.js.map +1 -0
  265. package/lib/esm/contract/index.d.ts +3 -0
  266. package/lib/esm/contract/index.js +1 -0
  267. package/lib/esm/contract/index.js.map +1 -1
  268. package/lib/esm/contract/sent_transaction.js +0 -20
  269. package/lib/esm/contract/sent_transaction.js.map +1 -1
  270. package/lib/esm/contract/signer.d.ts +104 -0
  271. package/lib/esm/contract/signer.js +91 -0
  272. package/lib/esm/contract/signer.js.map +1 -0
  273. package/lib/esm/contract/spec.d.ts +84 -0
  274. package/lib/esm/contract/spec.js +107 -3
  275. package/lib/esm/contract/spec.js.map +1 -1
  276. package/lib/esm/contract/types.d.ts +25 -8
  277. package/lib/esm/contract/types.js.map +1 -1
  278. package/lib/esm/errors/index.d.ts +1 -0
  279. package/lib/esm/errors/transaction_failed.d.ts +55 -0
  280. package/lib/esm/errors/transaction_failed.js +60 -0
  281. package/lib/esm/errors/transaction_failed.js.map +1 -0
  282. package/lib/esm/errors/wrap_http_error.d.ts +20 -0
  283. package/lib/esm/errors/wrap_http_error.js +18 -0
  284. package/lib/esm/errors/wrap_http_error.js.map +1 -0
  285. package/lib/esm/federation/server.js +15 -35
  286. package/lib/esm/federation/server.js.map +1 -1
  287. package/lib/esm/horizon/account_response.js +0 -20
  288. package/lib/esm/horizon/account_response.js.map +1 -1
  289. package/lib/esm/horizon/horizon_api.d.ts +12 -1
  290. package/lib/esm/horizon/horizon_api.js +5 -0
  291. package/lib/esm/horizon/horizon_api.js.map +1 -1
  292. package/lib/esm/horizon/horizon_axios_client.js +1 -1
  293. package/lib/esm/horizon/server.d.ts +10 -4
  294. package/lib/esm/horizon/server.js +20 -26
  295. package/lib/esm/horizon/server.js.map +1 -1
  296. package/lib/esm/index.js +27 -29
  297. package/lib/esm/index.js.map +1 -1
  298. package/lib/esm/rpc/api.d.ts +21 -0
  299. package/lib/esm/rpc/api.js.map +1 -1
  300. package/lib/esm/rpc/axios.js +1 -1
  301. package/lib/esm/rpc/server.d.ts +115 -3
  302. package/lib/esm/rpc/server.js +181 -13
  303. package/lib/esm/rpc/server.js.map +1 -1
  304. package/lib/esm/rpc/transaction.js +2 -20
  305. package/lib/esm/rpc/transaction.js.map +1 -1
  306. package/lib/esm/webauth/challenge_transaction.js +7 -22
  307. package/lib/esm/webauth/challenge_transaction.js.map +1 -1
  308. package/lib/esm/webauth/utils.js +1 -20
  309. package/lib/esm/webauth/utils.js.map +1 -1
  310. package/package.json +35 -30
@@ -1 +1 @@
1
- {"version":3,"file":"spec.js","sources":["../../../src/contract/spec.ts"],"sourcesContent":["import type { JSONSchema7, JSONSchema7Definition } from \"json-schema\";\nimport {\n type ScIntType,\n XdrLargeInt,\n xdr,\n Address,\n Contract,\n scValToBigInt,\n} from \"../base/index.js\";\nimport { Ok, Err } from \"./rust_result.js\";\nimport { processSpecEntryStream } from \"./utils.js\";\nimport { specFromWasm } from \"./wasm_spec_parser.js\";\n\nexport interface Union<T> {\n tag: string;\n values?: T;\n}\n\nfunction enumToJsonSchema(udt: xdr.ScSpecUdtEnumV0): any {\n const description = udt.doc().toString();\n const cases = udt.cases();\n const oneOf: any[] = [];\n cases.forEach((aCase) => {\n const title = aCase.name().toString();\n const desc = aCase.doc().toString();\n oneOf.push({\n description: desc,\n title,\n enum: [aCase.value()],\n type: \"number\",\n });\n });\n const res: any = { oneOf };\n if (description.length > 0) {\n res.description = description;\n }\n return res;\n}\n\nfunction isNumeric(field: xdr.ScSpecUdtStructFieldV0) {\n return /^\\d+$/.test(field.name().toString());\n}\n\nfunction readObj(args: object, input: xdr.ScSpecFunctionInputV0): any {\n const inputName = input.name().toString();\n const entry = Object.entries(args).find(([name]) => name === inputName);\n if (!entry) {\n throw new Error(`Missing field ${inputName}`);\n }\n return entry[1];\n}\n\nfunction findCase(name: string) {\n return function matches(entry: xdr.ScSpecUdtUnionCaseV0) {\n switch (entry.switch().value) {\n case xdr.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0().value: {\n const tuple = entry.tupleCase();\n return tuple.name().toString() === name;\n }\n case xdr.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseVoidV0().value: {\n const voidCase = entry.voidCase();\n return voidCase.name().toString() === name;\n }\n default:\n return false;\n }\n };\n}\n\nfunction stringToScVal(str: string, ty: xdr.ScSpecType): xdr.ScVal {\n switch (ty.value) {\n case xdr.ScSpecType.scSpecTypeString().value:\n return xdr.ScVal.scvString(str);\n case xdr.ScSpecType.scSpecTypeSymbol().value:\n return xdr.ScVal.scvSymbol(str);\n case xdr.ScSpecType.scSpecTypeAddress().value:\n case xdr.ScSpecType.scSpecTypeMuxedAddress().value:\n return Address.fromString(str).toScVal();\n case xdr.ScSpecType.scSpecTypeU64().value:\n return new XdrLargeInt(\"u64\", str).toScVal();\n case xdr.ScSpecType.scSpecTypeI64().value:\n return new XdrLargeInt(\"i64\", str).toScVal();\n case xdr.ScSpecType.scSpecTypeU128().value:\n return new XdrLargeInt(\"u128\", str).toScVal();\n case xdr.ScSpecType.scSpecTypeI128().value:\n return new XdrLargeInt(\"i128\", str).toScVal();\n case xdr.ScSpecType.scSpecTypeU256().value:\n return new XdrLargeInt(\"u256\", str).toScVal();\n case xdr.ScSpecType.scSpecTypeI256().value:\n return new XdrLargeInt(\"i256\", str).toScVal();\n case xdr.ScSpecType.scSpecTypeBytes().value:\n case xdr.ScSpecType.scSpecTypeBytesN().value:\n return xdr.ScVal.scvBytes(Buffer.from(str, \"base64\"));\n case xdr.ScSpecType.scSpecTypeTimepoint().value: {\n return xdr.ScVal.scvTimepoint(new xdr.Uint64(str));\n }\n case xdr.ScSpecType.scSpecTypeDuration().value: {\n return xdr.ScVal.scvDuration(new xdr.Uint64(str));\n }\n default:\n throw new TypeError(`invalid type ${ty.name} specified for string value`);\n }\n}\n\nconst PRIMITIVE_DEFINITONS: { [key: string]: JSONSchema7Definition } = {\n U32: {\n type: \"integer\",\n minimum: 0,\n maximum: 4294967295,\n },\n I32: {\n type: \"integer\",\n minimum: -2147483648,\n maximum: 2147483647,\n },\n U64: {\n type: \"string\",\n pattern: \"^([1-9][0-9]*|0)$\",\n minLength: 1,\n maxLength: 20, // 64-bit max value has 20 digits\n },\n Timepoint: {\n type: \"string\",\n pattern: \"^([1-9][0-9]*|0)$\",\n minLength: 1,\n maxLength: 20, // 64-bit max value has 20 digits\n },\n Duration: {\n type: \"string\",\n pattern: \"^([1-9][0-9]*|0)$\",\n minLength: 1,\n maxLength: 20, // 64-bit max value has 20 digits\n },\n I64: {\n type: \"string\",\n pattern: \"^(-?[1-9][0-9]*|0)$\",\n minLength: 1,\n maxLength: 21, // Includes additional digit for the potential '-'\n },\n U128: {\n type: \"string\",\n pattern: \"^([1-9][0-9]*|0)$\",\n minLength: 1,\n maxLength: 39, // 128-bit max value has 39 digits\n },\n I128: {\n type: \"string\",\n pattern: \"^(-?[1-9][0-9]*|0)$\",\n minLength: 1,\n maxLength: 40, // Includes additional digit for the potential '-'\n },\n U256: {\n type: \"string\",\n pattern: \"^([1-9][0-9]*|0)$\",\n minLength: 1,\n maxLength: 78, // 256-bit max value has 78 digits\n },\n I256: {\n type: \"string\",\n pattern: \"^(-?[1-9][0-9]*|0)$\",\n minLength: 1,\n maxLength: 79, // Includes additional digit for the potential '-'\n },\n Address: {\n type: \"string\",\n format: \"address\",\n description: \"Address can be a public key or contract id\",\n },\n MuxedAddress: {\n type: \"string\",\n format: \"address\",\n description:\n \"Stellar public key with M prefix combining a G address and unique ID\",\n },\n ScString: {\n type: \"string\",\n description: \"ScString is a string\",\n },\n ScSymbol: {\n type: \"string\",\n description: \"ScSymbol is a string\",\n },\n DataUrl: {\n type: \"string\",\n pattern:\n \"^(?:[A-Za-z0-9+\\\\/]{4})*(?:[A-Za-z0-9+\\\\/]{2}==|[A-Za-z0-9+\\\\/]{3}=)?$\",\n },\n};\n\n/**\n * Converts an XDR type definition to a JSON schema reference.\n * @param typeDef - type to convert to json schema reference\n * @returns a schema describing the type\n * @hidden\n */\nfunction typeRef(typeDef: xdr.ScSpecTypeDef): JSONSchema7 {\n const t = typeDef.switch();\n const value = t.value;\n let ref;\n switch (value) {\n case xdr.ScSpecType.scSpecTypeVal().value: {\n ref = \"Val\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeBool().value: {\n return { type: \"boolean\" };\n }\n case xdr.ScSpecType.scSpecTypeVoid().value: {\n return { type: \"null\" };\n }\n case xdr.ScSpecType.scSpecTypeError().value: {\n ref = \"Error\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeU32().value: {\n ref = \"U32\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeI32().value: {\n ref = \"I32\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeU64().value: {\n ref = \"U64\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeI64().value: {\n ref = \"I64\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeTimepoint().value: {\n ref = \"Timepoint\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeDuration().value: {\n ref = \"Duration\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeU128().value: {\n ref = \"U128\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeI128().value: {\n ref = \"I128\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeU256().value: {\n ref = \"U256\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeI256().value: {\n ref = \"I256\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeBytes().value: {\n ref = \"DataUrl\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeString().value: {\n ref = \"ScString\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeSymbol().value: {\n ref = \"ScSymbol\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeAddress().value: {\n ref = \"Address\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeMuxedAddress().value: {\n ref = \"MuxedAddress\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeOption().value: {\n const opt = typeDef.option();\n return typeRef(opt.valueType());\n }\n case xdr.ScSpecType.scSpecTypeResult().value: {\n const result = typeDef.result();\n return typeRef(result.okType());\n }\n case xdr.ScSpecType.scSpecTypeVec().value: {\n const arr = typeDef.vec();\n const reference = typeRef(arr.elementType());\n return {\n type: \"array\",\n items: reference,\n };\n }\n case xdr.ScSpecType.scSpecTypeMap().value: {\n const map = typeDef.map();\n const items = [typeRef(map.keyType()), typeRef(map.valueType())];\n return {\n type: \"array\",\n items: {\n type: \"array\",\n items,\n minItems: 2,\n maxItems: 2,\n },\n };\n }\n case xdr.ScSpecType.scSpecTypeTuple().value: {\n const tuple = typeDef.tuple();\n const minItems = tuple.valueTypes().length;\n const maxItems = minItems;\n const items = tuple.valueTypes().map(typeRef);\n return { type: \"array\", items, minItems, maxItems };\n }\n case xdr.ScSpecType.scSpecTypeBytesN().value: {\n const arr = typeDef.bytesN();\n return {\n $ref: \"#/definitions/DataUrl\",\n maxLength: arr.n(),\n };\n }\n case xdr.ScSpecType.scSpecTypeUdt().value: {\n const udt = typeDef.udt();\n ref = udt.name().toString();\n break;\n }\n }\n return { $ref: `#/definitions/${ref}` };\n}\n\ntype Func = { input: JSONSchema7; output: JSONSchema7 };\n\nfunction isRequired(typeDef: xdr.ScSpecTypeDef): boolean {\n return typeDef.switch().value !== xdr.ScSpecType.scSpecTypeOption().value;\n}\n\nfunction argsAndRequired(\n input: { type: () => xdr.ScSpecTypeDef; name: () => string | Buffer }[],\n): { properties: object; required?: string[] } {\n const properties: any = {};\n const required: string[] = [];\n input.forEach((arg) => {\n const aType = arg.type();\n const name = arg.name().toString();\n properties[name] = typeRef(aType);\n if (isRequired(aType)) {\n required.push(name);\n }\n });\n const res: { properties: object; required?: string[] } = { properties };\n if (required.length > 0) {\n res.required = required;\n }\n return res;\n}\n\nfunction structToJsonSchema(udt: xdr.ScSpecUdtStructV0): object {\n const fields = udt.fields();\n if (fields.some(isNumeric)) {\n if (!fields.every(isNumeric)) {\n throw new Error(\n \"mixed numeric and non-numeric field names are not allowed\",\n );\n }\n const items = fields.map((_, i) => typeRef(fields[i].type()));\n return {\n type: \"array\",\n items,\n minItems: fields.length,\n maxItems: fields.length,\n };\n }\n const description = udt.doc().toString();\n const { properties, required }: any = argsAndRequired(fields);\n return {\n description,\n properties,\n required,\n additionalProperties: false,\n type: \"object\",\n };\n}\n\nfunction functionToJsonSchema(func: xdr.ScSpecFunctionV0): Func {\n const { properties, required }: any = argsAndRequired(func.inputs());\n const args: any = {\n additionalProperties: false,\n properties,\n type: \"object\",\n };\n if (required?.length > 0) {\n args.required = required;\n }\n const input: Partial<JSONSchema7> = {\n properties: {\n args,\n },\n };\n const outputs = func.outputs();\n const output: Partial<JSONSchema7> =\n outputs.length > 0\n ? typeRef(outputs[0])\n : typeRef(xdr.ScSpecTypeDef.scSpecTypeVoid());\n const description = func.doc().toString();\n if (description.length > 0) {\n input.description = description;\n }\n input.additionalProperties = false;\n output.additionalProperties = false;\n return {\n input,\n output,\n };\n}\n\nfunction unionToJsonSchema(udt: xdr.ScSpecUdtUnionV0): any {\n const description = udt.doc().toString();\n const cases = udt.cases();\n const oneOf: any[] = [];\n cases.forEach((aCase) => {\n switch (aCase.switch().value) {\n case xdr.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseVoidV0().value: {\n const c = aCase.voidCase();\n const title = c.name().toString();\n oneOf.push({\n type: \"object\",\n title,\n properties: {\n tag: title,\n },\n additionalProperties: false,\n required: [\"tag\"],\n });\n break;\n }\n case xdr.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0().value: {\n const c = aCase.tupleCase();\n const title = c.name().toString();\n oneOf.push({\n type: \"object\",\n title,\n properties: {\n tag: title,\n values: {\n type: \"array\",\n items: c.type().map(typeRef),\n },\n },\n required: [\"tag\", \"values\"],\n additionalProperties: false,\n });\n }\n }\n });\n\n const res: any = {\n oneOf,\n };\n if (description.length > 0) {\n res.description = description;\n }\n return res;\n}\n\n/**\n * Provides a ContractSpec class which can contains the XDR types defined by the contract.\n * This allows the class to be used to convert between native and raw `xdr.ScVal`s.\n *\n * Constructs a new ContractSpec from an array of XDR spec entries.\n *\n * @param entries - the XDR spec entries\n * @throws if entries is invalid\n *\n * @example\n * ```ts\n * const specEntries = [...]; // XDR spec entries of a smart contract\n * const contractSpec = new ContractSpec(specEntries);\n *\n * // Convert native value to ScVal\n * const args = {\n * arg1: 'value1',\n * arg2: 1234\n * };\n * const scArgs = contractSpec.funcArgsToScVals('funcName', args);\n *\n * // Call contract\n * const resultScv = await callContract(contractId, 'funcName', scArgs);\n *\n * // Convert result ScVal back to native value\n * const result = contractSpec.funcResToNative('funcName', resultScv);\n *\n * console.log(result); // {success: true}\n * ```\n */\nexport class Spec {\n /**\n * The XDR spec entries.\n */\n public entries: xdr.ScSpecEntry[] = [];\n\n /**\n * Generates a Spec instance from the contract's wasm binary.\n *\n * @param wasm - The contract's wasm binary as a Buffer.\n * @returns A Promise that resolves to a Spec instance.\n * @throws If the contract spec cannot be obtained from the provided wasm binary.\n */\n static fromWasm(wasm: Buffer): Spec {\n const spec = specFromWasm(wasm);\n return new Spec(spec);\n }\n\n /**\n * Generates a Spec instance from contract specs in any of the following forms:\n * - An XDR encoded stream of xdr.ScSpecEntry entries, the format of the spec\n * stored inside Wasm files.\n * - A base64 XDR encoded stream of xdr.ScSpecEntry entries.\n * - An array of xdr.ScSpecEntry.\n * - An array of base64 XDR encoded xdr.ScSpecEntry.\n *\n * @returns A Promise that resolves to a Client instance.\n * @throws If the contract spec cannot be obtained from the provided wasm binary.\n */\n constructor(entries: Buffer | string | xdr.ScSpecEntry[] | string[]) {\n if (Buffer.isBuffer(entries)) {\n this.entries = processSpecEntryStream(entries as Buffer);\n } else if (typeof entries === \"string\") {\n this.entries = processSpecEntryStream(Buffer.from(entries, \"base64\"));\n } else {\n if (entries.length === 0) {\n throw new Error(\"Contract spec must have at least one entry\");\n }\n const entry = entries[0];\n if (typeof entry === \"string\") {\n this.entries = (entries as string[]).map((s) =>\n xdr.ScSpecEntry.fromXDR(s, \"base64\"),\n );\n } else {\n this.entries = entries as xdr.ScSpecEntry[];\n }\n }\n }\n\n /**\n * Gets the XDR functions from the spec.\n * @returns all contract functions\n */\n funcs(): xdr.ScSpecFunctionV0[] {\n return this.entries\n .filter(\n (entry) =>\n entry.switch().value ===\n xdr.ScSpecEntryKind.scSpecEntryFunctionV0().value,\n )\n .map((entry) => entry.functionV0());\n }\n\n /**\n * Gets the XDR function spec for the given function name.\n *\n * @param name - the name of the function\n * @returns the function spec\n *\n * @throws if no function with the given name exists\n */\n getFunc(name: string): xdr.ScSpecFunctionV0 {\n const entry = this.findEntry(name);\n if (\n entry.switch().value !== xdr.ScSpecEntryKind.scSpecEntryFunctionV0().value\n ) {\n throw new Error(`${name} is not a function`);\n }\n return entry.functionV0();\n }\n\n /**\n * Converts native JS arguments to ScVals for calling a contract function.\n *\n * @param name - the name of the function\n * @param args - the arguments object\n * @returns the converted arguments\n *\n * @throws if argument is missing or incorrect type\n *\n * @example\n * ```ts\n * const args = {\n * arg1: 'value1',\n * arg2: 1234\n * };\n * const scArgs = contractSpec.funcArgsToScVals('funcName', args);\n * ```\n */\n funcArgsToScVals(name: string, args: object): xdr.ScVal[] {\n const fn = this.getFunc(name);\n return fn\n .inputs()\n .map((input) => this.nativeToScVal(readObj(args, input), input.type()));\n }\n\n /**\n * Converts the result ScVal of a function call to a native JS value.\n *\n * @param name - the name of the function\n * @param val_or_base64 - the result ScVal or base64 encoded string\n * @returns the converted native value\n *\n * @throws if return type mismatch or invalid input\n *\n * @example\n * ```ts\n * const resultScv = 'AAA=='; // Base64 encoded ScVal\n * const result = contractSpec.funcResToNative('funcName', resultScv);\n * ```\n */\n funcResToNative(name: string, val_or_base64: xdr.ScVal | string): any {\n const val =\n typeof val_or_base64 === \"string\"\n ? xdr.ScVal.fromXDR(val_or_base64, \"base64\")\n : val_or_base64;\n const func = this.getFunc(name);\n const outputs = func.outputs();\n if (outputs.length === 0) {\n const type = val.switch();\n if (type.value !== xdr.ScValType.scvVoid().value) {\n throw new Error(`Expected void, got ${type.name}`);\n }\n return null;\n }\n if (outputs.length > 1) {\n throw new Error(`Multiple outputs not supported`);\n }\n const output = outputs[0];\n if (output.switch().value === xdr.ScSpecType.scSpecTypeResult().value) {\n if (val.switch().value === xdr.ScValType.scvError().value) {\n return new Err({ message: val.error().toXDR(\"base64\") });\n }\n return new Ok(this.scValToNative(val, output.result().okType()));\n }\n return this.scValToNative(val, output);\n }\n\n /**\n * Finds the XDR spec entry for the given name.\n *\n * @param name - the name to find\n * @returns the entry\n *\n * @throws if no entry with the given name exists\n */\n findEntry(name: string): xdr.ScSpecEntry {\n const entry = this.entries.find(\n (e) => e.value().name().toString() === name,\n );\n if (!entry) {\n throw new Error(`no such entry: ${name}`);\n }\n return entry;\n }\n\n /**\n * Converts a native JS value to an ScVal based on the given type.\n *\n * @param val - the native JS value\n * @param ty - (optional) the expected type\n * @returns the converted ScVal\n *\n * @throws if value cannot be converted to the given type\n */\n nativeToScVal(val: any, ty: xdr.ScSpecTypeDef): xdr.ScVal {\n const t: xdr.ScSpecType = ty.switch();\n const value = t.value;\n if (t.value === xdr.ScSpecType.scSpecTypeUdt().value) {\n const udt = ty.udt();\n return this.nativeToUdt(val, udt.name().toString());\n }\n if (value === xdr.ScSpecType.scSpecTypeOption().value) {\n const opt = ty.option();\n if (val === null || val === undefined) {\n return xdr.ScVal.scvVoid();\n }\n return this.nativeToScVal(val, opt.valueType());\n }\n switch (typeof val) {\n case \"object\": {\n if (val === null) {\n switch (value) {\n case xdr.ScSpecType.scSpecTypeVoid().value:\n return xdr.ScVal.scvVoid();\n default:\n throw new TypeError(\n `Type ${ty} was not void, but value was null`,\n );\n }\n }\n\n if (val instanceof xdr.ScVal) {\n return val; // should we copy?\n }\n\n if (val instanceof Address) {\n if (ty.switch().value !== xdr.ScSpecType.scSpecTypeAddress().value) {\n throw new TypeError(\n `Type ${ty} was not address, but value was Address`,\n );\n }\n return val.toScVal();\n }\n\n if (val instanceof Contract) {\n if (ty.switch().value !== xdr.ScSpecType.scSpecTypeAddress().value) {\n throw new TypeError(\n `Type ${ty} was not address, but value was Address`,\n );\n }\n return val.address().toScVal();\n }\n\n if (val instanceof Uint8Array || Buffer.isBuffer(val)) {\n const copy = Uint8Array.from(val);\n switch (value) {\n case xdr.ScSpecType.scSpecTypeBytesN().value: {\n const bytesN = ty.bytesN();\n if (copy.length !== bytesN.n()) {\n throw new TypeError(\n `expected ${bytesN.n()} bytes, but got ${copy.length}`,\n );\n }\n //@ts-expect-error scvBytes' generated type expects Buffer; copy is a Uint8Array accepted at runtime\n return xdr.ScVal.scvBytes(copy);\n }\n case xdr.ScSpecType.scSpecTypeBytes().value:\n //@ts-expect-error scvBytes' generated type expects Buffer; copy is a Uint8Array accepted at runtime\n return xdr.ScVal.scvBytes(copy);\n default:\n throw new TypeError(\n `invalid type (${ty}) specified for Bytes and BytesN`,\n );\n }\n }\n if (Array.isArray(val)) {\n switch (value) {\n case xdr.ScSpecType.scSpecTypeVec().value: {\n const vec = ty.vec();\n const elementType = vec.elementType();\n return xdr.ScVal.scvVec(\n val.map((v) => this.nativeToScVal(v, elementType)),\n );\n }\n case xdr.ScSpecType.scSpecTypeTuple().value: {\n const tup = ty.tuple();\n const valTypes = tup.valueTypes();\n if (val.length !== valTypes.length) {\n throw new TypeError(\n `Tuple expects ${valTypes.length} values, but ${val.length} were provided`,\n );\n }\n return xdr.ScVal.scvVec(\n val.map((v, i) => this.nativeToScVal(v, valTypes[i])),\n );\n }\n case xdr.ScSpecType.scSpecTypeMap().value: {\n const map = ty.map();\n const keyType = map.keyType();\n const valueType = map.valueType();\n return xdr.ScVal.scvMap(\n val.map((entry) => {\n const key = this.nativeToScVal(entry[0], keyType);\n const mapVal = this.nativeToScVal(entry[1], valueType);\n return new xdr.ScMapEntry({ key, val: mapVal });\n }),\n );\n }\n\n default:\n throw new TypeError(\n `Type ${ty} was not vec, but value was Array`,\n );\n }\n }\n if (val.constructor === Map) {\n if (value !== xdr.ScSpecType.scSpecTypeMap().value) {\n throw new TypeError(`Type ${ty} was not map, but value was Map`);\n }\n const scMap = ty.map();\n const map = val as Map<any, any>;\n const entries: xdr.ScMapEntry[] = [];\n const values = map.entries();\n let res = values.next();\n while (!res.done) {\n const [k, v] = res.value;\n const key = this.nativeToScVal(k, scMap.keyType());\n const mapval = this.nativeToScVal(v, scMap.valueType());\n entries.push(new xdr.ScMapEntry({ key, val: mapval }));\n res = values.next();\n }\n return xdr.ScVal.scvMap(entries);\n }\n\n if ((val.constructor?.name ?? \"\") !== \"Object\") {\n throw new TypeError(\n `cannot interpret ${\n val.constructor?.name\n } value as ScVal (${JSON.stringify(val)})`,\n );\n }\n\n throw new TypeError(\n `Received object ${val} did not match the provided type ${ty}`,\n );\n }\n\n case \"number\":\n case \"bigint\": {\n switch (value) {\n case xdr.ScSpecType.scSpecTypeU32().value:\n if (\n BigInt(val) < BigInt(xdr.Uint32.MIN_VALUE) ||\n BigInt(val) > BigInt(xdr.Uint32.MAX_VALUE)\n ) {\n throw new RangeError(`Value ${val} is out of range for U32`);\n }\n return xdr.ScVal.scvU32(Number(val));\n case xdr.ScSpecType.scSpecTypeI32().value:\n if (\n // TODO: remove the `-` cast on the min value once js-xdr fixes the issue where it treats the min value as unsigned\n BigInt(val) < -BigInt(xdr.Int32.MIN_VALUE) ||\n BigInt(val) > BigInt(xdr.Int32.MAX_VALUE)\n ) {\n throw new RangeError(`Value ${val} is out of range for I32`);\n }\n return xdr.ScVal.scvI32(Number(val));\n case xdr.ScSpecType.scSpecTypeU64().value:\n case xdr.ScSpecType.scSpecTypeI64().value:\n case xdr.ScSpecType.scSpecTypeU128().value:\n case xdr.ScSpecType.scSpecTypeI128().value:\n case xdr.ScSpecType.scSpecTypeU256().value:\n case xdr.ScSpecType.scSpecTypeI256().value:\n case xdr.ScSpecType.scSpecTypeTimepoint().value:\n case xdr.ScSpecType.scSpecTypeDuration().value: {\n const intType = t.name.substring(10).toLowerCase() as ScIntType;\n return new XdrLargeInt(intType, val as bigint).toScVal();\n }\n default:\n throw new TypeError(`invalid type (${ty}) specified for integer`);\n }\n }\n case \"string\":\n return stringToScVal(val, t);\n\n case \"boolean\": {\n if (value !== xdr.ScSpecType.scSpecTypeBool().value) {\n throw TypeError(`Type ${ty} was not bool, but value was bool`);\n }\n return xdr.ScVal.scvBool(val);\n }\n case \"undefined\": {\n if (!ty) {\n return xdr.ScVal.scvVoid();\n }\n switch (value) {\n case xdr.ScSpecType.scSpecTypeVoid().value:\n case xdr.ScSpecType.scSpecTypeOption().value:\n return xdr.ScVal.scvVoid();\n default:\n throw new TypeError(\n `Type ${ty} was not void, but value was undefined`,\n );\n }\n }\n\n case \"function\": // FIXME: Is this too helpful?\n return this.nativeToScVal(val(), ty);\n\n default:\n throw new TypeError(`failed to convert typeof ${typeof val} (${val})`);\n }\n }\n\n private nativeToUdt(val: any, name: string): xdr.ScVal {\n const entry = this.findEntry(name);\n switch (entry.switch()) {\n case xdr.ScSpecEntryKind.scSpecEntryUdtEnumV0():\n if (typeof val !== \"number\") {\n throw new TypeError(\n `expected number for enum ${name}, but got ${typeof val}`,\n );\n }\n return this.nativeToEnum(val as number, entry.udtEnumV0());\n case xdr.ScSpecEntryKind.scSpecEntryUdtStructV0():\n return this.nativeToStruct(val, entry.udtStructV0());\n case xdr.ScSpecEntryKind.scSpecEntryUdtUnionV0():\n return this.nativeToUnion(val, entry.udtUnionV0());\n default:\n throw new Error(`failed to parse udt ${name}`);\n }\n }\n\n private nativeToUnion(\n val: Union<any>,\n union_: xdr.ScSpecUdtUnionV0,\n ): xdr.ScVal {\n const entryName = val.tag;\n const caseFound = union_.cases().find((entry) => {\n const caseN = entry.value().name().toString();\n return caseN === entryName;\n });\n if (!caseFound) {\n throw new TypeError(`no such enum entry: ${entryName} in ${union_}`);\n }\n const key = xdr.ScVal.scvSymbol(entryName);\n switch (caseFound.switch()) {\n case xdr.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseVoidV0(): {\n return xdr.ScVal.scvVec([key]);\n }\n case xdr.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0(): {\n const types = caseFound.tupleCase().type();\n if (Array.isArray(val.values)) {\n if (val.values.length !== types.length) {\n throw new TypeError(\n `union ${union_} expects ${types.length} values, but got ${val.values.length}`,\n );\n }\n const scvals = val.values.map((v, i) =>\n this.nativeToScVal(v, types[i]),\n );\n scvals.unshift(key);\n return xdr.ScVal.scvVec(scvals);\n }\n throw new Error(`failed to parse union case ${caseFound} with ${val}`);\n }\n default:\n throw new Error(`failed to parse union ${union_} with ${val}`);\n }\n }\n\n private nativeToStruct(val: any, struct: xdr.ScSpecUdtStructV0): xdr.ScVal {\n const fields = struct.fields();\n if (fields.some(isNumeric)) {\n if (!fields.every(isNumeric)) {\n throw new Error(\n \"mixed numeric and non-numeric field names are not allowed\",\n );\n }\n return xdr.ScVal.scvVec(\n fields.map((_, i) => this.nativeToScVal(val[i], fields[i].type())),\n );\n }\n return xdr.ScVal.scvMap(\n fields.map((field) => {\n const name = field.name().toString();\n return new xdr.ScMapEntry({\n key: this.nativeToScVal(name, xdr.ScSpecTypeDef.scSpecTypeSymbol()),\n val: this.nativeToScVal(val[name], field.type()),\n });\n }),\n );\n }\n\n private nativeToEnum(val: number, enum_: xdr.ScSpecUdtEnumV0): xdr.ScVal {\n if (enum_.cases().some((entry) => entry.value() === val)) {\n return xdr.ScVal.scvU32(val);\n }\n throw new TypeError(`no such enum entry: ${val} in ${enum_}`);\n }\n\n /**\n * Converts an base64 encoded ScVal back to a native JS value based on the given type.\n *\n * @param scv - the base64 encoded ScVal\n * @param typeDef - the expected type\n * @returns the converted native JS value\n *\n * @throws if ScVal cannot be converted to the given type\n */\n scValStrToNative<T>(scv: string, typeDef: xdr.ScSpecTypeDef): T {\n return this.scValToNative<T>(xdr.ScVal.fromXDR(scv, \"base64\"), typeDef);\n }\n\n /**\n * Converts an ScVal back to a native JS value based on the given type.\n *\n * @param scv - the ScVal\n * @param typeDef - the expected type\n * @returns the converted native JS value\n *\n * @throws if ScVal cannot be converted to the given type\n */\n scValToNative<T>(scv: xdr.ScVal, typeDef: xdr.ScSpecTypeDef): T {\n const t = typeDef.switch();\n const value = t.value;\n\n if (value === xdr.ScSpecType.scSpecTypeOption().value) {\n switch (scv.switch().value) {\n case xdr.ScValType.scvVoid().value:\n return null as T;\n default:\n return this.scValToNative(scv, typeDef.option().valueType());\n }\n }\n\n if (value === xdr.ScSpecType.scSpecTypeUdt().value) {\n return this.scValUdtToNative(scv, typeDef.udt());\n }\n\n // we use the verbose xdr.ScValType.<type>.value form here because it's faster\n // than string comparisons and the underlying constants never need to be\n // updated\n switch (scv.switch().value) {\n case xdr.ScValType.scvVoid().value:\n return null as T;\n\n // these can be converted to bigints directly\n case xdr.ScValType.scvU64().value:\n case xdr.ScValType.scvI64().value:\n case xdr.ScValType.scvTimepoint().value:\n case xdr.ScValType.scvDuration().value:\n // these can be parsed by internal abstractions note that this can also\n // handle the above two cases, but it's not as efficient (another\n // type-check, parsing, etc.)\n case xdr.ScValType.scvU128().value:\n case xdr.ScValType.scvI128().value:\n case xdr.ScValType.scvU256().value:\n case xdr.ScValType.scvI256().value:\n return scValToBigInt(scv) as T;\n\n case xdr.ScValType.scvVec().value: {\n if (value === xdr.ScSpecType.scSpecTypeVec().value) {\n const vec = typeDef.vec();\n return (scv.vec() ?? []).map((elm) =>\n this.scValToNative(elm, vec.elementType()),\n ) as T;\n }\n if (value === xdr.ScSpecType.scSpecTypeTuple().value) {\n const tuple = typeDef.tuple();\n const valTypes = tuple.valueTypes();\n return (scv.vec() ?? []).map((elm, i) =>\n this.scValToNative(elm, valTypes[i]),\n ) as T;\n }\n throw new TypeError(`Type ${typeDef} was not vec, but ${scv} is`);\n }\n\n case xdr.ScValType.scvAddress().value:\n return Address.fromScVal(scv).toString() as T;\n\n case xdr.ScValType.scvMap().value: {\n const map = scv.map() ?? [];\n if (value === xdr.ScSpecType.scSpecTypeMap().value) {\n const typed = typeDef.map();\n const keyType = typed.keyType();\n const valueType = typed.valueType();\n const res = map.map((entry) => [\n this.scValToNative(entry.key(), keyType),\n this.scValToNative(entry.val(), valueType),\n ]) as T;\n return res;\n }\n throw new TypeError(\n `ScSpecType ${t.name} was not map, but ${JSON.stringify(\n scv,\n null,\n 2,\n )} is`,\n );\n }\n\n // these return the primitive type directly\n case xdr.ScValType.scvBool().value:\n case xdr.ScValType.scvU32().value:\n case xdr.ScValType.scvI32().value:\n case xdr.ScValType.scvBytes().value:\n return scv.value() as T;\n\n case xdr.ScValType.scvString().value:\n case xdr.ScValType.scvSymbol().value: {\n if (\n value !== xdr.ScSpecType.scSpecTypeString().value &&\n value !== xdr.ScSpecType.scSpecTypeSymbol().value\n ) {\n throw new Error(\n `ScSpecType ${\n t.name\n } was not string or symbol, but ${JSON.stringify(scv, null, 2)} is`,\n );\n }\n return scv.value()?.toString() as T;\n }\n\n // in the fallthrough case, just return the underlying value directly\n default:\n throw new TypeError(\n `failed to convert ${JSON.stringify(\n scv,\n null,\n 2,\n )} to native type from type ${t.name}`,\n );\n }\n }\n\n private scValUdtToNative(scv: xdr.ScVal, udt: xdr.ScSpecTypeUdt): any {\n const entry = this.findEntry(udt.name().toString());\n switch (entry.switch()) {\n case xdr.ScSpecEntryKind.scSpecEntryUdtEnumV0():\n return this.enumToNative(scv);\n case xdr.ScSpecEntryKind.scSpecEntryUdtStructV0():\n return this.structToNative(scv, entry.udtStructV0());\n case xdr.ScSpecEntryKind.scSpecEntryUdtUnionV0():\n return this.unionToNative(scv, entry.udtUnionV0());\n default:\n throw new Error(\n `failed to parse udt ${udt.name().toString()}: ${entry}`,\n );\n }\n }\n\n private unionToNative(val: xdr.ScVal, udt: xdr.ScSpecUdtUnionV0): any {\n const vec = val.vec();\n if (!vec) {\n throw new Error(`${JSON.stringify(val, null, 2)} is not a vec`);\n }\n if (vec.length === 0 && udt.cases.length !== 0) {\n throw new Error(\n `${val} has length 0, but the there are at least one case in the union`,\n );\n }\n const name = vec[0].sym().toString();\n if (vec[0].switch().value !== xdr.ScValType.scvSymbol().value) {\n throw new Error(`${vec[0]} is not a symbol`);\n }\n const entry = udt.cases().find(findCase(name));\n if (!entry) {\n throw new Error(\n `failed to find entry ${name} in union ${udt.name().toString()}`,\n );\n }\n const res: Union<any> = { tag: name };\n if (\n entry.switch().value ===\n xdr.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0().value\n ) {\n const tuple = entry.tupleCase();\n const ty = tuple.type();\n const values = ty.map((e, i) => this.scValToNative(vec![i + 1], e));\n res.values = values;\n }\n return res;\n }\n\n private structToNative(val: xdr.ScVal, udt: xdr.ScSpecUdtStructV0): any {\n const res: any = {};\n const fields = udt.fields();\n if (fields.some(isNumeric)) {\n const r = val\n .vec()\n ?.map((entry, i) => this.scValToNative(entry, fields[i].type()));\n return r;\n }\n val.map()?.forEach((entry, i) => {\n const field = fields[i];\n res[field.name().toString()] = this.scValToNative(\n entry.val(),\n field.type(),\n );\n });\n return res;\n }\n\n private enumToNative(scv: xdr.ScVal): number {\n if (scv.switch().value !== xdr.ScValType.scvU32().value) {\n throw new Error(`Enum must have a u32 value`);\n }\n const num = scv.u32();\n return num;\n }\n\n /**\n * Gets the XDR error cases from the spec.\n *\n * @returns all contract functions\n *\n */\n errorCases(): xdr.ScSpecUdtErrorEnumCaseV0[] {\n return this.entries\n .filter(\n (entry) =>\n entry.switch().value ===\n xdr.ScSpecEntryKind.scSpecEntryUdtErrorEnumV0().value,\n )\n .flatMap((entry) => (entry.value() as xdr.ScSpecUdtErrorEnumV0).cases());\n }\n\n /**\n * Converts the contract spec to a JSON schema.\n *\n * If `funcName` is provided, the schema will be a reference to the function schema.\n *\n * @param funcName - (optional) the name of the function to convert\n * @returns the converted JSON schema\n *\n * @throws if the contract spec is invalid\n */\n jsonSchema(funcName?: string): JSONSchema7 {\n const definitions: { [key: string]: JSONSchema7Definition } = {};\n\n this.entries.forEach((entry) => {\n switch (entry.switch().value) {\n case xdr.ScSpecEntryKind.scSpecEntryUdtEnumV0().value: {\n const udt = entry.udtEnumV0();\n definitions[udt.name().toString()] = enumToJsonSchema(udt);\n break;\n }\n case xdr.ScSpecEntryKind.scSpecEntryUdtStructV0().value: {\n const udt = entry.udtStructV0();\n definitions[udt.name().toString()] = structToJsonSchema(udt);\n break;\n }\n case xdr.ScSpecEntryKind.scSpecEntryUdtUnionV0().value: {\n const udt = entry.udtUnionV0();\n definitions[udt.name().toString()] = unionToJsonSchema(udt);\n break;\n }\n case xdr.ScSpecEntryKind.scSpecEntryFunctionV0().value: {\n const fn = entry.functionV0();\n const fnName = fn.name().toString();\n const { input } = functionToJsonSchema(fn);\n definitions[fnName] = input;\n break;\n }\n case xdr.ScSpecEntryKind.scSpecEntryUdtErrorEnumV0().value: {\n // console.debug(\"Error enums not supported yet\");\n }\n }\n });\n\n const res: JSONSchema7 = {\n $schema: \"http://json-schema.org/draft-07/schema#\",\n definitions: { ...PRIMITIVE_DEFINITONS, ...definitions },\n };\n if (funcName) {\n res.$ref = `#/definitions/${funcName}`;\n }\n return res;\n }\n}\n"],"names":["xdr","Address","XdrLargeInt","Buffer","specFromWasm","processSpecEntryStream","Err","Ok","Contract","scValToBigInt"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAkBA,SAAS,iBAAiB,GAAA,EAA+B;AACvD,EAAA,MAAM,WAAA,GAAc,GAAA,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AC,CAAA;AAED,IAAA,MAAM,GAAA,GAAmB;AAAA,MACvB,OAAA,EAAS,yCAAA;AAAA,MACT,WAAA,EAAa,EAAE,GAAG,oBAAA,EAAsB,GAAG,WAAA;AAAY,KACzD;AACA,IAAA,IAAI,QAAA,EAAU;AACZ,MAAA,GAAA,CAAI,IAAA,GAAO,iBAAiB,QAAQ,CAAA,CAAA;AAAA,IACtC;AACA,IAAA,OAAO,GAAA;AAAA,EACT;AACF;;;;"}
1
+ {"version":3,"file":"spec.js","sources":["../../../src/contract/spec.ts"],"sourcesContent":["import type { JSONSchema7, JSONSchema7Definition } from \"json-schema\";\nimport {\n type ScIntType,\n XdrLargeInt,\n xdr,\n Address,\n Contract,\n scValToBigInt,\n nativeToScVal,\n scValToNative,\n} from \"../base/index.js\";\nimport { Ok, Err } from \"./rust_result.js\";\nimport { processSpecEntryStream } from \"./utils.js\";\nimport { specFromWasm } from \"./wasm_spec_parser.js\";\nimport {\n events as eventsImpl,\n findEvent as findEventImpl,\n parseEvent as parseEventImpl,\n eventTopicFilter as eventTopicFilterImpl,\n type ParsedEvent,\n} from \"./event_spec.js\";\n\nexport type { ParsedEvent };\n\nexport interface Union<T> {\n tag: string;\n values?: T;\n}\n\nfunction enumToJsonSchema(udt: xdr.ScSpecUdtEnumV0): any {\n const description = udt.doc().toString();\n const cases = udt.cases();\n const oneOf: any[] = [];\n cases.forEach((aCase) => {\n const title = aCase.name().toString();\n const desc = aCase.doc().toString();\n oneOf.push({\n description: desc,\n title,\n enum: [aCase.value()],\n type: \"number\",\n });\n });\n const res: any = { oneOf };\n if (description.length > 0) {\n res.description = description;\n }\n return res;\n}\n\nfunction isNumeric(field: xdr.ScSpecUdtStructFieldV0) {\n return /^\\d+$/.test(field.name().toString());\n}\n\nfunction readObj(args: object, input: xdr.ScSpecFunctionInputV0): any {\n const inputName = input.name().toString();\n const entry = Object.entries(args).find(([name]) => name === inputName);\n if (!entry) {\n throw new Error(`Missing field ${inputName}`);\n }\n return entry[1];\n}\n\nfunction findCase(name: string) {\n return function matches(entry: xdr.ScSpecUdtUnionCaseV0) {\n switch (entry.switch().value) {\n case xdr.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0().value: {\n const tuple = entry.tupleCase();\n return tuple.name().toString() === name;\n }\n case xdr.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseVoidV0().value: {\n const voidCase = entry.voidCase();\n return voidCase.name().toString() === name;\n }\n default:\n return false;\n }\n };\n}\n\nfunction stringToScVal(str: string, ty: xdr.ScSpecType): xdr.ScVal {\n switch (ty.value) {\n case xdr.ScSpecType.scSpecTypeString().value:\n return xdr.ScVal.scvString(str);\n case xdr.ScSpecType.scSpecTypeSymbol().value:\n return xdr.ScVal.scvSymbol(str);\n case xdr.ScSpecType.scSpecTypeAddress().value:\n case xdr.ScSpecType.scSpecTypeMuxedAddress().value:\n return Address.fromString(str).toScVal();\n case xdr.ScSpecType.scSpecTypeU64().value:\n return new XdrLargeInt(\"u64\", str).toScVal();\n case xdr.ScSpecType.scSpecTypeI64().value:\n return new XdrLargeInt(\"i64\", str).toScVal();\n case xdr.ScSpecType.scSpecTypeU128().value:\n return new XdrLargeInt(\"u128\", str).toScVal();\n case xdr.ScSpecType.scSpecTypeI128().value:\n return new XdrLargeInt(\"i128\", str).toScVal();\n case xdr.ScSpecType.scSpecTypeU256().value:\n return new XdrLargeInt(\"u256\", str).toScVal();\n case xdr.ScSpecType.scSpecTypeI256().value:\n return new XdrLargeInt(\"i256\", str).toScVal();\n case xdr.ScSpecType.scSpecTypeBytes().value:\n case xdr.ScSpecType.scSpecTypeBytesN().value:\n return xdr.ScVal.scvBytes(Buffer.from(str, \"base64\"));\n case xdr.ScSpecType.scSpecTypeTimepoint().value: {\n return xdr.ScVal.scvTimepoint(new xdr.Uint64(str));\n }\n case xdr.ScSpecType.scSpecTypeDuration().value: {\n return xdr.ScVal.scvDuration(new xdr.Uint64(str));\n }\n default:\n throw new TypeError(`invalid type ${ty.name} specified for string value`);\n }\n}\n\nconst PRIMITIVE_DEFINITONS: { [key: string]: JSONSchema7Definition } = {\n U32: {\n type: \"integer\",\n minimum: 0,\n maximum: 4294967295,\n },\n I32: {\n type: \"integer\",\n minimum: -2147483648,\n maximum: 2147483647,\n },\n U64: {\n type: \"string\",\n pattern: \"^([1-9][0-9]*|0)$\",\n minLength: 1,\n maxLength: 20, // 64-bit max value has 20 digits\n },\n Timepoint: {\n type: \"string\",\n pattern: \"^([1-9][0-9]*|0)$\",\n minLength: 1,\n maxLength: 20, // 64-bit max value has 20 digits\n },\n Duration: {\n type: \"string\",\n pattern: \"^([1-9][0-9]*|0)$\",\n minLength: 1,\n maxLength: 20, // 64-bit max value has 20 digits\n },\n I64: {\n type: \"string\",\n pattern: \"^(-?[1-9][0-9]*|0)$\",\n minLength: 1,\n maxLength: 21, // Includes additional digit for the potential '-'\n },\n U128: {\n type: \"string\",\n pattern: \"^([1-9][0-9]*|0)$\",\n minLength: 1,\n maxLength: 39, // 128-bit max value has 39 digits\n },\n I128: {\n type: \"string\",\n pattern: \"^(-?[1-9][0-9]*|0)$\",\n minLength: 1,\n maxLength: 40, // Includes additional digit for the potential '-'\n },\n U256: {\n type: \"string\",\n pattern: \"^([1-9][0-9]*|0)$\",\n minLength: 1,\n maxLength: 78, // 256-bit max value has 78 digits\n },\n I256: {\n type: \"string\",\n pattern: \"^(-?[1-9][0-9]*|0)$\",\n minLength: 1,\n maxLength: 79, // Includes additional digit for the potential '-'\n },\n Address: {\n type: \"string\",\n format: \"address\",\n description: \"Address can be a public key or contract id\",\n },\n MuxedAddress: {\n type: \"string\",\n format: \"address\",\n description:\n \"Stellar public key with M prefix combining a G address and unique ID\",\n },\n ScString: {\n type: \"string\",\n description: \"ScString is a string\",\n },\n ScSymbol: {\n type: \"string\",\n description: \"ScSymbol is a string\",\n },\n DataUrl: {\n type: \"string\",\n pattern:\n \"^(?:[A-Za-z0-9+\\\\/]{4})*(?:[A-Za-z0-9+\\\\/]{2}==|[A-Za-z0-9+\\\\/]{3}=)?$\",\n },\n};\n\n/**\n * Converts an XDR type definition to a JSON schema reference.\n * @param typeDef - type to convert to json schema reference\n * @returns a schema describing the type\n * @hidden\n */\nfunction typeRef(typeDef: xdr.ScSpecTypeDef): JSONSchema7 {\n const t = typeDef.switch();\n const value = t.value;\n let ref;\n switch (value) {\n case xdr.ScSpecType.scSpecTypeVal().value: {\n ref = \"Val\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeBool().value: {\n return { type: \"boolean\" };\n }\n case xdr.ScSpecType.scSpecTypeVoid().value: {\n return { type: \"null\" };\n }\n case xdr.ScSpecType.scSpecTypeError().value: {\n ref = \"Error\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeU32().value: {\n ref = \"U32\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeI32().value: {\n ref = \"I32\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeU64().value: {\n ref = \"U64\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeI64().value: {\n ref = \"I64\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeTimepoint().value: {\n ref = \"Timepoint\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeDuration().value: {\n ref = \"Duration\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeU128().value: {\n ref = \"U128\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeI128().value: {\n ref = \"I128\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeU256().value: {\n ref = \"U256\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeI256().value: {\n ref = \"I256\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeBytes().value: {\n ref = \"DataUrl\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeString().value: {\n ref = \"ScString\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeSymbol().value: {\n ref = \"ScSymbol\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeAddress().value: {\n ref = \"Address\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeMuxedAddress().value: {\n ref = \"MuxedAddress\";\n break;\n }\n case xdr.ScSpecType.scSpecTypeOption().value: {\n const opt = typeDef.option();\n return typeRef(opt.valueType());\n }\n case xdr.ScSpecType.scSpecTypeResult().value: {\n const result = typeDef.result();\n return typeRef(result.okType());\n }\n case xdr.ScSpecType.scSpecTypeVec().value: {\n const arr = typeDef.vec();\n const reference = typeRef(arr.elementType());\n return {\n type: \"array\",\n items: reference,\n };\n }\n case xdr.ScSpecType.scSpecTypeMap().value: {\n const map = typeDef.map();\n const items = [typeRef(map.keyType()), typeRef(map.valueType())];\n return {\n type: \"array\",\n items: {\n type: \"array\",\n items,\n minItems: 2,\n maxItems: 2,\n },\n };\n }\n case xdr.ScSpecType.scSpecTypeTuple().value: {\n const tuple = typeDef.tuple();\n const minItems = tuple.valueTypes().length;\n const maxItems = minItems;\n const items = tuple.valueTypes().map(typeRef);\n return { type: \"array\", items, minItems, maxItems };\n }\n case xdr.ScSpecType.scSpecTypeBytesN().value: {\n const arr = typeDef.bytesN();\n return {\n $ref: \"#/definitions/DataUrl\",\n maxLength: arr.n(),\n };\n }\n case xdr.ScSpecType.scSpecTypeUdt().value: {\n const udt = typeDef.udt();\n ref = udt.name().toString();\n break;\n }\n }\n return { $ref: `#/definitions/${ref}` };\n}\n\ntype Func = { input: JSONSchema7; output: JSONSchema7 };\n\nfunction isRequired(typeDef: xdr.ScSpecTypeDef): boolean {\n return typeDef.switch().value !== xdr.ScSpecType.scSpecTypeOption().value;\n}\n\nfunction argsAndRequired(\n input: { type: () => xdr.ScSpecTypeDef; name: () => string | Buffer }[],\n): { properties: object; required?: string[] } {\n const properties: any = {};\n const required: string[] = [];\n input.forEach((arg) => {\n const aType = arg.type();\n const name = arg.name().toString();\n properties[name] = typeRef(aType);\n if (isRequired(aType)) {\n required.push(name);\n }\n });\n const res: { properties: object; required?: string[] } = { properties };\n if (required.length > 0) {\n res.required = required;\n }\n return res;\n}\n\nfunction structToJsonSchema(udt: xdr.ScSpecUdtStructV0): object {\n const fields = udt.fields();\n if (fields.some(isNumeric)) {\n if (!fields.every(isNumeric)) {\n throw new Error(\n \"mixed numeric and non-numeric field names are not allowed\",\n );\n }\n const items = fields.map((_, i) => typeRef(fields[i].type()));\n return {\n type: \"array\",\n items,\n minItems: fields.length,\n maxItems: fields.length,\n };\n }\n const description = udt.doc().toString();\n const { properties, required }: any = argsAndRequired(fields);\n return {\n description,\n properties,\n required,\n additionalProperties: false,\n type: \"object\",\n };\n}\n\nfunction functionToJsonSchema(func: xdr.ScSpecFunctionV0): Func {\n const { properties, required }: any = argsAndRequired(func.inputs());\n const args: any = {\n additionalProperties: false,\n properties,\n type: \"object\",\n };\n if (required?.length > 0) {\n args.required = required;\n }\n const input: Partial<JSONSchema7> = {\n properties: {\n args,\n },\n };\n const outputs = func.outputs();\n const output: Partial<JSONSchema7> =\n outputs.length > 0\n ? typeRef(outputs[0])\n : typeRef(xdr.ScSpecTypeDef.scSpecTypeVoid());\n const description = func.doc().toString();\n if (description.length > 0) {\n input.description = description;\n }\n input.additionalProperties = false;\n output.additionalProperties = false;\n return {\n input,\n output,\n };\n}\n\nfunction unionToJsonSchema(udt: xdr.ScSpecUdtUnionV0): any {\n const description = udt.doc().toString();\n const cases = udt.cases();\n const oneOf: any[] = [];\n cases.forEach((aCase) => {\n switch (aCase.switch().value) {\n case xdr.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseVoidV0().value: {\n const c = aCase.voidCase();\n const title = c.name().toString();\n oneOf.push({\n type: \"object\",\n title,\n properties: {\n tag: title,\n },\n additionalProperties: false,\n required: [\"tag\"],\n });\n break;\n }\n case xdr.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0().value: {\n const c = aCase.tupleCase();\n const title = c.name().toString();\n oneOf.push({\n type: \"object\",\n title,\n properties: {\n tag: title,\n values: {\n type: \"array\",\n items: c.type().map(typeRef),\n },\n },\n required: [\"tag\", \"values\"],\n additionalProperties: false,\n });\n }\n }\n });\n\n const res: any = {\n oneOf,\n };\n if (description.length > 0) {\n res.description = description;\n }\n return res;\n}\n\n/**\n * Provides a ContractSpec class which can contains the XDR types defined by the contract.\n * This allows the class to be used to convert between native and raw `xdr.ScVal`s.\n *\n * Constructs a new ContractSpec from an array of XDR spec entries.\n *\n * @param entries - the XDR spec entries\n * @throws if entries is invalid\n *\n * @example\n * ```ts\n * const specEntries = [...]; // XDR spec entries of a smart contract\n * const contractSpec = new ContractSpec(specEntries);\n *\n * // Convert native value to ScVal\n * const args = {\n * arg1: 'value1',\n * arg2: 1234\n * };\n * const scArgs = contractSpec.funcArgsToScVals('funcName', args);\n *\n * // Call contract\n * const resultScv = await callContract(contractId, 'funcName', scArgs);\n *\n * // Convert result ScVal back to native value\n * const result = contractSpec.funcResToNative('funcName', resultScv);\n *\n * console.log(result); // {success: true}\n * ```\n */\nexport class Spec {\n /**\n * The XDR spec entries.\n */\n public entries: xdr.ScSpecEntry[] = [];\n\n /**\n * Generates a Spec instance from the contract's wasm binary.\n *\n * @param wasm - The contract's wasm binary as a Buffer.\n * @returns A Promise that resolves to a Spec instance.\n * @throws If the contract spec cannot be obtained from the provided wasm binary.\n */\n static fromWasm(wasm: Buffer): Spec {\n const spec = specFromWasm(wasm);\n return new Spec(spec);\n }\n\n /**\n * Generates a Spec instance from contract specs in any of the following forms:\n * - An XDR encoded stream of xdr.ScSpecEntry entries, the format of the spec\n * stored inside Wasm files.\n * - A base64 XDR encoded stream of xdr.ScSpecEntry entries.\n * - An array of xdr.ScSpecEntry.\n * - An array of base64 XDR encoded xdr.ScSpecEntry.\n *\n * @returns A Promise that resolves to a Client instance.\n * @throws If the contract spec cannot be obtained from the provided wasm binary.\n */\n constructor(entries: Buffer | string | xdr.ScSpecEntry[] | string[]) {\n if (Buffer.isBuffer(entries)) {\n this.entries = processSpecEntryStream(entries as Buffer);\n } else if (typeof entries === \"string\") {\n this.entries = processSpecEntryStream(Buffer.from(entries, \"base64\"));\n } else {\n if (entries.length === 0) {\n throw new Error(\"Contract spec must have at least one entry\");\n }\n const entry = entries[0];\n if (typeof entry === \"string\") {\n this.entries = (entries as string[]).map((s) =>\n xdr.ScSpecEntry.fromXDR(s, \"base64\"),\n );\n } else {\n this.entries = entries as xdr.ScSpecEntry[];\n }\n }\n }\n\n /**\n * Gets the XDR functions from the spec.\n * @returns all contract functions\n */\n funcs(): xdr.ScSpecFunctionV0[] {\n return this.entries\n .filter(\n (entry) =>\n entry.switch().value ===\n xdr.ScSpecEntryKind.scSpecEntryFunctionV0().value,\n )\n .map((entry) => entry.functionV0());\n }\n\n /**\n * Gets the XDR function spec for the given function name.\n *\n * @param name - the name of the function\n * @returns the function spec\n *\n * @throws if no function with the given name exists\n */\n getFunc(name: string): xdr.ScSpecFunctionV0 {\n const entry = this.findEntry(name);\n if (\n entry.switch().value !== xdr.ScSpecEntryKind.scSpecEntryFunctionV0().value\n ) {\n throw new Error(`${name} is not a function`);\n }\n return entry.functionV0();\n }\n\n /**\n * Converts native JS arguments to ScVals for calling a contract function.\n *\n * @param name - the name of the function\n * @param args - the arguments object\n * @returns the converted arguments\n *\n * @throws if argument is missing or incorrect type\n *\n * @example\n * ```ts\n * const args = {\n * arg1: 'value1',\n * arg2: 1234\n * };\n * const scArgs = contractSpec.funcArgsToScVals('funcName', args);\n * ```\n */\n funcArgsToScVals(name: string, args: object): xdr.ScVal[] {\n const fn = this.getFunc(name);\n return fn\n .inputs()\n .map((input) => this.nativeToScVal(readObj(args, input), input.type()));\n }\n\n /**\n * Converts the result ScVal of a function call to a native JS value.\n *\n * @param name - the name of the function\n * @param val_or_base64 - the result ScVal or base64 encoded string\n * @returns the converted native value\n *\n * @throws if return type mismatch or invalid input\n *\n * @example\n * ```ts\n * const resultScv = 'AAA=='; // Base64 encoded ScVal\n * const result = contractSpec.funcResToNative('funcName', resultScv);\n * ```\n */\n funcResToNative(name: string, val_or_base64: xdr.ScVal | string): any {\n const val =\n typeof val_or_base64 === \"string\"\n ? xdr.ScVal.fromXDR(val_or_base64, \"base64\")\n : val_or_base64;\n const func = this.getFunc(name);\n const outputs = func.outputs();\n if (outputs.length === 0) {\n const type = val.switch();\n if (type.value !== xdr.ScValType.scvVoid().value) {\n throw new Error(`Expected void, got ${type.name}`);\n }\n return null;\n }\n if (outputs.length > 1) {\n throw new Error(`Multiple outputs not supported`);\n }\n const output = outputs[0];\n if (output.switch().value === xdr.ScSpecType.scSpecTypeResult().value) {\n if (val.switch().value === xdr.ScValType.scvError().value) {\n return new Err({ message: val.error().toXDR(\"base64\") });\n }\n return new Ok(this.scValToNative(val, output.result().okType()));\n }\n return this.scValToNative(val, output);\n }\n\n /**\n * Finds the XDR spec entry for the given name.\n *\n * @param name - the name to find\n * @returns the entry\n *\n * @throws if no entry with the given name exists\n */\n findEntry(name: string): xdr.ScSpecEntry {\n const entry = this.entries.find(\n (e) => e.value().name().toString() === name,\n );\n if (!entry) {\n throw new Error(`no such entry: ${name}`);\n }\n return entry;\n }\n\n /**\n * Converts a native JS value to an ScVal based on the given type.\n *\n * @param val - the native JS value\n * @param ty - (optional) the expected type\n * @returns the converted ScVal\n *\n * @throws if value cannot be converted to the given type\n */\n nativeToScVal(val: any, ty: xdr.ScSpecTypeDef): xdr.ScVal {\n const t: xdr.ScSpecType = ty.switch();\n const value = t.value;\n if (t.value === xdr.ScSpecType.scSpecTypeUdt().value) {\n const udt = ty.udt();\n return this.nativeToUdt(val, udt.name().toString());\n }\n if (value === xdr.ScSpecType.scSpecTypeOption().value) {\n const opt = ty.option();\n if (val === null || val === undefined) {\n return xdr.ScVal.scvVoid();\n }\n return this.nativeToScVal(val, opt.valueType());\n }\n\n // Delegate scSpecTypeVal to the base nativeToScVal helper, which handles\n // strings, numbers/bigints (via ScInt), booleans, null/undefined, arrays,\n // plain objects (sorted), Map, Address, Contract, Uint8Array, and xdr.ScVal\n // passthroughs — keeping this in one place so the two code paths can't\n // drift apart over time.\n if (value === xdr.ScSpecType.scSpecTypeVal().value) {\n return nativeToScVal(val);\n }\n\n switch (typeof val) {\n case \"object\": {\n if (val === null) {\n switch (value) {\n case xdr.ScSpecType.scSpecTypeVoid().value:\n return xdr.ScVal.scvVoid();\n default:\n throw new TypeError(\n `Type ${ty} was not void, but value was null`,\n );\n }\n }\n\n if (val instanceof xdr.ScVal) {\n return val; // should we copy?\n }\n\n if (val instanceof Address) {\n if (ty.switch().value !== xdr.ScSpecType.scSpecTypeAddress().value) {\n throw new TypeError(\n `Type ${ty} was not address, but value was Address`,\n );\n }\n return val.toScVal();\n }\n\n if (val instanceof Contract) {\n if (ty.switch().value !== xdr.ScSpecType.scSpecTypeAddress().value) {\n throw new TypeError(\n `Type ${ty} was not address, but value was Address`,\n );\n }\n return val.address().toScVal();\n }\n\n if (val instanceof Uint8Array || Buffer.isBuffer(val)) {\n const copy = Uint8Array.from(val);\n switch (value) {\n case xdr.ScSpecType.scSpecTypeBytesN().value: {\n const bytesN = ty.bytesN();\n if (copy.length !== bytesN.n()) {\n throw new TypeError(\n `expected ${bytesN.n()} bytes, but got ${copy.length}`,\n );\n }\n //@ts-expect-error scvBytes' generated type expects Buffer; copy is a Uint8Array accepted at runtime\n return xdr.ScVal.scvBytes(copy);\n }\n case xdr.ScSpecType.scSpecTypeBytes().value:\n //@ts-expect-error scvBytes' generated type expects Buffer; copy is a Uint8Array accepted at runtime\n return xdr.ScVal.scvBytes(copy);\n default:\n throw new TypeError(\n `invalid type (${ty}) specified for Bytes and BytesN`,\n );\n }\n }\n if (Array.isArray(val)) {\n switch (value) {\n case xdr.ScSpecType.scSpecTypeVec().value: {\n const vec = ty.vec();\n const elementType = vec.elementType();\n return xdr.ScVal.scvVec(\n val.map((v) => this.nativeToScVal(v, elementType)),\n );\n }\n case xdr.ScSpecType.scSpecTypeTuple().value: {\n const tup = ty.tuple();\n const valTypes = tup.valueTypes();\n if (val.length !== valTypes.length) {\n throw new TypeError(\n `Tuple expects ${valTypes.length} values, but ${val.length} were provided`,\n );\n }\n return xdr.ScVal.scvVec(\n val.map((v, i) => this.nativeToScVal(v, valTypes[i])),\n );\n }\n case xdr.ScSpecType.scSpecTypeMap().value: {\n const map = ty.map();\n const keyType = map.keyType();\n const valueType = map.valueType();\n return xdr.ScVal.scvMap(\n val.map((entry) => {\n const key = this.nativeToScVal(entry[0], keyType);\n const mapVal = this.nativeToScVal(entry[1], valueType);\n return new xdr.ScMapEntry({ key, val: mapVal });\n }),\n );\n }\n\n default:\n throw new TypeError(\n `Type ${ty} was not vec, but value was Array`,\n );\n }\n }\n if (val instanceof Map) {\n if (value !== xdr.ScSpecType.scSpecTypeMap().value) {\n throw new TypeError(`Type ${ty} was not map, but value was Map`);\n }\n const scMap = ty.map();\n const map = val as Map<any, any>;\n const entries: xdr.ScMapEntry[] = [];\n const values = map.entries();\n let res = values.next();\n while (!res.done) {\n const [k, v] = res.value;\n const key = this.nativeToScVal(k, scMap.keyType());\n const mapval = this.nativeToScVal(v, scMap.valueType());\n entries.push(new xdr.ScMapEntry({ key, val: mapval }));\n res = values.next();\n }\n return xdr.ScVal.scvMap(entries);\n }\n\n const proto = Object.getPrototypeOf(val);\n if (proto !== Object.prototype && proto !== null) {\n throw new TypeError(\n `cannot interpret ${\n val.constructor?.name\n } value as ScVal (${JSON.stringify(val)})`,\n );\n }\n\n throw new TypeError(\n `Received object ${val} did not match the provided type ${ty}`,\n );\n }\n\n case \"number\":\n case \"bigint\": {\n switch (value) {\n case xdr.ScSpecType.scSpecTypeU32().value:\n if (\n BigInt(val) < BigInt(xdr.Uint32.MIN_VALUE) ||\n BigInt(val) > BigInt(xdr.Uint32.MAX_VALUE)\n ) {\n throw new RangeError(`Value ${val} is out of range for U32`);\n }\n return xdr.ScVal.scvU32(Number(val));\n case xdr.ScSpecType.scSpecTypeI32().value:\n if (\n // TODO: remove the `-` cast on the min value once js-xdr fixes the issue where it treats the min value as unsigned\n BigInt(val) < -BigInt(xdr.Int32.MIN_VALUE) ||\n BigInt(val) > BigInt(xdr.Int32.MAX_VALUE)\n ) {\n throw new RangeError(`Value ${val} is out of range for I32`);\n }\n return xdr.ScVal.scvI32(Number(val));\n case xdr.ScSpecType.scSpecTypeU64().value:\n case xdr.ScSpecType.scSpecTypeI64().value:\n case xdr.ScSpecType.scSpecTypeU128().value:\n case xdr.ScSpecType.scSpecTypeI128().value:\n case xdr.ScSpecType.scSpecTypeU256().value:\n case xdr.ScSpecType.scSpecTypeI256().value:\n case xdr.ScSpecType.scSpecTypeTimepoint().value:\n case xdr.ScSpecType.scSpecTypeDuration().value: {\n const intType = t.name.substring(10).toLowerCase() as ScIntType;\n return new XdrLargeInt(intType, val as bigint).toScVal();\n }\n default:\n throw new TypeError(`invalid type (${ty}) specified for integer`);\n }\n }\n case \"string\":\n return stringToScVal(val, t);\n\n case \"boolean\": {\n if (value !== xdr.ScSpecType.scSpecTypeBool().value) {\n throw TypeError(`Type ${ty} was not bool, but value was bool`);\n }\n return xdr.ScVal.scvBool(val);\n }\n case \"undefined\": {\n if (!ty) {\n return xdr.ScVal.scvVoid();\n }\n switch (value) {\n case xdr.ScSpecType.scSpecTypeVoid().value:\n case xdr.ScSpecType.scSpecTypeOption().value:\n return xdr.ScVal.scvVoid();\n default:\n throw new TypeError(\n `Type ${ty} was not void, but value was undefined`,\n );\n }\n }\n\n case \"function\": // FIXME: Is this too helpful?\n return this.nativeToScVal(val(), ty);\n\n default:\n throw new TypeError(`failed to convert typeof ${typeof val} (${val})`);\n }\n }\n\n private nativeToUdt(val: any, name: string): xdr.ScVal {\n const entry = this.findEntry(name);\n switch (entry.switch()) {\n case xdr.ScSpecEntryKind.scSpecEntryUdtEnumV0():\n if (typeof val !== \"number\") {\n throw new TypeError(\n `expected number for enum ${name}, but got ${typeof val}`,\n );\n }\n return this.nativeToEnum(val as number, entry.udtEnumV0());\n case xdr.ScSpecEntryKind.scSpecEntryUdtStructV0():\n return this.nativeToStruct(val, entry.udtStructV0());\n case xdr.ScSpecEntryKind.scSpecEntryUdtUnionV0():\n return this.nativeToUnion(val, entry.udtUnionV0());\n default:\n throw new Error(`failed to parse udt ${name}`);\n }\n }\n\n private nativeToUnion(\n val: Union<any>,\n union_: xdr.ScSpecUdtUnionV0,\n ): xdr.ScVal {\n const entryName = val.tag;\n const caseFound = union_.cases().find((entry) => {\n const caseN = entry.value().name().toString();\n return caseN === entryName;\n });\n if (!caseFound) {\n throw new TypeError(`no such enum entry: ${entryName} in ${union_}`);\n }\n const key = xdr.ScVal.scvSymbol(entryName);\n switch (caseFound.switch()) {\n case xdr.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseVoidV0(): {\n return xdr.ScVal.scvVec([key]);\n }\n case xdr.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0(): {\n const types = caseFound.tupleCase().type();\n if (Array.isArray(val.values)) {\n if (val.values.length !== types.length) {\n throw new TypeError(\n `union ${union_} expects ${types.length} values, but got ${val.values.length}`,\n );\n }\n const scvals = val.values.map((v, i) =>\n this.nativeToScVal(v, types[i]),\n );\n scvals.unshift(key);\n return xdr.ScVal.scvVec(scvals);\n }\n throw new Error(`failed to parse union case ${caseFound} with ${val}`);\n }\n default:\n throw new Error(`failed to parse union ${union_} with ${val}`);\n }\n }\n\n private nativeToStruct(val: any, struct: xdr.ScSpecUdtStructV0): xdr.ScVal {\n const fields = struct.fields();\n if (fields.some(isNumeric)) {\n if (!fields.every(isNumeric)) {\n throw new Error(\n \"mixed numeric and non-numeric field names are not allowed\",\n );\n }\n return xdr.ScVal.scvVec(\n fields.map((_, i) => this.nativeToScVal(val[i], fields[i].type())),\n );\n }\n return xdr.ScVal.scvMap(\n fields.map((field) => {\n const name = field.name().toString();\n return new xdr.ScMapEntry({\n key: this.nativeToScVal(name, xdr.ScSpecTypeDef.scSpecTypeSymbol()),\n val: this.nativeToScVal(val[name], field.type()),\n });\n }),\n );\n }\n\n private nativeToEnum(val: number, enum_: xdr.ScSpecUdtEnumV0): xdr.ScVal {\n if (enum_.cases().some((entry) => entry.value() === val)) {\n return xdr.ScVal.scvU32(val);\n }\n throw new TypeError(`no such enum entry: ${val} in ${enum_}`);\n }\n\n /**\n * Converts an base64 encoded ScVal back to a native JS value based on the given type.\n *\n * @param scv - the base64 encoded ScVal\n * @param typeDef - the expected type\n * @returns the converted native JS value\n *\n * @throws if ScVal cannot be converted to the given type\n */\n scValStrToNative<T>(scv: string, typeDef: xdr.ScSpecTypeDef): T {\n return this.scValToNative<T>(xdr.ScVal.fromXDR(scv, \"base64\"), typeDef);\n }\n\n /**\n * Converts an ScVal back to a native JS value based on the given type.\n *\n * @param scv - the ScVal\n * @param typeDef - the expected type\n * @returns the converted native JS value\n *\n * @throws if ScVal cannot be converted to the given type\n */\n scValToNative<T>(scv: xdr.ScVal, typeDef: xdr.ScSpecTypeDef): T {\n const t = typeDef.switch();\n const value = t.value;\n\n if (value === xdr.ScSpecType.scSpecTypeOption().value) {\n switch (scv.switch().value) {\n case xdr.ScValType.scvVoid().value:\n return null as T;\n default:\n return this.scValToNative(scv, typeDef.option().valueType());\n }\n }\n\n if (value === xdr.ScSpecType.scSpecTypeUdt().value) {\n return this.scValUdtToNative(scv, typeDef.udt());\n }\n\n // Delegate scSpecTypeVal to the base scValToNative helper, mirroring the\n // encoding side (nativeToScVal above): a `Val` field carries no type\n // information, so decode each value to its natural native representation.\n if (value === xdr.ScSpecType.scSpecTypeVal().value) {\n return scValToNative(scv) as T;\n }\n\n // we use the verbose xdr.ScValType.<type>.value form here because it's faster\n // than string comparisons and the underlying constants never need to be\n // updated\n switch (scv.switch().value) {\n case xdr.ScValType.scvVoid().value:\n return null as T;\n\n // these can be converted to bigints directly\n case xdr.ScValType.scvU64().value:\n case xdr.ScValType.scvI64().value:\n case xdr.ScValType.scvTimepoint().value:\n case xdr.ScValType.scvDuration().value:\n // these can be parsed by internal abstractions note that this can also\n // handle the above two cases, but it's not as efficient (another\n // type-check, parsing, etc.)\n case xdr.ScValType.scvU128().value:\n case xdr.ScValType.scvI128().value:\n case xdr.ScValType.scvU256().value:\n case xdr.ScValType.scvI256().value:\n return scValToBigInt(scv) as T;\n\n case xdr.ScValType.scvVec().value: {\n if (value === xdr.ScSpecType.scSpecTypeVec().value) {\n const vec = typeDef.vec();\n return (scv.vec() ?? []).map((elm) =>\n this.scValToNative(elm, vec.elementType()),\n ) as T;\n }\n if (value === xdr.ScSpecType.scSpecTypeTuple().value) {\n const tuple = typeDef.tuple();\n const valTypes = tuple.valueTypes();\n return (scv.vec() ?? []).map((elm, i) =>\n this.scValToNative(elm, valTypes[i]),\n ) as T;\n }\n throw new TypeError(`Type ${typeDef} was not vec, but ${scv} is`);\n }\n\n case xdr.ScValType.scvAddress().value:\n return Address.fromScVal(scv).toString() as T;\n\n case xdr.ScValType.scvMap().value: {\n const map = scv.map() ?? [];\n if (value === xdr.ScSpecType.scSpecTypeMap().value) {\n const typed = typeDef.map();\n const keyType = typed.keyType();\n const valueType = typed.valueType();\n const res = map.map((entry) => [\n this.scValToNative(entry.key(), keyType),\n this.scValToNative(entry.val(), valueType),\n ]) as T;\n return res;\n }\n throw new TypeError(\n `ScSpecType ${t.name} was not map, but ${JSON.stringify(\n scv,\n null,\n 2,\n )} is`,\n );\n }\n\n // these return the primitive type directly\n case xdr.ScValType.scvBool().value:\n case xdr.ScValType.scvU32().value:\n case xdr.ScValType.scvI32().value:\n case xdr.ScValType.scvBytes().value:\n return scv.value() as T;\n\n case xdr.ScValType.scvString().value:\n case xdr.ScValType.scvSymbol().value: {\n if (\n value !== xdr.ScSpecType.scSpecTypeString().value &&\n value !== xdr.ScSpecType.scSpecTypeSymbol().value\n ) {\n throw new Error(\n `ScSpecType ${\n t.name\n } was not string or symbol, but ${JSON.stringify(scv, null, 2)} is`,\n );\n }\n return scv.value()?.toString() as T;\n }\n\n // in the fallthrough case, just return the underlying value directly\n default:\n throw new TypeError(\n `failed to convert ${JSON.stringify(\n scv,\n null,\n 2,\n )} to native type from type ${t.name}`,\n );\n }\n }\n\n private scValUdtToNative(scv: xdr.ScVal, udt: xdr.ScSpecTypeUdt): any {\n const entry = this.findEntry(udt.name().toString());\n switch (entry.switch()) {\n case xdr.ScSpecEntryKind.scSpecEntryUdtEnumV0():\n return this.enumToNative(scv);\n case xdr.ScSpecEntryKind.scSpecEntryUdtStructV0():\n return this.structToNative(scv, entry.udtStructV0());\n case xdr.ScSpecEntryKind.scSpecEntryUdtUnionV0():\n return this.unionToNative(scv, entry.udtUnionV0());\n default:\n throw new Error(\n `failed to parse udt ${udt.name().toString()}: ${entry}`,\n );\n }\n }\n\n private unionToNative(val: xdr.ScVal, udt: xdr.ScSpecUdtUnionV0): any {\n const vec = val.vec();\n if (!vec) {\n throw new Error(`${JSON.stringify(val, null, 2)} is not a vec`);\n }\n if (vec.length === 0 && udt.cases.length !== 0) {\n throw new Error(\n `${val} has length 0, but the there are at least one case in the union`,\n );\n }\n const name = vec[0].sym().toString();\n if (vec[0].switch().value !== xdr.ScValType.scvSymbol().value) {\n throw new Error(`${vec[0]} is not a symbol`);\n }\n const entry = udt.cases().find(findCase(name));\n if (!entry) {\n throw new Error(\n `failed to find entry ${name} in union ${udt.name().toString()}`,\n );\n }\n const res: Union<any> = { tag: name };\n if (\n entry.switch().value ===\n xdr.ScSpecUdtUnionCaseV0Kind.scSpecUdtUnionCaseTupleV0().value\n ) {\n const tuple = entry.tupleCase();\n const ty = tuple.type();\n const values = ty.map((e, i) => this.scValToNative(vec![i + 1], e));\n res.values = values;\n }\n return res;\n }\n\n private structToNative(val: xdr.ScVal, udt: xdr.ScSpecUdtStructV0): any {\n const res: any = {};\n const fields = udt.fields();\n if (fields.some(isNumeric)) {\n const r = val\n .vec()\n ?.map((entry, i) => this.scValToNative(entry, fields[i].type()));\n return r;\n }\n val.map()?.forEach((entry, i) => {\n const field = fields[i];\n res[field.name().toString()] = this.scValToNative(\n entry.val(),\n field.type(),\n );\n });\n return res;\n }\n\n private enumToNative(scv: xdr.ScVal): number {\n if (scv.switch().value !== xdr.ScValType.scvU32().value) {\n throw new Error(`Enum must have a u32 value`);\n }\n const num = scv.u32();\n return num;\n }\n\n /**\n * Gets the XDR error cases from the spec.\n *\n * @returns all contract functions\n *\n */\n errorCases(): xdr.ScSpecUdtErrorEnumCaseV0[] {\n return this.entries\n .filter(\n (entry) =>\n entry.switch().value ===\n xdr.ScSpecEntryKind.scSpecEntryUdtErrorEnumV0().value,\n )\n .flatMap((entry) => (entry.value() as xdr.ScSpecUdtErrorEnumV0).cases());\n }\n\n /**\n * Gets the SEP-48 event spec entries from the spec.\n *\n * @returns all contract events\n */\n events(): xdr.ScSpecEventV0[] {\n return eventsImpl(this.entries);\n }\n\n /**\n * Finds the XDR event spec for the given event name.\n *\n * Unlike {@link Spec.findEntry}, a missing event is not an error: this\n * returns `undefined` so callers can probe a contract for an event without\n * wrapping the call in a `try`.\n *\n * @param name - the name of the event\n * @param occurrence - (optional) 0-based index among same-named events, in\n * declaration order, for contracts that declare the same event name\n * more than once (defaults to the first)\n * @returns the event spec, or `undefined` if the contract declares no event\n * with that name (at that occurrence)\n *\n * @throws if `occurrence` is not a non-negative integer\n *\n * @example\n * ```ts\n * if (contractSpec.findEvent(\"transfer\")) {\n * // the contract declares a \"transfer\" event\n * }\n * ```\n */\n findEvent(name: string, occurrence?: number): xdr.ScSpecEventV0 | undefined {\n return findEventImpl(this.entries, name, occurrence);\n }\n\n /**\n * Attempts to parse an emitted contract event (its topics and data) using\n * the event specs (SEP-48) declared in this contract's spec.\n *\n * An event's topics are `[...prefixTopics, ...topicListParamValues]` (in\n * that order), and its data is decoded according to the event's\n * `dataFormat` (`singleValue`, `vec`, or `map`).\n *\n * @param topics - the event's topics, as `xdr.ScVal[]` or base64 XDR strings\n * @param data - the event's data, as an `xdr.ScVal` or a base64 XDR string\n * @returns the parsed event (its name plus all decoded params — topic-list\n * and data-located alike — merged into `data`), or `undefined` if\n * no event spec matches (e.g. when filtering a mixed stream of\n * events from multiple contracts/specs)\n *\n * Note that matching compares only the prefix topics and the topic count;\n * if two event specs share both (in particular, events with no prefix\n * topics match on arity alone), the first declared spec whose values\n * decode successfully wins.\n *\n * @example\n * ```ts\n * const parsed = contractSpec.parseEvent(response.topic, response.value);\n * if (parsed) {\n * console.log(parsed.name, parsed.data);\n * }\n * ```\n */\n parseEvent(\n topics: xdr.ScVal[] | string[],\n data: xdr.ScVal | string,\n ): ParsedEvent | undefined {\n return parseEventImpl(this, this.entries, topics, data);\n }\n\n /**\n * Builds a `getEvents` topic filter (a single row of `Api.EventFilter.topics`)\n * for the named event: base64-encoded `scvSymbol`s for the event's prefix\n * topics, followed by one entry per topic-list param — either the\n * base64-encoded ScVal for a value supplied in `topicValues`, or the\n * wildcard `\"*\"`.\n *\n * @param name - the name of the event\n * @param topicValues - (optional) native values for topic-list params, keyed by param name\n * @param occurrence - (optional) 0-based index among same-named events, in\n * declaration order, for contracts that declare the same event name\n * more than once (defaults to the first)\n * @returns a single topic filter row\n *\n * @throws if no event with the given name (at the given occurrence) exists,\n * or if `occurrence` is not a non-negative integer\n *\n * @example\n * ```ts\n * const topics = contractSpec.eventTopicFilter('transfer', { to: someAddress });\n * ```\n */\n eventTopicFilter(\n name: string,\n topicValues?: Record<string, any>,\n occurrence?: number,\n ): string[] {\n return eventTopicFilterImpl(\n this,\n this.entries,\n name,\n topicValues,\n occurrence,\n );\n }\n\n /**\n * Converts the contract spec to a JSON schema.\n *\n * If `funcName` is provided, the schema will be a reference to the function schema.\n *\n * @param funcName - (optional) the name of the function to convert\n * @returns the converted JSON schema\n *\n * @throws if the contract spec is invalid\n */\n jsonSchema(funcName?: string): JSONSchema7 {\n const definitions: { [key: string]: JSONSchema7Definition } = {};\n\n this.entries.forEach((entry) => {\n switch (entry.switch().value) {\n case xdr.ScSpecEntryKind.scSpecEntryUdtEnumV0().value: {\n const udt = entry.udtEnumV0();\n definitions[udt.name().toString()] = enumToJsonSchema(udt);\n break;\n }\n case xdr.ScSpecEntryKind.scSpecEntryUdtStructV0().value: {\n const udt = entry.udtStructV0();\n definitions[udt.name().toString()] = structToJsonSchema(udt);\n break;\n }\n case xdr.ScSpecEntryKind.scSpecEntryUdtUnionV0().value: {\n const udt = entry.udtUnionV0();\n definitions[udt.name().toString()] = unionToJsonSchema(udt);\n break;\n }\n case xdr.ScSpecEntryKind.scSpecEntryFunctionV0().value: {\n const fn = entry.functionV0();\n const fnName = fn.name().toString();\n const { input } = functionToJsonSchema(fn);\n definitions[fnName] = input;\n break;\n }\n case xdr.ScSpecEntryKind.scSpecEntryUdtErrorEnumV0().value: {\n // console.debug(\"Error enums not supported yet\");\n }\n }\n });\n\n const res: JSONSchema7 = {\n $schema: \"http://json-schema.org/draft-07/schema#\",\n definitions: { ...PRIMITIVE_DEFINITONS, ...definitions },\n };\n if (funcName) {\n res.$ref = `#/definitions/${funcName}`;\n }\n return res;\n }\n}\n"],"names":["xdr","Address","XdrLargeInt","Buffer","specFromWasm","processSpecEntryStream","Err","Ok","nativeToScVal","Contract","scValToNative","scValToBigInt","eventsImpl","findEventImpl","parseEventImpl","eventTopicFilterImpl"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAS,iBAAiB,GAAA,EAA+B;AACvD,EAAA,MAAM,WAAA,GAAc,GAAA,CAAI,GAAA,EAAI,CAAE,QAAA,EAAS;AACvC,EAAA,MAAM,KAAA,GAAQ,IAAI,KAAA,EAAM;AACxB,EAAA,MAAM,QAAe,EAAC;AACtB,EAAA,KAAA,CAAM,OAAA,CAAQ,CAAC,KAAA,KAAU;AACvB,IAAA,MAAM,KAAA,GAAQ,KAAA,CAAM,IAAA,EAAK,CAAE,QAAA,EAAS;AACpC,IAAA,MAAM,IAAA,GAAO,KAAA,CAAM,GAAA,EAAI,CAAE,QAAA,EAAS;AAClC,IAAA,KAAA,CAAM,IAAA,CAAK;AAAA,MACT,WAAA,EAAa,IAAA;AAAA,MACb,KAAA;AAAA,MACA,IAAA,EAAM,CAAC,KAAA,CAAM,KAAA,EAAO,CAAA;AAAA,MACpB,IAAA,EAAM;AAAA,KACP,CAAA;AAAA,EACH,CAAC,CAAA;AACD,EAAA,MAAM,GAAA,GAAW,EAAE,KAAA,EAAM;AACzB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WAAA,EAAY;AAC9B,UAAA,WAAA,CAAY,IAAI,IAAA,EAAK,CAAE,UAAU,CAAA,GAAI,mBAAmB,GAAG,CAAA;AAC3D,UAAA;AAAA,QACF;AAAA,QACA,KAAKA,sBAAA,CAAI,eAAA,CAAgB,qBAAA,GAAwB,KAAA,EAAO;AACtD,UAAA,MAAM,GAAA,GAAM,MAAM,UAAA,EAAW;AAC7B,UAAA,WAAA,CAAY,IAAI,IAAA,EAAK,CAAE,UAAU,CAAA,GAAI,kBAAkB,GAAG,CAAA;AAC1D,UAAA;AAAA,QACF;AAAA,QACA,KAAKA,sBAAA,CAAI,eAAA,CAAgB,qBAAA,GAAwB,KAAA,EAAO;AACtD,UAAA,MAAM,EAAA,GAAK,MAAM,UAAA,EAAW;AAC5B,UAAA,MAAM,MAAA,GAAS,EAAA,CAAG,IAAA,EAAK,CAAE,QAAA,EAAS;AAClC,UAAA,MAAM,EAAE,KAAA,EAAM,GAAI,oBAAA,CAAqB,EAAE,CAAA;AACzC,UAAA,WAAA,CAAY,MAAM,CAAA,GAAI,KAAA;AACtB,UAAA;AAAA,QACF;AAAA,QACA,KAAKA,sBAAA,CAAI,eAAA,CAAgB,yBAAA,GAA4B,KAAA,CAErD;AACF,IACF,CAAC,CAAA;AAED,IAAA,MAAM,GAAA,GAAmB;AAAA,MACvB,OAAA,EAAS,yCAAA;AAAA,MACT,WAAA,EAAa,EAAE,GAAG,oBAAA,EAAsB,GAAG,WAAA;AAAY,KACzD;AACA,IAAA,IAAI,QAAA,EAAU;AACZ,MAAA,GAAA,CAAI,IAAA,GAAO,iBAAiB,QAAQ,CAAA,CAAA;AAAA,IACtC;AACA,IAAA,OAAO,GAAA;AAAA,EACT;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sources":["../../../src/contract/types.ts"],"sourcesContent":["/* Type aliases below intentionally use non-PascalCase names (e.g. `XDR_BASE64`,\n `u32`) to preserve the public API — renaming them would be a breaking change. */\n\nimport { Transaction, xdr } from \"../base/index.js\";\nimport type { SentTransaction } from \"./sent_transaction.js\";\nimport type { Client } from \"./client.js\";\nimport { Server } from \"../rpc/index.js\";\n\nexport type XDR_BASE64 = string;\n/**\n * An unsigned 32-bit integer.\n */\nexport type u32 = number;\n/**\n * A signed 32-bit integer.\n */\nexport type i32 = number;\n/**\n * An unsigned 64-bit integer.\n */\nexport type u64 = bigint;\n/**\n * A signed 64-bit integer.\n */\nexport type i64 = bigint;\n/**\n * An unsigned 128-bit integer.\n */\nexport type u128 = bigint;\n/**\n * A signed 128-bit integer.\n */\nexport type i128 = bigint;\n/**\n * An unsigned 256-bit integer.\n */\nexport type u256 = bigint;\n/**\n * A signed 256-bit integer.\n */\nexport type i256 = bigint;\nexport type Option<T> = T | undefined;\n/**\n * @deprecated Use {@link Timepoint} instead.\n */\nexport type Typepoint = bigint;\n/**\n * An unsigned 64-bit integer.\n */\nexport type Timepoint = bigint;\n/**\n * An unsigned 64-bit integer.\n */\nexport type Duration = bigint;\n\n/**\n * A \"regular\" transaction, as opposed to a FeeBumpTransaction.\n */\nexport type Tx = Transaction;\n\nexport interface WalletError {\n message: string; // general description message returned to the client app\n code: number; // unique error code\n ext?: Array<string>; // optional extended details\n}\n\n/**\n * A function to request a wallet to sign a built transaction\n *\n * This function takes an XDR provided by the requester and applies a signature to it.\n * It returns a base64-encoded string XDR-encoded Transaction Envelope with Decorated Signatures\n * and the signer address back to the requester.\n *\n * @param xdr - The XDR string representing the transaction to be signed.\n * @param opts - Options for signing the transaction.\n * - `networkPassphrase`: The network's passphrase on which the transaction is intended to be signed.\n * - `address`: The public key of the account that should be used to sign.\n * - `submit`: If set to true, submits the transaction immediately after signing.\n * - `submitUrl`: The URL of the network to which the transaction should be submitted, if applicable.\n *\n * @returns A promise resolving to an object with the signed transaction XDR and optional signer address and error.\n */\nexport type SignTransaction = (\n xdr: string,\n opts?: {\n networkPassphrase?: string;\n address?: string;\n submit?: boolean;\n submitUrl?: string;\n },\n) => Promise<\n {\n signedTxXdr: string;\n signerAddress?: string;\n } & { error?: WalletError }\n>;\n\n/**\n * A function to request a wallet to sign an authorization entry preimage.\n *\n * Similar to signing a transaction, this function takes an authorization entry preimage provided by the\n * requester and applies a signature to it.\n * It returns a signed hash of the same authorization entry and the signer address back to the requester.\n *\n * @param authEntry - The authorization entry preimage to be signed.\n * @param opts - Options for signing the authorization entry.\n * - `networkPassphrase`: The network's passphrase on which the authorization entry is intended to be signed.\n * - `address`: The public key of the account that should be used to sign.\n *\n * @returns A promise resolving to an object with the signed authorization entry and optional signer address and error.\n */\nexport type SignAuthEntry = (\n authEntry: string,\n opts?: {\n networkPassphrase?: string;\n address?: string;\n },\n) => Promise<\n {\n signedAuthEntry: string;\n signerAddress?: string;\n } & { error?: WalletError }\n>;\n\n/**\n * Options for a smart contract client.\n */\nexport type ClientOptions = {\n /**\n * The public key of the source account for this transaction. You can\n * override this for specific methods later; see {@link MethodOptions}.\n */\n publicKey?: string;\n /**\n * A function to sign the transaction using the private key corresponding to\n * the given `publicKey`. You do not need to provide this, for read-only\n * calls, which only need to be simulated. If you do not provide it during\n * initialization, you can provide it later, either when you initialize a\n * method (see {@link MethodOptions}) or when you call\n * {@link contract.AssembledTransaction.signAndSend | signAndSend}.\n *\n * Matches signature of `signTransaction` from Freighter.\n */\n signTransaction?: SignTransaction;\n /**\n * A function to sign a specific auth entry for a transaction, using the\n * private key corresponding to the provided `publicKey`. This is only needed\n * for multi-auth transactions, in which one transaction is signed by\n * multiple parties. If you do not provide it during initialization, you can\n * provide it later either when you initialize a method (see {@link MethodOptions})\n * or when you call {@link contract.AssembledTransaction.signAuthEntries | signAuthEntries}.\n *\n * Matches signature of `signAuthEntry` from Freighter.\n */\n signAuthEntry?: SignAuthEntry;\n /** The address of the contract the client will interact with. */\n contractId: string;\n /**\n * The network passphrase for the Stellar network this contract is deployed\n * to.\n */\n networkPassphrase: string;\n /**\n * The URL of the RPC instance that will be used to interact with this\n * contract.\n */\n rpcUrl: string;\n /**\n * If true, will allow HTTP requests to the RPC. If false, will\n * only allow HTTPS requests.\n * @defaultValue false\n */\n allowHttp?: boolean;\n /** Optional headers to include in requests to the RPC. */\n headers?: Record<string, string>;\n /**\n * This gets filled in automatically from the ContractSpec when you\n * instantiate a {@link Client}.\n *\n * Background: If the contract you're calling uses the `#[contracterror]`\n * macro to create an `Error` enum, then those errors get included in the\n * on-chain XDR that also describes your contract's methods. Each error will\n * have a specific number.\n *\n * A Client makes method calls with an {@link contract.AssembledTransaction | AssembledTransaction}.\n * When one of these method calls encounters an error, `AssembledTransaction`\n * will first attempt to parse the error as an \"official\" `contracterror`\n * error, by using this passed-in `errorTypes` object. See `parseError`\n * on {@link contract.AssembledTransaction}. If `errorTypes` is blank or no\n * matching error is found, then it will throw the raw error.\n * @defaultValue `{}`\n */\n errorTypes?: Record<number, { message: string }>;\n /**\n * The Server instance to use for RPC calls. If not provided, one will be\n * created automatically from `rpcUrl` and `serverOptions`.\n */\n server?: Server;\n};\n\n/**\n * Options for a smart contract method invocation.\n */\nexport type MethodOptions = {\n /**\n * The fee to pay for the transaction.\n * @defaultValue 100\n */\n fee?: string;\n\n /**\n * The timebounds which should be set for transactions generated by this\n * contract client. {@link contract.DEFAULT_TIMEOUT}\n * @defaultValue 300\n */\n timeoutInSeconds?: number;\n\n /**\n * Whether to automatically simulate the transaction when constructing the\n * AssembledTransaction.\n * @defaultValue true\n */\n simulate?: boolean;\n\n /**\n * If true, will automatically attempt to restore the transaction if there\n * are archived entries that need renewal.\n * @defaultValue false\n */\n restore?: boolean;\n\n /**\n * The public key of the source account for this transaction.\n *\n * Default: the one provided to the {@link Client} in {@link ClientOptions}\n */\n publicKey?: string;\n /**\n * A function to sign the transaction using the private key corresponding to\n * the given `publicKey`. You do not need to provide this, for read-only\n * calls, which only need to be simulated.\n *\n * Matches signature of `signTransaction` from Freighter.\n *\n * Default: the one provided to the {@link Client} in {@link ClientOptions}\n */\n signTransaction?: SignTransaction;\n /**\n * A function to sign a specific auth entry for a transaction, using the\n * private key corresponding to the provided `publicKey`. This is only needed\n * for multi-auth transactions, in which one transaction is signed by\n * multiple parties.\n *\n * Matches signature of `signAuthEntry` from Freighter.\n *\n * Default: the one provided to the {@link Client} in {@link ClientOptions}\n */\n signAuthEntry?: SignAuthEntry;\n};\n\nexport type AssembledTransactionOptions<T = string> = MethodOptions &\n ClientOptions & {\n method: string;\n args?: any[];\n parseResultXdr: (xdr: xdr.ScVal) => T;\n\n /**\n * The address of the account that should sign the transaction. Useful when\n * a wallet holds multiple addresses to ensure signing with the intended one.\n */\n address?: string;\n\n /**\n * This option will be passed through to the SEP43-compatible wallet extension. If true, and if the wallet supports it, the transaction will be signed and immediately submitted to the network by the wallet, bypassing the submit logic in {@link SentTransaction}.\n * @defaultValue false\n */\n submit?: boolean;\n\n /**\n * The URL of the network to which the transaction should be submitted.\n * Only applicable when 'submit' is set to true.\n */\n submitUrl?: string;\n };\n\n/**\n * The default timebounds, in seconds, during which a transaction will be valid.\n * This is attached to the transaction _before_ transaction simulation (it is\n * needed for simulation to succeed). It is also re-calculated and re-added\n * _before_ transaction signing.\n * @defaultValue 300\n */\nexport const DEFAULT_TIMEOUT = 5 * 60;\n\n/**\n * An impossible account on the Stellar network\n * @defaultValue GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF\n */\nexport const NULL_ACCOUNT =\n \"GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF\";\n"],"names":[],"mappings":";;AAoSO,MAAM,kBAAkB,CAAA,GAAI;AAM5B,MAAM,YAAA,GACX;;;;;"}
1
+ {"version":3,"file":"types.js","sources":["../../../src/contract/types.ts"],"sourcesContent":["/* Type aliases below intentionally use non-PascalCase names (e.g. `XDR_BASE64`,\n `u32`) to preserve the public API — renaming them would be a breaking change. */\n\nimport { Transaction, xdr } from \"../base/index.js\";\nimport type { SentTransaction } from \"./sent_transaction.js\";\nimport type { Client } from \"./client.js\";\nimport type { SignAuthEntryLike, SignTransactionLike } from \"./signer.js\";\nimport { Server } from \"../rpc/index.js\";\n\nexport type XDR_BASE64 = string;\n/**\n * An unsigned 32-bit integer.\n */\nexport type u32 = number;\n/**\n * A signed 32-bit integer.\n */\nexport type i32 = number;\n/**\n * An unsigned 64-bit integer.\n */\nexport type u64 = bigint;\n/**\n * A signed 64-bit integer.\n */\nexport type i64 = bigint;\n/**\n * An unsigned 128-bit integer.\n */\nexport type u128 = bigint;\n/**\n * A signed 128-bit integer.\n */\nexport type i128 = bigint;\n/**\n * An unsigned 256-bit integer.\n */\nexport type u256 = bigint;\n/**\n * A signed 256-bit integer.\n */\nexport type i256 = bigint;\nexport type Option<T> = T | undefined;\n/**\n * @deprecated Use {@link Timepoint} instead.\n */\nexport type Typepoint = bigint;\n/**\n * An unsigned 64-bit integer.\n */\nexport type Timepoint = bigint;\n/**\n * An unsigned 64-bit integer.\n */\nexport type Duration = bigint;\n\n/**\n * A \"regular\" transaction, as opposed to a FeeBumpTransaction.\n */\nexport type Tx = Transaction;\n\nexport interface WalletError {\n message: string; // general description message returned to the client app\n code: number; // unique error code\n ext?: Array<string>; // optional extended details\n}\n\n/**\n * A function to request a wallet to sign a built transaction\n *\n * This function takes an XDR provided by the requester and applies a signature to it.\n * It returns a base64-encoded string XDR-encoded Transaction Envelope with Decorated Signatures\n * and the signer address back to the requester.\n *\n * @param xdr - The XDR string representing the transaction to be signed.\n * @param opts - Options for signing the transaction.\n * - `networkPassphrase`: The network's passphrase on which the transaction is intended to be signed.\n * - `address`: The public key of the account that should be used to sign.\n * - `submit`: If set to true, submits the transaction immediately after signing.\n * - `submitUrl`: The URL of the network to which the transaction should be submitted, if applicable.\n *\n * @returns A promise resolving to an object with the signed transaction XDR and optional signer address and error.\n */\nexport type SignTransaction = (\n xdr: string,\n opts?: {\n networkPassphrase?: string;\n address?: string;\n submit?: boolean;\n submitUrl?: string;\n },\n) => Promise<\n {\n signedTxXdr: string;\n signerAddress?: string;\n } & { error?: WalletError }\n>;\n\n/**\n * A function to request a wallet to sign an authorization entry preimage.\n *\n * Similar to signing a transaction, this function takes an authorization entry preimage provided by the\n * requester and applies a signature to it.\n * It returns a signed hash of the same authorization entry and the signer address back to the requester.\n *\n * @param authEntry - The authorization entry preimage to be signed.\n * @param opts - Options for signing the authorization entry.\n * - `networkPassphrase`: The network's passphrase on which the authorization entry is intended to be signed.\n * - `address`: The public key of the account that should be used to sign.\n *\n * @returns A promise resolving to an object with the signed authorization entry and optional signer address and error.\n */\nexport type SignAuthEntry = (\n authEntry: string,\n opts?: {\n networkPassphrase?: string;\n address?: string;\n },\n) => Promise<\n {\n signedAuthEntry: string;\n signerAddress?: string;\n } & { error?: WalletError }\n>;\n\n/**\n * Options for a smart contract client.\n */\nexport type ClientOptions = {\n /**\n * The public key of the source account for this transaction. You can\n * override this for specific methods later; see {@link MethodOptions}.\n */\n publicKey?: string;\n /**\n * A function to sign the transaction using the private key corresponding to\n * the given `publicKey`. You do not need to provide this, for read-only\n * calls, which only need to be simulated. If you do not provide it during\n * initialization, you can provide it later, either when you initialize a\n * method (see {@link MethodOptions}) or when you call\n * {@link contract.AssembledTransaction.signAndSend | signAndSend}.\n *\n * Matches signature of `signTransaction` from Freighter. May instead be a\n * {@link Signer} or a {@link Keypair}, which are converted internally.\n */\n signTransaction?: SignTransactionLike;\n /**\n * A function to sign a specific auth entry for a transaction, using the\n * private key corresponding to the provided `publicKey`. This is only needed\n * for multi-auth transactions, in which one transaction is signed by\n * multiple parties. If you do not provide it during initialization, you can\n * provide it later either when you initialize a method (see {@link MethodOptions})\n * or when you call {@link contract.AssembledTransaction.signAuthEntries | signAuthEntries}.\n *\n * Matches signature of `signAuthEntry` from Freighter. May instead be a\n * {@link Signer} or a {@link Keypair}, which are converted internally.\n */\n signAuthEntry?: SignAuthEntryLike;\n /** The address of the contract the client will interact with. */\n contractId: string;\n /**\n * The network passphrase for the Stellar network this contract is deployed\n * to.\n */\n networkPassphrase: string;\n /**\n * The URL of the RPC instance that will be used to interact with this\n * contract.\n */\n rpcUrl: string;\n /**\n * If true, will allow HTTP requests to the RPC. If false, will\n * only allow HTTPS requests.\n * @defaultValue false\n */\n allowHttp?: boolean;\n /** Optional headers to include in requests to the RPC. */\n headers?: Record<string, string>;\n /**\n * This gets filled in automatically from the ContractSpec when you\n * instantiate a {@link Client}.\n *\n * Background: If the contract you're calling uses the `#[contracterror]`\n * macro to create an `Error` enum, then those errors get included in the\n * on-chain XDR that also describes your contract's methods. Each error will\n * have a specific number.\n *\n * A Client makes method calls with an {@link contract.AssembledTransaction | AssembledTransaction}.\n * When one of these method calls encounters an error, `AssembledTransaction`\n * will first attempt to parse the error as an \"official\" `contracterror`\n * error, by using this passed-in `errorTypes` object. See `parseError`\n * on {@link contract.AssembledTransaction}. If `errorTypes` is blank or no\n * matching error is found, then it will throw the raw error.\n * @defaultValue `{}`\n */\n errorTypes?: Record<number, { message: string }>;\n /**\n * The Server instance to use for RPC calls. If not provided, one will be\n * created automatically from `rpcUrl` and `serverOptions`.\n */\n server?: Server;\n};\n\n/**\n * Options for a smart contract method invocation.\n */\nexport type MethodOptions = {\n /**\n * The fee to pay for the transaction.\n * @defaultValue 100\n */\n fee?: string;\n\n /**\n * The timebounds which should be set for transactions generated by this\n * contract client. {@link contract.DEFAULT_TIMEOUT}\n * @defaultValue 300\n */\n timeoutInSeconds?: number;\n\n /**\n * Whether to automatically simulate the transaction when constructing the\n * AssembledTransaction.\n * @defaultValue true\n */\n simulate?: boolean;\n\n /**\n * If true, will automatically attempt to restore the transaction if there\n * are archived entries that need renewal.\n * @defaultValue false\n */\n restore?: boolean;\n\n /**\n * If true, simulation records v2 address credentials (CAP-71) instead of\n * the legacy v1 address credentials. Best-effort: it only affects the\n * recording auth modes and is silently ignored on protocol versions whose\n * host cannot emit v2 credentials.\n *\n * @deprecated This flag is transitional. Once the network returns v2\n * credentials by default (protocol 28), it becomes a no-op — do not rely on\n * omitting it to keep receiving the legacy v1 format.\n * @defaultValue false\n */\n useUpgradedAuth?: boolean;\n\n /**\n * The public key of the source account for this transaction.\n *\n * Default: the one provided to the {@link Client} in {@link ClientOptions}\n */\n publicKey?: string;\n /**\n * A function to sign the transaction using the private key corresponding to\n * the given `publicKey`. You do not need to provide this, for read-only\n * calls, which only need to be simulated.\n *\n * Matches signature of `signTransaction` from Freighter. May instead be a\n * {@link Signer} or a {@link Keypair}, which are converted internally.\n *\n * Default: the one provided to the {@link Client} in {@link ClientOptions}\n */\n signTransaction?: SignTransactionLike;\n /**\n * A function to sign a specific auth entry for a transaction, using the\n * private key corresponding to the provided `publicKey`. This is only needed\n * for multi-auth transactions, in which one transaction is signed by\n * multiple parties.\n *\n * Matches signature of `signAuthEntry` from Freighter. May instead be a\n * {@link Signer} or a {@link Keypair}, which are converted internally.\n *\n * Default: the one provided to the {@link Client} in {@link ClientOptions}\n */\n signAuthEntry?: SignAuthEntryLike;\n};\n\nexport type AssembledTransactionOptions<T = string> = MethodOptions &\n ClientOptions & {\n method: string;\n args?: any[];\n parseResultXdr: (xdr: xdr.ScVal) => T;\n\n /**\n * The address of the account that should sign the transaction. Useful when\n * a wallet holds multiple addresses to ensure signing with the intended one.\n */\n address?: string;\n\n /**\n * This option will be passed through to the SEP43-compatible wallet extension. If true, and if the wallet supports it, the transaction will be signed and immediately submitted to the network by the wallet, bypassing the submit logic in {@link SentTransaction}.\n * @defaultValue false\n */\n submit?: boolean;\n\n /**\n * The URL of the network to which the transaction should be submitted.\n * Only applicable when 'submit' is set to true.\n */\n submitUrl?: string;\n };\n\n/**\n * The default timebounds, in seconds, during which a transaction will be valid.\n * This is attached to the transaction _before_ transaction simulation (it is\n * needed for simulation to succeed). It is also re-calculated and re-added\n * _before_ transaction signing.\n * @defaultValue 300\n */\nexport const DEFAULT_TIMEOUT = 5 * 60;\n\n/**\n * An impossible account on the Stellar network\n * @defaultValue GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF\n */\nexport const NULL_ACCOUNT =\n \"GAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAWHF\";\n"],"names":[],"mappings":";;AAsTO,MAAM,kBAAkB,CAAA,GAAI;AAM5B,MAAM,YAAA,GACX;;;;;"}
@@ -0,0 +1,62 @@
1
+ 'use strict';
2
+
3
+ require('../node_modules/.pnpm/@stellar_js-xdr@4.0.0/node_modules/@stellar/js-xdr/src/int.js');
4
+ require('../node_modules/.pnpm/@stellar_js-xdr@4.0.0/node_modules/@stellar/js-xdr/src/hyper.js');
5
+ require('../node_modules/.pnpm/@stellar_js-xdr@4.0.0/node_modules/@stellar/js-xdr/src/unsigned-int.js');
6
+ require('../node_modules/.pnpm/@stellar_js-xdr@4.0.0/node_modules/@stellar/js-xdr/src/unsigned-hyper.js');
7
+ require('../node_modules/.pnpm/@stellar_js-xdr@4.0.0/node_modules/@stellar/js-xdr/src/xdr-type.js');
8
+ require('buffer');
9
+ var curr_generated = require('../base/generated/curr_generated.js');
10
+ require('@noble/hashes/sha2.js');
11
+ require('../base/signing.js');
12
+ require('../base/keypair.js');
13
+ require('base32.js');
14
+ require('../base/util/continued_fraction.js');
15
+ require('../base/util/bignumber.js');
16
+ require('../base/transaction_builder.js');
17
+ require('../base/muxed_account.js');
18
+ require('../base/scval.js');
19
+ require('../base/numbers/uint128.js');
20
+ require('../base/numbers/uint256.js');
21
+ require('../base/numbers/int128.js');
22
+ require('../base/numbers/int256.js');
23
+ var bad_response = require('./bad_response.js');
24
+
25
+ class TransactionFailedError extends bad_response.BadResponseError {
26
+ /**
27
+ * Returns the transaction- and operation-level result codes reported by
28
+ * Horizon, e.g. `{ transaction: "tx_failed", operations: ["op_underfunded"] }`.
29
+ *
30
+ * Horizon omits `operations` when the transaction failed a
31
+ * transaction-level check (e.g. `tx_bad_seq`) and no operations were
32
+ * evaluated; this accessor normalizes that to an empty array.
33
+ *
34
+ * @returns The `result_codes` object from the response's `extras`.
35
+ */
36
+ getResultCodes() {
37
+ const { transaction, operations = [] } = this.extras().result_codes;
38
+ return { transaction, operations };
39
+ }
40
+ /**
41
+ * Decodes and returns the {@link xdr.TransactionResult} from the response's
42
+ * `extras.result_xdr`, providing structured access to per-operation results.
43
+ *
44
+ * @returns The decoded transaction result, or `null` if the response did not
45
+ * include a `result_xdr`.
46
+ * @throws If the server returned a `result_xdr` that is not valid base64-encoded
47
+ * {@link xdr.TransactionResult} XDR.
48
+ */
49
+ getTransactionResult() {
50
+ const resultXdr = this.extras().result_xdr;
51
+ if (!resultXdr) {
52
+ return null;
53
+ }
54
+ return curr_generated.default.TransactionResult.fromXDR(resultXdr, "base64");
55
+ }
56
+ extras() {
57
+ return this.response.data.extras;
58
+ }
59
+ }
60
+
61
+ exports.TransactionFailedError = TransactionFailedError;
62
+ //# sourceMappingURL=transaction_failed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction_failed.js","sources":["../../../src/errors/transaction_failed.ts"],"sourcesContent":["import { xdr } from \"../base/index.js\";\nimport { HorizonApi } from \"../horizon/horizon_api.js\";\nimport { BadResponseError } from \"./bad_response.js\";\n\n/**\n * TransactionFailedError is raised when a transaction submitted to Horizon\n * is rejected with a `transaction_failed` error response (HTTP 400). It\n * provides convenient accessors for the result codes and the decoded\n * {@link xdr.TransactionResult}, which are otherwise nested deep inside the\n * raw Horizon response.\n *\n * @example\n * ```js\n * try {\n * await server.submitTransaction(tx);\n * } catch (err) {\n * if (err instanceof TransactionFailedError) {\n * const { transaction, operations } = err.getResultCodes();\n * console.log(transaction); // e.g. \"tx_failed\"\n * console.log(operations); // e.g. [\"op_underfunded\"]\n * console.log(err.getTransactionResult()?.result().switch().name);\n * }\n * }\n * ```\n *\n * @param message - Human-readable error message.\n * @param response - Response details, received from the Horizon server, whose\n * `data` field contains a `transaction_failed` error response with `extras`.\n */\nexport class TransactionFailedError extends BadResponseError {\n /**\n * Returns the transaction- and operation-level result codes reported by\n * Horizon, e.g. `{ transaction: \"tx_failed\", operations: [\"op_underfunded\"] }`.\n *\n * Horizon omits `operations` when the transaction failed a\n * transaction-level check (e.g. `tx_bad_seq`) and no operations were\n * evaluated; this accessor normalizes that to an empty array.\n *\n * @returns The `result_codes` object from the response's `extras`.\n */\n public getResultCodes(): {\n transaction: HorizonApi.TransactionFailedResultCodes;\n operations: string[];\n } {\n const { transaction, operations = [] } = this.extras().result_codes;\n return { transaction, operations };\n }\n\n /**\n * Decodes and returns the {@link xdr.TransactionResult} from the response's\n * `extras.result_xdr`, providing structured access to per-operation results.\n *\n * @returns The decoded transaction result, or `null` if the response did not\n * include a `result_xdr`.\n * @throws If the server returned a `result_xdr` that is not valid base64-encoded\n * {@link xdr.TransactionResult} XDR.\n */\n public getTransactionResult(): xdr.TransactionResult | null {\n const resultXdr = this.extras().result_xdr;\n if (!resultXdr) {\n return null;\n }\n return xdr.TransactionResult.fromXDR(resultXdr, \"base64\");\n }\n\n private extras(): HorizonApi.TransactionFailedExtras {\n return (\n this.response.data as HorizonApi.ErrorResponseData.TransactionFailed\n ).extras;\n }\n}\n"],"names":["BadResponseError","xdr"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AA6BO,MAAM,+BAA+BA,6BAAA,CAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWpD,cAAA,GAGL;AACA,IAAA,MAAM,EAAE,aAAa,UAAA,GAAa,IAAG,GAAI,IAAA,CAAK,QAAO,CAAE,YAAA;AACvD,IAAA,OAAO,EAAE,aAAa,UAAA,EAAW;AAAA,EACnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWO,oBAAA,GAAqD;AAC1D,IAAA,MAAM,SAAA,GAAY,IAAA,CAAK,MAAA,EAAO,CAAE,UAAA;AAChC,IAAA,IAAI,CAAC,SAAA,EAAW;AACd,MAAA,OAAO,IAAA;AAAA,IACT;AACA,IAAA,OAAOC,sBAAA,CAAI,iBAAA,CAAkB,OAAA,CAAQ,SAAA,EAAW,QAAQ,CAAA;AAAA,EAC1D;AAAA,EAEQ,MAAA,GAA6C;AACnD,IAAA,OACE,IAAA,CAAK,SAAS,IAAA,CACd,MAAA;AAAA,EACJ;AACF;;;;"}
@@ -0,0 +1,20 @@
1
+ 'use strict';
2
+
3
+ function wrapHttpError(error, wrap) {
4
+ const response = error?.response ?? error;
5
+ if (response && typeof response.status === "number") {
6
+ const wrapped = wrap({
7
+ data: response.data,
8
+ status: response.status,
9
+ statusText: response.statusText
10
+ });
11
+ if (error instanceof Error) {
12
+ wrapped.cause = error;
13
+ }
14
+ return wrapped;
15
+ }
16
+ return error instanceof Error ? error : new Error(String(error));
17
+ }
18
+
19
+ exports.wrapHttpError = wrapHttpError;
20
+ //# sourceMappingURL=wrap_http_error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap_http_error.js","sources":["../../../src/errors/wrap_http_error.ts"],"sourcesContent":["import { NetworkError } from \"./network.js\";\n\n/**\n * Normalizes a rejection from the HTTP client into an SDK error. HTTP-level\n * failures from the http client are Error instances carrying a `.response`,\n * so an instanceof check alone would leak them through raw.\n *\n * If the rejection carries an HTTP response (directly or via `.response`),\n * `wrap` is called with the normalized response details to build the SDK\n * error, and the original error is kept reachable via `cause`. Otherwise the\n * original error is returned as-is (coerced to an `Error` if needed).\n *\n * @param error - The rejection value from the HTTP client.\n * @param wrap - Builds the SDK error from the normalized response details.\n * @returns The SDK error, or the original error if it was not HTTP-level.\n */\nexport function wrapHttpError(\n error: any,\n wrap: (details: {\n data: any;\n status: number;\n statusText: string;\n }) => NetworkError,\n): Error {\n const response = error?.response ?? error;\n if (response && typeof response.status === \"number\") {\n const wrapped = wrap({\n data: response.data,\n status: response.status,\n statusText: response.statusText,\n });\n // keep the underlying http client error (headers, config, etc.) reachable\n if (error instanceof Error) {\n wrapped.cause = error;\n }\n return wrapped;\n }\n return error instanceof Error ? error : new Error(String(error));\n}\n"],"names":[],"mappings":";;AAgBO,SAAS,aAAA,CACd,OACA,IAAA,EAKO;AACP,EAAA,MAAM,QAAA,GAAW,OAAO,QAAA,IAAY,KAAA;AACpC,EAAA,IAAI,QAAA,IAAY,OAAO,QAAA,CAAS,MAAA,KAAW,QAAA,EAAU;AACnD,IAAA,MAAM,UAAU,IAAA,CAAK;AAAA,MACnB,MAAM,QAAA,CAAS,IAAA;AAAA,MACf,QAAQ,QAAA,CAAS,MAAA;AAAA,MACjB,YAAY,QAAA,CAAS;AAAA,KACtB,CAAA;AAED,IAAA,IAAI,iBAAiB,KAAA,EAAO;AAC1B,MAAA,OAAA,CAAQ,KAAA,GAAQ,KAAA;AAAA,IAClB;AACA,IAAA,OAAO,OAAA;AAAA,EACT;AACA,EAAA,OAAO,iBAAiB,KAAA,GAAQ,KAAA,GAAQ,IAAI,KAAA,CAAM,MAAA,CAAO,KAAK,CAAC,CAAA;AACjE;;;;"}
@@ -1,29 +1,11 @@
1
1
  'use strict';
2
2
 
3
- require('../node_modules/.pnpm/@stellar_js-xdr@4.0.0/node_modules/@stellar/js-xdr/src/int.js');
4
- require('../node_modules/.pnpm/@stellar_js-xdr@4.0.0/node_modules/@stellar/js-xdr/src/hyper.js');
5
- require('../node_modules/.pnpm/@stellar_js-xdr@4.0.0/node_modules/@stellar/js-xdr/src/unsigned-int.js');
6
- require('../node_modules/.pnpm/@stellar_js-xdr@4.0.0/node_modules/@stellar/js-xdr/src/unsigned-hyper.js');
7
- require('../node_modules/.pnpm/@stellar_js-xdr@4.0.0/node_modules/@stellar/js-xdr/src/xdr-type.js');
8
- require('buffer');
9
- require('../base/generated/curr_generated.js');
10
- require('@noble/hashes/sha2.js');
11
- require('../base/signing.js');
12
- require('../base/keypair.js');
13
- var strkey = require('../base/strkey.js');
14
- require('../base/util/continued_fraction.js');
15
- require('../base/util/bignumber.js');
16
- require('../base/transaction_builder.js');
17
- require('../base/muxed_account.js');
18
- require('../base/scval.js');
19
- require('../base/numbers/uint128.js');
20
- require('../base/numbers/uint256.js');
21
- require('../base/numbers/int128.js');
22
- require('../base/numbers/int256.js');
23
3
  var config = require('../config.js');
24
4
  var bad_response = require('../errors/bad_response.js');
5
+ var wrap_http_error = require('../errors/wrap_http_error.js');
25
6
  var index = require('../stellartoml/index.js');
26
7
  var utils = require('./utils.js');
8
+ var strkey = require('../base/strkey.js');
27
9
  var fetchClient = require('../http-client/fetch-client.js');
28
10
 
29
11
  const FEDERATION_RESPONSE_MAX_SIZE = 100 * 1024;
@@ -203,23 +185,21 @@ class FederationServer {
203
185
  throw new Error("memo value should be of type string");
204
186
  }
205
187
  return response.data;
206
- }).catch((response) => {
207
- if (response instanceof Error) {
208
- if (response.message.match(/^maxContentLength size/)) {
209
- throw new Error(
210
- `federation response exceeds allowed size of ${FEDERATION_RESPONSE_MAX_SIZE}`
211
- );
212
- } else {
213
- return Promise.reject(response);
214
- }
215
- } else {
216
- return Promise.reject(
217
- new bad_response.BadResponseError(
218
- `Server query failed. Server responded: ${response.status} ${response.statusText}`,
219
- response.data
220
- )
188
+ }).catch((error) => {
189
+ if (error instanceof Error && error.message.match(/^maxContentLength size/)) {
190
+ throw new Error(
191
+ `federation response exceeds allowed size of ${FEDERATION_RESPONSE_MAX_SIZE}`
221
192
  );
222
193
  }
194
+ return Promise.reject(
195
+ wrap_http_error.wrapHttpError(
196
+ error,
197
+ (details) => new bad_response.BadResponseError(
198
+ `Server query failed. Server responded: ${details.status} ${details.statusText}`,
199
+ details
200
+ )
201
+ )
202
+ );
223
203
  });
224
204
  }
225
205
  }