@buildonspark/issuer-sdk 0.0.22 → 0.0.23

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 (385) hide show
  1. package/dist/chunk-GB7N6I5O.js +48 -0
  2. package/dist/index.cjs +518 -0
  3. package/dist/index.d.cts +110 -0
  4. package/dist/index.d.ts +110 -0
  5. package/dist/index.js +497 -0
  6. package/dist/types.cjs +77 -0
  7. package/dist/types.d.cts +99 -0
  8. package/dist/{issuer-sdk/src/types.d.ts → types.d.ts} +14 -12
  9. package/dist/types.js +12 -0
  10. package/package.json +31 -32
  11. package/src/examples/example.ts +1 -1
  12. package/src/index.ts +1 -0
  13. package/src/interface/wallet-interface.ts +7 -6
  14. package/src/{issuer-sdk.ts → issuer-spark-wallet.ts} +5 -5
  15. package/src/tests/integration/spark.test.ts +3 -12
  16. package/src/types.ts +1 -2
  17. package/src/utils/constants.ts +2 -2
  18. package/dist/issuer-sdk/src/interface/wallet-interface.d.ts +0 -67
  19. package/dist/issuer-sdk/src/interface/wallet-interface.js +0 -2
  20. package/dist/issuer-sdk/src/interface/wallet-interface.js.map +0 -1
  21. package/dist/issuer-sdk/src/issuer-sdk.d.ts +0 -43
  22. package/dist/issuer-sdk/src/issuer-sdk.js +0 -153
  23. package/dist/issuer-sdk/src/issuer-sdk.js.map +0 -1
  24. package/dist/issuer-sdk/src/proto/common.d.ts +0 -58
  25. package/dist/issuer-sdk/src/proto/common.js +0 -350
  26. package/dist/issuer-sdk/src/proto/common.js.map +0 -1
  27. package/dist/issuer-sdk/src/proto/google/protobuf/descriptor.d.ts +0 -1228
  28. package/dist/issuer-sdk/src/proto/google/protobuf/descriptor.js +0 -5070
  29. package/dist/issuer-sdk/src/proto/google/protobuf/descriptor.js.map +0 -1
  30. package/dist/issuer-sdk/src/proto/google/protobuf/duration.d.ts +0 -99
  31. package/dist/issuer-sdk/src/proto/google/protobuf/duration.js +0 -90
  32. package/dist/issuer-sdk/src/proto/google/protobuf/duration.js.map +0 -1
  33. package/dist/issuer-sdk/src/proto/google/protobuf/empty.d.ts +0 -33
  34. package/dist/issuer-sdk/src/proto/google/protobuf/empty.js +0 -46
  35. package/dist/issuer-sdk/src/proto/google/protobuf/empty.js.map +0 -1
  36. package/dist/issuer-sdk/src/proto/google/protobuf/timestamp.d.ts +0 -128
  37. package/dist/issuer-sdk/src/proto/google/protobuf/timestamp.js +0 -90
  38. package/dist/issuer-sdk/src/proto/google/protobuf/timestamp.js.map +0 -1
  39. package/dist/issuer-sdk/src/proto/mock.d.ts +0 -48
  40. package/dist/issuer-sdk/src/proto/mock.js +0 -103
  41. package/dist/issuer-sdk/src/proto/mock.js.map +0 -1
  42. package/dist/issuer-sdk/src/proto/spark.d.ts +0 -1101
  43. package/dist/issuer-sdk/src/proto/spark.js +0 -9565
  44. package/dist/issuer-sdk/src/proto/spark.js.map +0 -1
  45. package/dist/issuer-sdk/src/proto/spark_authn.d.ts +0 -111
  46. package/dist/issuer-sdk/src/proto/spark_authn.js +0 -517
  47. package/dist/issuer-sdk/src/proto/spark_authn.js.map +0 -1
  48. package/dist/issuer-sdk/src/proto/validate/validate.d.ts +0 -1087
  49. package/dist/issuer-sdk/src/proto/validate/validate.js +0 -4437
  50. package/dist/issuer-sdk/src/proto/validate/validate.js.map +0 -1
  51. package/dist/issuer-sdk/src/services/freeze.d.ts +0 -11
  52. package/dist/issuer-sdk/src/services/freeze.js +0 -44
  53. package/dist/issuer-sdk/src/services/freeze.js.map +0 -1
  54. package/dist/issuer-sdk/src/services/token-transactions.d.ts +0 -8
  55. package/dist/issuer-sdk/src/services/token-transactions.js +0 -27
  56. package/dist/issuer-sdk/src/services/token-transactions.js.map +0 -1
  57. package/dist/issuer-sdk/src/tests/integration/spark.test.d.ts +0 -1
  58. package/dist/issuer-sdk/src/tests/integration/spark.test.js +0 -373
  59. package/dist/issuer-sdk/src/tests/integration/spark.test.js.map +0 -1
  60. package/dist/issuer-sdk/src/types.js +0 -33
  61. package/dist/issuer-sdk/src/types.js.map +0 -1
  62. package/dist/issuer-sdk/src/utils/constants.d.ts +0 -16
  63. package/dist/issuer-sdk/src/utils/constants.js +0 -18
  64. package/dist/issuer-sdk/src/utils/constants.js.map +0 -1
  65. package/dist/issuer-sdk/src/utils/enum-mappers.d.ts +0 -6
  66. package/dist/issuer-sdk/src/utils/enum-mappers.js +0 -66
  67. package/dist/issuer-sdk/src/utils/enum-mappers.js.map +0 -1
  68. package/dist/issuer-sdk/src/utils/token-hashing.d.ts +0 -2
  69. package/dist/issuer-sdk/src/utils/token-hashing.js +0 -45
  70. package/dist/issuer-sdk/src/utils/token-hashing.js.map +0 -1
  71. package/dist/issuer-sdk/src/utils/type-mappers.d.ts +0 -4
  72. package/dist/issuer-sdk/src/utils/type-mappers.js +0 -106
  73. package/dist/issuer-sdk/src/utils/type-mappers.js.map +0 -1
  74. package/dist/spark-sdk/src/graphql/client.d.ts +0 -29
  75. package/dist/spark-sdk/src/graphql/client.js +0 -246
  76. package/dist/spark-sdk/src/graphql/client.js.map +0 -1
  77. package/dist/spark-sdk/src/graphql/mutations/CompleteCoopExit.d.ts +0 -1
  78. package/dist/spark-sdk/src/graphql/mutations/CompleteCoopExit.js +0 -19
  79. package/dist/spark-sdk/src/graphql/mutations/CompleteCoopExit.js.map +0 -1
  80. package/dist/spark-sdk/src/graphql/mutations/CompleteLeavesSwap.d.ts +0 -1
  81. package/dist/spark-sdk/src/graphql/mutations/CompleteLeavesSwap.js +0 -17
  82. package/dist/spark-sdk/src/graphql/mutations/CompleteLeavesSwap.js.map +0 -1
  83. package/dist/spark-sdk/src/graphql/mutations/RequestCoopExit.d.ts +0 -1
  84. package/dist/spark-sdk/src/graphql/mutations/RequestCoopExit.js +0 -20
  85. package/dist/spark-sdk/src/graphql/mutations/RequestCoopExit.js.map +0 -1
  86. package/dist/spark-sdk/src/graphql/mutations/RequestLightningReceive.d.ts +0 -1
  87. package/dist/spark-sdk/src/graphql/mutations/RequestLightningReceive.js +0 -26
  88. package/dist/spark-sdk/src/graphql/mutations/RequestLightningReceive.js.map +0 -1
  89. package/dist/spark-sdk/src/graphql/mutations/RequestLightningSend.d.ts +0 -1
  90. package/dist/spark-sdk/src/graphql/mutations/RequestLightningSend.js +0 -18
  91. package/dist/spark-sdk/src/graphql/mutations/RequestLightningSend.js.map +0 -1
  92. package/dist/spark-sdk/src/graphql/mutations/RequestSwapLeaves.d.ts +0 -1
  93. package/dist/spark-sdk/src/graphql/mutations/RequestSwapLeaves.js +0 -24
  94. package/dist/spark-sdk/src/graphql/mutations/RequestSwapLeaves.js.map +0 -1
  95. package/dist/spark-sdk/src/graphql/objects/BitcoinNetwork.d.ts +0 -17
  96. package/dist/spark-sdk/src/graphql/objects/BitcoinNetwork.js +0 -20
  97. package/dist/spark-sdk/src/graphql/objects/BitcoinNetwork.js.map +0 -1
  98. package/dist/spark-sdk/src/graphql/objects/CompleteCoopExitInput.d.ts +0 -7
  99. package/dist/spark-sdk/src/graphql/objects/CompleteCoopExitInput.js +0 -14
  100. package/dist/spark-sdk/src/graphql/objects/CompleteCoopExitInput.js.map +0 -1
  101. package/dist/spark-sdk/src/graphql/objects/CompleteCoopExitOutput.d.ts +0 -7
  102. package/dist/spark-sdk/src/graphql/objects/CompleteCoopExitOutput.js +0 -19
  103. package/dist/spark-sdk/src/graphql/objects/CompleteCoopExitOutput.js.map +0 -1
  104. package/dist/spark-sdk/src/graphql/objects/CompleteLeavesSwapInput.d.ts +0 -8
  105. package/dist/spark-sdk/src/graphql/objects/CompleteLeavesSwapInput.js +0 -16
  106. package/dist/spark-sdk/src/graphql/objects/CompleteLeavesSwapInput.js.map +0 -1
  107. package/dist/spark-sdk/src/graphql/objects/CompleteLeavesSwapOutput.d.ts +0 -7
  108. package/dist/spark-sdk/src/graphql/objects/CompleteLeavesSwapOutput.js +0 -19
  109. package/dist/spark-sdk/src/graphql/objects/CompleteLeavesSwapOutput.js.map +0 -1
  110. package/dist/spark-sdk/src/graphql/objects/CompleteSeedReleaseInput.d.ts +0 -7
  111. package/dist/spark-sdk/src/graphql/objects/CompleteSeedReleaseInput.js +0 -14
  112. package/dist/spark-sdk/src/graphql/objects/CompleteSeedReleaseInput.js.map +0 -1
  113. package/dist/spark-sdk/src/graphql/objects/CompleteSeedReleaseOutput.d.ts +0 -7
  114. package/dist/spark-sdk/src/graphql/objects/CompleteSeedReleaseOutput.js +0 -17
  115. package/dist/spark-sdk/src/graphql/objects/CompleteSeedReleaseOutput.js.map +0 -1
  116. package/dist/spark-sdk/src/graphql/objects/Connection.d.ts +0 -16
  117. package/dist/spark-sdk/src/graphql/objects/Connection.js +0 -56
  118. package/dist/spark-sdk/src/graphql/objects/Connection.js.map +0 -1
  119. package/dist/spark-sdk/src/graphql/objects/CoopExitFeeEstimateInput.d.ts +0 -7
  120. package/dist/spark-sdk/src/graphql/objects/CoopExitFeeEstimateInput.js +0 -14
  121. package/dist/spark-sdk/src/graphql/objects/CoopExitFeeEstimateInput.js.map +0 -1
  122. package/dist/spark-sdk/src/graphql/objects/CoopExitFeeEstimateOutput.d.ts +0 -8
  123. package/dist/spark-sdk/src/graphql/objects/CoopExitFeeEstimateOutput.js +0 -26
  124. package/dist/spark-sdk/src/graphql/objects/CoopExitFeeEstimateOutput.js.map +0 -1
  125. package/dist/spark-sdk/src/graphql/objects/CoopExitRequest.d.ts +0 -35
  126. package/dist/spark-sdk/src/graphql/objects/CoopExitRequest.js +0 -68
  127. package/dist/spark-sdk/src/graphql/objects/CoopExitRequest.js.map +0 -1
  128. package/dist/spark-sdk/src/graphql/objects/CurrencyAmount.d.ts +0 -24
  129. package/dist/spark-sdk/src/graphql/objects/CurrencyAmount.js +0 -30
  130. package/dist/spark-sdk/src/graphql/objects/CurrencyAmount.js.map +0 -1
  131. package/dist/spark-sdk/src/graphql/objects/CurrencyUnit.d.ts +0 -29
  132. package/dist/spark-sdk/src/graphql/objects/CurrencyUnit.js +0 -32
  133. package/dist/spark-sdk/src/graphql/objects/CurrencyUnit.js.map +0 -1
  134. package/dist/spark-sdk/src/graphql/objects/Entity.d.ts +0 -16
  135. package/dist/spark-sdk/src/graphql/objects/Entity.js +0 -169
  136. package/dist/spark-sdk/src/graphql/objects/Entity.js.map +0 -1
  137. package/dist/spark-sdk/src/graphql/objects/GetChallengeInput.d.ts +0 -6
  138. package/dist/spark-sdk/src/graphql/objects/GetChallengeInput.js +0 -12
  139. package/dist/spark-sdk/src/graphql/objects/GetChallengeInput.js.map +0 -1
  140. package/dist/spark-sdk/src/graphql/objects/GetChallengeOutput.d.ts +0 -7
  141. package/dist/spark-sdk/src/graphql/objects/GetChallengeOutput.js +0 -17
  142. package/dist/spark-sdk/src/graphql/objects/GetChallengeOutput.js.map +0 -1
  143. package/dist/spark-sdk/src/graphql/objects/Invoice.d.ts +0 -15
  144. package/dist/spark-sdk/src/graphql/objects/Invoice.js +0 -45
  145. package/dist/spark-sdk/src/graphql/objects/Invoice.js.map +0 -1
  146. package/dist/spark-sdk/src/graphql/objects/Leaf.d.ts +0 -11
  147. package/dist/spark-sdk/src/graphql/objects/Leaf.js +0 -29
  148. package/dist/spark-sdk/src/graphql/objects/Leaf.js.map +0 -1
  149. package/dist/spark-sdk/src/graphql/objects/LeavesSwapFeeEstimateInput.d.ts +0 -6
  150. package/dist/spark-sdk/src/graphql/objects/LeavesSwapFeeEstimateInput.js +0 -12
  151. package/dist/spark-sdk/src/graphql/objects/LeavesSwapFeeEstimateInput.js.map +0 -1
  152. package/dist/spark-sdk/src/graphql/objects/LeavesSwapFeeEstimateOutput.d.ts +0 -8
  153. package/dist/spark-sdk/src/graphql/objects/LeavesSwapFeeEstimateOutput.js +0 -26
  154. package/dist/spark-sdk/src/graphql/objects/LeavesSwapFeeEstimateOutput.js.map +0 -1
  155. package/dist/spark-sdk/src/graphql/objects/LeavesSwapRequest.d.ts +0 -42
  156. package/dist/spark-sdk/src/graphql/objects/LeavesSwapRequest.js +0 -123
  157. package/dist/spark-sdk/src/graphql/objects/LeavesSwapRequest.js.map +0 -1
  158. package/dist/spark-sdk/src/graphql/objects/LightningReceiveFeeEstimateInput.d.ts +0 -8
  159. package/dist/spark-sdk/src/graphql/objects/LightningReceiveFeeEstimateInput.js +0 -15
  160. package/dist/spark-sdk/src/graphql/objects/LightningReceiveFeeEstimateInput.js.map +0 -1
  161. package/dist/spark-sdk/src/graphql/objects/LightningReceiveFeeEstimateOutput.d.ts +0 -8
  162. package/dist/spark-sdk/src/graphql/objects/LightningReceiveFeeEstimateOutput.js +0 -26
  163. package/dist/spark-sdk/src/graphql/objects/LightningReceiveFeeEstimateOutput.js.map +0 -1
  164. package/dist/spark-sdk/src/graphql/objects/LightningReceiveRequest.d.ts +0 -34
  165. package/dist/spark-sdk/src/graphql/objects/LightningReceiveRequest.js +0 -97
  166. package/dist/spark-sdk/src/graphql/objects/LightningReceiveRequest.js.map +0 -1
  167. package/dist/spark-sdk/src/graphql/objects/LightningReceiveRequestStatus.d.ts +0 -18
  168. package/dist/spark-sdk/src/graphql/objects/LightningReceiveRequestStatus.js +0 -21
  169. package/dist/spark-sdk/src/graphql/objects/LightningReceiveRequestStatus.js.map +0 -1
  170. package/dist/spark-sdk/src/graphql/objects/LightningSendFeeEstimateInput.d.ts +0 -6
  171. package/dist/spark-sdk/src/graphql/objects/LightningSendFeeEstimateInput.js +0 -12
  172. package/dist/spark-sdk/src/graphql/objects/LightningSendFeeEstimateInput.js.map +0 -1
  173. package/dist/spark-sdk/src/graphql/objects/LightningSendFeeEstimateOutput.d.ts +0 -8
  174. package/dist/spark-sdk/src/graphql/objects/LightningSendFeeEstimateOutput.js +0 -26
  175. package/dist/spark-sdk/src/graphql/objects/LightningSendFeeEstimateOutput.js.map +0 -1
  176. package/dist/spark-sdk/src/graphql/objects/LightningSendRequest.d.ts +0 -35
  177. package/dist/spark-sdk/src/graphql/objects/LightningSendRequest.js +0 -82
  178. package/dist/spark-sdk/src/graphql/objects/LightningSendRequest.js.map +0 -1
  179. package/dist/spark-sdk/src/graphql/objects/LightningSendRequestStatus.d.ts +0 -15
  180. package/dist/spark-sdk/src/graphql/objects/LightningSendRequestStatus.js +0 -18
  181. package/dist/spark-sdk/src/graphql/objects/LightningSendRequestStatus.js.map +0 -1
  182. package/dist/spark-sdk/src/graphql/objects/NotifyReceiverTransferInput.d.ts +0 -7
  183. package/dist/spark-sdk/src/graphql/objects/NotifyReceiverTransferInput.js +0 -14
  184. package/dist/spark-sdk/src/graphql/objects/NotifyReceiverTransferInput.js.map +0 -1
  185. package/dist/spark-sdk/src/graphql/objects/PageInfo.d.ts +0 -11
  186. package/dist/spark-sdk/src/graphql/objects/PageInfo.js +0 -26
  187. package/dist/spark-sdk/src/graphql/objects/PageInfo.js.map +0 -1
  188. package/dist/spark-sdk/src/graphql/objects/Provider.d.ts +0 -7
  189. package/dist/spark-sdk/src/graphql/objects/Provider.js +0 -14
  190. package/dist/spark-sdk/src/graphql/objects/Provider.js.map +0 -1
  191. package/dist/spark-sdk/src/graphql/objects/RequestCoopExitInput.d.ts +0 -7
  192. package/dist/spark-sdk/src/graphql/objects/RequestCoopExitInput.js +0 -14
  193. package/dist/spark-sdk/src/graphql/objects/RequestCoopExitInput.js.map +0 -1
  194. package/dist/spark-sdk/src/graphql/objects/RequestCoopExitOutput.d.ts +0 -7
  195. package/dist/spark-sdk/src/graphql/objects/RequestCoopExitOutput.js +0 -19
  196. package/dist/spark-sdk/src/graphql/objects/RequestCoopExitOutput.js.map +0 -1
  197. package/dist/spark-sdk/src/graphql/objects/RequestLeavesSwapInput.d.ts +0 -11
  198. package/dist/spark-sdk/src/graphql/objects/RequestLeavesSwapInput.js +0 -22
  199. package/dist/spark-sdk/src/graphql/objects/RequestLeavesSwapInput.js.map +0 -1
  200. package/dist/spark-sdk/src/graphql/objects/RequestLeavesSwapOutput.d.ts +0 -7
  201. package/dist/spark-sdk/src/graphql/objects/RequestLeavesSwapOutput.js +0 -19
  202. package/dist/spark-sdk/src/graphql/objects/RequestLeavesSwapOutput.js.map +0 -1
  203. package/dist/spark-sdk/src/graphql/objects/RequestLightningReceiveInput.d.ts +0 -16
  204. package/dist/spark-sdk/src/graphql/objects/RequestLightningReceiveInput.js +0 -21
  205. package/dist/spark-sdk/src/graphql/objects/RequestLightningReceiveInput.js.map +0 -1
  206. package/dist/spark-sdk/src/graphql/objects/RequestLightningReceiveOutput.d.ts +0 -7
  207. package/dist/spark-sdk/src/graphql/objects/RequestLightningReceiveOutput.js +0 -19
  208. package/dist/spark-sdk/src/graphql/objects/RequestLightningReceiveOutput.js.map +0 -1
  209. package/dist/spark-sdk/src/graphql/objects/RequestLightningSendInput.d.ts +0 -7
  210. package/dist/spark-sdk/src/graphql/objects/RequestLightningSendInput.js +0 -14
  211. package/dist/spark-sdk/src/graphql/objects/RequestLightningSendInput.js.map +0 -1
  212. package/dist/spark-sdk/src/graphql/objects/RequestLightningSendOutput.d.ts +0 -7
  213. package/dist/spark-sdk/src/graphql/objects/RequestLightningSendOutput.js +0 -19
  214. package/dist/spark-sdk/src/graphql/objects/RequestLightningSendOutput.js.map +0 -1
  215. package/dist/spark-sdk/src/graphql/objects/SparkCoopExitRequestStatus.d.ts +0 -14
  216. package/dist/spark-sdk/src/graphql/objects/SparkCoopExitRequestStatus.js +0 -17
  217. package/dist/spark-sdk/src/graphql/objects/SparkCoopExitRequestStatus.js.map +0 -1
  218. package/dist/spark-sdk/src/graphql/objects/SparkLeavesSwapRequestStatus.d.ts +0 -14
  219. package/dist/spark-sdk/src/graphql/objects/SparkLeavesSwapRequestStatus.js +0 -17
  220. package/dist/spark-sdk/src/graphql/objects/SparkLeavesSwapRequestStatus.js.map +0 -1
  221. package/dist/spark-sdk/src/graphql/objects/SparkTransferToLeavesConnection.d.ts +0 -19
  222. package/dist/spark-sdk/src/graphql/objects/SparkTransferToLeavesConnection.js +0 -45
  223. package/dist/spark-sdk/src/graphql/objects/SparkTransferToLeavesConnection.js.map +0 -1
  224. package/dist/spark-sdk/src/graphql/objects/SparkWalletUser.d.ts +0 -21
  225. package/dist/spark-sdk/src/graphql/objects/SparkWalletUser.js +0 -45
  226. package/dist/spark-sdk/src/graphql/objects/SparkWalletUser.js.map +0 -1
  227. package/dist/spark-sdk/src/graphql/objects/StartSeedReleaseInput.d.ts +0 -6
  228. package/dist/spark-sdk/src/graphql/objects/StartSeedReleaseInput.js +0 -12
  229. package/dist/spark-sdk/src/graphql/objects/StartSeedReleaseInput.js.map +0 -1
  230. package/dist/spark-sdk/src/graphql/objects/SwapLeaf.d.ts +0 -9
  231. package/dist/spark-sdk/src/graphql/objects/SwapLeaf.js +0 -23
  232. package/dist/spark-sdk/src/graphql/objects/SwapLeaf.js.map +0 -1
  233. package/dist/spark-sdk/src/graphql/objects/Transfer.d.ts +0 -24
  234. package/dist/spark-sdk/src/graphql/objects/Transfer.js +0 -82
  235. package/dist/spark-sdk/src/graphql/objects/Transfer.js.map +0 -1
  236. package/dist/spark-sdk/src/graphql/objects/UserLeafInput.d.ts +0 -8
  237. package/dist/spark-sdk/src/graphql/objects/UserLeafInput.js +0 -16
  238. package/dist/spark-sdk/src/graphql/objects/UserLeafInput.js.map +0 -1
  239. package/dist/spark-sdk/src/graphql/objects/UserRequest.d.ts +0 -22
  240. package/dist/spark-sdk/src/graphql/objects/UserRequest.js +0 -310
  241. package/dist/spark-sdk/src/graphql/objects/UserRequest.js.map +0 -1
  242. package/dist/spark-sdk/src/graphql/objects/VerifyChallengeInput.d.ts +0 -10
  243. package/dist/spark-sdk/src/graphql/objects/VerifyChallengeInput.js +0 -20
  244. package/dist/spark-sdk/src/graphql/objects/VerifyChallengeInput.js.map +0 -1
  245. package/dist/spark-sdk/src/graphql/objects/VerifyChallengeOutput.d.ts +0 -7
  246. package/dist/spark-sdk/src/graphql/objects/VerifyChallengeOutput.js +0 -17
  247. package/dist/spark-sdk/src/graphql/objects/VerifyChallengeOutput.js.map +0 -1
  248. package/dist/spark-sdk/src/graphql/objects/WalletUserIdentityPublicKeyInput.d.ts +0 -6
  249. package/dist/spark-sdk/src/graphql/objects/WalletUserIdentityPublicKeyInput.js +0 -12
  250. package/dist/spark-sdk/src/graphql/objects/WalletUserIdentityPublicKeyInput.js.map +0 -1
  251. package/dist/spark-sdk/src/graphql/objects/WalletUserIdentityPublicKeyOutput.d.ts +0 -7
  252. package/dist/spark-sdk/src/graphql/objects/WalletUserIdentityPublicKeyOutput.js +0 -17
  253. package/dist/spark-sdk/src/graphql/objects/WalletUserIdentityPublicKeyOutput.js.map +0 -1
  254. package/dist/spark-sdk/src/graphql/objects/index.d.ts +0 -53
  255. package/dist/spark-sdk/src/graphql/objects/index.js +0 -14
  256. package/dist/spark-sdk/src/graphql/objects/index.js.map +0 -1
  257. package/dist/spark-sdk/src/graphql/queries/CoopExitFeeEstimate.d.ts +0 -1
  258. package/dist/spark-sdk/src/graphql/queries/CoopExitFeeEstimate.js +0 -18
  259. package/dist/spark-sdk/src/graphql/queries/CoopExitFeeEstimate.js.map +0 -1
  260. package/dist/spark-sdk/src/graphql/queries/LeavesSwapFeeEstimate.d.ts +0 -1
  261. package/dist/spark-sdk/src/graphql/queries/LeavesSwapFeeEstimate.js +0 -16
  262. package/dist/spark-sdk/src/graphql/queries/LeavesSwapFeeEstimate.js.map +0 -1
  263. package/dist/spark-sdk/src/graphql/queries/LightningReceiveFeeEstimate.d.ts +0 -1
  264. package/dist/spark-sdk/src/graphql/queries/LightningReceiveFeeEstimate.js +0 -18
  265. package/dist/spark-sdk/src/graphql/queries/LightningReceiveFeeEstimate.js.map +0 -1
  266. package/dist/spark-sdk/src/graphql/queries/LightningSendFeeEstimate.d.ts +0 -1
  267. package/dist/spark-sdk/src/graphql/queries/LightningSendFeeEstimate.js +0 -16
  268. package/dist/spark-sdk/src/graphql/queries/LightningSendFeeEstimate.js.map +0 -1
  269. package/dist/spark-sdk/src/graphql/queries/UserRequest.d.ts +0 -1
  270. package/dist/spark-sdk/src/graphql/queries/UserRequest.js +0 -10
  271. package/dist/spark-sdk/src/graphql/queries/UserRequest.js.map +0 -1
  272. package/dist/spark-sdk/src/proto/common.d.ts +0 -58
  273. package/dist/spark-sdk/src/proto/common.js +0 -350
  274. package/dist/spark-sdk/src/proto/common.js.map +0 -1
  275. package/dist/spark-sdk/src/proto/google/protobuf/empty.d.ts +0 -33
  276. package/dist/spark-sdk/src/proto/google/protobuf/empty.js +0 -46
  277. package/dist/spark-sdk/src/proto/google/protobuf/empty.js.map +0 -1
  278. package/dist/spark-sdk/src/proto/google/protobuf/timestamp.d.ts +0 -128
  279. package/dist/spark-sdk/src/proto/google/protobuf/timestamp.js +0 -90
  280. package/dist/spark-sdk/src/proto/google/protobuf/timestamp.js.map +0 -1
  281. package/dist/spark-sdk/src/proto/mock.d.ts +0 -48
  282. package/dist/spark-sdk/src/proto/mock.js +0 -103
  283. package/dist/spark-sdk/src/proto/mock.js.map +0 -1
  284. package/dist/spark-sdk/src/proto/spark.d.ts +0 -1209
  285. package/dist/spark-sdk/src/proto/spark.js +0 -10516
  286. package/dist/spark-sdk/src/proto/spark.js.map +0 -1
  287. package/dist/spark-sdk/src/proto/spark_authn.d.ts +0 -111
  288. package/dist/spark-sdk/src/proto/spark_authn.js +0 -517
  289. package/dist/spark-sdk/src/proto/spark_authn.js.map +0 -1
  290. package/dist/spark-sdk/src/services/config.d.ts +0 -17
  291. package/dist/spark-sdk/src/services/config.js +0 -54
  292. package/dist/spark-sdk/src/services/config.js.map +0 -1
  293. package/dist/spark-sdk/src/services/connection.d.ts +0 -22
  294. package/dist/spark-sdk/src/services/connection.js +0 -180
  295. package/dist/spark-sdk/src/services/connection.js.map +0 -1
  296. package/dist/spark-sdk/src/services/coop-exit.d.ts +0 -20
  297. package/dist/spark-sdk/src/services/coop-exit.js +0 -101
  298. package/dist/spark-sdk/src/services/coop-exit.js.map +0 -1
  299. package/dist/spark-sdk/src/services/deposit.d.ts +0 -21
  300. package/dist/spark-sdk/src/services/deposit.js +0 -214
  301. package/dist/spark-sdk/src/services/deposit.js.map +0 -1
  302. package/dist/spark-sdk/src/services/lightning.d.ts +0 -32
  303. package/dist/spark-sdk/src/services/lightning.js +0 -210
  304. package/dist/spark-sdk/src/services/lightning.js.map +0 -1
  305. package/dist/spark-sdk/src/services/lrc20.d.ts +0 -5
  306. package/dist/spark-sdk/src/services/lrc20.js +0 -27
  307. package/dist/spark-sdk/src/services/lrc20.js.map +0 -1
  308. package/dist/spark-sdk/src/services/token-transactions.d.ts +0 -16
  309. package/dist/spark-sdk/src/services/token-transactions.js +0 -299
  310. package/dist/spark-sdk/src/services/token-transactions.js.map +0 -1
  311. package/dist/spark-sdk/src/services/transfer.d.ts +0 -66
  312. package/dist/spark-sdk/src/services/transfer.js +0 -791
  313. package/dist/spark-sdk/src/services/transfer.js.map +0 -1
  314. package/dist/spark-sdk/src/services/tree-creation.d.ts +0 -29
  315. package/dist/spark-sdk/src/services/tree-creation.js +0 -399
  316. package/dist/spark-sdk/src/services/tree-creation.js.map +0 -1
  317. package/dist/spark-sdk/src/services/wallet-config.d.ts +0 -23
  318. package/dist/spark-sdk/src/services/wallet-config.js +0 -107
  319. package/dist/spark-sdk/src/services/wallet-config.js.map +0 -1
  320. package/dist/spark-sdk/src/signer/signer.d.ts +0 -106
  321. package/dist/spark-sdk/src/signer/signer.js +0 -275
  322. package/dist/spark-sdk/src/signer/signer.js.map +0 -1
  323. package/dist/spark-sdk/src/spark-sdk.d.ts +0 -414
  324. package/dist/spark-sdk/src/spark-sdk.js +0 -1285
  325. package/dist/spark-sdk/src/spark-sdk.js.map +0 -1
  326. package/dist/spark-sdk/src/tests/utils/test-faucet.d.ts +0 -24
  327. package/dist/spark-sdk/src/tests/utils/test-faucet.js +0 -182
  328. package/dist/spark-sdk/src/tests/utils/test-faucet.js.map +0 -1
  329. package/dist/spark-sdk/src/types/grpc.d.ts +0 -6
  330. package/dist/spark-sdk/src/types/grpc.js +0 -2
  331. package/dist/spark-sdk/src/types/grpc.js.map +0 -1
  332. package/dist/spark-sdk/src/types/index.d.ts +0 -3
  333. package/dist/spark-sdk/src/types/index.js +0 -4
  334. package/dist/spark-sdk/src/types/index.js.map +0 -1
  335. package/dist/spark-sdk/src/utils/adaptor-signature.d.ts +0 -7
  336. package/dist/spark-sdk/src/utils/adaptor-signature.js +0 -114
  337. package/dist/spark-sdk/src/utils/adaptor-signature.js.map +0 -1
  338. package/dist/spark-sdk/src/utils/bitcoin.d.ts +0 -12
  339. package/dist/spark-sdk/src/utils/bitcoin.js +0 -87
  340. package/dist/spark-sdk/src/utils/bitcoin.js.map +0 -1
  341. package/dist/spark-sdk/src/utils/crypto.d.ts +0 -1
  342. package/dist/spark-sdk/src/utils/crypto.js +0 -14
  343. package/dist/spark-sdk/src/utils/crypto.js.map +0 -1
  344. package/dist/spark-sdk/src/utils/index.d.ts +0 -12
  345. package/dist/spark-sdk/src/utils/index.js +0 -13
  346. package/dist/spark-sdk/src/utils/index.js.map +0 -1
  347. package/dist/spark-sdk/src/utils/keys.d.ts +0 -9
  348. package/dist/spark-sdk/src/utils/keys.js +0 -73
  349. package/dist/spark-sdk/src/utils/keys.js.map +0 -1
  350. package/dist/spark-sdk/src/utils/mempool.d.ts +0 -1
  351. package/dist/spark-sdk/src/utils/mempool.js +0 -29
  352. package/dist/spark-sdk/src/utils/mempool.js.map +0 -1
  353. package/dist/spark-sdk/src/utils/network.d.ts +0 -36
  354. package/dist/spark-sdk/src/utils/network.js +0 -65
  355. package/dist/spark-sdk/src/utils/network.js.map +0 -1
  356. package/dist/spark-sdk/src/utils/proof.d.ts +0 -1
  357. package/dist/spark-sdk/src/utils/proof.js +0 -12
  358. package/dist/spark-sdk/src/utils/proof.js.map +0 -1
  359. package/dist/spark-sdk/src/utils/response-validation.d.ts +0 -1
  360. package/dist/spark-sdk/src/utils/response-validation.js +0 -16
  361. package/dist/spark-sdk/src/utils/response-validation.js.map +0 -1
  362. package/dist/spark-sdk/src/utils/secret-sharing.d.ts +0 -26
  363. package/dist/spark-sdk/src/utils/secret-sharing.js +0 -174
  364. package/dist/spark-sdk/src/utils/secret-sharing.js.map +0 -1
  365. package/dist/spark-sdk/src/utils/signing.d.ts +0 -12
  366. package/dist/spark-sdk/src/utils/signing.js +0 -67
  367. package/dist/spark-sdk/src/utils/signing.js.map +0 -1
  368. package/dist/spark-sdk/src/utils/token-hashing.d.ts +0 -3
  369. package/dist/spark-sdk/src/utils/token-hashing.js +0 -116
  370. package/dist/spark-sdk/src/utils/token-hashing.js.map +0 -1
  371. package/dist/spark-sdk/src/utils/token-keyshares.d.ts +0 -5
  372. package/dist/spark-sdk/src/utils/token-keyshares.js +0 -17
  373. package/dist/spark-sdk/src/utils/token-keyshares.js.map +0 -1
  374. package/dist/spark-sdk/src/utils/token-transactions.d.ts +0 -5
  375. package/dist/spark-sdk/src/utils/token-transactions.js +0 -40
  376. package/dist/spark-sdk/src/utils/token-transactions.js.map +0 -1
  377. package/dist/spark-sdk/src/utils/transaction.d.ts +0 -9
  378. package/dist/spark-sdk/src/utils/transaction.js +0 -35
  379. package/dist/spark-sdk/src/utils/transaction.js.map +0 -1
  380. package/dist/spark-sdk/src/utils/wasm-wrapper.d.ts +0 -2
  381. package/dist/spark-sdk/src/utils/wasm-wrapper.js +0 -46
  382. package/dist/spark-sdk/src/utils/wasm-wrapper.js.map +0 -1
  383. package/dist/spark-sdk/src/utils/wasm.d.ts +0 -54
  384. package/dist/spark-sdk/src/utils/wasm.js +0 -26
  385. package/dist/spark-sdk/src/utils/wasm.js.map +0 -1
@@ -0,0 +1,110 @@
1
+ import { CreateLightningInvoiceParams, PayLightningInvoiceParams, TokenInfo, SparkWallet, SparkWalletProps } from '@buildonspark/spark-sdk';
2
+ import { QueryAllTransfersResponse, Transfer, LeafWithPreviousTransactionData, TokenTransactionWithStatus } from '@buildonspark/spark-sdk/proto/spark';
3
+ import { ListAllTokenTransactionsCursor, OperationType } from '@buildonspark/lrc20-sdk/proto/rpc/v1/types';
4
+ import { LRCWallet } from '@buildonspark/lrc20-sdk';
5
+ import { LightningReceiveRequest } from '@buildonspark/spark-sdk/types';
6
+ import { GetTokenActivityResponse, TokenPubKeyInfoResponse } from './types.js';
7
+
8
+ /**
9
+ * Interface for the IssuerSparkWallet that includes all functions from both SparkWallet and IssuerSparkWallet
10
+ */
11
+ interface IssuerWalletInterface {
12
+ getIdentityPublicKey(): Promise<string>;
13
+ getSparkAddress(): Promise<string>;
14
+ getTransfers(limit?: number, offset?: number): Promise<QueryAllTransfersResponse>;
15
+ getBalance(forceRefetch?: boolean): Promise<{
16
+ balance: bigint;
17
+ tokenBalances: Map<string, {
18
+ balance: bigint;
19
+ }>;
20
+ }>;
21
+ getDepositAddress(): Promise<string>;
22
+ transfer(params: {
23
+ receiverSparkAddress: string;
24
+ amountSats: number;
25
+ }): Promise<Transfer | string>;
26
+ createLightningInvoice(params: CreateLightningInvoiceParams): Promise<LightningReceiveRequest>;
27
+ payLightningInvoice(params: PayLightningInvoiceParams): Promise<any>;
28
+ withdraw(params: {
29
+ onchainAddress: string;
30
+ amountSats?: number;
31
+ }): Promise<any>;
32
+ transferTokens(params: {
33
+ tokenPublicKey: string;
34
+ tokenAmount: bigint;
35
+ receiverSparkAddress: string;
36
+ selectedLeaves?: LeafWithPreviousTransactionData[];
37
+ }): Promise<string>;
38
+ getIssuerTokenPublicKey(): Promise<string>;
39
+ getIssuerTokenBalance(): Promise<{
40
+ balance: bigint;
41
+ }>;
42
+ mintTokens(tokenAmount: bigint): Promise<string>;
43
+ getTokenActivity(pageSize: number, cursor?: ListAllTokenTransactionsCursor, operationTypes?: OperationType[], beforeTimestamp?: Date): Promise<GetTokenActivityResponse>;
44
+ getIssuerTokenActivity(pageSize: number, cursor?: ListAllTokenTransactionsCursor, operationTypes?: OperationType[], beforeTimestamp?: Date, afterTimestamp?: Date): Promise<GetTokenActivityResponse>;
45
+ getTokenTransactions(tokenPublicKeys: string[], tokenTransactionHashes?: string[]): Promise<TokenTransactionWithStatus[]>;
46
+ getTokenInfo(): Promise<TokenInfo[]>;
47
+ getIssuerTokenInfo(): Promise<TokenPubKeyInfoResponse | null>;
48
+ burnTokens(tokenAmount: bigint, selectedLeaves?: LeafWithPreviousTransactionData[]): Promise<string>;
49
+ freezeTokens(ownerPublicKey: string): Promise<{
50
+ impactedLeafIds: string[];
51
+ impactedTokenAmount: bigint;
52
+ }>;
53
+ unfreezeTokens(ownerPublicKey: string): Promise<{
54
+ impactedLeafIds: string[];
55
+ impactedTokenAmount: bigint;
56
+ }>;
57
+ getTokenL1Address(): Promise<string>;
58
+ announceTokenL1(params: {
59
+ lrc20Wallet: LRCWallet;
60
+ tokenName: string;
61
+ tokenTicker: string;
62
+ decimals: number;
63
+ maxSupply: bigint;
64
+ isFreezable: boolean;
65
+ feeRateSatsPerVb?: number;
66
+ }): Promise<string>;
67
+ mintTokensL1(tokenAmount: bigint): Promise<string>;
68
+ transferTokensL1(tokenAmount: bigint, p2trAddress: string): Promise<string>;
69
+ }
70
+
71
+ declare class IssuerSparkWallet extends SparkWallet implements IssuerWalletInterface {
72
+ private issuerTokenTransactionService;
73
+ private tokenFreezeService;
74
+ private tokenPublicKeyInfo?;
75
+ static initialize(options: SparkWalletProps): Promise<{
76
+ mnemonic?: string | undefined;
77
+ wallet: IssuerSparkWallet;
78
+ }>;
79
+ private constructor();
80
+ private initIssuerWallet;
81
+ getIssuerTokenBalance(): Promise<{
82
+ balance: bigint;
83
+ }>;
84
+ getIssuerTokenInfo(): Promise<TokenPubKeyInfoResponse | null>;
85
+ getIssuerTokenPublicKey(): Promise<string>;
86
+ mintTokens(tokenAmount: bigint): Promise<string>;
87
+ burnTokens(tokenAmount: bigint, selectedLeaves?: LeafWithPreviousTransactionData[]): Promise<string>;
88
+ freezeTokens(ownerPublicKey: string): Promise<{
89
+ impactedLeafIds: string[];
90
+ impactedTokenAmount: bigint;
91
+ }>;
92
+ unfreezeTokens(ownerPublicKey: string): Promise<{
93
+ impactedLeafIds: string[];
94
+ impactedTokenAmount: bigint;
95
+ }>;
96
+ getTokenActivity(pageSize?: number, cursor?: ListAllTokenTransactionsCursor, operationTypes?: OperationType[], beforeTimestamp?: Date, afterTimestamp?: Date): Promise<GetTokenActivityResponse>;
97
+ getIssuerTokenActivity(pageSize?: number, cursor?: ListAllTokenTransactionsCursor, operationTypes?: OperationType[], beforeTimestamp?: Date, afterTimestamp?: Date): Promise<GetTokenActivityResponse>;
98
+ announceTokenL1({ tokenName, tokenTicker, decimals, maxSupply, isFreezable, feeRateSatsPerVb, }: {
99
+ tokenName: any;
100
+ tokenTicker: any;
101
+ decimals: any;
102
+ maxSupply: any;
103
+ isFreezable: any;
104
+ feeRateSatsPerVb?: number | undefined;
105
+ }): Promise<string>;
106
+ mintTokensL1(tokenAmount: bigint): Promise<string>;
107
+ transferTokensL1(tokenAmount: bigint, p2trAddress: string): Promise<string>;
108
+ }
109
+
110
+ export { IssuerSparkWallet };
package/dist/index.js ADDED
@@ -0,0 +1,497 @@
1
+ import "./chunk-GB7N6I5O.js";
2
+
3
+ // src/issuer-spark-wallet.ts
4
+ import {
5
+ LRCWallet,
6
+ TokenPubkey,
7
+ TokenPubkeyAnnouncement
8
+ } from "@buildonspark/lrc20-sdk";
9
+ import { SparkWallet } from "@buildonspark/spark-sdk";
10
+ import {
11
+ getMasterHDKeyFromSeed,
12
+ LRC_WALLET_NETWORK,
13
+ LRC_WALLET_NETWORK_TYPE,
14
+ Network
15
+ } from "@buildonspark/spark-sdk/utils";
16
+ import {
17
+ bytesToHex as bytesToHex2,
18
+ bytesToNumberBE as bytesToNumberBE2,
19
+ hexToBytes
20
+ } from "@noble/curves/abstract/utils";
21
+ import { validateMnemonic } from "@scure/bip39";
22
+ import { wordlist } from "@scure/bip39/wordlists/english";
23
+
24
+ // src/services/freeze.ts
25
+ import { validateResponses } from "@buildonspark/spark-sdk/utils";
26
+
27
+ // src/utils/token-hashing.ts
28
+ import { sha256 } from "@scure/btc-signer/utils";
29
+ function hashFreezeTokensPayload(payload) {
30
+ if (!payload) {
31
+ throw new Error("freeze tokens payload cannot be nil");
32
+ }
33
+ let allHashes = [];
34
+ const ownerPubKeyHash = sha256.create();
35
+ if (payload.ownerPublicKey) {
36
+ ownerPubKeyHash.update(payload.ownerPublicKey);
37
+ }
38
+ allHashes.push(ownerPubKeyHash.digest());
39
+ const tokenPubKeyHash = sha256.create();
40
+ if (payload.tokenPublicKey) {
41
+ tokenPubKeyHash.update(payload.tokenPublicKey);
42
+ }
43
+ allHashes.push(tokenPubKeyHash.digest());
44
+ const shouldUnfreezeHash = sha256.create();
45
+ shouldUnfreezeHash.update(new Uint8Array([payload.shouldUnfreeze ? 1 : 0]));
46
+ allHashes.push(shouldUnfreezeHash.digest());
47
+ const timestampHash = sha256.create();
48
+ if (payload.issuerProvidedTimestamp) {
49
+ const timestampBytes = new Uint8Array(8);
50
+ new DataView(timestampBytes.buffer).setBigUint64(
51
+ 0,
52
+ BigInt(payload.issuerProvidedTimestamp),
53
+ true
54
+ // true for little-endian
55
+ );
56
+ timestampHash.update(timestampBytes);
57
+ }
58
+ allHashes.push(timestampHash.digest());
59
+ const operatorPubKeyHash = sha256.create();
60
+ if (payload.operatorIdentityPublicKey) {
61
+ operatorPubKeyHash.update(payload.operatorIdentityPublicKey);
62
+ }
63
+ allHashes.push(operatorPubKeyHash.digest());
64
+ const finalHash = sha256.create();
65
+ for (const hash of allHashes) {
66
+ finalHash.update(hash);
67
+ }
68
+ return finalHash.digest();
69
+ }
70
+
71
+ // src/services/freeze.ts
72
+ var TokenFreezeService = class {
73
+ config;
74
+ connectionManager;
75
+ constructor(config, connectionManager) {
76
+ this.config = config;
77
+ this.connectionManager = connectionManager;
78
+ }
79
+ async freezeTokens(ownerPublicKey, tokenPublicKey) {
80
+ return this.freezeOperation(ownerPublicKey, tokenPublicKey, false);
81
+ }
82
+ async unfreezeTokens(ownerPublicKey, tokenPublicKey) {
83
+ return this.freezeOperation(ownerPublicKey, tokenPublicKey, true);
84
+ }
85
+ async freezeOperation(ownerPublicKey, tokenPublicKey, shouldUnfreeze) {
86
+ const signingOperators = this.config.getSigningOperators();
87
+ const issuerProvidedTimestamp = Date.now();
88
+ const freezeResponses = await Promise.allSettled(
89
+ Object.entries(signingOperators).map(async ([identifier, operator]) => {
90
+ const internalSparkClient = await this.connectionManager.createSparkClient(operator.address);
91
+ const freezeTokensPayload = {
92
+ ownerPublicKey,
93
+ tokenPublicKey,
94
+ shouldUnfreeze,
95
+ issuerProvidedTimestamp,
96
+ operatorIdentityPublicKey: operator.identityPublicKey
97
+ };
98
+ const hashedPayload = hashFreezeTokensPayload(freezeTokensPayload);
99
+ const issuerSignature = await this.config.signer.signMessageWithIdentityKey(hashedPayload);
100
+ const response = await internalSparkClient.freeze_tokens({
101
+ freezeTokensPayload,
102
+ issuerSignature
103
+ });
104
+ return {
105
+ identifier,
106
+ response
107
+ };
108
+ })
109
+ );
110
+ const successfulResponses = validateResponses(freezeResponses);
111
+ return successfulResponses[0].response;
112
+ }
113
+ };
114
+
115
+ // src/services/token-transactions.ts
116
+ import { TokenTransactionService } from "@buildonspark/spark-sdk/token-transactions";
117
+ import { numberToBytesBE } from "@noble/curves/abstract/utils";
118
+ var IssuerTokenTransactionService = class extends TokenTransactionService {
119
+ constructor(config, connectionManager) {
120
+ super(config, connectionManager);
121
+ }
122
+ async constructMintTokenTransaction(tokenPublicKey, tokenAmount) {
123
+ return {
124
+ tokenInput: {
125
+ $case: "mintInput",
126
+ mintInput: {
127
+ issuerPublicKey: tokenPublicKey,
128
+ issuerProvidedTimestamp: Date.now()
129
+ }
130
+ },
131
+ outputLeaves: [
132
+ {
133
+ ownerPublicKey: tokenPublicKey,
134
+ tokenPublicKey,
135
+ tokenAmount: numberToBytesBE(tokenAmount, 16)
136
+ }
137
+ ],
138
+ sparkOperatorIdentityPublicKeys: super.collectOperatorIdentityPublicKeys()
139
+ };
140
+ }
141
+ };
142
+
143
+ // src/utils/type-mappers.ts
144
+ import { bytesToHex, bytesToNumberBE } from "@noble/curves/abstract/utils";
145
+
146
+ // src/utils/enum-mappers.ts
147
+ import { Lrc20Protos } from "@buildonspark/lrc20-sdk";
148
+ function mapOperationType(type) {
149
+ switch (type) {
150
+ case Lrc20Protos.OperationType.USER_TRANSFER:
151
+ return "USER_TRANSFER" /* USER_TRANSFER */;
152
+ case Lrc20Protos.OperationType.USER_BURN:
153
+ return "USER_BURN" /* USER_BURN */;
154
+ case Lrc20Protos.OperationType.ISSUER_ANNOUNCE:
155
+ return "ISSUER_ANNOUNCE" /* ISSUER_ANNOUNCE */;
156
+ case Lrc20Protos.OperationType.ISSUER_MINT:
157
+ return "ISSUER_MINT" /* ISSUER_MINT */;
158
+ case Lrc20Protos.OperationType.ISSUER_TRANSFER:
159
+ return "ISSUER_TRANSFER" /* ISSUER_TRANSFER */;
160
+ case Lrc20Protos.OperationType.ISSUER_FREEZE:
161
+ return "ISSUER_FREEZE" /* ISSUER_FREEZE */;
162
+ case Lrc20Protos.OperationType.ISSUER_UNFREEZE:
163
+ return "ISSUER_UNFREEZE" /* ISSUER_UNFREEZE */;
164
+ case Lrc20Protos.OperationType.ISSUER_BURN:
165
+ return "ISSUER_BURN" /* ISSUER_BURN */;
166
+ default:
167
+ return "USER_TRANSFER" /* USER_TRANSFER */;
168
+ }
169
+ }
170
+ function mapOnChainTransactionStatus(status) {
171
+ switch (status) {
172
+ case Lrc20Protos.OnChainTransactionStatus.PENDING:
173
+ return "PENDING" /* PENDING */;
174
+ case Lrc20Protos.OnChainTransactionStatus.CONFIRMED:
175
+ return "CONFIRMED" /* CONFIRMED */;
176
+ case Lrc20Protos.OnChainTransactionStatus.WAITING_MINED:
177
+ return "WAITING_MINED" /* WAITING_MINED */;
178
+ case Lrc20Protos.OnChainTransactionStatus.MINED:
179
+ return "MINED" /* MINED */;
180
+ case Lrc20Protos.OnChainTransactionStatus.ATTACHING:
181
+ return "ATTACHING" /* ATTACHING */;
182
+ case Lrc20Protos.OnChainTransactionStatus.ATTACHED:
183
+ return "ATTACHED" /* ATTACHED */;
184
+ default:
185
+ return "PENDING" /* PENDING */;
186
+ }
187
+ }
188
+ function mapSparkTransactionStatus(status) {
189
+ switch (status) {
190
+ case Lrc20Protos.SparkTransactionStatus.STARTED:
191
+ return "STARTED" /* STARTED */;
192
+ case Lrc20Protos.SparkTransactionStatus.SIGNED:
193
+ return "SIGNED" /* SIGNED */;
194
+ case Lrc20Protos.SparkTransactionStatus.FINALIZED:
195
+ return "FINALIZED" /* FINALIZED */;
196
+ default:
197
+ return "STARTED" /* STARTED */;
198
+ }
199
+ }
200
+ function mapLayer(layer) {
201
+ switch (layer) {
202
+ case 0:
203
+ return "L1" /* L1 */;
204
+ case 1:
205
+ return "SPARK" /* SPARK */;
206
+ default:
207
+ return "L1" /* L1 */;
208
+ }
209
+ }
210
+
211
+ // src/utils/type-mappers.ts
212
+ function convertToTokenPubKeyInfoResponse(tokenPubkeyInfo) {
213
+ return {
214
+ announcement: tokenPubkeyInfo?.announcement ? {
215
+ tokenPubkey: {
216
+ pubkey: bytesToHex(tokenPubkeyInfo.announcement.tokenPubkey.pubkey)
217
+ },
218
+ name: tokenPubkeyInfo.announcement.name,
219
+ symbol: tokenPubkeyInfo.announcement.symbol,
220
+ decimal: tokenPubkeyInfo.announcement.decimal,
221
+ maxSupply: tokenPubkeyInfo.announcement.maxSupply,
222
+ isFreezable: tokenPubkeyInfo.announcement.isFreezable
223
+ } : null,
224
+ totalSupply: tokenPubkeyInfo?.totalSupply ?? "0"
225
+ };
226
+ }
227
+ function convertTokenActivityToHexEncoded(rawTransactions) {
228
+ const response = {
229
+ transactions: rawTransactions.transactions.map((transaction) => {
230
+ if (!transaction.transaction) {
231
+ return { transaction: void 0 };
232
+ }
233
+ if (transaction.transaction.$case === "onChain") {
234
+ const onChain = transaction.transaction.onChain;
235
+ return {
236
+ transaction: {
237
+ $case: "onChain",
238
+ onChain: {
239
+ operationType: mapOperationType(onChain.operationType),
240
+ transactionHash: bytesToHex(onChain.transactionHash),
241
+ rawtx: bytesToHex(onChain.rawtx),
242
+ status: mapOnChainTransactionStatus(onChain.status),
243
+ inputs: onChain.inputs.map((input) => ({
244
+ rawTx: bytesToHex(input.rawTx),
245
+ vout: input.vout,
246
+ amountSats: input.amountSats,
247
+ tokenPublicKey: input.tokenPublicKey,
248
+ tokenAmount: input.tokenAmount ? bytesToNumberBE(input.tokenAmount).toString() : void 0
249
+ })),
250
+ outputs: onChain.outputs.map((output) => ({
251
+ rawTx: bytesToHex(output.rawTx),
252
+ vout: output.vout,
253
+ amountSats: output.amountSats,
254
+ tokenPublicKey: output.tokenPublicKey,
255
+ tokenAmount: output.tokenAmount ? bytesToNumberBE(output.tokenAmount).toString() : void 0
256
+ })),
257
+ broadcastedAt: onChain.broadcastedAt,
258
+ confirmedAt: onChain.confirmedAt
259
+ }
260
+ }
261
+ };
262
+ } else if (transaction.transaction.$case === "spark") {
263
+ const spark = transaction.transaction.spark;
264
+ return {
265
+ transaction: {
266
+ $case: "spark",
267
+ spark: {
268
+ operationType: mapOperationType(spark.operationType),
269
+ transactionHash: bytesToHex(spark.transactionHash),
270
+ status: mapSparkTransactionStatus(spark.status),
271
+ confirmedAt: spark.confirmedAt,
272
+ leavesToCreate: spark.leavesToCreate.map((leaf) => ({
273
+ tokenPublicKey: bytesToHex(leaf.tokenPublicKey),
274
+ id: leaf.id,
275
+ ownerPublicKey: bytesToHex(leaf.ownerPublicKey),
276
+ revocationPublicKey: bytesToHex(leaf.revocationPublicKey),
277
+ withdrawalBondSats: leaf.withdrawalBondSats,
278
+ withdrawalLocktime: leaf.withdrawalLocktime,
279
+ tokenAmount: bytesToNumberBE(leaf.tokenAmount).toString(),
280
+ createTxHash: bytesToHex(leaf.createTxHash),
281
+ createTxVoutIndex: leaf.createTxVoutIndex,
282
+ spendTxHash: leaf.spendTxHash ? bytesToHex(leaf.spendTxHash) : void 0,
283
+ spendTxVoutIndex: leaf.spendTxVoutIndex,
284
+ isFrozen: leaf.isFrozen
285
+ })),
286
+ leavesToSpend: spark.leavesToSpend.map((leaf) => ({
287
+ tokenPublicKey: bytesToHex(leaf.tokenPublicKey),
288
+ id: leaf.id,
289
+ ownerPublicKey: bytesToHex(leaf.ownerPublicKey),
290
+ revocationPublicKey: bytesToHex(leaf.revocationPublicKey),
291
+ withdrawalBondSats: leaf.withdrawalBondSats,
292
+ withdrawalLocktime: leaf.withdrawalLocktime,
293
+ tokenAmount: bytesToNumberBE(leaf.tokenAmount).toString(),
294
+ createTxHash: bytesToHex(leaf.createTxHash),
295
+ createTxVoutIndex: leaf.createTxVoutIndex,
296
+ spendTxHash: leaf.spendTxHash ? bytesToHex(leaf.spendTxHash) : void 0,
297
+ spendTxVoutIndex: leaf.spendTxVoutIndex,
298
+ isFrozen: leaf.isFrozen
299
+ })),
300
+ sparkOperatorIdentityPublicKeys: spark.sparkOperatorIdentityPublicKeys.map((key) => bytesToHex(key))
301
+ }
302
+ }
303
+ };
304
+ }
305
+ return { transaction: void 0 };
306
+ }),
307
+ nextCursor: rawTransactions.nextCursor ? {
308
+ lastTransactionHash: bytesToHex(rawTransactions.nextCursor.lastTransactionHash),
309
+ layer: mapLayer(rawTransactions.nextCursor.layer)
310
+ } : void 0
311
+ };
312
+ return response;
313
+ }
314
+
315
+ // src/issuer-spark-wallet.ts
316
+ var BURN_ADDRESS = "02".repeat(33);
317
+ var IssuerSparkWallet = class _IssuerSparkWallet extends SparkWallet {
318
+ issuerTokenTransactionService;
319
+ tokenFreezeService;
320
+ tokenPublicKeyInfo;
321
+ static async initialize(options) {
322
+ const wallet = new _IssuerSparkWallet(options.options);
323
+ const initResponse = await wallet.initIssuerWallet(options.mnemonicOrSeed);
324
+ return {
325
+ wallet,
326
+ ...initResponse
327
+ };
328
+ }
329
+ constructor(configOptions) {
330
+ super(configOptions);
331
+ this.issuerTokenTransactionService = new IssuerTokenTransactionService(
332
+ this.config,
333
+ this.connectionManager
334
+ );
335
+ this.tokenFreezeService = new TokenFreezeService(
336
+ this.config,
337
+ this.connectionManager
338
+ );
339
+ }
340
+ async initIssuerWallet(mnemonicOrSeed) {
341
+ const initResponse = await super.initWallet(mnemonicOrSeed);
342
+ mnemonicOrSeed = mnemonicOrSeed || initResponse?.mnemonic;
343
+ if (mnemonicOrSeed) {
344
+ let seed;
345
+ if (typeof mnemonicOrSeed !== "string") {
346
+ seed = mnemonicOrSeed;
347
+ } else {
348
+ if (validateMnemonic(mnemonicOrSeed, wordlist)) {
349
+ seed = await this.config.signer.mnemonicToSeed(mnemonicOrSeed);
350
+ } else {
351
+ seed = hexToBytes(mnemonicOrSeed);
352
+ }
353
+ }
354
+ const hdkey = getMasterHDKeyFromSeed(seed);
355
+ const accountType = this.config.getNetwork() === Network.REGTEST ? 0 : 1;
356
+ const identityKey = hdkey.derive(`m/8797555'/${accountType}'/0'`);
357
+ const network = this.config.getNetwork();
358
+ this.lrc20Wallet = new LRCWallet(
359
+ bytesToHex2(identityKey.privateKey),
360
+ LRC_WALLET_NETWORK[network],
361
+ LRC_WALLET_NETWORK_TYPE[network]
362
+ );
363
+ }
364
+ return initResponse;
365
+ }
366
+ async getIssuerTokenBalance() {
367
+ const publicKey = await super.getIdentityPublicKey();
368
+ const balanceObj = await this.getBalance();
369
+ if (!balanceObj.tokenBalances || !balanceObj.tokenBalances.has(publicKey)) {
370
+ return {
371
+ balance: 0n
372
+ };
373
+ }
374
+ return {
375
+ balance: balanceObj.tokenBalances.get(publicKey).balance
376
+ };
377
+ }
378
+ async getIssuerTokenInfo() {
379
+ if (this.tokenPublicKeyInfo) {
380
+ return convertToTokenPubKeyInfoResponse(this.tokenPublicKeyInfo);
381
+ }
382
+ const tokenPublicKey = bytesToHex2(this.lrc20Wallet.pubkey);
383
+ const rawTokenPubkeyInfo = await this.lrc20Wallet.getTokenPubkeyInfo(tokenPublicKey);
384
+ this.tokenPublicKeyInfo = rawTokenPubkeyInfo;
385
+ if (!rawTokenPubkeyInfo) {
386
+ return null;
387
+ }
388
+ return convertToTokenPubKeyInfoResponse(rawTokenPubkeyInfo);
389
+ }
390
+ async getIssuerTokenPublicKey() {
391
+ return await super.getIdentityPublicKey();
392
+ }
393
+ async mintTokens(tokenAmount) {
394
+ var tokenPublicKey = await super.getIdentityPublicKey();
395
+ const tokenTransaction = await this.issuerTokenTransactionService.constructMintTokenTransaction(
396
+ hexToBytes(tokenPublicKey),
397
+ tokenAmount
398
+ );
399
+ return await this.issuerTokenTransactionService.broadcastTokenTransaction(
400
+ tokenTransaction
401
+ );
402
+ }
403
+ async burnTokens(tokenAmount, selectedLeaves) {
404
+ return await this.transferTokens({
405
+ tokenPublicKey: await super.getIdentityPublicKey(),
406
+ tokenAmount,
407
+ receiverSparkAddress: BURN_ADDRESS,
408
+ selectedLeaves
409
+ });
410
+ }
411
+ async freezeTokens(ownerPublicKey) {
412
+ await this.syncTokenLeaves();
413
+ const tokenPublicKey = await super.getIdentityPublicKey();
414
+ const response = await this.tokenFreezeService.freezeTokens(
415
+ hexToBytes(ownerPublicKey),
416
+ hexToBytes(tokenPublicKey)
417
+ );
418
+ const tokenAmount = bytesToNumberBE2(response.impactedTokenAmount);
419
+ return {
420
+ impactedLeafIds: response.impactedLeafIds,
421
+ impactedTokenAmount: tokenAmount
422
+ };
423
+ }
424
+ async unfreezeTokens(ownerPublicKey) {
425
+ await this.syncTokenLeaves();
426
+ const tokenPublicKey = await super.getIdentityPublicKey();
427
+ const response = await this.tokenFreezeService.unfreezeTokens(
428
+ hexToBytes(ownerPublicKey),
429
+ hexToBytes(tokenPublicKey)
430
+ );
431
+ const tokenAmount = bytesToNumberBE2(response.impactedTokenAmount);
432
+ return {
433
+ impactedLeafIds: response.impactedLeafIds,
434
+ impactedTokenAmount: tokenAmount
435
+ };
436
+ }
437
+ async getTokenActivity(pageSize = 100, cursor, operationTypes, beforeTimestamp, afterTimestamp) {
438
+ const lrc20Client = await this.lrc20ConnectionManager.createLrc20Client();
439
+ const transactions = await lrc20Client.listTransactions({
440
+ tokenPublicKey: hexToBytes(await super.getIdentityPublicKey()),
441
+ cursor,
442
+ pageSize,
443
+ beforeTimestamp,
444
+ afterTimestamp,
445
+ operationTypes
446
+ });
447
+ return convertTokenActivityToHexEncoded(transactions);
448
+ }
449
+ async getIssuerTokenActivity(pageSize = 100, cursor, operationTypes, beforeTimestamp, afterTimestamp) {
450
+ const lrc20Client = await this.lrc20ConnectionManager.createLrc20Client();
451
+ const transactions = await lrc20Client.listTransactions({
452
+ tokenPublicKey: hexToBytes(await super.getIdentityPublicKey()),
453
+ ownerPublicKey: hexToBytes(await super.getIdentityPublicKey()),
454
+ cursor,
455
+ pageSize,
456
+ beforeTimestamp,
457
+ afterTimestamp,
458
+ operationTypes
459
+ });
460
+ return convertTokenActivityToHexEncoded(transactions);
461
+ }
462
+ async announceTokenL1({
463
+ tokenName,
464
+ tokenTicker,
465
+ decimals,
466
+ maxSupply,
467
+ isFreezable,
468
+ feeRateSatsPerVb = 2
469
+ }) {
470
+ await this.lrc20Wallet.syncWallet();
471
+ const tokenPublicKey = new TokenPubkey(this.lrc20Wallet.pubkey);
472
+ const announcement = new TokenPubkeyAnnouncement(
473
+ tokenPublicKey,
474
+ tokenName,
475
+ tokenTicker,
476
+ decimals,
477
+ maxSupply,
478
+ isFreezable
479
+ );
480
+ const tx = await this.lrc20Wallet.prepareAnnouncement(
481
+ announcement,
482
+ feeRateSatsPerVb
483
+ );
484
+ return await this.lrc20Wallet.broadcastRawBtcTransaction(
485
+ tx.bitcoin_tx.toHex()
486
+ );
487
+ }
488
+ mintTokensL1(tokenAmount) {
489
+ throw new Error("Not implemented");
490
+ }
491
+ transferTokensL1(tokenAmount, p2trAddress) {
492
+ throw new Error("Not implemented");
493
+ }
494
+ };
495
+ export {
496
+ IssuerSparkWallet
497
+ };
package/dist/types.cjs ADDED
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/types.ts
21
+ var types_exports = {};
22
+ __export(types_exports, {
23
+ LayerType: () => LayerType,
24
+ OnChainTransactionStatus: () => OnChainTransactionStatus,
25
+ OperationType: () => OperationType,
26
+ SparkTransactionStatus: () => SparkTransactionStatus
27
+ });
28
+ module.exports = __toCommonJS(types_exports);
29
+
30
+ // buffer.js
31
+ var import_buffer = require("buffer");
32
+ if (typeof globalThis.Buffer === "undefined") {
33
+ globalThis.Buffer = import_buffer.Buffer;
34
+ }
35
+ if (typeof global === "undefined") {
36
+ window.global = window.globalThis;
37
+ }
38
+
39
+ // src/types.ts
40
+ var LayerType = /* @__PURE__ */ ((LayerType2) => {
41
+ LayerType2["L1"] = "L1";
42
+ LayerType2["SPARK"] = "SPARK";
43
+ return LayerType2;
44
+ })(LayerType || {});
45
+ var OperationType = /* @__PURE__ */ ((OperationType2) => {
46
+ OperationType2["USER_TRANSFER"] = "USER_TRANSFER";
47
+ OperationType2["USER_BURN"] = "USER_BURN";
48
+ OperationType2["ISSUER_ANNOUNCE"] = "ISSUER_ANNOUNCE";
49
+ OperationType2["ISSUER_MINT"] = "ISSUER_MINT";
50
+ OperationType2["ISSUER_TRANSFER"] = "ISSUER_TRANSFER";
51
+ OperationType2["ISSUER_FREEZE"] = "ISSUER_FREEZE";
52
+ OperationType2["ISSUER_UNFREEZE"] = "ISSUER_UNFREEZE";
53
+ OperationType2["ISSUER_BURN"] = "ISSUER_BURN";
54
+ return OperationType2;
55
+ })(OperationType || {});
56
+ var OnChainTransactionStatus = /* @__PURE__ */ ((OnChainTransactionStatus2) => {
57
+ OnChainTransactionStatus2["PENDING"] = "PENDING";
58
+ OnChainTransactionStatus2["CONFIRMED"] = "CONFIRMED";
59
+ OnChainTransactionStatus2["WAITING_MINED"] = "WAITING_MINED";
60
+ OnChainTransactionStatus2["MINED"] = "MINED";
61
+ OnChainTransactionStatus2["ATTACHING"] = "ATTACHING";
62
+ OnChainTransactionStatus2["ATTACHED"] = "ATTACHED";
63
+ return OnChainTransactionStatus2;
64
+ })(OnChainTransactionStatus || {});
65
+ var SparkTransactionStatus = /* @__PURE__ */ ((SparkTransactionStatus2) => {
66
+ SparkTransactionStatus2["STARTED"] = "STARTED";
67
+ SparkTransactionStatus2["SIGNED"] = "SIGNED";
68
+ SparkTransactionStatus2["FINALIZED"] = "FINALIZED";
69
+ return SparkTransactionStatus2;
70
+ })(SparkTransactionStatus || {});
71
+ // Annotate the CommonJS export names for ESM import in node:
72
+ 0 && (module.exports = {
73
+ LayerType,
74
+ OnChainTransactionStatus,
75
+ OperationType,
76
+ SparkTransactionStatus
77
+ });