@kontor/kontor-sdk 1.0.0-alpha.15 → 1.0.0-alpha.16

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 (293) hide show
  1. package/dist/cjs/exports/index.js +17 -1
  2. package/dist/cjs/exports/index.js.map +1 -1
  3. package/dist/cjs/tsconfig.build.tsbuildinfo +1 -1
  4. package/dist/esm/exports/index.js +8 -0
  5. package/dist/esm/exports/index.js.map +1 -1
  6. package/dist/esm/tsconfig.build.tsbuildinfo +1 -1
  7. package/dist/types/exports/index.d.ts +8 -0
  8. package/dist/types/exports/index.d.ts.map +1 -1
  9. package/package.json +2 -6
  10. package/src/exports/index.ts +44 -0
  11. package/dist/src/exports/index.js +0 -11
  12. package/dist/src/exports/index.js.map +0 -1
  13. package/dist/src/exports/index.test.js +0 -10
  14. package/dist/src/exports/index.test.js.map +0 -1
  15. package/dist/src/sdk/accounts/hd-key-to-account.js +0 -20
  16. package/dist/src/sdk/accounts/hd-key-to-account.js.map +0 -1
  17. package/dist/src/sdk/accounts/mnemonic-to-account.js +0 -16
  18. package/dist/src/sdk/accounts/mnemonic-to-account.js.map +0 -1
  19. package/dist/src/sdk/accounts/mnemonic-to-account.test.js +0 -96
  20. package/dist/src/sdk/accounts/mnemonic-to-account.test.js.map +0 -1
  21. package/dist/src/sdk/accounts/private-key-to-account.js +0 -42
  22. package/dist/src/sdk/accounts/private-key-to-account.js.map +0 -1
  23. package/dist/src/sdk/accounts/to-local-account.js +0 -28
  24. package/dist/src/sdk/accounts/to-local-account.js.map +0 -1
  25. package/dist/src/sdk/accounts/types.js +0 -2
  26. package/dist/src/sdk/accounts/types.js.map +0 -1
  27. package/dist/src/sdk/accounts/utils/parse-account.js +0 -10
  28. package/dist/src/sdk/accounts/utils/parse-account.js.map +0 -1
  29. package/dist/src/sdk/accounts/utils/public-key-to-p2tr-payment.js +0 -14
  30. package/dist/src/sdk/accounts/utils/public-key-to-p2tr-payment.js.map +0 -1
  31. package/dist/src/sdk/accounts/utils/sign-psbt.js +0 -17
  32. package/dist/src/sdk/accounts/utils/sign-psbt.js.map +0 -1
  33. package/dist/src/sdk/actions/get-contract.js +0 -50
  34. package/dist/src/sdk/actions/get-contract.js.map +0 -1
  35. package/dist/src/sdk/actions/get-contract.test-d.js +0 -43
  36. package/dist/src/sdk/actions/get-contract.test-d.js.map +0 -1
  37. package/dist/src/sdk/actions/kontor/public/build-compose-query.js +0 -30
  38. package/dist/src/sdk/actions/kontor/public/build-compose-query.js.map +0 -1
  39. package/dist/src/sdk/actions/kontor/public/build-instruction-query.js +0 -45
  40. package/dist/src/sdk/actions/kontor/public/build-instruction-query.js.map +0 -1
  41. package/dist/src/sdk/actions/kontor/public/call-compose.js +0 -38
  42. package/dist/src/sdk/actions/kontor/public/call-compose.js.map +0 -1
  43. package/dist/src/sdk/actions/kontor/public/call-view.js +0 -21
  44. package/dist/src/sdk/actions/kontor/public/call-view.js.map +0 -1
  45. package/dist/src/sdk/actions/kontor/public/inspect.js +0 -20
  46. package/dist/src/sdk/actions/kontor/public/inspect.js.map +0 -1
  47. package/dist/src/sdk/actions/kontor/public/proc-contract.js +0 -54
  48. package/dist/src/sdk/actions/kontor/public/proc-contract.js.map +0 -1
  49. package/dist/src/sdk/actions/kontor/public/proc-contract.test.js +0 -47
  50. package/dist/src/sdk/actions/kontor/public/proc-contract.test.js.map +0 -1
  51. package/dist/src/sdk/actions/kontor/public/view-contract.js +0 -43
  52. package/dist/src/sdk/actions/kontor/public/view-contract.js.map +0 -1
  53. package/dist/src/sdk/actions/kontor/public/view-contract.test-d.js +0 -43
  54. package/dist/src/sdk/actions/kontor/public/view-contract.test-d.js.map +0 -1
  55. package/dist/src/sdk/actions/kontor/wallet/sign-commit.js +0 -34
  56. package/dist/src/sdk/actions/kontor/wallet/sign-commit.js.map +0 -1
  57. package/dist/src/sdk/actions/kontor/wallet/sign-reveal.js +0 -88
  58. package/dist/src/sdk/actions/kontor/wallet/sign-reveal.js.map +0 -1
  59. package/dist/src/sdk/actions/public/send-raw-transaction.js +0 -7
  60. package/dist/src/sdk/actions/public/send-raw-transaction.js.map +0 -1
  61. package/dist/src/sdk/actions/public/test-mempool-accept.js +0 -20
  62. package/dist/src/sdk/actions/public/test-mempool-accept.js.map +0 -1
  63. package/dist/src/sdk/actions/wallet/get-addresses.js +0 -20
  64. package/dist/src/sdk/actions/wallet/get-addresses.js.map +0 -1
  65. package/dist/src/sdk/actions/wallet/sign-psbt.js +0 -28
  66. package/dist/src/sdk/actions/wallet/sign-psbt.js.map +0 -1
  67. package/dist/src/sdk/chains/definitions/index.js +0 -2
  68. package/dist/src/sdk/chains/definitions/index.js.map +0 -1
  69. package/dist/src/sdk/chains/definitions/signet.js +0 -36
  70. package/dist/src/sdk/chains/definitions/signet.js.map +0 -1
  71. package/dist/src/sdk/clients/base/create-http-client.js +0 -41
  72. package/dist/src/sdk/clients/base/create-http-client.js.map +0 -1
  73. package/dist/src/sdk/clients/base/create-rpc-client.js +0 -41
  74. package/dist/src/sdk/clients/base/create-rpc-client.js.map +0 -1
  75. package/dist/src/sdk/clients/base/create-rpc-client.test.js +0 -145
  76. package/dist/src/sdk/clients/base/create-rpc-client.test.js.map +0 -1
  77. package/dist/src/sdk/clients/create-public-client.js +0 -13
  78. package/dist/src/sdk/clients/create-public-client.js.map +0 -1
  79. package/dist/src/sdk/clients/create-public-client.test.js +0 -113
  80. package/dist/src/sdk/clients/create-public-client.test.js.map +0 -1
  81. package/dist/src/sdk/clients/create-wallet-client.js +0 -14
  82. package/dist/src/sdk/clients/create-wallet-client.js.map +0 -1
  83. package/dist/src/sdk/clients/decorators/kontor/public.js +0 -19
  84. package/dist/src/sdk/clients/decorators/kontor/public.js.map +0 -1
  85. package/dist/src/sdk/clients/decorators/kontor/wallet.js +0 -13
  86. package/dist/src/sdk/clients/decorators/kontor/wallet.js.map +0 -1
  87. package/dist/src/sdk/clients/decorators/public.js +0 -9
  88. package/dist/src/sdk/clients/decorators/public.js.map +0 -1
  89. package/dist/src/sdk/clients/decorators/wallet.js +0 -9
  90. package/dist/src/sdk/clients/decorators/wallet.js.map +0 -1
  91. package/dist/src/sdk/clients/kontor/create-public-client.js +0 -14
  92. package/dist/src/sdk/clients/kontor/create-public-client.js.map +0 -1
  93. package/dist/src/sdk/clients/kontor/create-public-client.test.js +0 -44
  94. package/dist/src/sdk/clients/kontor/create-public-client.test.js.map +0 -1
  95. package/dist/src/sdk/clients/kontor/create-wallet-client.js +0 -14
  96. package/dist/src/sdk/clients/kontor/create-wallet-client.js.map +0 -1
  97. package/dist/src/sdk/clients/transports/create-http-transport.js +0 -25
  98. package/dist/src/sdk/clients/transports/create-http-transport.js.map +0 -1
  99. package/dist/src/sdk/clients/transports/create-rpc-transport.js +0 -36
  100. package/dist/src/sdk/clients/transports/create-rpc-transport.js.map +0 -1
  101. package/dist/src/sdk/clients/transports/create-rpc-transport.test.js +0 -58
  102. package/dist/src/sdk/clients/transports/create-rpc-transport.test.js.map +0 -1
  103. package/dist/src/sdk/clients/transports/custom.js +0 -14
  104. package/dist/src/sdk/clients/transports/custom.js.map +0 -1
  105. package/dist/src/sdk/clients/transports/http-rpc.js +0 -84
  106. package/dist/src/sdk/clients/transports/http-rpc.js.map +0 -1
  107. package/dist/src/sdk/clients/transports/http-rpc.test.js +0 -147
  108. package/dist/src/sdk/clients/transports/http-rpc.test.js.map +0 -1
  109. package/dist/src/sdk/clients/transports/http.js +0 -45
  110. package/dist/src/sdk/clients/transports/http.js.map +0 -1
  111. package/dist/src/sdk/contracts/wits.js +0 -26
  112. package/dist/src/sdk/contracts/wits.js.map +0 -1
  113. package/dist/src/sdk/errors/address.js +0 -13
  114. package/dist/src/sdk/errors/address.js.map +0 -1
  115. package/dist/src/sdk/errors/base.js +0 -92
  116. package/dist/src/sdk/errors/base.js.map +0 -1
  117. package/dist/src/sdk/errors/request.js +0 -100
  118. package/dist/src/sdk/errors/request.js.map +0 -1
  119. package/dist/src/sdk/errors/rpc.js +0 -30
  120. package/dist/src/sdk/errors/rpc.js.map +0 -1
  121. package/dist/src/sdk/errors/transport.js +0 -10
  122. package/dist/src/sdk/errors/transport.js.map +0 -1
  123. package/dist/src/sdk/errors/utils.js +0 -2
  124. package/dist/src/sdk/errors/utils.js.map +0 -1
  125. package/dist/src/sdk/errors/version.js +0 -2
  126. package/dist/src/sdk/errors/version.js.map +0 -1
  127. package/dist/src/sdk/errors/wit.js +0 -19
  128. package/dist/src/sdk/errors/wit.js.map +0 -1
  129. package/dist/src/sdk/test/e2e.test.js +0 -166
  130. package/dist/src/sdk/test/e2e.test.js.map +0 -1
  131. package/dist/src/sdk/types/account.js +0 -2
  132. package/dist/src/sdk/types/account.js.map +0 -1
  133. package/dist/src/sdk/types/btc-rpc.js +0 -2
  134. package/dist/src/sdk/types/btc-rpc.js.map +0 -1
  135. package/dist/src/sdk/types/chain.js +0 -2
  136. package/dist/src/sdk/types/chain.js.map +0 -1
  137. package/dist/src/sdk/types/contract.js +0 -2
  138. package/dist/src/sdk/types/contract.js.map +0 -1
  139. package/dist/src/sdk/types/contract.test-d.js +0 -35
  140. package/dist/src/sdk/types/contract.test-d.js.map +0 -1
  141. package/dist/src/sdk/types/http-schema.js +0 -73
  142. package/dist/src/sdk/types/http-schema.js.map +0 -1
  143. package/dist/src/sdk/types/http-schema.test-d.js +0 -133
  144. package/dist/src/sdk/types/http-schema.test-d.js.map +0 -1
  145. package/dist/src/sdk/types/kontor.js +0 -28
  146. package/dist/src/sdk/types/kontor.js.map +0 -1
  147. package/dist/src/sdk/types/misc.js +0 -2
  148. package/dist/src/sdk/types/misc.js.map +0 -1
  149. package/dist/src/sdk/types/rpc-schema.js +0 -2
  150. package/dist/src/sdk/types/rpc-schema.js.map +0 -1
  151. package/dist/src/sdk/types/rpc.js +0 -19
  152. package/dist/src/sdk/types/rpc.js.map +0 -1
  153. package/dist/src/sdk/types/utils.js +0 -2
  154. package/dist/src/sdk/types/utils.js.map +0 -1
  155. package/dist/src/sdk/types/wbip001.js +0 -3
  156. package/dist/src/sdk/types/wbip001.js.map +0 -1
  157. package/dist/src/sdk/utils/build-http-request.js +0 -55
  158. package/dist/src/sdk/utils/build-http-request.js.map +0 -1
  159. package/dist/src/sdk/utils/build-request.js +0 -35
  160. package/dist/src/sdk/utils/build-request.js.map +0 -1
  161. package/dist/src/sdk/utils/build-rpc-request.js +0 -84
  162. package/dist/src/sdk/utils/build-rpc-request.js.map +0 -1
  163. package/dist/src/sdk/utils/chain/defineChain.js +0 -9
  164. package/dist/src/sdk/utils/chain/defineChain.js.map +0 -1
  165. package/dist/src/sdk/utils/encoding/to-hex.js +0 -23
  166. package/dist/src/sdk/utils/encoding/to-hex.js.map +0 -1
  167. package/dist/src/sdk/utils/get-action.js +0 -27
  168. package/dist/src/sdk/utils/get-action.js.map +0 -1
  169. package/dist/src/sdk/utils/http.js +0 -137
  170. package/dist/src/sdk/utils/http.js.map +0 -1
  171. package/dist/src/sdk/utils/lru.js +0 -35
  172. package/dist/src/sdk/utils/lru.js.map +0 -1
  173. package/dist/src/sdk/utils/promise/create-batch-scheduler.js +0 -49
  174. package/dist/src/sdk/utils/promise/create-batch-scheduler.js.map +0 -1
  175. package/dist/src/sdk/utils/promise/with-dedupe.js +0 -14
  176. package/dist/src/sdk/utils/promise/with-dedupe.js.map +0 -1
  177. package/dist/src/sdk/utils/promise/with-resolvers.js +0 -10
  178. package/dist/src/sdk/utils/promise/with-resolvers.js.map +0 -1
  179. package/dist/src/sdk/utils/promise/with-retry.js +0 -25
  180. package/dist/src/sdk/utils/promise/with-retry.js.map +0 -1
  181. package/dist/src/sdk/utils/promise/with-timeout.js +0 -30
  182. package/dist/src/sdk/utils/promise/with-timeout.js.map +0 -1
  183. package/dist/src/sdk/utils/rpc/http.js +0 -86
  184. package/dist/src/sdk/utils/rpc/http.js.map +0 -1
  185. package/dist/src/sdk/utils/rpc/id.js +0 -13
  186. package/dist/src/sdk/utils/rpc/id.js.map +0 -1
  187. package/dist/src/sdk/utils/stringify.js +0 -5
  188. package/dist/src/sdk/utils/stringify.js.map +0 -1
  189. package/dist/src/sdk/utils/uid.js +0 -14
  190. package/dist/src/sdk/utils/uid.js.map +0 -1
  191. package/dist/src/sdk/utils/wait.js +0 -4
  192. package/dist/src/sdk/utils/wait.js.map +0 -1
  193. package/dist/src/sdk/utils/wit/codecs/decimal.js +0 -165
  194. package/dist/src/sdk/utils/wit/codecs/decimal.js.map +0 -1
  195. package/dist/src/sdk/utils/wit/codecs/enum.js +0 -104
  196. package/dist/src/sdk/utils/wit/codecs/enum.js.map +0 -1
  197. package/dist/src/sdk/utils/wit/codecs/integer.js +0 -167
  198. package/dist/src/sdk/utils/wit/codecs/integer.js.map +0 -1
  199. package/dist/src/sdk/utils/wit/codecs/list.js +0 -117
  200. package/dist/src/sdk/utils/wit/codecs/list.js.map +0 -1
  201. package/dist/src/sdk/utils/wit/codecs/option.js +0 -91
  202. package/dist/src/sdk/utils/wit/codecs/option.js.map +0 -1
  203. package/dist/src/sdk/utils/wit/codecs/string.js +0 -27
  204. package/dist/src/sdk/utils/wit/codecs/string.js.map +0 -1
  205. package/dist/src/sdk/utils/wit/codecs/types.js +0 -45
  206. package/dist/src/sdk/utils/wit/codecs/types.js.map +0 -1
  207. package/dist/src/sdk/utils/wit/codecs/unit.js +0 -22
  208. package/dist/src/sdk/utils/wit/codecs/unit.js.map +0 -1
  209. package/dist/src/sdk/utils/wit/decode-function-result.js +0 -36
  210. package/dist/src/sdk/utils/wit/decode-function-result.js.map +0 -1
  211. package/dist/src/sdk/utils/wit/decode-wit-parameter.js +0 -286
  212. package/dist/src/sdk/utils/wit/decode-wit-parameter.js.map +0 -1
  213. package/dist/src/sdk/utils/wit/decode-wit-parameter.test.js +0 -75
  214. package/dist/src/sdk/utils/wit/decode-wit-parameter.test.js.map +0 -1
  215. package/dist/src/sdk/utils/wit/encode-function-data.js +0 -17
  216. package/dist/src/sdk/utils/wit/encode-function-data.js.map +0 -1
  217. package/dist/src/sdk/utils/wit/encode-function-data.test-d.js +0 -21
  218. package/dist/src/sdk/utils/wit/encode-function-data.test-d.js.map +0 -1
  219. package/dist/src/sdk/utils/wit/encode-function-data.test.js +0 -91
  220. package/dist/src/sdk/utils/wit/encode-function-data.test.js.map +0 -1
  221. package/dist/src/sdk/utils/wit/encode-wit-parameters.js +0 -250
  222. package/dist/src/sdk/utils/wit/encode-wit-parameters.js.map +0 -1
  223. package/dist/src/sdk/utils/wit/encode-wit-parameters.test.js +0 -62
  224. package/dist/src/sdk/utils/wit/encode-wit-parameters.test.js.map +0 -1
  225. package/dist/src/sdk/utils/wit/get-wit-item.js +0 -15
  226. package/dist/src/sdk/utils/wit/get-wit-item.js.map +0 -1
  227. package/dist/src/sdk/utils/wit/get-wit-item.test.js +0 -118
  228. package/dist/src/sdk/utils/wit/get-wit-item.test.js.map +0 -1
  229. package/dist/src/sdk/utils/wit/prepare-encode-function-data.js +0 -24
  230. package/dist/src/sdk/utils/wit/prepare-encode-function-data.js.map +0 -1
  231. package/dist/src/wit/error.js +0 -59
  232. package/dist/src/wit/error.js.map +0 -1
  233. package/dist/src/wit/narrow.js +0 -14
  234. package/dist/src/wit/narrow.js.map +0 -1
  235. package/dist/src/wit/regex.js +0 -6
  236. package/dist/src/wit/regex.js.map +0 -1
  237. package/dist/src/wit/register.js +0 -2
  238. package/dist/src/wit/register.js.map +0 -1
  239. package/dist/src/wit/type-utils.js +0 -2
  240. package/dist/src/wit/type-utils.js.map +0 -1
  241. package/dist/src/wit/utils.js +0 -2
  242. package/dist/src/wit/utils.js.map +0 -1
  243. package/dist/src/wit/utils.test-d.js +0 -16
  244. package/dist/src/wit/utils.test-d.js.map +0 -1
  245. package/dist/src/wit/version.js +0 -2
  246. package/dist/src/wit/version.js.map +0 -1
  247. package/dist/src/wit/wit-parser/core/errors/signature.js +0 -42
  248. package/dist/src/wit/wit-parser/core/errors/signature.js.map +0 -1
  249. package/dist/src/wit/wit-parser/core/errors/splitParameters.js +0 -18
  250. package/dist/src/wit/wit-parser/core/errors/splitParameters.js.map +0 -1
  251. package/dist/src/wit/wit-parser/core/errors/wit-parameter.js +0 -29
  252. package/dist/src/wit/wit-parser/core/errors/wit-parameter.js.map +0 -1
  253. package/dist/src/wit/wit-parser/core/records.js +0 -73
  254. package/dist/src/wit/wit-parser/core/records.js.map +0 -1
  255. package/dist/src/wit/wit-parser/core/records.test.js +0 -53
  256. package/dist/src/wit/wit-parser/core/records.test.js.map +0 -1
  257. package/dist/src/wit/wit-parser/core/signatures.js +0 -32
  258. package/dist/src/wit/wit-parser/core/signatures.js.map +0 -1
  259. package/dist/src/wit/wit-parser/core/signatures.test.js +0 -54
  260. package/dist/src/wit/wit-parser/core/signatures.test.js.map +0 -1
  261. package/dist/src/wit/wit-parser/core/types/records.js +0 -2
  262. package/dist/src/wit/wit-parser/core/types/records.js.map +0 -1
  263. package/dist/src/wit/wit-parser/core/types/records.test-d.js +0 -19
  264. package/dist/src/wit/wit-parser/core/types/records.test-d.js.map +0 -1
  265. package/dist/src/wit/wit-parser/core/types/signatures.js +0 -3
  266. package/dist/src/wit/wit-parser/core/types/signatures.js.map +0 -1
  267. package/dist/src/wit/wit-parser/core/types/signatures.test-d.js +0 -18
  268. package/dist/src/wit/wit-parser/core/types/signatures.test-d.js.map +0 -1
  269. package/dist/src/wit/wit-parser/core/types/utils.js +0 -2
  270. package/dist/src/wit/wit-parser/core/types/utils.js.map +0 -1
  271. package/dist/src/wit/wit-parser/core/types/utils.test-d.js +0 -138
  272. package/dist/src/wit/wit-parser/core/types/utils.test-d.js.map +0 -1
  273. package/dist/src/wit/wit-parser/core/utils.js +0 -212
  274. package/dist/src/wit/wit-parser/core/utils.js.map +0 -1
  275. package/dist/src/wit/wit-parser/core/utils.test.js +0 -302
  276. package/dist/src/wit/wit-parser/core/utils.test.js.map +0 -1
  277. package/dist/src/wit/wit-parser/parse-wit-parameter.js +0 -26
  278. package/dist/src/wit/wit-parser/parse-wit-parameter.js.map +0 -1
  279. package/dist/src/wit/wit-parser/parse-wit-parameter.test.js +0 -77
  280. package/dist/src/wit/wit-parser/parse-wit-parameter.test.js.map +0 -1
  281. package/dist/src/wit/wit-parser/parse-wit.js +0 -16
  282. package/dist/src/wit/wit-parser/parse-wit.js.map +0 -1
  283. package/dist/src/wit/wit-parser/parse-wit.test.js +0 -78
  284. package/dist/src/wit/wit-parser/parse-wit.test.js.map +0 -1
  285. package/dist/src/wit/wit.js +0 -2
  286. package/dist/src/wit/wit.js.map +0 -1
  287. package/dist/src/wit/wit.test.js +0 -6
  288. package/dist/src/wit/wit.test.js.map +0 -1
  289. package/dist/test/globalSetup.js +0 -14
  290. package/dist/test/globalSetup.js.map +0 -1
  291. package/dist/test/src/wits.js +0 -21
  292. package/dist/test/src/wits.js.map +0 -1
  293. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1,54 +0,0 @@
1
- import { expect, test, describe } from "vitest";
2
- import { execFunctionSignature, isFunctionSignature } from "./signatures.js";
3
- describe("isFunctionSignature", () => {
4
- test.each([
5
- "export fib: func(ctx: borrow<proc-context>, arith-address: contract-address, n: u64) -> u64;",
6
- "export fib-of-sub: func(ctx: borrow<proc-context>, arith-address: contract-address, x: string, y: string) -> result<u64, error>;",
7
- "export cached-values: func(ctx: borrow<view-context>) -> list<u64>;",
8
- ])("%s -> %s", (input) => {
9
- expect(isFunctionSignature(input)).toBe(true);
10
- });
11
- });
12
- describe("execFunctionSignature", () => {
13
- test.each([
14
- {
15
- input: "export fib: func(ctx: borrow<proc-context>, arith-address: contract-address, n: u64) -> u64;",
16
- expected: {
17
- name: "fib",
18
- type: "proc",
19
- parameters: "ctx: borrow<proc-context>, arith-address: contract-address, n: u64",
20
- returns: "u64",
21
- },
22
- },
23
- {
24
- input: "export fib-of-sub: func(ctx: borrow<proc-context>, arith-address: contract-address, x: string, y: string) -> result<u64, error>;",
25
- expected: {
26
- name: "fib-of-sub",
27
- type: "proc",
28
- parameters: "ctx: borrow<proc-context>, arith-address: contract-address, x: string, y: string",
29
- returns: "result<u64, error>",
30
- },
31
- },
32
- {
33
- input: "export cached-values: func(ctx: borrow<view-context>) -> list<u64>;",
34
- expected: {
35
- name: "cached-values",
36
- type: "view",
37
- parameters: "ctx: borrow<view-context>",
38
- returns: "list<u64>",
39
- },
40
- },
41
- {
42
- input: "export cached-values: func(ctx: borrow<core-context>) -> list<u64>;",
43
- expected: {
44
- name: "cached-values",
45
- type: "core",
46
- parameters: "ctx: borrow<core-context>",
47
- returns: "list<u64>",
48
- },
49
- },
50
- ])("%s", ({ input, expected }) => {
51
- expect(execFunctionSignature(input)).toStrictEqual(expected);
52
- });
53
- });
54
- //# sourceMappingURL=signatures.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signatures.test.js","sourceRoot":"","sources":["../../../../../src/wit/wit-parser/core/signatures.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAEhD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAE7E,QAAQ,CAAC,qBAAqB,EAAE,GAAG,EAAE;IACnC,IAAI,CAAC,IAAI,CAAC;QACR,8FAA8F;QAE9F,kIAAkI;QAElI,qEAAqE;KACtE,CAAC,CAAC,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE;QACvB,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,QAAQ,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACrC,IAAI,CAAC,IAAI,CAAC;QACR;YACE,KAAK,EACH,8FAA8F;YAChG,QAAQ,EAAE;gBACR,IAAI,EAAE,KAAK;gBACX,IAAI,EAAE,MAAM;gBACZ,UAAU,EACR,oEAAoE;gBACtE,OAAO,EAAE,KAAK;aACf;SACF;QACD;YACE,KAAK,EACH,kIAAkI;YACpI,QAAQ,EAAE;gBACR,IAAI,EAAE,YAAY;gBAClB,IAAI,EAAE,MAAM;gBACZ,UAAU,EACR,kFAAkF;gBACpF,OAAO,EAAE,oBAAoB;aAC9B;SACF;QACD;YACE,KAAK,EACH,qEAAqE;YACvE,QAAQ,EAAE;gBACR,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,MAAM;gBACZ,UAAU,EAAE,2BAA2B;gBACvC,OAAO,EAAE,WAAW;aACrB;SACF;QACD;YACE,KAAK,EACH,qEAAqE;YACvE,QAAQ,EAAE;gBACR,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,MAAM;gBACZ,UAAU,EAAE,2BAA2B;gBACvC,OAAO,EAAE,WAAW;aACrB;SACF;KACF,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC/B,MAAM,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAC/D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=records.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"records.js","sourceRoot":"","sources":["../../../../../../src/wit/wit-parser/core/types/records.ts"],"names":[],"mappings":""}
@@ -1,19 +0,0 @@
1
- import { expectTypeOf, test } from "vitest";
2
- test("ParseRecords", () => {
3
- expectTypeOf().toEqualTypeOf();
4
- expectTypeOf().toEqualTypeOf();
5
- expectTypeOf().toEqualTypeOf();
6
- });
7
- test("ParseRecord", () => {
8
- expectTypeOf().toEqualTypeOf();
9
- expectTypeOf().toEqualTypeOf();
10
- expectTypeOf().toEqualTypeOf();
11
- });
12
- test("ParseRecordProperties", () => {
13
- expectTypeOf().toEqualTypeOf();
14
- expectTypeOf().toEqualTypeOf();
15
- expectTypeOf().toEqualTypeOf();
16
- expectTypeOf().toEqualTypeOf();
17
- expectTypeOf().toEqualTypeOf();
18
- });
19
- //# sourceMappingURL=records.test-d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"records.test-d.js","sourceRoot":"","sources":["../../../../../../src/wit/wit-parser/core/types/records.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAiB5C,IAAI,CAAC,cAAc,EAAE,GAAG,EAAE;IACxB,YAAY,EAOT,CAAC,aAAa,EA2Bb,CAAC;IACL,YAAY,EAOT,CAAC,aAAa,EAab,CAAC;IACL,YAAY,EAET,CAAC,aAAa,EAYb,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE;IACvB,YAAY,EAET,CAAC,aAAa,EAOb,CAAC;IAEL,YAAY,EAET,CAAC,aAAa,EAMb,CAAC;IAEL,YAAY,EAKT,CAAC,aAAa,EAsBb,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,uBAAuB,EAAE,GAAG,EAAE;IACjC,YAAY,EAET,CAAC,aAAa,EAMd,CAAC;IAEJ,YAAY,EAET,CAAC,aAAa,EAKd,CAAC;IAEJ,YAAY,EAET,CAAC,aAAa,EAqBd,CAAC;IAEJ,YAAY,EAET,CAAC,aAAa,EAOd,CAAC;IAEJ,YAAY,EAET,CAAC,aAAa,EAYd,CAAC;AACN,CAAC,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- export {};
2
- // Single
3
- //# sourceMappingURL=signatures.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signatures.js","sourceRoot":"","sources":["../../../../../../src/wit/wit-parser/core/types/signatures.ts"],"names":[],"mappings":";AAmLA,SAAS"}
@@ -1,18 +0,0 @@
1
- import { assertType, test } from "vitest";
2
- test("IsFunctionSignature", () => {
3
- assertType(true);
4
- assertType(true);
5
- assertType(true);
6
- });
7
- test("IsRecordSignature", () => {
8
- assertType(true);
9
- assertType(true);
10
- });
11
- test("IsSignature", () => {
12
- assertType(true);
13
- assertType(true);
14
- assertType(true);
15
- assertType(true);
16
- assertType(true);
17
- });
18
- //# sourceMappingURL=signatures.test-d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"signatures.test-d.js","sourceRoot":"","sources":["../../../../../../src/wit/wit-parser/core/types/signatures.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAQ1C,IAAI,CAAC,qBAAqB,EAAE,GAAG,EAAE;IAC/B,UAAU,CAER,IAAI,CAAC,CAAC;IAER,UAAU,CAER,IAAI,CAAC,CAAC;IAER,UAAU,CAER,IAAI,CAAC,CAAC;AACV,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC7B,UAAU,CAER,IAAI,CAAC,CAAC;IAER,UAAU,CAER,IAAI,CAAC,CAAC;AACV,CAAC,CAAC,CAAC;AACH,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE;IACvB,UAAU,CAER,IAAI,CAAC,CAAC;IAER,UAAU,CAER,IAAI,CAAC,CAAC;IAER,UAAU,CAER,IAAI,CAAC,CAAC;IAER,UAAU,CAER,IAAI,CAAC,CAAC;IAER,UAAU,CAER,IAAI,CAAC,CAAC;AACV,CAAC,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../src/wit/wit-parser/core/types/utils.ts"],"names":[],"mappings":""}
@@ -1,138 +0,0 @@
1
- import { assertType, test } from "vitest";
2
- test("ParseWitParameter", () => {
3
- // everything in fib contrct
4
- assertType({
5
- name: "ctx",
6
- type: "borrow<proc-context>",
7
- });
8
- assertType({
9
- name: "arith-address",
10
- type: "contract-address",
11
- });
12
- assertType({
13
- name: "n",
14
- type: "u64",
15
- });
16
- assertType({
17
- type: "u64",
18
- });
19
- assertType({
20
- name: "x",
21
- type: "string",
22
- });
23
- assertType({
24
- name: "y",
25
- type: "string",
26
- });
27
- assertType({
28
- name: "option-string",
29
- type: "option<string>",
30
- });
31
- assertType({
32
- name: "option-list-string",
33
- type: "option<list<string>>",
34
- });
35
- assertType({
36
- name: "option-list-result-string-contract-address",
37
- type: "option<list<result<string, contract-address>>>",
38
- });
39
- assertType({
40
- type: "contract-address",
41
- });
42
- assertType({
43
- name: "ctx",
44
- type: "borrow<view-context>",
45
- });
46
- assertType({
47
- name: "arith-address",
48
- type: "contract-address",
49
- });
50
- });
51
- test("_ParseFunctionParametersAndContext", () => {
52
- assertType({
53
- Inputs: "arith-address: contract-address, n: u64",
54
- Context: "proc",
55
- });
56
- assertType({
57
- Inputs: "",
58
- Context: "view",
59
- });
60
- assertType({
61
- Inputs: "",
62
- Context: "view",
63
- });
64
- assertType({
65
- Inputs: "",
66
- Context: "core",
67
- });
68
- });
69
- test("SplitParameters", () => {
70
- assertType(["u64"]);
71
- assertType([
72
- "arith-address: contract-address",
73
- "n: list<u64>",
74
- ]);
75
- });
76
- test("Parse Signature", () => {
77
- assertType({
78
- type: "function",
79
- name: "fib",
80
- context: "proc",
81
- inputs: [
82
- { name: "arith-address", type: "contract-address" },
83
- { name: "n", type: "list<u64>" },
84
- ],
85
- outputs: [
86
- {
87
- type: "u64",
88
- },
89
- ],
90
- });
91
- assertType({
92
- type: "function",
93
- name: "fib",
94
- context: "proc",
95
- inputs: [
96
- { name: "arith-address", type: "contract-address" },
97
- { name: "n", type: "list<u64>" },
98
- ],
99
- outputs: [
100
- {
101
- type: "contract-address",
102
- },
103
- ],
104
- });
105
- assertType({
106
- type: "function",
107
- name: "fib",
108
- context: "proc",
109
- inputs: [
110
- {
111
- name: "arith-address",
112
- type: "contract-address",
113
- },
114
- { name: "n", type: "list<u64>" },
115
- ],
116
- outputs: [
117
- {
118
- type: "contract-address",
119
- },
120
- ],
121
- });
122
- assertType({
123
- type: "function",
124
- name: "get-dogs",
125
- context: "proc",
126
- inputs: [],
127
- outputs: [
128
- {
129
- type: "list<tuple>",
130
- components: [
131
- { type: "string", name: "name" },
132
- { type: "string", name: "breed" },
133
- ],
134
- },
135
- ],
136
- });
137
- });
138
- //# sourceMappingURL=utils.test-d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.test-d.js","sourceRoot":"","sources":["../../../../../../src/wit/wit-parser/core/types/utils.test-d.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AA2C1C,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;IAC7B,4BAA4B;IAC5B,UAAU,CAAiD;QACzD,IAAI,EAAE,KAAK;QACX,IAAI,EAAE,sBAAsB;KAC7B,CAAC,CAAC;IAEH,UAAU,CAAuD;QAC/D,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,kBAAkB;KACzB,CAAC,CAAC;IAEH,UAAU,CAA8B;QACtC,IAAI,EAAE,GAAG;QACT,IAAI,EAAE,KAAK;KACZ,CAAC,CAAC;IAEH,UAAU,CAA2B;QACnC,IAAI,EAAE,KAAK;KACZ,CAAC,CAAC;IAEH,UAAU,CAAiC;QACzC,IAAI,EAAE,GAAG;QACT,IAAI,EAAE,QAAQ;KACf,CAAC,CAAC;IAEH,UAAU,CAAiC;QACzC,IAAI,EAAE,GAAG;QACT,IAAI,EAAE,QAAQ;KACf,CAAC,CAAC;IAEH,UAAU,CAAqD;QAC7D,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,gBAAgB;KACvB,CAAC,CAAC;IAEH,UAAU,CAAgE;QACxE,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,sBAAsB;KAC7B,CAAC,CAAC;IAEH,UAAU,CAER;QACA,IAAI,EAAE,4CAA4C;QAClD,IAAI,EAAE,gDAAgD;KACvD,CAAC,CAAC;IAEH,UAAU,CAAwC;QAChD,IAAI,EAAE,kBAAkB;KACzB,CAAC,CAAC;IACH,UAAU,CAAiD;QACzD,IAAI,EAAE,KAAK;QACX,IAAI,E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AE;YACnD,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE;SACjC;QACD,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,kBAAkB;aACzB;SACF;KACF,CAAC,CAAC;IACH,UAAU,CAER;QACA,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,MAAM;QACf,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,eAAe;gBACrB,IAAI,EAAE,kBAAkB;aACzB;YACD,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE;SACjC;QACD,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,kBAAkB;aACzB;SACF;KACF,CAAC,CAAC;IACH,UAAU,CAKR;QACA,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,UAAU;QAChB,OAAO,EAAE,MAAM;QACf,MAAM,EAAE,EAAE;QACV,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,aAAa;gBACnB,UAAU,EAAE;oBACV,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE;oBAChC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE;iBAClC;aACF;SACF;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,212 +0,0 @@
1
- import { execTyped, isGenericRegex } from "../../regex.js";
2
- import { InvalidWitParameterError, WitProtectedKeywordError, } from "./errors/wit-parameter.js";
3
- import { InvalidSignatureError, UnknownSignatureError, } from "./errors/signature.js";
4
- import { InvalidGenericDepthError } from "./errors/splitParameters.js";
5
- import { execFunctionSignature, isFunctionSignature } from "./signatures.js";
6
- //
7
- // export const witParameterRegex =
8
- // /^(?:(?<name>[a-z][a-z0-9-]*)\s*:\s*)?(?<type>(?:borrow|list|option|result|tuple)\s*<[\s\S]+>|[a-z][a-z0-9-]*|(?:record|variant|flags|enum)\s*\{[\s\S]*\})$/;
9
- //
10
- export const witParameterRegex = /^(?:(?<name>[a-z][a-z0-9-]*)\s*:\s*)?(?<type>_|(?:borrow|list|option|result|tuple)\s*<[\s\S]+>|[a-z][a-z0-9-]*|(?:record|variant|flags|enum)\s*\{[\s\S]*\})$/;
11
- export function isGeneric(type) {
12
- return isGenericRegex.test(type.trim());
13
- }
14
- export function execGeneric(type) {
15
- const m = type.trim().match(isGenericRegex);
16
- if (!m || !m.groups)
17
- return null;
18
- return m.groups;
19
- }
20
- export function parseWitParameter(param, options) {
21
- // TODO: cache
22
- // const parameterCacheKey = getParameterCacheKey(
23
- // param,
24
- // options?.type,
25
- // options?.structs,
26
- // );
27
- // if (parameterCache.has(parameterCacheKey))
28
- // return parameterCache.get(parameterCacheKey)!;
29
- //
30
- //
31
- const match = execTyped(witParameterRegex, param);
32
- if (!match)
33
- throw new InvalidWitParameterError({ param });
34
- const isGenericType = isGeneric(match.type);
35
- if (match.name && isWitKeyword(match.name))
36
- throw new WitProtectedKeywordError({ param, name: match.name });
37
- // TODO: smell
38
- const name = match.name ? { name: match.name } : {};
39
- const records = options?.records ?? {};
40
- let type;
41
- let components = {};
42
- if (isGenericType) {
43
- const g = execGeneric(match.type);
44
- const parts = splitParameters(g.inner);
45
- const parsed = parts.map((p) => parseWitParameter(p, { records }));
46
- // normalize inner types for the outer type string
47
- const innerTypeSig = parsed.map((x) => x.type).join(", ");
48
- switch (g.outer) {
49
- case "list":
50
- case "option": {
51
- if (parsed.length !== 1) {
52
- throw new InvalidWitParameterError({
53
- param,
54
- });
55
- }
56
- const t = parsed[0];
57
- type = `${g.outer}<${t.type}>`;
58
- // flatten record fields for list/option only
59
- components = t.components ? { components: t.components } : {};
60
- break;
61
- }
62
- case "result": {
63
- if (parsed.length !== 2) {
64
- throw new InvalidWitParameterError({
65
- param,
66
- });
67
- }
68
- const left = parsed[0];
69
- // @ts-ignore
70
- const right = parsed[1];
71
- type = `result<${innerTypeSig}>`;
72
- components = {
73
- ...(left.components && { components: left.components }),
74
- // components: [
75
- //
76
- // {
77
- // name: "left",
78
- // type: left.type,
79
- // ...(left.components && { components: left.components }),
80
- // },
81
- // {
82
- // name: "right",
83
- // type: right.type,
84
- // ...(right.components && { components: right.components }),
85
- // },
86
- // ],
87
- };
88
- // the right / error channel is always assumed to be wit built-in `error` primitive
89
- // components = {
90
- // components: [
91
- // {
92
- // name: "left",
93
- // type: left.type,
94
- // ...(left.components && { components: left.components }),
95
- // },
96
- // {
97
- // name: "right",
98
- // type: right.type,
99
- // ...(right.components && { components: right.components }),
100
- // },
101
- // ],
102
- // };
103
- break;
104
- }
105
- default: {
106
- type = `${g.outer}<${innerTypeSig}>`;
107
- components = {};
108
- }
109
- }
110
- }
111
- else if (match.type in records) {
112
- // scalar that maps to a record in `records`
113
- type = "tuple";
114
- components = { components: records[match.type] };
115
- }
116
- else {
117
- type = match.type;
118
- }
119
- const witParameter = {
120
- type: `${type}${match.array ?? ""}`,
121
- ...name,
122
- ...components,
123
- };
124
- // parameterCache.set(parameterCacheKey, witParameter);
125
- //
126
- return witParameter;
127
- }
128
- export const witKeywordRegex = /^(?:package|world|interface|contract|include|use|import|export|func|borrow|record|list|enum|flags|variant|option|result|tuple|bool|s8|s16|s32|s64|u8|u16|u32|u64|f32|f64|char|string)$/;
129
- export function isWitKeyword(word) {
130
- return witKeywordRegex.test(word);
131
- }
132
- // class InvalidParenthesisError extends Error { constructor(public info: { current: string; depth: number }) { super('Unbalanced <>'); } }
133
- export function splitParameters(params, result = []) {
134
- const s = params.trim();
135
- if (s.length === 0)
136
- return result;
137
- let current = "";
138
- let depth = 0; // nesting depth for <...>
139
- for (let i = 0; i < s.length; i++) {
140
- const ch = s[i];
141
- if (ch === "<") {
142
- depth += 1;
143
- current += ch;
144
- continue;
145
- }
146
- if (ch === ">") {
147
- depth -= 1;
148
- if (depth < 0)
149
- throw new InvalidGenericDepthError({
150
- current: s.slice(0, i + 1),
151
- depth,
152
- });
153
- current += ch;
154
- continue;
155
- }
156
- if (ch === "," && depth === 0) {
157
- const tok = current.trim();
158
- if (tok.length)
159
- result.push(tok);
160
- current = "";
161
- continue;
162
- }
163
- current += ch;
164
- }
165
- if (depth !== 0)
166
- throw new InvalidGenericDepthError({ current, depth });
167
- const tail = current.trim();
168
- if (tail.length)
169
- result.push(tail);
170
- return result;
171
- }
172
- export function parseSignature(signature, structs = {}) {
173
- if (isFunctionSignature(signature))
174
- return parseFunctionSignature(signature, structs);
175
- throw new UnknownSignatureError({ signature });
176
- }
177
- export function parseFunctionSignature(signature, records = {}) {
178
- const match = execFunctionSignature(signature);
179
- if (!match)
180
- throw new InvalidSignatureError({ signature, type: "func" });
181
- const inputParams = splitParameters(match.parameters);
182
- const inputs = [];
183
- const inputLength = inputParams.length;
184
- for (let i = 0; i < inputLength; i++) {
185
- inputs.push(parseWitParameter(inputParams[i], {
186
- records,
187
- }));
188
- }
189
- const outputs = [];
190
- if (match.returns) {
191
- const outputParams = splitParameters(match.returns);
192
- const outputLength = outputParams.length;
193
- for (let i = 0; i < outputLength; i++) {
194
- outputs.push(parseWitParameter(outputParams[i], {
195
- records,
196
- }));
197
- }
198
- }
199
- const contextInput = inputs.shift();
200
- return {
201
- name: match.name,
202
- type: "function",
203
- context: contextInput?.type === "borrow<proc-context>"
204
- ? "proc"
205
- : contextInput?.type === "borrow<view-context>"
206
- ? "view"
207
- : "core",
208
- inputs,
209
- outputs,
210
- };
211
- }
212
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../src/wit/wit-parser/core/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EACL,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AACvE,OAAO,EAAE,q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