@airgap/tezos 0.13.45-beta.3 → 0.13.45-beta.5

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 (421) hide show
  1. package/package.json +5 -5
  2. package/v0/actions/GetKtAccountsAction.js +81 -11
  3. package/v0/actions/GetKtAccountsAction.js.map +1 -1
  4. package/v0/constants.js +6 -6
  5. package/v0/constants.js.map +1 -1
  6. package/v0/index.js +38 -38
  7. package/v0/index.js.map +1 -1
  8. package/v0/protocol/TezosAddress.d.ts +1 -0
  9. package/v0/protocol/TezosAddress.js +81 -41
  10. package/v0/protocol/TezosAddress.js.map +1 -1
  11. package/v0/protocol/TezosCryptoClient.d.ts +1 -0
  12. package/v0/protocol/TezosCryptoClient.js +123 -68
  13. package/v0/protocol/TezosCryptoClient.js.map +1 -1
  14. package/v0/protocol/TezosProtocol.js +1631 -978
  15. package/v0/protocol/TezosProtocol.js.map +1 -1
  16. package/v0/protocol/TezosProtocolOptions.d.ts +1 -1
  17. package/v0/protocol/TezosProtocolOptions.js +98 -26
  18. package/v0/protocol/TezosProtocolOptions.js.map +1 -1
  19. package/v0/protocol/TezosUtils.d.ts +1 -0
  20. package/v0/protocol/TezosUtils.js +165 -131
  21. package/v0/protocol/TezosUtils.js.map +1 -1
  22. package/v0/protocol/contract/TezosContract.js +472 -243
  23. package/v0/protocol/contract/TezosContract.js.map +1 -1
  24. package/v0/protocol/contract/TezosContractCall.js +10 -8
  25. package/v0/protocol/contract/TezosContractCall.js.map +1 -1
  26. package/v0/protocol/contract/TezosContractEntrypoint.js +19 -14
  27. package/v0/protocol/contract/TezosContractEntrypoint.js.map +1 -1
  28. package/v0/protocol/contract/TezosContractStorage.js +9 -8
  29. package/v0/protocol/contract/TezosContractStorage.js.map +1 -1
  30. package/v0/protocol/contract/remote-data/TezosContractRemoteDataFactory.js +25 -8
  31. package/v0/protocol/contract/remote-data/TezosContractRemoteDataFactory.js.map +1 -1
  32. package/v0/protocol/contract/remote-data/TezosStorageRemoteData.js +113 -39
  33. package/v0/protocol/contract/remote-data/TezosStorageRemoteData.js.map +1 -1
  34. package/v0/protocol/domains/TezosDomains.js +270 -165
  35. package/v0/protocol/domains/TezosDomains.js.map +1 -1
  36. package/v0/protocol/fa/TezosBTC.js +98 -19
  37. package/v0/protocol/fa/TezosBTC.js.map +1 -1
  38. package/v0/protocol/fa/TezosBTCtez.js +48 -17
  39. package/v0/protocol/fa/TezosBTCtez.js.map +1 -1
  40. package/v0/protocol/fa/TezosCTez.js +45 -17
  41. package/v0/protocol/fa/TezosCTez.js.map +1 -1
  42. package/v0/protocol/fa/TezosDOGA.js +45 -17
  43. package/v0/protocol/fa/TezosDOGA.js.map +1 -1
  44. package/v0/protocol/fa/TezosETHtz.js +68 -10
  45. package/v0/protocol/fa/TezosETHtz.js.map +1 -1
  46. package/v0/protocol/fa/TezosFA1Protocol.js +276 -119
  47. package/v0/protocol/fa/TezosFA1Protocol.js.map +1 -1
  48. package/v0/protocol/fa/TezosFA1p2Protocol.js +101 -22
  49. package/v0/protocol/fa/TezosFA1p2Protocol.js.map +1 -1
  50. package/v0/protocol/fa/TezosFA2Protocol.js +402 -213
  51. package/v0/protocol/fa/TezosFA2Protocol.js.map +1 -1
  52. package/v0/protocol/fa/TezosFAProtocol.js +418 -211
  53. package/v0/protocol/fa/TezosFAProtocol.js.map +1 -1
  54. package/v0/protocol/fa/TezosFAProtocolOptions.d.ts +2 -2
  55. package/v0/protocol/fa/TezosFAProtocolOptions.js +195 -92
  56. package/v0/protocol/fa/TezosFAProtocolOptions.js.map +1 -1
  57. package/v0/protocol/fa/TezosKolibriUSD.js +70 -11
  58. package/v0/protocol/fa/TezosKolibriUSD.js.map +1 -1
  59. package/v0/protocol/fa/TezosPlanty.js +45 -17
  60. package/v0/protocol/fa/TezosPlanty.js.map +1 -1
  61. package/v0/protocol/fa/TezosQUIPU.js +48 -17
  62. package/v0/protocol/fa/TezosQUIPU.js.map +1 -1
  63. package/v0/protocol/fa/TezosSIRS.js +45 -17
  64. package/v0/protocol/fa/TezosSIRS.js.map +1 -1
  65. package/v0/protocol/fa/TezosStaker.js +70 -11
  66. package/v0/protocol/fa/TezosStaker.js.map +1 -1
  67. package/v0/protocol/fa/TezosUBTC.js +48 -17
  68. package/v0/protocol/fa/TezosUBTC.js.map +1 -1
  69. package/v0/protocol/fa/TezosUDEFI.js +48 -17
  70. package/v0/protocol/fa/TezosUDEFI.js.map +1 -1
  71. package/v0/protocol/fa/TezosUSD.js +70 -11
  72. package/v0/protocol/fa/TezosUSD.js.map +1 -1
  73. package/v0/protocol/fa/TezosUSDT.js +48 -17
  74. package/v0/protocol/fa/TezosUSDT.js.map +1 -1
  75. package/v0/protocol/fa/TezosUUSD.js +27 -8
  76. package/v0/protocol/fa/TezosUUSD.js.map +1 -1
  77. package/v0/protocol/fa/TezosUXTZ.js +48 -17
  78. package/v0/protocol/fa/TezosUXTZ.js.map +1 -1
  79. package/v0/protocol/fa/TezosWRAP.js +48 -17
  80. package/v0/protocol/fa/TezosWRAP.js.map +1 -1
  81. package/v0/protocol/fa/TezosWrapped.js +70 -11
  82. package/v0/protocol/fa/TezosWrapped.js.map +1 -1
  83. package/v0/protocol/fa/TezosYOU.js +27 -8
  84. package/v0/protocol/fa/TezosYOU.js.map +1 -1
  85. package/v0/protocol/fa/metadata/BigMapTokenMetadataIndexer.js +162 -84
  86. package/v0/protocol/fa/metadata/BigMapTokenMetadataIndexer.js.map +1 -1
  87. package/v0/protocol/fa/metadata/ObjktTokenMetadataIndexer.js +87 -37
  88. package/v0/protocol/fa/metadata/ObjktTokenMetadataIndexer.js.map +1 -1
  89. package/v0/protocol/indexerClient/TezosIndexerClient.js +259 -115
  90. package/v0/protocol/indexerClient/TezosIndexerClient.js.map +1 -1
  91. package/v0/protocol/kt/TezosKtAddress.js +67 -7
  92. package/v0/protocol/kt/TezosKtAddress.js.map +1 -1
  93. package/v0/protocol/kt/TezosKtProtocol.js +309 -161
  94. package/v0/protocol/kt/TezosKtProtocol.js.map +1 -1
  95. package/v0/protocol/sapling/TezosSaplingAddress.d.ts +1 -0
  96. package/v0/protocol/sapling/TezosSaplingAddress.js +117 -46
  97. package/v0/protocol/sapling/TezosSaplingAddress.js.map +1 -1
  98. package/v0/protocol/sapling/TezosSaplingCryptoClient.d.ts +1 -0
  99. package/v0/protocol/sapling/TezosSaplingCryptoClient.js +220 -125
  100. package/v0/protocol/sapling/TezosSaplingCryptoClient.js.map +1 -1
  101. package/v0/protocol/sapling/TezosSaplingProtocol.d.ts +1 -0
  102. package/v0/protocol/sapling/TezosSaplingProtocol.js +1127 -600
  103. package/v0/protocol/sapling/TezosSaplingProtocol.js.map +1 -1
  104. package/v0/protocol/sapling/TezosSaplingProtocolOptions.d.ts +1 -0
  105. package/v0/protocol/sapling/TezosSaplingProtocolOptions.js +61 -32
  106. package/v0/protocol/sapling/TezosSaplingProtocolOptions.js.map +1 -1
  107. package/v0/protocol/sapling/TezosShieldedTezProtocol.js +134 -50
  108. package/v0/protocol/sapling/TezosShieldedTezProtocol.js.map +1 -1
  109. package/v0/protocol/sapling/injector/TezosSaplingInjectorClient.js +56 -10
  110. package/v0/protocol/sapling/injector/TezosSaplingInjectorClient.js.map +1 -1
  111. package/v0/protocol/sapling/node/TezosSaplingNodeClient.js +67 -12
  112. package/v0/protocol/sapling/node/TezosSaplingNodeClient.js.map +1 -1
  113. package/v0/protocol/sapling/utils/TezosSaplingBookkeeper.d.ts +1 -0
  114. package/v0/protocol/sapling/utils/TezosSaplingBookkeeper.js +539 -221
  115. package/v0/protocol/sapling/utils/TezosSaplingBookkeeper.js.map +1 -1
  116. package/v0/protocol/sapling/utils/TezosSaplingEncoder.d.ts +1 -0
  117. package/v0/protocol/sapling/utils/TezosSaplingEncoder.js +104 -101
  118. package/v0/protocol/sapling/utils/TezosSaplingEncoder.js.map +1 -1
  119. package/v0/protocol/sapling/utils/TezosSaplingForger.d.ts +1 -0
  120. package/v0/protocol/sapling/utils/TezosSaplingForger.js +266 -107
  121. package/v0/protocol/sapling/utils/TezosSaplingForger.js.map +1 -1
  122. package/v0/protocol/sapling/utils/TezosSaplingState.js +239 -110
  123. package/v0/protocol/sapling/utils/TezosSaplingState.js.map +1 -1
  124. package/v0/protocol/types/TezosOperationType.js +1 -1
  125. package/v0/protocol/types/TezosOperationType.js.map +1 -1
  126. package/v0/protocol/types/contract/BigMapEntry.d.ts +1 -1
  127. package/v0/protocol/types/contract/TezosContractMetadata.d.ts +2 -2
  128. package/v0/protocol/types/micheline/MichelineNode.d.ts +7 -7
  129. package/v0/protocol/types/micheline/MichelineNodeUtils.js +13 -9
  130. package/v0/protocol/types/micheline/MichelineNodeUtils.js.map +1 -1
  131. package/v0/protocol/types/michelson/MichelsonType.d.ts +1 -0
  132. package/v0/protocol/types/michelson/MichelsonType.js +12 -11
  133. package/v0/protocol/types/michelson/MichelsonType.js.map +1 -1
  134. package/v0/protocol/types/michelson/MichelsonTypeMeta.js +92 -45
  135. package/v0/protocol/types/michelson/MichelsonTypeMeta.js.map +1 -1
  136. package/v0/protocol/types/michelson/MichelsonTypeUtils.d.ts +1 -0
  137. package/v0/protocol/types/michelson/MichelsonTypeUtils.js +219 -58
  138. package/v0/protocol/types/michelson/MichelsonTypeUtils.js.map +1 -1
  139. package/v0/protocol/types/michelson/generics/MichelsonList.js +43 -24
  140. package/v0/protocol/types/michelson/generics/MichelsonList.js.map +1 -1
  141. package/v0/protocol/types/michelson/generics/MichelsonMap.js +61 -39
  142. package/v0/protocol/types/michelson/generics/MichelsonMap.js.map +1 -1
  143. package/v0/protocol/types/michelson/generics/MichelsonOption.d.ts +1 -1
  144. package/v0/protocol/types/michelson/generics/MichelsonOption.js +75 -46
  145. package/v0/protocol/types/michelson/generics/MichelsonOption.js.map +1 -1
  146. package/v0/protocol/types/michelson/generics/MichelsonOr.d.ts +1 -1
  147. package/v0/protocol/types/michelson/generics/MichelsonOr.js +76 -50
  148. package/v0/protocol/types/michelson/generics/MichelsonOr.js.map +1 -1
  149. package/v0/protocol/types/michelson/generics/MichelsonPair.js +85 -52
  150. package/v0/protocol/types/michelson/generics/MichelsonPair.js.map +1 -1
  151. package/v0/protocol/types/michelson/grammar/MichelsonGrammarData.d.ts +1 -1
  152. package/v0/protocol/types/michelson/grammar/MichelsonGrammarInstruction.d.ts +1 -1
  153. package/v0/protocol/types/michelson/grammar/MichelsonGrammarType.d.ts +1 -1
  154. package/v0/protocol/types/michelson/primitives/MichelsonAddress.d.ts +1 -0
  155. package/v0/protocol/types/michelson/primitives/MichelsonAddress.js +47 -28
  156. package/v0/protocol/types/michelson/primitives/MichelsonAddress.js.map +1 -1
  157. package/v0/protocol/types/michelson/primitives/MichelsonBool.js +39 -20
  158. package/v0/protocol/types/michelson/primitives/MichelsonBool.js.map +1 -1
  159. package/v0/protocol/types/michelson/primitives/MichelsonBytes.d.ts +1 -0
  160. package/v0/protocol/types/michelson/primitives/MichelsonBytes.js +54 -35
  161. package/v0/protocol/types/michelson/primitives/MichelsonBytes.js.map +1 -1
  162. package/v0/protocol/types/michelson/primitives/MichelsonInt.d.ts +1 -0
  163. package/v0/protocol/types/michelson/primitives/MichelsonInt.js +49 -30
  164. package/v0/protocol/types/michelson/primitives/MichelsonInt.js.map +1 -1
  165. package/v0/protocol/types/michelson/primitives/MichelsonString.d.ts +1 -0
  166. package/v0/protocol/types/michelson/primitives/MichelsonString.js +52 -33
  167. package/v0/protocol/types/michelson/primitives/MichelsonString.js.map +1 -1
  168. package/v0/protocol/types/michelson/primitives/MichelsonUnit.js +34 -14
  169. package/v0/protocol/types/michelson/primitives/MichelsonUnit.js.map +1 -1
  170. package/v0/protocol/types/sapling/TezosSaplingStateTree.d.ts +1 -1
  171. package/v0/protocol/types/sapling/TezosSaplingTransaction.d.ts +1 -0
  172. package/v0/protocol/types/utils.js +10 -8
  173. package/v0/protocol/types/utils.js.map +1 -1
  174. package/v0/serializer/validators/transaction-validator.js +78 -29
  175. package/v0/serializer/validators/transaction-validator.js.map +1 -1
  176. package/v0/serializer/validators/transaction-xtz-btc-validator.js +129 -55
  177. package/v0/serializer/validators/transaction-xtz-btc-validator.js.map +1 -1
  178. package/v0/serializer/validators/validators.js +103 -43
  179. package/v0/serializer/validators/validators.js.map +1 -1
  180. package/v1/block-explorer/TzKTBlockExplorer.js +61 -12
  181. package/v1/block-explorer/TzKTBlockExplorer.js.map +1 -1
  182. package/v1/block-explorer/factory.js +5 -4
  183. package/v1/block-explorer/factory.js.map +1 -1
  184. package/v1/contract/TezosContract.js +471 -242
  185. package/v1/contract/TezosContract.js.map +1 -1
  186. package/v1/contract/TezosContractCall.js +10 -8
  187. package/v1/contract/TezosContractCall.js.map +1 -1
  188. package/v1/contract/TezosContractEntrypoint.d.ts +1 -1
  189. package/v1/contract/TezosContractEntrypoint.js +19 -14
  190. package/v1/contract/TezosContractEntrypoint.js.map +1 -1
  191. package/v1/contract/TezosContractStorage.js +9 -8
  192. package/v1/contract/TezosContractStorage.js.map +1 -1
  193. package/v1/contract/remote-data/TezosContractRemoteDataFactory.js +25 -8
  194. package/v1/contract/remote-data/TezosContractRemoteDataFactory.js.map +1 -1
  195. package/v1/contract/remote-data/TezosStorageRemoteData.js +113 -39
  196. package/v1/contract/remote-data/TezosStorageRemoteData.js.map +1 -1
  197. package/v1/crypto/TezosCryptoClient.d.ts +1 -0
  198. package/v1/crypto/TezosCryptoClient.js +117 -64
  199. package/v1/crypto/TezosCryptoClient.js.map +1 -1
  200. package/v1/crypto/TezosSaplingCryptoClient.d.ts +1 -0
  201. package/v1/crypto/TezosSaplingCryptoClient.js +194 -116
  202. package/v1/crypto/TezosSaplingCryptoClient.js.map +1 -1
  203. package/v1/data/TezosAddress.js +14 -13
  204. package/v1/data/TezosAddress.js.map +1 -1
  205. package/v1/data/TezosSaplingAddress.d.ts +1 -0
  206. package/v1/data/TezosSaplingAddress.js +94 -29
  207. package/v1/data/TezosSaplingAddress.js.map +1 -1
  208. package/v1/domains/TezosDomains.js +270 -165
  209. package/v1/domains/TezosDomains.js.map +1 -1
  210. package/v1/index.js +39 -39
  211. package/v1/index.js.map +1 -1
  212. package/v1/indexer/TzKTIndexerClient.js +270 -126
  213. package/v1/indexer/TzKTIndexerClient.js.map +1 -1
  214. package/v1/indexer/factory.js +5 -4
  215. package/v1/indexer/factory.js.map +1 -1
  216. package/v1/indexer/token-metadata/BigMapTokenMetadataIndexerClient.js +161 -83
  217. package/v1/indexer/token-metadata/BigMapTokenMetadataIndexerClient.js.map +1 -1
  218. package/v1/indexer/token-metadata/ObjktTokenMetadataIndexerClient.js +85 -36
  219. package/v1/indexer/token-metadata/ObjktTokenMetadataIndexerClient.js.map +1 -1
  220. package/v1/injector/TezosSaplingInjectorClient.js +56 -10
  221. package/v1/injector/TezosSaplingInjectorClient.js.map +1 -1
  222. package/v1/module/TezosModule.js +155 -88
  223. package/v1/module/TezosModule.js.map +1 -1
  224. package/v1/module.js +3 -2
  225. package/v1/module.js.map +1 -1
  226. package/v1/node/TezosSaplingNodeClient.js +67 -12
  227. package/v1/node/TezosSaplingNodeClient.js.map +1 -1
  228. package/v1/protocol/TezosProtocol.js +1385 -848
  229. package/v1/protocol/TezosProtocol.js.map +1 -1
  230. package/v1/protocol/fa/TezosFA1Protocol.js +205 -81
  231. package/v1/protocol/fa/TezosFA1Protocol.js.map +1 -1
  232. package/v1/protocol/fa/TezosFA1p2Protocol.js +111 -32
  233. package/v1/protocol/fa/TezosFA1p2Protocol.js.map +1 -1
  234. package/v1/protocol/fa/TezosFA2Protocol.js +332 -174
  235. package/v1/protocol/fa/TezosFA2Protocol.js.map +1 -1
  236. package/v1/protocol/fa/TezosFAProtocol.js +528 -255
  237. package/v1/protocol/fa/TezosFAProtocol.js.map +1 -1
  238. package/v1/protocol/fa/tokens/BTCTezProtocol.d.ts +2 -2
  239. package/v1/protocol/fa/tokens/BTCTezProtocol.js +47 -30
  240. package/v1/protocol/fa/tokens/BTCTezProtocol.js.map +1 -1
  241. package/v1/protocol/fa/tokens/CTezProtocol.d.ts +2 -2
  242. package/v1/protocol/fa/tokens/CTezProtocol.js +47 -27
  243. package/v1/protocol/fa/tokens/CTezProtocol.js.map +1 -1
  244. package/v1/protocol/fa/tokens/DogamiProtocol.d.ts +2 -2
  245. package/v1/protocol/fa/tokens/DogamiProtocol.js +47 -27
  246. package/v1/protocol/fa/tokens/DogamiProtocol.js.map +1 -1
  247. package/v1/protocol/fa/tokens/ETHTezProtocol.d.ts +2 -2
  248. package/v1/protocol/fa/tokens/ETHTezProtocol.js +90 -30
  249. package/v1/protocol/fa/tokens/ETHTezProtocol.js.map +1 -1
  250. package/v1/protocol/fa/tokens/KolibriUSDProtocol.d.ts +2 -2
  251. package/v1/protocol/fa/tokens/KolibriUSDProtocol.js +90 -30
  252. package/v1/protocol/fa/tokens/KolibriUSDProtocol.js.map +1 -1
  253. package/v1/protocol/fa/tokens/PlentyProtocol.d.ts +2 -2
  254. package/v1/protocol/fa/tokens/PlentyProtocol.js +90 -30
  255. package/v1/protocol/fa/tokens/PlentyProtocol.js.map +1 -1
  256. package/v1/protocol/fa/tokens/QuipuswapProtocol.d.ts +2 -2
  257. package/v1/protocol/fa/tokens/QuipuswapProtocol.js +47 -30
  258. package/v1/protocol/fa/tokens/QuipuswapProtocol.js.map +1 -1
  259. package/v1/protocol/fa/tokens/SiriusProtocol.d.ts +2 -2
  260. package/v1/protocol/fa/tokens/SiriusProtocol.js +47 -27
  261. package/v1/protocol/fa/tokens/SiriusProtocol.js.map +1 -1
  262. package/v1/protocol/fa/tokens/StakerProtocol.d.ts +2 -2
  263. package/v1/protocol/fa/tokens/StakerProtocol.js +90 -30
  264. package/v1/protocol/fa/tokens/StakerProtocol.js.map +1 -1
  265. package/v1/protocol/fa/tokens/TetherUSDProtocol.d.ts +2 -2
  266. package/v1/protocol/fa/tokens/TetherUSDProtocol.js +47 -30
  267. package/v1/protocol/fa/tokens/TetherUSDProtocol.js.map +1 -1
  268. package/v1/protocol/fa/tokens/TzBTCProtocol.d.ts +2 -2
  269. package/v1/protocol/fa/tokens/TzBTCProtocol.js +47 -27
  270. package/v1/protocol/fa/tokens/TzBTCProtocol.js.map +1 -1
  271. package/v1/protocol/fa/tokens/UBTCProtocol.d.ts +2 -2
  272. package/v1/protocol/fa/tokens/UBTCProtocol.js +47 -30
  273. package/v1/protocol/fa/tokens/UBTCProtocol.js.map +1 -1
  274. package/v1/protocol/fa/tokens/UDEFIProtocol.d.ts +2 -2
  275. package/v1/protocol/fa/tokens/UDEFIProtocol.js +47 -30
  276. package/v1/protocol/fa/tokens/UDEFIProtocol.js.map +1 -1
  277. package/v1/protocol/fa/tokens/USDTezProtocol.d.ts +2 -2
  278. package/v1/protocol/fa/tokens/USDTezProtocol.js +47 -27
  279. package/v1/protocol/fa/tokens/USDTezProtocol.js.map +1 -1
  280. package/v1/protocol/fa/tokens/UUSDProtocol.d.ts +2 -2
  281. package/v1/protocol/fa/tokens/UUSDProtocol.js +47 -30
  282. package/v1/protocol/fa/tokens/UUSDProtocol.js.map +1 -1
  283. package/v1/protocol/fa/tokens/UXTZProtocol.d.ts +2 -2
  284. package/v1/protocol/fa/tokens/UXTZProtocol.js +47 -30
  285. package/v1/protocol/fa/tokens/UXTZProtocol.js.map +1 -1
  286. package/v1/protocol/fa/tokens/WrapProtocol.d.ts +2 -2
  287. package/v1/protocol/fa/tokens/WrapProtocol.js +47 -30
  288. package/v1/protocol/fa/tokens/WrapProtocol.js.map +1 -1
  289. package/v1/protocol/fa/tokens/WrappedTezosProtocol.d.ts +2 -2
  290. package/v1/protocol/fa/tokens/WrappedTezosProtocol.js +47 -27
  291. package/v1/protocol/fa/tokens/WrappedTezosProtocol.js.map +1 -1
  292. package/v1/protocol/fa/tokens/YouProtocol.d.ts +2 -2
  293. package/v1/protocol/fa/tokens/YouProtocol.js +47 -30
  294. package/v1/protocol/fa/tokens/YouProtocol.js.map +1 -1
  295. package/v1/protocol/fa/tokens/stXTZProtocol.d.ts +2 -2
  296. package/v1/protocol/fa/tokens/stXTZProtocol.js +47 -30
  297. package/v1/protocol/fa/tokens/stXTZProtocol.js.map +1 -1
  298. package/v1/protocol/kt/TezosKtProtocol.js +498 -254
  299. package/v1/protocol/kt/TezosKtProtocol.js.map +1 -1
  300. package/v1/protocol/sapling/TezosSaplingProtocol.d.ts +1 -0
  301. package/v1/protocol/sapling/TezosSaplingProtocol.js +933 -532
  302. package/v1/protocol/sapling/TezosSaplingProtocol.js.map +1 -1
  303. package/v1/protocol/sapling/TezosShieldedTezProtocol.js +164 -72
  304. package/v1/protocol/sapling/TezosShieldedTezProtocol.js.map +1 -1
  305. package/v1/serializer/v3/schemas/converter/transaction-converter.js +26 -14
  306. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
  307. package/v1/serializer/v3/serializer-companion.js +188 -103
  308. package/v1/serializer/v3/serializer-companion.js.map +1 -1
  309. package/v1/serializer/v3/validators/transaction-validator.js +143 -54
  310. package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
  311. package/v1/serializer/v3/validators/validators.js +100 -40
  312. package/v1/serializer/v3/validators/validators.js.map +1 -1
  313. package/v1/types/block-explorer.d.ts +1 -1
  314. package/v1/types/contract/TezosContractMetadata.d.ts +2 -2
  315. package/v1/types/contract/bigmap/BigMapEntry.d.ts +1 -1
  316. package/v1/types/crypto.d.ts +2 -2
  317. package/v1/types/fa/TezosFA1ContractEntrypoint.d.ts +1 -1
  318. package/v1/types/fa/TezosFA1p2ContractEntrypoint.d.ts +1 -1
  319. package/v1/types/fa/TezosFA2ContractEntrypoint.d.ts +1 -1
  320. package/v1/types/indexer.d.ts +1 -1
  321. package/v1/types/micheline/MichelineNode.d.ts +7 -7
  322. package/v1/types/micheline/MichelineNodeUtils.js +13 -9
  323. package/v1/types/micheline/MichelineNodeUtils.js.map +1 -1
  324. package/v1/types/michelson/MichelsonType.d.ts +1 -0
  325. package/v1/types/michelson/MichelsonType.js +12 -11
  326. package/v1/types/michelson/MichelsonType.js.map +1 -1
  327. package/v1/types/michelson/MichelsonTypeMeta.js +92 -45
  328. package/v1/types/michelson/MichelsonTypeMeta.js.map +1 -1
  329. package/v1/types/michelson/MichelsonTypeUtils.d.ts +1 -0
  330. package/v1/types/michelson/MichelsonTypeUtils.js +219 -58
  331. package/v1/types/michelson/MichelsonTypeUtils.js.map +1 -1
  332. package/v1/types/michelson/generics/MichelsonList.js +43 -24
  333. package/v1/types/michelson/generics/MichelsonList.js.map +1 -1
  334. package/v1/types/michelson/generics/MichelsonMap.js +61 -39
  335. package/v1/types/michelson/generics/MichelsonMap.js.map +1 -1
  336. package/v1/types/michelson/generics/MichelsonOption.d.ts +1 -1
  337. package/v1/types/michelson/generics/MichelsonOption.js +75 -46
  338. package/v1/types/michelson/generics/MichelsonOption.js.map +1 -1
  339. package/v1/types/michelson/generics/MichelsonOr.d.ts +1 -1
  340. package/v1/types/michelson/generics/MichelsonOr.js +76 -50
  341. package/v1/types/michelson/generics/MichelsonOr.js.map +1 -1
  342. package/v1/types/michelson/generics/MichelsonPair.js +85 -52
  343. package/v1/types/michelson/generics/MichelsonPair.js.map +1 -1
  344. package/v1/types/michelson/grammar/MichelsonGrammarData.d.ts +1 -1
  345. package/v1/types/michelson/grammar/MichelsonGrammarInstruction.d.ts +1 -1
  346. package/v1/types/michelson/grammar/MichelsonGrammarType.d.ts +1 -1
  347. package/v1/types/michelson/primitives/MichelsonAddress.d.ts +1 -0
  348. package/v1/types/michelson/primitives/MichelsonAddress.js +47 -28
  349. package/v1/types/michelson/primitives/MichelsonAddress.js.map +1 -1
  350. package/v1/types/michelson/primitives/MichelsonBool.js +39 -20
  351. package/v1/types/michelson/primitives/MichelsonBool.js.map +1 -1
  352. package/v1/types/michelson/primitives/MichelsonBytes.d.ts +1 -0
  353. package/v1/types/michelson/primitives/MichelsonBytes.js +54 -35
  354. package/v1/types/michelson/primitives/MichelsonBytes.js.map +1 -1
  355. package/v1/types/michelson/primitives/MichelsonInt.d.ts +1 -0
  356. package/v1/types/michelson/primitives/MichelsonInt.js +49 -30
  357. package/v1/types/michelson/primitives/MichelsonInt.js.map +1 -1
  358. package/v1/types/michelson/primitives/MichelsonString.d.ts +1 -0
  359. package/v1/types/michelson/primitives/MichelsonString.js +52 -33
  360. package/v1/types/michelson/primitives/MichelsonString.js.map +1 -1
  361. package/v1/types/michelson/primitives/MichelsonUnit.js +34 -14
  362. package/v1/types/michelson/primitives/MichelsonUnit.js.map +1 -1
  363. package/v1/types/network.js +1 -1
  364. package/v1/types/network.js.map +1 -1
  365. package/v1/types/operations/TezosOperationType.js +1 -1
  366. package/v1/types/operations/TezosOperationType.js.map +1 -1
  367. package/v1/types/protocol.d.ts +3 -3
  368. package/v1/types/sapling/TezosSaplingExternalMethodProvider.d.ts +1 -0
  369. package/v1/types/sapling/TezosSaplingStateTree.d.ts +1 -1
  370. package/v1/types/sapling/TezosSaplingTransaction.d.ts +1 -0
  371. package/v1/types/staking/TezosDelegatorAction.js +1 -1
  372. package/v1/types/staking/TezosDelegatorAction.js.map +1 -1
  373. package/v1/utils/address.js +7 -6
  374. package/v1/utils/address.js.map +1 -1
  375. package/v1/utils/bip.d.ts +1 -0
  376. package/v1/utils/bip.js +7 -6
  377. package/v1/utils/bip.js.map +1 -1
  378. package/v1/utils/convert.js +8 -7
  379. package/v1/utils/convert.js.map +1 -1
  380. package/v1/utils/encoding.d.ts +1 -0
  381. package/v1/utils/encoding.js +64 -74
  382. package/v1/utils/encoding.js.map +1 -1
  383. package/v1/utils/fa.js +3 -2
  384. package/v1/utils/fa.js.map +1 -1
  385. package/v1/utils/key.js +12 -9
  386. package/v1/utils/key.js.map +1 -1
  387. package/v1/utils/micheline.js +10 -8
  388. package/v1/utils/micheline.js.map +1 -1
  389. package/v1/utils/operations.js +22 -21
  390. package/v1/utils/operations.js.map +1 -1
  391. package/v1/utils/pack.d.ts +1 -0
  392. package/v1/utils/pack.js +107 -65
  393. package/v1/utils/pack.js.map +1 -1
  394. package/v1/utils/protocol/fa/TezosFA1Accountant.js +52 -24
  395. package/v1/utils/protocol/fa/TezosFA1Accountant.js.map +1 -1
  396. package/v1/utils/protocol/fa/TezosFA2Accountant.js +77 -40
  397. package/v1/utils/protocol/fa/TezosFA2Accountant.js.map +1 -1
  398. package/v1/utils/protocol/fa/TezosFAAccountant.js +89 -21
  399. package/v1/utils/protocol/fa/TezosFAAccountant.js.map +1 -1
  400. package/v1/utils/protocol/instance.js +26 -90
  401. package/v1/utils/protocol/instance.js.map +1 -1
  402. package/v1/utils/protocol/sapling/TezosSaplingAccountant.d.ts +1 -0
  403. package/v1/utils/protocol/sapling/TezosSaplingAccountant.js +539 -221
  404. package/v1/utils/protocol/sapling/TezosSaplingAccountant.js.map +1 -1
  405. package/v1/utils/protocol/sapling/TezosSaplingEncoder.d.ts +1 -0
  406. package/v1/utils/protocol/sapling/TezosSaplingEncoder.js +104 -101
  407. package/v1/utils/protocol/sapling/TezosSaplingEncoder.js.map +1 -1
  408. package/v1/utils/protocol/sapling/TezosSaplingForger.d.ts +1 -0
  409. package/v1/utils/protocol/sapling/TezosSaplingForger.js +266 -107
  410. package/v1/utils/protocol/sapling/TezosSaplingForger.js.map +1 -1
  411. package/v1/utils/protocol/sapling/TezosSaplingState.js +239 -110
  412. package/v1/utils/protocol/sapling/TezosSaplingState.js.map +1 -1
  413. package/v1/utils/protocol/tezos/TezosAccountant.js +166 -97
  414. package/v1/utils/protocol/tezos/TezosAccountant.js.map +1 -1
  415. package/v1/utils/protocol/tezos/TezosForger.js +76 -21
  416. package/v1/utils/protocol/tezos/TezosForger.js.map +1 -1
  417. package/v1/utils/signature.js +6 -5
  418. package/v1/utils/signature.js.map +1 -1
  419. package/v1/utils/transaction.d.ts +5 -4
  420. package/v1/utils/transaction.js +3 -3
  421. package/v1/utils/transaction.js.map +1 -1
@@ -1,4 +1,30 @@
1
1
  "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
2
28
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
29
  if (k2 === undefined) k2 = k;
4
30
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -15,552 +41,964 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
41
  }) : function(o, v) {
16
42
  o["default"] = v;
17
43
  });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
44
+ var __importStar = (this && this.__importStar) || function (mod) {
45
+ if (mod && mod.__esModule) return mod;
46
+ var result = {};
47
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
48
+ __setModuleDefault(result, mod);
49
+ return result;
50
+ };
51
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
52
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
53
+ return new (P || (P = Promise))(function (resolve, reject) {
54
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
55
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
56
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
57
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
58
+ });
59
+ };
60
+ var __generator = (this && this.__generator) || function (thisArg, body) {
61
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
62
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
63
+ function verb(n) { return function (v) { return step([n, v]); }; }
64
+ function step(op) {
65
+ if (f) throw new TypeError("Generator is already executing.");
66
+ while (_) try {
67
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
68
+ if (y = 0, t) op = [op[0] & 2, t.value];
69
+ switch (op[0]) {
70
+ case 0: case 1: t = op; break;
71
+ case 4: _.label++; return { value: op[1], done: false };
72
+ case 5: _.label++; y = op[1]; op = [0]; continue;
73
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
74
+ default:
75
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
76
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
77
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
78
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
79
+ if (t[2]) _.ops.pop();
80
+ _.trys.pop(); continue;
81
+ }
82
+ op = body.call(thisArg, _);
83
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
84
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
85
+ }
86
+ };
87
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
88
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
89
+ if (ar || !(i in from)) {
90
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
91
+ ar[i] = from[i];
92
+ }
93
+ }
94
+ return to.concat(ar || Array.prototype.slice.call(from));
95
+ };
35
96
  var __importDefault = (this && this.__importDefault) || function (mod) {
36
97
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
98
  };
38
99
  Object.defineProperty(exports, "__esModule", { value: true });
39
100
  exports.TezosSaplingProtocol = void 0;
40
- const bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
101
+ var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
41
102
  // @ts-ignore
42
- const bip39_2_5_0_1 = require("@airgap/coinlib-core/dependencies/src/bip39-2.5.0");
43
- const errors_1 = require("@airgap/coinlib-core/errors");
44
- const coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
45
- const NonExtendedProtocol_1 = require("@airgap/coinlib-core/protocols/NonExtendedProtocol");
46
- const array_1 = require("@airgap/coinlib-core/utils/array");
47
- const sapling = __importStar(require("@airgap/sapling-wasm"));
48
- const random_1 = require("@stablelib/random");
49
- const TezosContract_1 = require("../contract/TezosContract");
50
- const TezosAddress_1 = require("../TezosAddress");
51
- const TezosProtocol_1 = require("../TezosProtocol");
52
- const TezosProtocolOptions_1 = require("../TezosProtocolOptions");
53
- const TezosUtils_1 = require("../TezosUtils");
54
- const MichelsonAddress_1 = require("../types/michelson/primitives/MichelsonAddress");
55
- const TezosOperationType_1 = require("../types/TezosOperationType");
56
- const TezosSaplingInjectorClient_1 = require("./injector/TezosSaplingInjectorClient");
57
- const TezosSaplingNodeClient_1 = require("./node/TezosSaplingNodeClient");
58
- const TezosSaplingAddress_1 = require("./TezosSaplingAddress");
59
- const TezosSaplingCryptoClient_1 = require("./TezosSaplingCryptoClient");
60
- const TezosSaplingBookkeeper_1 = require("./utils/TezosSaplingBookkeeper");
61
- const TezosSaplingEncoder_1 = require("./utils/TezosSaplingEncoder");
62
- const TezosSaplingForger_1 = require("./utils/TezosSaplingForger");
63
- const TezosSaplingState_1 = require("./utils/TezosSaplingState");
64
- class TezosSaplingProtocol extends NonExtendedProtocol_1.NonExtendedProtocol {
65
- constructor(options) {
66
- super();
67
- this.options = options;
68
- this.supportsHD = false;
69
- this.addressIsCaseSensitive = true;
70
- this.addressValidationPattern = '^(zet1[1-9A-Za-z]{65}|tz1[1-9A-Za-z]{33})$';
71
- this.addressPlaceholder = 'zet1...';
72
- this.tezosProtocol = new TezosProtocol_1.TezosProtocol(new TezosProtocolOptions_1.TezosProtocolOptions(this.options.network, new TezosProtocolOptions_1.TezosProtocolConfig()));
73
- this.name = options.config.name;
74
- this.symbol = options.config.symbol ?? this.tezosProtocol.symbol;
75
- this.marketSymbol = options.config.marketSymbol ?? this.tezosProtocol.marketSymbol;
76
- this.feeSymbol = this.tezosProtocol.feeSymbol;
77
- this.feeDefaults = options.config.feeDefaults ?? this.tezosProtocol.feeDefaults;
78
- this.decimals = options.config.decimals ?? this.tezosProtocol.decimals;
79
- this.feeDecimals = this.tezosProtocol.feeDecimals;
80
- this.identifier = options.config.identifier ?? this.tezosProtocol.identifier;
81
- this.units = this.options.config.units ?? this.tezosProtocol.units;
82
- this.standardDerivationPath = this.tezosProtocol.standardDerivationPath;
83
- this.cryptoClient = new TezosSaplingCryptoClient_1.TezosSaplingCryptoClient(this.tezosProtocol.cryptoClient);
84
- this.nodeClient = this.options.config.contractAddress
85
- ? new TezosSaplingNodeClient_1.TezosSaplingNodeClient(this.options.network.rpcUrl, this.options.config.contractAddress)
103
+ var bip39_2_5_0_1 = require("@airgap/coinlib-core/dependencies/src/bip39-2.5.0");
104
+ var errors_1 = require("@airgap/coinlib-core/errors");
105
+ var coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
106
+ var NonExtendedProtocol_1 = require("@airgap/coinlib-core/protocols/NonExtendedProtocol");
107
+ var array_1 = require("@airgap/coinlib-core/utils/array");
108
+ var sapling = __importStar(require("@airgap/sapling-wasm"));
109
+ var random_1 = require("@stablelib/random");
110
+ var TezosContract_1 = require("../contract/TezosContract");
111
+ var TezosAddress_1 = require("../TezosAddress");
112
+ var TezosProtocol_1 = require("../TezosProtocol");
113
+ var TezosProtocolOptions_1 = require("../TezosProtocolOptions");
114
+ var TezosUtils_1 = require("../TezosUtils");
115
+ var MichelsonAddress_1 = require("../types/michelson/primitives/MichelsonAddress");
116
+ var TezosOperationType_1 = require("../types/TezosOperationType");
117
+ var TezosSaplingInjectorClient_1 = require("./injector/TezosSaplingInjectorClient");
118
+ var TezosSaplingNodeClient_1 = require("./node/TezosSaplingNodeClient");
119
+ var TezosSaplingAddress_1 = require("./TezosSaplingAddress");
120
+ var TezosSaplingCryptoClient_1 = require("./TezosSaplingCryptoClient");
121
+ var TezosSaplingBookkeeper_1 = require("./utils/TezosSaplingBookkeeper");
122
+ var TezosSaplingEncoder_1 = require("./utils/TezosSaplingEncoder");
123
+ var TezosSaplingForger_1 = require("./utils/TezosSaplingForger");
124
+ var TezosSaplingState_1 = require("./utils/TezosSaplingState");
125
+ var TezosSaplingProtocol = /** @class */ (function (_super) {
126
+ __extends(TezosSaplingProtocol, _super);
127
+ function TezosSaplingProtocol(options) {
128
+ var _this = this;
129
+ var _a, _b, _c, _d, _e, _f;
130
+ _this = _super.call(this) || this;
131
+ _this.options = options;
132
+ _this.supportsHD = false;
133
+ _this.addressIsCaseSensitive = true;
134
+ _this.addressValidationPattern = '^(zet1[1-9A-Za-z]{65}|tz1[1-9A-Za-z]{33})$';
135
+ _this.addressPlaceholder = 'zet1...';
136
+ _this.tezosProtocol = new TezosProtocol_1.TezosProtocol(new TezosProtocolOptions_1.TezosProtocolOptions(_this.options.network, new TezosProtocolOptions_1.TezosProtocolConfig()));
137
+ _this.name = options.config.name;
138
+ _this.symbol = (_a = options.config.symbol) !== null && _a !== void 0 ? _a : _this.tezosProtocol.symbol;
139
+ _this.marketSymbol = (_b = options.config.marketSymbol) !== null && _b !== void 0 ? _b : _this.tezosProtocol.marketSymbol;
140
+ _this.feeSymbol = _this.tezosProtocol.feeSymbol;
141
+ _this.feeDefaults = (_c = options.config.feeDefaults) !== null && _c !== void 0 ? _c : _this.tezosProtocol.feeDefaults;
142
+ _this.decimals = (_d = options.config.decimals) !== null && _d !== void 0 ? _d : _this.tezosProtocol.decimals;
143
+ _this.feeDecimals = _this.tezosProtocol.feeDecimals;
144
+ _this.identifier = (_e = options.config.identifier) !== null && _e !== void 0 ? _e : _this.tezosProtocol.identifier;
145
+ _this.units = (_f = _this.options.config.units) !== null && _f !== void 0 ? _f : _this.tezosProtocol.units;
146
+ _this.standardDerivationPath = _this.tezosProtocol.standardDerivationPath;
147
+ _this.cryptoClient = new TezosSaplingCryptoClient_1.TezosSaplingCryptoClient(_this.tezosProtocol.cryptoClient);
148
+ _this.nodeClient = _this.options.config.contractAddress
149
+ ? new TezosSaplingNodeClient_1.TezosSaplingNodeClient(_this.options.network.rpcUrl, _this.options.config.contractAddress)
86
150
  : undefined;
87
- this.contract = this.options.config.contractAddress
88
- ? new TezosContract_1.TezosContract(this.options.config.contractAddress, this.options.network)
151
+ _this.contract = _this.options.config.contractAddress
152
+ ? new TezosContract_1.TezosContract(_this.options.config.contractAddress, _this.options.network)
89
153
  : undefined;
90
- this.injectorClient =
91
- this.options.config.injectorUrl && this.options.config.contractAddress
92
- ? new TezosSaplingInjectorClient_1.TezosSaplingInjectorClient(this.options.config.injectorUrl, this.options.config.contractAddress)
154
+ _this.injectorClient =
155
+ _this.options.config.injectorUrl && _this.options.config.contractAddress
156
+ ? new TezosSaplingInjectorClient_1.TezosSaplingInjectorClient(_this.options.config.injectorUrl, _this.options.config.contractAddress)
93
157
  : undefined;
94
- this.state = new TezosSaplingState_1.TezosSaplingState(this.options.config.merkleTreeHeight);
95
- this.encoder = new TezosSaplingEncoder_1.TezosSaplingEncoder();
96
- this.forger = new TezosSaplingForger_1.TezosSaplingForger(this.cryptoClient, this.state, this.encoder, this.options.config.externalProvider);
97
- this.bookkeeper = new TezosSaplingBookkeeper_1.TezosSaplingBookkeeper(this.identifier, this.options.network, this.cryptoClient, this.encoder);
98
- }
99
- async getSymbol() {
100
- return this.symbol;
101
- }
102
- async getName() {
103
- return this.name;
104
- }
105
- async getMarketSymbol() {
106
- return this.marketSymbol;
107
- }
108
- async getAssetSymbol() {
109
- return undefined;
110
- }
111
- async getFeeSymbol() {
112
- return this.feeSymbol;
113
- }
114
- async getDecimals() {
115
- return this.decimals;
116
- }
117
- async getFeeDecimals() {
118
- return this.feeDecimals;
119
- }
120
- async getIdentifier() {
121
- return this.identifier;
122
- }
123
- async getFeeDefaults() {
124
- return this.feeDefaults;
125
- }
126
- async getUnits() {
127
- return this.units;
128
- }
129
- async getSupportsHD() {
130
- return this.supportsHD;
131
- }
132
- async getStandardDerivationPath() {
133
- return this.standardDerivationPath;
134
- }
135
- async getAddressIsCaseSensitive() {
136
- return this.addressIsCaseSensitive;
137
- }
138
- async getAddressValidationPattern() {
139
- return this.addressValidationPattern;
140
- }
141
- async getAddressPlaceholder() {
142
- return this.addressPlaceholder;
143
- }
144
- async getOptions() {
145
- return this.options;
146
- }
147
- async getContractAddress() {
148
- return this.contract?.address;
149
- }
150
- async setContractAddress(address, configuration) {
151
- this.options.config.contractAddress = address;
152
- this.nodeClient = new TezosSaplingNodeClient_1.TezosSaplingNodeClient(this.options.network.rpcUrl, address);
153
- this.contract = new TezosContract_1.TezosContract(address, this.options.network);
154
- this.options.config.injectorUrl = configuration?.injectorUrl;
155
- this.injectorClient = new TezosSaplingInjectorClient_1.TezosSaplingInjectorClient(configuration?.injectorUrl, address);
156
- }
157
- async initParameters(spendParams, outputParams) {
158
- const externalInitParameters = this.options.config.externalProvider?.initParameters;
159
- if (externalInitParameters !== undefined) {
160
- await externalInitParameters(spendParams, outputParams);
161
- }
162
- else {
163
- await sapling.initParameters(spendParams, outputParams);
164
- }
165
- }
166
- async getBlockExplorerLinkForTxId(txId) {
167
- return this.tezosProtocol.getBlockExplorerLinkForTxId(txId);
168
- }
169
- async getPublicKeyFromMnemonic(mnemonic, derivationPath, password) {
170
- const seed = this.getSeedFromMnemonic(mnemonic, password);
171
- return this.getPublicKeyFromHexSecret(seed.toString('hex'), derivationPath);
172
- }
173
- async getPrivateKeyFromMnemonic(mnemonic, derivationPath, password) {
174
- const seed = this.getSeedFromMnemonic(mnemonic, password);
175
- return this.getPrivateKeyFromHexSecret(seed.toString('hex'), derivationPath);
176
- }
177
- getSeedFromMnemonic(mnemonic, password) {
178
- const seed = (0, bip39_2_5_0_1.mnemonicToSeed)(mnemonic, password);
158
+ _this.state = new TezosSaplingState_1.TezosSaplingState(_this.options.config.merkleTreeHeight);
159
+ _this.encoder = new TezosSaplingEncoder_1.TezosSaplingEncoder();
160
+ _this.forger = new TezosSaplingForger_1.TezosSaplingForger(_this.cryptoClient, _this.state, _this.encoder, _this.options.config.externalProvider);
161
+ _this.bookkeeper = new TezosSaplingBookkeeper_1.TezosSaplingBookkeeper(_this.identifier, _this.options.network, _this.cryptoClient, _this.encoder);
162
+ return _this;
163
+ }
164
+ TezosSaplingProtocol.prototype.getSymbol = function () {
165
+ return __awaiter(this, void 0, void 0, function () {
166
+ return __generator(this, function (_a) {
167
+ return [2 /*return*/, this.symbol];
168
+ });
169
+ });
170
+ };
171
+ TezosSaplingProtocol.prototype.getName = function () {
172
+ return __awaiter(this, void 0, void 0, function () {
173
+ return __generator(this, function (_a) {
174
+ return [2 /*return*/, this.name];
175
+ });
176
+ });
177
+ };
178
+ TezosSaplingProtocol.prototype.getMarketSymbol = function () {
179
+ return __awaiter(this, void 0, void 0, function () {
180
+ return __generator(this, function (_a) {
181
+ return [2 /*return*/, this.marketSymbol];
182
+ });
183
+ });
184
+ };
185
+ TezosSaplingProtocol.prototype.getAssetSymbol = function () {
186
+ return __awaiter(this, void 0, void 0, function () {
187
+ return __generator(this, function (_a) {
188
+ return [2 /*return*/, undefined];
189
+ });
190
+ });
191
+ };
192
+ TezosSaplingProtocol.prototype.getFeeSymbol = function () {
193
+ return __awaiter(this, void 0, void 0, function () {
194
+ return __generator(this, function (_a) {
195
+ return [2 /*return*/, this.feeSymbol];
196
+ });
197
+ });
198
+ };
199
+ TezosSaplingProtocol.prototype.getDecimals = function () {
200
+ return __awaiter(this, void 0, void 0, function () {
201
+ return __generator(this, function (_a) {
202
+ return [2 /*return*/, this.decimals];
203
+ });
204
+ });
205
+ };
206
+ TezosSaplingProtocol.prototype.getFeeDecimals = function () {
207
+ return __awaiter(this, void 0, void 0, function () {
208
+ return __generator(this, function (_a) {
209
+ return [2 /*return*/, this.feeDecimals];
210
+ });
211
+ });
212
+ };
213
+ TezosSaplingProtocol.prototype.getIdentifier = function () {
214
+ return __awaiter(this, void 0, void 0, function () {
215
+ return __generator(this, function (_a) {
216
+ return [2 /*return*/, this.identifier];
217
+ });
218
+ });
219
+ };
220
+ TezosSaplingProtocol.prototype.getFeeDefaults = function () {
221
+ return __awaiter(this, void 0, void 0, function () {
222
+ return __generator(this, function (_a) {
223
+ return [2 /*return*/, this.feeDefaults];
224
+ });
225
+ });
226
+ };
227
+ TezosSaplingProtocol.prototype.getUnits = function () {
228
+ return __awaiter(this, void 0, void 0, function () {
229
+ return __generator(this, function (_a) {
230
+ return [2 /*return*/, this.units];
231
+ });
232
+ });
233
+ };
234
+ TezosSaplingProtocol.prototype.getSupportsHD = function () {
235
+ return __awaiter(this, void 0, void 0, function () {
236
+ return __generator(this, function (_a) {
237
+ return [2 /*return*/, this.supportsHD];
238
+ });
239
+ });
240
+ };
241
+ TezosSaplingProtocol.prototype.getStandardDerivationPath = function () {
242
+ return __awaiter(this, void 0, void 0, function () {
243
+ return __generator(this, function (_a) {
244
+ return [2 /*return*/, this.standardDerivationPath];
245
+ });
246
+ });
247
+ };
248
+ TezosSaplingProtocol.prototype.getAddressIsCaseSensitive = function () {
249
+ return __awaiter(this, void 0, void 0, function () {
250
+ return __generator(this, function (_a) {
251
+ return [2 /*return*/, this.addressIsCaseSensitive];
252
+ });
253
+ });
254
+ };
255
+ TezosSaplingProtocol.prototype.getAddressValidationPattern = function () {
256
+ return __awaiter(this, void 0, void 0, function () {
257
+ return __generator(this, function (_a) {
258
+ return [2 /*return*/, this.addressValidationPattern];
259
+ });
260
+ });
261
+ };
262
+ TezosSaplingProtocol.prototype.getAddressPlaceholder = function () {
263
+ return __awaiter(this, void 0, void 0, function () {
264
+ return __generator(this, function (_a) {
265
+ return [2 /*return*/, this.addressPlaceholder];
266
+ });
267
+ });
268
+ };
269
+ TezosSaplingProtocol.prototype.getOptions = function () {
270
+ return __awaiter(this, void 0, void 0, function () {
271
+ return __generator(this, function (_a) {
272
+ return [2 /*return*/, this.options];
273
+ });
274
+ });
275
+ };
276
+ TezosSaplingProtocol.prototype.getContractAddress = function () {
277
+ var _a;
278
+ return __awaiter(this, void 0, void 0, function () {
279
+ return __generator(this, function (_b) {
280
+ return [2 /*return*/, (_a = this.contract) === null || _a === void 0 ? void 0 : _a.address];
281
+ });
282
+ });
283
+ };
284
+ TezosSaplingProtocol.prototype.setContractAddress = function (address, configuration) {
285
+ return __awaiter(this, void 0, void 0, function () {
286
+ return __generator(this, function (_a) {
287
+ this.options.config.contractAddress = address;
288
+ this.nodeClient = new TezosSaplingNodeClient_1.TezosSaplingNodeClient(this.options.network.rpcUrl, address);
289
+ this.contract = new TezosContract_1.TezosContract(address, this.options.network);
290
+ this.options.config.injectorUrl = configuration === null || configuration === void 0 ? void 0 : configuration.injectorUrl;
291
+ this.injectorClient = new TezosSaplingInjectorClient_1.TezosSaplingInjectorClient(configuration === null || configuration === void 0 ? void 0 : configuration.injectorUrl, address);
292
+ return [2 /*return*/];
293
+ });
294
+ });
295
+ };
296
+ TezosSaplingProtocol.prototype.initParameters = function (spendParams, outputParams) {
297
+ var _a;
298
+ return __awaiter(this, void 0, void 0, function () {
299
+ var externalInitParameters;
300
+ return __generator(this, function (_b) {
301
+ switch (_b.label) {
302
+ case 0:
303
+ externalInitParameters = (_a = this.options.config.externalProvider) === null || _a === void 0 ? void 0 : _a.initParameters;
304
+ if (!(externalInitParameters !== undefined)) return [3 /*break*/, 2];
305
+ return [4 /*yield*/, externalInitParameters(spendParams, outputParams)];
306
+ case 1:
307
+ _b.sent();
308
+ return [3 /*break*/, 4];
309
+ case 2: return [4 /*yield*/, sapling.initParameters(spendParams, outputParams)];
310
+ case 3:
311
+ _b.sent();
312
+ _b.label = 4;
313
+ case 4: return [2 /*return*/];
314
+ }
315
+ });
316
+ });
317
+ };
318
+ TezosSaplingProtocol.prototype.getBlockExplorerLinkForTxId = function (txId) {
319
+ return __awaiter(this, void 0, void 0, function () {
320
+ return __generator(this, function (_a) {
321
+ return [2 /*return*/, this.tezosProtocol.getBlockExplorerLinkForTxId(txId)];
322
+ });
323
+ });
324
+ };
325
+ TezosSaplingProtocol.prototype.getPublicKeyFromMnemonic = function (mnemonic, derivationPath, password) {
326
+ return __awaiter(this, void 0, void 0, function () {
327
+ var seed;
328
+ return __generator(this, function (_a) {
329
+ seed = this.getSeedFromMnemonic(mnemonic, password);
330
+ return [2 /*return*/, this.getPublicKeyFromHexSecret(seed.toString('hex'), derivationPath)];
331
+ });
332
+ });
333
+ };
334
+ TezosSaplingProtocol.prototype.getPrivateKeyFromMnemonic = function (mnemonic, derivationPath, password) {
335
+ return __awaiter(this, void 0, void 0, function () {
336
+ var seed;
337
+ return __generator(this, function (_a) {
338
+ seed = this.getSeedFromMnemonic(mnemonic, password);
339
+ return [2 /*return*/, this.getPrivateKeyFromHexSecret(seed.toString('hex'), derivationPath)];
340
+ });
341
+ });
342
+ };
343
+ TezosSaplingProtocol.prototype.getSeedFromMnemonic = function (mnemonic, password) {
344
+ var seed = (0, bip39_2_5_0_1.mnemonicToSeed)(mnemonic, password);
179
345
  // We xor the two halves of the BIP-39 seed, as does `tezos-client`
180
- const first32 = seed.slice(0, 32);
181
- const second32 = seed.slice(32);
182
- return Buffer.from(first32.map((byte, index) => byte ^ second32[index]));
183
- }
184
- async getPublicKeyFromHexSecret(secret, derivationPath) {
185
- const viewingKey = await sapling.getExtendedFullViewingKey(secret, derivationPath);
186
- return viewingKey.toString('hex');
187
- }
188
- async getPrivateKeyFromHexSecret(secret, derivationPath) {
189
- const xsk = await sapling.getExtendedSpendingKey(secret, derivationPath);
190
- return xsk.toString('hex');
191
- }
192
- async getAddressFromPublicKey(viewingKey, cursor) {
193
- const current = cursor?.hasNext && cursor?.diversifierIndex
194
- ? await TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(viewingKey, cursor.diversifierIndex)
195
- : undefined;
196
- const address = current
197
- ? await TezosSaplingAddress_1.TezosSaplingAddress.next(viewingKey, current)
198
- : await TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(viewingKey);
199
- return {
200
- address: address.asString(),
201
- cursor: {
202
- hasNext: address.diversifierIndex !== undefined,
203
- diversifierIndex: address.diversifierIndex
204
- }
205
- };
206
- }
207
- async getAddressesFromPublicKey(viewingKey, cursor) {
208
- return [await this.getAddressFromPublicKey(viewingKey, cursor)];
209
- }
210
- async getAddressFromViewingKey(viewingKey, index) {
211
- const address = await TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(viewingKey, index);
212
- return {
213
- address: address.asString(),
214
- cursor: {
215
- hasNext: address.diversifierIndex !== undefined,
216
- diversifierIndex: address.diversifierIndex
217
- }
218
- };
219
- }
220
- async getTransactionsFromPublicKey(publicKey, limit, cursor) {
221
- if (this.nodeClient === undefined) {
222
- return {
223
- transactions: [],
224
- cursor: { page: 0 }
225
- };
226
- }
227
- const saplingStateDiff = await this.nodeClient.getSaplingStateDiff();
228
- const incoming = [];
229
- const outgoing = [];
230
- let page = cursor?.page ?? 0;
231
- let pageStart = page * limit;
232
- let pageEnd = pageStart + limit;
233
- while (incoming.length + outgoing.length < limit && pageStart < saplingStateDiff.commitments_and_ciphertexts.length) {
234
- const commitmentsAndCiphertexts = saplingStateDiff.commitments_and_ciphertexts
235
- .map(([commitment, ciphertext], index) => [commitment, ciphertext, new bignumber_1.default(index)])
236
- .reverse()
237
- .slice(pageStart, pageEnd);
238
- const inputs = await Promise.all([
239
- this.bookkeeper.getIncomingInputs(publicKey, commitmentsAndCiphertexts),
240
- this.bookkeeper.getOutgoingInputs(publicKey, commitmentsAndCiphertexts)
241
- ]);
242
- incoming.push(...inputs[0]);
243
- outgoing.push(...inputs[1]);
244
- page += 1;
245
- pageStart += limit;
246
- pageEnd += limit;
247
- }
248
- const airGapIncoming = await Promise.all(incoming.map(async (input) => ({
249
- from: ['Shielded Pool'],
250
- to: [input.address],
251
- isInbound: true,
252
- amount: input.value,
253
- fee: '0',
254
- protocolIdentifier: this.identifier,
255
- network: this.options.network
256
- })));
257
- const airGapOutgoing = await Promise.all(outgoing.map(async (input) => ({
258
- from: [(await this.getAddressFromPublicKey(publicKey)).address],
259
- to: [input.address],
260
- isInbound: false,
261
- amount: input.value,
262
- fee: '0',
263
- protocolIdentifier: this.identifier,
264
- network: this.options.network
265
- })));
266
- return {
267
- transactions: airGapIncoming.concat(airGapOutgoing),
268
- cursor: { page: page + 1 }
269
- };
270
- }
271
- async signWithPrivateKey(privateKey, transaction) {
272
- const stateTree = await this.state.getStateTreeFromStateDiff(transaction.stateDiff);
273
- const boundData = transaction.unshieldTarget && transaction.unshieldTarget.length > 0
274
- ? this.createAddressBoundData(transaction.unshieldTarget)
275
- : undefined;
276
- const forgedTransaction = await this.forger.forgeSaplingTransaction(transaction.ins, transaction.outs, stateTree, this.getAntiReplay(transaction.chainId, transaction.contractAddress), boundData, Buffer.from(privateKey, 'hex'));
277
- return this.encoder.encodeTransaction(forgedTransaction).toString('hex');
278
- }
279
- async getTransactionDetails(transaction, data) {
280
- const tx = transaction.transaction;
281
- const airGapTxs = [];
282
- if (this.isRawTezosSaplingTransaction(tx)) {
283
- const unshieldTarget = tx.unshieldTarget.length > 0 ? tx.unshieldTarget : undefined;
284
- const from = await this.getAddressFromPublicKey(transaction.publicKey).then((address) => TezosSaplingAddress_1.TezosSaplingAddress.fromValue(address.address, address.cursor.diversifierIndex));
285
- const details = this.bookkeeper
286
- .getUnsignedTransactionDetails(from, tx.ins, tx.outs, unshieldTarget)
287
- .map((details) => ({
288
- ...details,
289
- extra: {
290
- ...details.extra,
291
- destination: tx.contractAddress,
292
- chainId: tx.chainId
293
- },
294
- transactionDetails: tx
295
- }));
296
- airGapTxs.push(...details);
297
- }
298
- else {
299
- const wrappedOperation = await this.tezosProtocol.unforgeUnsignedTezosWrappedOperation(tx.binaryTransaction);
300
- airGapTxs.push(...(await this.getTransactionDetailsFromWrappedOperation(wrappedOperation, data?.knownViewingKeys)));
301
- }
302
- return this.filterOutPaybacks(airGapTxs);
303
- }
304
- async getTransactionDetailsFromSigned(transaction, data) {
305
- const airGapTxs = [];
306
- const tx = transaction.transaction;
307
- const defaultDetails = {
308
- from: ['Shielded Pool'],
309
- to: ['Shielded Pool'],
310
- isInbound: false,
311
- amount: '0',
312
- fee: '0',
313
- protocolIdentifier: this.identifier,
314
- network: this.options.network
315
- };
316
- if (this.contract?.areValidParameters(tx)) {
317
- const partialDetails = await this.getPartialDetailsFromContractParameters(tx, data?.knownViewingKeys);
318
- airGapTxs.push(...partialDetails.map((partial) => ({
319
- ...defaultDetails,
320
- ...partial
321
- })));
322
- }
323
- else {
324
- try {
325
- const wrappedOperation = await this.tezosProtocol.unforgeSignedTezosWrappedOperation(tx);
326
- airGapTxs.push(...(await this.getTransactionDetailsFromWrappedOperation(wrappedOperation, data?.knownViewingKeys)));
327
- }
328
- catch {
329
- const partialDetails = await this.bookkeeper.getTransactionsPartialDetails([tx], data?.knownViewingKeys);
330
- airGapTxs.push(...partialDetails.map((partial) => ({
331
- ...defaultDetails,
332
- ...partial
333
- })));
334
- }
335
- }
336
- return this.filterOutPaybacks(airGapTxs);
337
- }
338
- async getTransactionDetailsFromWrappedOperation(operation, knownViewingKeys = []) {
339
- const contractOperations = operation.contents.filter((content) => content.kind === TezosOperationType_1.TezosOperationType.TRANSACTION && content.parameters !== undefined);
340
- const details = await Promise.all(contractOperations.map(async (operation) => {
341
- const saplingDetails = await this.getPartialDetailsFromContractParameters(operation.parameters, knownViewingKeys);
342
- return saplingDetails.map((partials) => ({
343
- from: [operation.source],
344
- to: ['Shielded Pool'],
345
- isInbound: false,
346
- amount: operation.amount,
347
- fee: operation.fee,
348
- protocolIdentifier: this.identifier,
349
- network: this.options.network,
350
- ...partials,
351
- transactionDetails: operation
352
- }));
353
- }));
354
- return (0, array_1.flattenArray)(details);
355
- }
356
- async getPartialDetailsFromContractParameters(rawOrParsed, knownViewingKeys = []) {
357
- const parameters = typeof rawOrParsed === 'string' ? (this.contract ? this.contract.parseParameters(rawOrParsed) : JSON.parse(rawOrParsed)) : rawOrParsed;
358
- const txs = await this.parseParameters(parameters);
359
- return this.bookkeeper.getTransactionsPartialDetails(txs, knownViewingKeys);
360
- }
361
- filterOutPaybacks(airGapTxs) {
362
- const filtered = airGapTxs.filter((details) => {
346
+ var first32 = seed.slice(0, 32);
347
+ var second32 = seed.slice(32);
348
+ return Buffer.from(first32.map(function (byte, index) { return byte ^ second32[index]; }));
349
+ };
350
+ TezosSaplingProtocol.prototype.getPublicKeyFromHexSecret = function (secret, derivationPath) {
351
+ return __awaiter(this, void 0, void 0, function () {
352
+ var viewingKey;
353
+ return __generator(this, function (_a) {
354
+ switch (_a.label) {
355
+ case 0: return [4 /*yield*/, sapling.getExtendedFullViewingKey(secret, derivationPath)];
356
+ case 1:
357
+ viewingKey = _a.sent();
358
+ return [2 /*return*/, viewingKey.toString('hex')];
359
+ }
360
+ });
361
+ });
362
+ };
363
+ TezosSaplingProtocol.prototype.getPrivateKeyFromHexSecret = function (secret, derivationPath) {
364
+ return __awaiter(this, void 0, void 0, function () {
365
+ var xsk;
366
+ return __generator(this, function (_a) {
367
+ switch (_a.label) {
368
+ case 0: return [4 /*yield*/, sapling.getExtendedSpendingKey(secret, derivationPath)];
369
+ case 1:
370
+ xsk = _a.sent();
371
+ return [2 /*return*/, xsk.toString('hex')];
372
+ }
373
+ });
374
+ });
375
+ };
376
+ TezosSaplingProtocol.prototype.getAddressFromPublicKey = function (viewingKey, cursor) {
377
+ return __awaiter(this, void 0, void 0, function () {
378
+ var current, _a, address, _b;
379
+ return __generator(this, function (_c) {
380
+ switch (_c.label) {
381
+ case 0:
382
+ if (!((cursor === null || cursor === void 0 ? void 0 : cursor.hasNext) && (cursor === null || cursor === void 0 ? void 0 : cursor.diversifierIndex))) return [3 /*break*/, 2];
383
+ return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(viewingKey, cursor.diversifierIndex)];
384
+ case 1:
385
+ _a = _c.sent();
386
+ return [3 /*break*/, 3];
387
+ case 2:
388
+ _a = undefined;
389
+ _c.label = 3;
390
+ case 3:
391
+ current = _a;
392
+ if (!current) return [3 /*break*/, 5];
393
+ return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.next(viewingKey, current)];
394
+ case 4:
395
+ _b = _c.sent();
396
+ return [3 /*break*/, 7];
397
+ case 5: return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(viewingKey)];
398
+ case 6:
399
+ _b = _c.sent();
400
+ _c.label = 7;
401
+ case 7:
402
+ address = _b;
403
+ return [2 /*return*/, {
404
+ address: address.asString(),
405
+ cursor: {
406
+ hasNext: address.diversifierIndex !== undefined,
407
+ diversifierIndex: address.diversifierIndex
408
+ }
409
+ }];
410
+ }
411
+ });
412
+ });
413
+ };
414
+ TezosSaplingProtocol.prototype.getAddressesFromPublicKey = function (viewingKey, cursor) {
415
+ return __awaiter(this, void 0, void 0, function () {
416
+ return __generator(this, function (_a) {
417
+ switch (_a.label) {
418
+ case 0: return [4 /*yield*/, this.getAddressFromPublicKey(viewingKey, cursor)];
419
+ case 1: return [2 /*return*/, [_a.sent()]];
420
+ }
421
+ });
422
+ });
423
+ };
424
+ TezosSaplingProtocol.prototype.getAddressFromViewingKey = function (viewingKey, index) {
425
+ return __awaiter(this, void 0, void 0, function () {
426
+ var address;
427
+ return __generator(this, function (_a) {
428
+ switch (_a.label) {
429
+ case 0: return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(viewingKey, index)];
430
+ case 1:
431
+ address = _a.sent();
432
+ return [2 /*return*/, {
433
+ address: address.asString(),
434
+ cursor: {
435
+ hasNext: address.diversifierIndex !== undefined,
436
+ diversifierIndex: address.diversifierIndex
437
+ }
438
+ }];
439
+ }
440
+ });
441
+ });
442
+ };
443
+ TezosSaplingProtocol.prototype.getTransactionsFromPublicKey = function (publicKey, limit, cursor) {
444
+ var _a;
445
+ return __awaiter(this, void 0, void 0, function () {
446
+ var saplingStateDiff, incoming, outgoing, page, pageStart, pageEnd, commitmentsAndCiphertexts, inputs, airGapIncoming, airGapOutgoing;
447
+ var _this = this;
448
+ return __generator(this, function (_b) {
449
+ switch (_b.label) {
450
+ case 0:
451
+ if (this.nodeClient === undefined) {
452
+ return [2 /*return*/, {
453
+ transactions: [],
454
+ cursor: { page: 0 }
455
+ }];
456
+ }
457
+ return [4 /*yield*/, this.nodeClient.getSaplingStateDiff()];
458
+ case 1:
459
+ saplingStateDiff = _b.sent();
460
+ incoming = [];
461
+ outgoing = [];
462
+ page = (_a = cursor === null || cursor === void 0 ? void 0 : cursor.page) !== null && _a !== void 0 ? _a : 0;
463
+ pageStart = page * limit;
464
+ pageEnd = pageStart + limit;
465
+ _b.label = 2;
466
+ case 2:
467
+ if (!(incoming.length + outgoing.length < limit && pageStart < saplingStateDiff.commitments_and_ciphertexts.length)) return [3 /*break*/, 4];
468
+ commitmentsAndCiphertexts = saplingStateDiff.commitments_and_ciphertexts
469
+ .map(function (_a, index) {
470
+ var commitment = _a[0], ciphertext = _a[1];
471
+ return [commitment, ciphertext, new bignumber_1.default(index)];
472
+ })
473
+ .reverse()
474
+ .slice(pageStart, pageEnd);
475
+ return [4 /*yield*/, Promise.all([
476
+ this.bookkeeper.getIncomingInputs(publicKey, commitmentsAndCiphertexts),
477
+ this.bookkeeper.getOutgoingInputs(publicKey, commitmentsAndCiphertexts)
478
+ ])];
479
+ case 3:
480
+ inputs = _b.sent();
481
+ incoming.push.apply(incoming, inputs[0]);
482
+ outgoing.push.apply(outgoing, inputs[1]);
483
+ page += 1;
484
+ pageStart += limit;
485
+ pageEnd += limit;
486
+ return [3 /*break*/, 2];
487
+ case 4: return [4 /*yield*/, Promise.all(incoming.map(function (input) { return __awaiter(_this, void 0, void 0, function () {
488
+ return __generator(this, function (_a) {
489
+ return [2 /*return*/, ({
490
+ from: ['Shielded Pool'],
491
+ to: [input.address],
492
+ isInbound: true,
493
+ amount: input.value,
494
+ fee: '0',
495
+ protocolIdentifier: this.identifier,
496
+ network: this.options.network
497
+ })];
498
+ });
499
+ }); }))];
500
+ case 5:
501
+ airGapIncoming = _b.sent();
502
+ return [4 /*yield*/, Promise.all(outgoing.map(function (input) { return __awaiter(_this, void 0, void 0, function () {
503
+ var _a;
504
+ return __generator(this, function (_b) {
505
+ switch (_b.label) {
506
+ case 0:
507
+ _a = {};
508
+ return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
509
+ case 1: return [2 /*return*/, (_a.from = [(_b.sent()).address],
510
+ _a.to = [input.address],
511
+ _a.isInbound = false,
512
+ _a.amount = input.value,
513
+ _a.fee = '0',
514
+ _a.protocolIdentifier = this.identifier,
515
+ _a.network = this.options.network,
516
+ _a)];
517
+ }
518
+ });
519
+ }); }))];
520
+ case 6:
521
+ airGapOutgoing = _b.sent();
522
+ return [2 /*return*/, {
523
+ transactions: airGapIncoming.concat(airGapOutgoing),
524
+ cursor: { page: page + 1 }
525
+ }];
526
+ }
527
+ });
528
+ });
529
+ };
530
+ TezosSaplingProtocol.prototype.signWithPrivateKey = function (privateKey, transaction) {
531
+ return __awaiter(this, void 0, void 0, function () {
532
+ var stateTree, boundData, forgedTransaction;
533
+ return __generator(this, function (_a) {
534
+ switch (_a.label) {
535
+ case 0: return [4 /*yield*/, this.state.getStateTreeFromStateDiff(transaction.stateDiff)];
536
+ case 1:
537
+ stateTree = _a.sent();
538
+ boundData = transaction.unshieldTarget && transaction.unshieldTarget.length > 0
539
+ ? this.createAddressBoundData(transaction.unshieldTarget)
540
+ : undefined;
541
+ return [4 /*yield*/, this.forger.forgeSaplingTransaction(transaction.ins, transaction.outs, stateTree, this.getAntiReplay(transaction.chainId, transaction.contractAddress), boundData, Buffer.from(privateKey, 'hex'))];
542
+ case 2:
543
+ forgedTransaction = _a.sent();
544
+ return [2 /*return*/, this.encoder.encodeTransaction(forgedTransaction).toString('hex')];
545
+ }
546
+ });
547
+ });
548
+ };
549
+ TezosSaplingProtocol.prototype.getTransactionDetails = function (transaction, data) {
550
+ return __awaiter(this, void 0, void 0, function () {
551
+ var tx, airGapTxs, unshieldTarget, from, details, wrappedOperation, _a, _b, _c;
552
+ return __generator(this, function (_d) {
553
+ switch (_d.label) {
554
+ case 0:
555
+ tx = transaction.transaction;
556
+ airGapTxs = [];
557
+ if (!this.isRawTezosSaplingTransaction(tx)) return [3 /*break*/, 2];
558
+ unshieldTarget = tx.unshieldTarget.length > 0 ? tx.unshieldTarget : undefined;
559
+ return [4 /*yield*/, this.getAddressFromPublicKey(transaction.publicKey).then(function (address) { return TezosSaplingAddress_1.TezosSaplingAddress.fromValue(address.address, address.cursor.diversifierIndex); })];
560
+ case 1:
561
+ from = _d.sent();
562
+ details = this.bookkeeper
563
+ .getUnsignedTransactionDetails(from, tx.ins, tx.outs, unshieldTarget)
564
+ .map(function (details) { return (__assign(__assign({}, details), { extra: __assign(__assign({}, details.extra), { destination: tx.contractAddress, chainId: tx.chainId }), transactionDetails: tx })); });
565
+ airGapTxs.push.apply(airGapTxs, details);
566
+ return [3 /*break*/, 5];
567
+ case 2: return [4 /*yield*/, this.tezosProtocol.unforgeUnsignedTezosWrappedOperation(tx.binaryTransaction)];
568
+ case 3:
569
+ wrappedOperation = _d.sent();
570
+ _b = (_a = airGapTxs.push).apply;
571
+ _c = [airGapTxs];
572
+ return [4 /*yield*/, this.getTransactionDetailsFromWrappedOperation(wrappedOperation, data === null || data === void 0 ? void 0 : data.knownViewingKeys)];
573
+ case 4:
574
+ _b.apply(_a, _c.concat([(_d.sent())]));
575
+ _d.label = 5;
576
+ case 5: return [2 /*return*/, this.filterOutPaybacks(airGapTxs)];
577
+ }
578
+ });
579
+ });
580
+ };
581
+ TezosSaplingProtocol.prototype.getTransactionDetailsFromSigned = function (transaction, data) {
582
+ var _a;
583
+ return __awaiter(this, void 0, void 0, function () {
584
+ var airGapTxs, tx, defaultDetails, partialDetails, wrappedOperation, _b, _c, _d, _e, partialDetails;
585
+ return __generator(this, function (_f) {
586
+ switch (_f.label) {
587
+ case 0:
588
+ airGapTxs = [];
589
+ tx = transaction.transaction;
590
+ defaultDetails = {
591
+ from: ['Shielded Pool'],
592
+ to: ['Shielded Pool'],
593
+ isInbound: false,
594
+ amount: '0',
595
+ fee: '0',
596
+ protocolIdentifier: this.identifier,
597
+ network: this.options.network
598
+ };
599
+ if (!((_a = this.contract) === null || _a === void 0 ? void 0 : _a.areValidParameters(tx))) return [3 /*break*/, 2];
600
+ return [4 /*yield*/, this.getPartialDetailsFromContractParameters(tx, data === null || data === void 0 ? void 0 : data.knownViewingKeys)];
601
+ case 1:
602
+ partialDetails = _f.sent();
603
+ airGapTxs.push.apply(airGapTxs, partialDetails.map(function (partial) { return (__assign(__assign({}, defaultDetails), partial)); }));
604
+ return [3 /*break*/, 7];
605
+ case 2:
606
+ _f.trys.push([2, 5, , 7]);
607
+ return [4 /*yield*/, this.tezosProtocol.unforgeSignedTezosWrappedOperation(tx)];
608
+ case 3:
609
+ wrappedOperation = _f.sent();
610
+ _c = (_b = airGapTxs.push).apply;
611
+ _d = [airGapTxs];
612
+ return [4 /*yield*/, this.getTransactionDetailsFromWrappedOperation(wrappedOperation, data === null || data === void 0 ? void 0 : data.knownViewingKeys)];
613
+ case 4:
614
+ _c.apply(_b, _d.concat([(_f.sent())]));
615
+ return [3 /*break*/, 7];
616
+ case 5:
617
+ _e = _f.sent();
618
+ return [4 /*yield*/, this.bookkeeper.getTransactionsPartialDetails([tx], data === null || data === void 0 ? void 0 : data.knownViewingKeys)];
619
+ case 6:
620
+ partialDetails = _f.sent();
621
+ airGapTxs.push.apply(airGapTxs, partialDetails.map(function (partial) { return (__assign(__assign({}, defaultDetails), partial)); }));
622
+ return [3 /*break*/, 7];
623
+ case 7: return [2 /*return*/, this.filterOutPaybacks(airGapTxs)];
624
+ }
625
+ });
626
+ });
627
+ };
628
+ TezosSaplingProtocol.prototype.getTransactionDetailsFromWrappedOperation = function (operation, knownViewingKeys) {
629
+ if (knownViewingKeys === void 0) { knownViewingKeys = []; }
630
+ return __awaiter(this, void 0, void 0, function () {
631
+ var contractOperations, details;
632
+ var _this = this;
633
+ return __generator(this, function (_a) {
634
+ switch (_a.label) {
635
+ case 0:
636
+ contractOperations = operation.contents.filter(function (content) {
637
+ return content.kind === TezosOperationType_1.TezosOperationType.TRANSACTION && content.parameters !== undefined;
638
+ });
639
+ return [4 /*yield*/, Promise.all(contractOperations.map(function (operation) { return __awaiter(_this, void 0, void 0, function () {
640
+ var saplingDetails;
641
+ var _this = this;
642
+ return __generator(this, function (_a) {
643
+ switch (_a.label) {
644
+ case 0: return [4 /*yield*/, this.getPartialDetailsFromContractParameters(operation.parameters, knownViewingKeys)];
645
+ case 1:
646
+ saplingDetails = _a.sent();
647
+ return [2 /*return*/, saplingDetails.map(function (partials) { return (__assign(__assign({ from: [operation.source], to: ['Shielded Pool'], isInbound: false, amount: operation.amount, fee: operation.fee, protocolIdentifier: _this.identifier, network: _this.options.network }, partials), { transactionDetails: operation })); })];
648
+ }
649
+ });
650
+ }); }))];
651
+ case 1:
652
+ details = _a.sent();
653
+ return [2 /*return*/, (0, array_1.flattenArray)(details)];
654
+ }
655
+ });
656
+ });
657
+ };
658
+ TezosSaplingProtocol.prototype.getPartialDetailsFromContractParameters = function (rawOrParsed, knownViewingKeys) {
659
+ if (knownViewingKeys === void 0) { knownViewingKeys = []; }
660
+ return __awaiter(this, void 0, void 0, function () {
661
+ var parameters, txs;
662
+ return __generator(this, function (_a) {
663
+ switch (_a.label) {
664
+ case 0:
665
+ parameters = typeof rawOrParsed === 'string' ? (this.contract ? this.contract.parseParameters(rawOrParsed) : JSON.parse(rawOrParsed)) : rawOrParsed;
666
+ return [4 /*yield*/, this.parseParameters(parameters)];
667
+ case 1:
668
+ txs = _a.sent();
669
+ return [2 /*return*/, this.bookkeeper.getTransactionsPartialDetails(txs, knownViewingKeys)];
670
+ }
671
+ });
672
+ });
673
+ };
674
+ TezosSaplingProtocol.prototype.filterOutPaybacks = function (airGapTxs) {
675
+ var filtered = airGapTxs.filter(function (details) {
363
676
  if (details.from.length !== details.to.length) {
364
677
  return true;
365
678
  }
366
- const fromSet = new Set(details.from);
367
- const toSet = new Set(details.to);
368
- return Array.from(fromSet).some((address) => !toSet.has(address));
679
+ var fromSet = new Set(details.from);
680
+ var toSet = new Set(details.to);
681
+ return Array.from(fromSet).some(function (address) { return !toSet.has(address); });
369
682
  });
370
683
  return filtered.length > 0 ? filtered : airGapTxs;
371
- }
372
- async getBalanceOfPublicKey(publicKey) {
373
- if (this.nodeClient === undefined) {
374
- return '0';
375
- }
376
- const saplingStateDiff = await this.nodeClient.getSaplingStateDiff();
377
- const unspends = await this.bookkeeper.getUnspends(publicKey, saplingStateDiff.commitments_and_ciphertexts, saplingStateDiff.nullifiers);
378
- const balance = unspends.reduce((sum, next) => sum.plus(next.value), new bignumber_1.default(0));
379
- return balance.toString();
380
- }
381
- async getTransactionStatuses(transactionHash) {
382
- throw new Error('Method not implemented.');
383
- }
384
- async estimateMaxTransactionValueFromPublicKey(publicKey, recipients, fee) {
385
- return this.getBalanceOfPublicKey(publicKey);
386
- }
387
- async prepareTransactionFromPublicKey(publicKey, recipients, values, fee, data) {
388
- if (recipients.length > 1 && values.length > 1) {
389
- return Promise.reject('Multiple sapling transactions are not supported');
390
- }
391
- if (recipients.length === 0 && values.length === 0) {
392
- return Promise.reject('No recpients and values have been provided');
393
- }
394
- const recipient = recipients[0];
395
- const value = values[0];
396
- if (TezosAddress_1.TezosAddress.isTzAddress(recipient)) {
397
- return this.prepareUnshieldTransaction(publicKey, recipient, value, data);
398
- }
399
- else if (TezosSaplingAddress_1.TezosSaplingAddress.isZetAddress(recipient)) {
400
- return this.prepareSaplingTransaction(publicKey, recipient, value, data);
401
- }
402
- return Promise.reject(`Invalid recpient, expected a 'tz' or 'zet' address, got ${recipient}`);
403
- }
404
- async wrapSaplingTransactions(publicKey, transactionsOrString, fee, overrideFees = false) {
405
- if (this.contract === undefined) {
406
- throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
407
- }
408
- let operations;
409
- if (typeof transactionsOrString === 'string' && this.contract.areValidParameters(transactionsOrString)) {
410
- const parameters = this.contract.parseParameters(transactionsOrString);
411
- operations = [this.prepareTezosOperation(parameters, fee)];
412
- }
413
- else {
414
- const transactions = Array.isArray(transactionsOrString) ? transactionsOrString : [transactionsOrString];
415
- const contractCalls = await this.prepareContractCalls(transactions);
416
- operations = contractCalls.map((contractCall) => this.prepareTezosOperation(contractCall.toJSON(), fee, contractCall.amount?.toString()));
417
- }
418
- try {
419
- const tezosWrappedOperation = await this.tezosProtocol.prepareOperations(publicKey, operations, overrideFees);
420
- const binaryTx = await this.tezosProtocol.forgeTezosOperation(tezosWrappedOperation);
421
- return { binaryTransaction: binaryTx };
422
- }
423
- catch (error) {
424
- console.error(error);
425
- if (error.code !== undefined && error.code === errors_1.ProtocolErrorType.TRANSACTION_FAILED) {
426
- const rpcErrors = error.data;
427
- const cannotPayStorageFee = rpcErrors.find((error) => error.id.endsWith('.contract.cannot_pay_storage_fee'));
428
- if (cannotPayStorageFee) {
429
- throw new errors_1.BalanceError(coinlib_error_1.Domain.TEZOS, 'Balance too low, cannot pay for storage fee');
684
+ };
685
+ TezosSaplingProtocol.prototype.getBalanceOfPublicKey = function (publicKey) {
686
+ return __awaiter(this, void 0, void 0, function () {
687
+ var saplingStateDiff, unspends, balance;
688
+ return __generator(this, function (_a) {
689
+ switch (_a.label) {
690
+ case 0:
691
+ if (this.nodeClient === undefined) {
692
+ return [2 /*return*/, '0'];
693
+ }
694
+ return [4 /*yield*/, this.nodeClient.getSaplingStateDiff()];
695
+ case 1:
696
+ saplingStateDiff = _a.sent();
697
+ return [4 /*yield*/, this.bookkeeper.getUnspends(publicKey, saplingStateDiff.commitments_and_ciphertexts, saplingStateDiff.nullifiers)];
698
+ case 2:
699
+ unspends = _a.sent();
700
+ balance = unspends.reduce(function (sum, next) { return sum.plus(next.value); }, new bignumber_1.default(0));
701
+ return [2 /*return*/, balance.toString()];
430
702
  }
431
- const balanceTooLowError = rpcErrors.find((error) => error.id.endsWith('.contract.balance_too_low'));
432
- if (balanceTooLowError) {
433
- throw new errors_1.BalanceError(coinlib_error_1.Domain.TEZOS, 'Balance too low');
703
+ });
704
+ });
705
+ };
706
+ TezosSaplingProtocol.prototype.getTransactionStatuses = function (transactionHash) {
707
+ return __awaiter(this, void 0, void 0, function () {
708
+ return __generator(this, function (_a) {
709
+ throw new Error('Method not implemented.');
710
+ });
711
+ });
712
+ };
713
+ TezosSaplingProtocol.prototype.estimateMaxTransactionValueFromPublicKey = function (publicKey, recipients, fee) {
714
+ return __awaiter(this, void 0, void 0, function () {
715
+ return __generator(this, function (_a) {
716
+ return [2 /*return*/, this.getBalanceOfPublicKey(publicKey)];
717
+ });
718
+ });
719
+ };
720
+ TezosSaplingProtocol.prototype.prepareTransactionFromPublicKey = function (publicKey, recipients, values, fee, data) {
721
+ return __awaiter(this, void 0, void 0, function () {
722
+ var recipient, value;
723
+ return __generator(this, function (_a) {
724
+ if (recipients.length > 1 && values.length > 1) {
725
+ return [2 /*return*/, Promise.reject('Multiple sapling transactions are not supported')];
434
726
  }
435
- }
436
- throw error;
437
- }
438
- }
439
- prepareTezosOperation(parameters, fee, amount = '0') {
727
+ if (recipients.length === 0 && values.length === 0) {
728
+ return [2 /*return*/, Promise.reject('No recpients and values have been provided')];
729
+ }
730
+ recipient = recipients[0];
731
+ value = values[0];
732
+ if (TezosAddress_1.TezosAddress.isTzAddress(recipient)) {
733
+ return [2 /*return*/, this.prepareUnshieldTransaction(publicKey, recipient, value, data)];
734
+ }
735
+ else if (TezosSaplingAddress_1.TezosSaplingAddress.isZetAddress(recipient)) {
736
+ return [2 /*return*/, this.prepareSaplingTransaction(publicKey, recipient, value, data)];
737
+ }
738
+ return [2 /*return*/, Promise.reject("Invalid recpient, expected a 'tz' or 'zet' address, got ".concat(recipient))];
739
+ });
740
+ });
741
+ };
742
+ TezosSaplingProtocol.prototype.wrapSaplingTransactions = function (publicKey, transactionsOrString, fee, overrideFees) {
743
+ if (overrideFees === void 0) { overrideFees = false; }
744
+ return __awaiter(this, void 0, void 0, function () {
745
+ var operations, parameters, transactions, contractCalls, tezosWrappedOperation, binaryTx, error_1, rpcErrors, cannotPayStorageFee, balanceTooLowError;
746
+ var _this = this;
747
+ return __generator(this, function (_a) {
748
+ switch (_a.label) {
749
+ case 0:
750
+ if (this.contract === undefined) {
751
+ throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
752
+ }
753
+ if (!(typeof transactionsOrString === 'string' && this.contract.areValidParameters(transactionsOrString))) return [3 /*break*/, 1];
754
+ parameters = this.contract.parseParameters(transactionsOrString);
755
+ operations = [this.prepareTezosOperation(parameters, fee)];
756
+ return [3 /*break*/, 3];
757
+ case 1:
758
+ transactions = Array.isArray(transactionsOrString) ? transactionsOrString : [transactionsOrString];
759
+ return [4 /*yield*/, this.prepareContractCalls(transactions)];
760
+ case 2:
761
+ contractCalls = _a.sent();
762
+ operations = contractCalls.map(function (contractCall) { var _a; return _this.prepareTezosOperation(contractCall.toJSON(), fee, (_a = contractCall.amount) === null || _a === void 0 ? void 0 : _a.toString()); });
763
+ _a.label = 3;
764
+ case 3:
765
+ _a.trys.push([3, 6, , 7]);
766
+ return [4 /*yield*/, this.tezosProtocol.prepareOperations(publicKey, operations, overrideFees)];
767
+ case 4:
768
+ tezosWrappedOperation = _a.sent();
769
+ return [4 /*yield*/, this.tezosProtocol.forgeTezosOperation(tezosWrappedOperation)];
770
+ case 5:
771
+ binaryTx = _a.sent();
772
+ return [2 /*return*/, { binaryTransaction: binaryTx }];
773
+ case 6:
774
+ error_1 = _a.sent();
775
+ console.error(error_1);
776
+ if (error_1.code !== undefined && error_1.code === errors_1.ProtocolErrorType.TRANSACTION_FAILED) {
777
+ rpcErrors = error_1.data;
778
+ cannotPayStorageFee = rpcErrors.find(function (error) { return error.id.endsWith('.contract.cannot_pay_storage_fee'); });
779
+ if (cannotPayStorageFee) {
780
+ throw new errors_1.BalanceError(coinlib_error_1.Domain.TEZOS, 'Balance too low, cannot pay for storage fee');
781
+ }
782
+ balanceTooLowError = rpcErrors.find(function (error) { return error.id.endsWith('.contract.balance_too_low'); });
783
+ if (balanceTooLowError) {
784
+ throw new errors_1.BalanceError(coinlib_error_1.Domain.TEZOS, 'Balance too low');
785
+ }
786
+ }
787
+ throw error_1;
788
+ case 7: return [2 /*return*/];
789
+ }
790
+ });
791
+ });
792
+ };
793
+ TezosSaplingProtocol.prototype.prepareTezosOperation = function (parameters, fee, amount) {
794
+ if (amount === void 0) { amount = '0'; }
440
795
  return {
441
796
  kind: TezosOperationType_1.TezosOperationType.TRANSACTION,
442
- fee,
443
- amount,
797
+ fee: fee,
798
+ amount: amount,
444
799
  destination: this.options.config.contractAddress,
445
- parameters
800
+ parameters: parameters
446
801
  };
447
- }
448
- async prepareShieldTransaction(publicKey, recipient, value, fee, data) {
449
- const encodedTransaction = await this.mint(recipient, value);
450
- return this.wrapSaplingTransactions(publicKey, [encodedTransaction], fee, data?.overrideFees);
451
- }
452
- async prepareUnshieldTransaction(viewingKey, recipient, value, data) {
453
- if (!TezosAddress_1.TezosAddress.isTzAddress(recipient)) {
454
- return Promise.reject(`Invalid recpient, expected a 'tz' address, got ${recipient}`);
455
- }
456
- const burnTransaction = await this.burn(viewingKey, value);
457
- return {
458
- ...burnTransaction,
459
- unshieldTarget: recipient
460
- };
461
- }
462
- async prepareSaplingTransaction(viewingKey, recipient, value, data) {
463
- if (this.nodeClient === undefined || this.options.config.contractAddress === undefined) {
464
- throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
465
- }
466
- if (!TezosSaplingAddress_1.TezosSaplingAddress.isZetAddress(recipient)) {
467
- return Promise.reject(`Invalid recpient, expected a 'zet' address, got ${recipient}`);
468
- }
469
- const dummyInputsAmount = Math.max(new bignumber_1.default(data?.dummyInputs ?? 0).toNumber(), 0);
470
- const dummyOutputsAmount = Math.max(new bignumber_1.default(data?.dummyOutputs ?? 0).toNumber(), 0);
471
- const [stateDiff, chainId] = await Promise.all([
472
- this.nodeClient.getSaplingStateDiff(),
473
- this.nodeClient.getChainId()
474
- ]);
475
- const [inputs, toSpend] = await this.chooseInputs(viewingKey, stateDiff.commitments_and_ciphertexts, stateDiff.nullifiers, value);
476
- const address = await this.getAddressFromPublicKey(viewingKey).then((address) => TezosSaplingAddress_1.TezosSaplingAddress.fromValue(address.address, address.cursor.diversifierIndex));
477
- const paymentOutput = this.createPaymentOutput(await TezosSaplingAddress_1.TezosSaplingAddress.fromValue(recipient), value);
478
- const paybackOutput = this.createPaybackOutput(address, toSpend, value);
479
- const [dummyInputs, dummyOutputs] = await Promise.all([
480
- Promise.all(Array.from({ length: dummyInputsAmount }, (_v, _k) => this.createDummyInput(address))),
481
- Promise.all(Array.from({ length: dummyOutputsAmount }, (_v, _k) => this.createDummyOutput()))
482
- ]);
483
- return {
484
- ins: inputs.concat(dummyInputs),
485
- outs: [paymentOutput, paybackOutput, ...dummyOutputs].filter((output) => output !== undefined),
486
- contractAddress: this.options.config.contractAddress,
487
- chainId,
488
- stateDiff,
489
- unshieldTarget: ''
490
- };
491
- }
492
- async mint(recipient, value) {
493
- if (this.nodeClient === undefined || this.options.config.contractAddress === undefined) {
494
- throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
495
- }
496
- if (!TezosSaplingAddress_1.TezosSaplingAddress.isZetAddress(recipient)) {
497
- return Promise.reject(`Invalid recipient, expected a 'zet' address, got ${recipient}`);
498
- }
499
- const [saplingStateDiff, chainId] = await Promise.all([
500
- this.nodeClient.getSaplingStateDiff(),
501
- this.nodeClient.getChainId()
502
- ]);
503
- const output = {
504
- address: (await TezosSaplingAddress_1.TezosSaplingAddress.fromValue(recipient)).asString(),
505
- value,
506
- memo: Buffer.alloc(this.options.config.memoSize).toString('hex'),
507
- browsable: true
508
- };
509
- const stateTree = await this.state.getStateTreeFromStateDiff(saplingStateDiff, true);
510
- const forgedTransaction = await this.forger.forgeSaplingTransaction([], [output], stateTree, this.getAntiReplay(chainId, this.options.config.contractAddress));
511
- return this.encoder.encodeTransaction(forgedTransaction).toString('hex');
512
- }
513
- async burn(viewingKey, value) {
514
- if (this.nodeClient === undefined || this.options.config.contractAddress === undefined) {
515
- throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
516
- }
517
- const [stateDiff, chainId] = await Promise.all([
518
- this.nodeClient.getSaplingStateDiff(),
519
- this.nodeClient.getChainId()
520
- ]);
521
- const [inputs, toSpend] = await this.chooseInputs(viewingKey, stateDiff.commitments_and_ciphertexts, stateDiff.nullifiers, value);
522
- const paybackOutput = {
523
- address: (await this.getAddressFromPublicKey(viewingKey)).address,
524
- value: toSpend.minus(value).toString(),
525
- memo: Buffer.alloc(this.options.config.memoSize).toString('hex'),
526
- browsable: true
527
- };
528
- return {
529
- ins: inputs,
530
- outs: [paybackOutput],
531
- contractAddress: this.options.config.contractAddress,
532
- chainId,
533
- stateDiff,
534
- unshieldTarget: ''
535
- };
536
- }
537
- async chooseInputs(viewingKey, commitmentsWithCiphertext, nullifiers, value) {
538
- const unspends = await this.bookkeeper.getUnspends(viewingKey, commitmentsWithCiphertext, nullifiers);
539
- const balance = this.bookkeeper.sumNotes(unspends);
540
- if (balance.lt(value)) {
541
- return Promise.reject('Not enough balance');
542
- }
543
- const chosenUnspends = [];
544
- let toSpend = new bignumber_1.default(0);
545
- for (const unspend of unspends) {
546
- if (toSpend.gte(value)) {
547
- break;
548
- }
549
- toSpend = toSpend.plus(unspend.value);
550
- chosenUnspends.push(unspend);
551
- }
552
- return [chosenUnspends, toSpend];
553
- }
554
- createPaymentOutput(address, value, memo = Buffer.alloc(this.options.config.memoSize)) {
802
+ };
803
+ TezosSaplingProtocol.prototype.prepareShieldTransaction = function (publicKey, recipient, value, fee, data) {
804
+ return __awaiter(this, void 0, void 0, function () {
805
+ var encodedTransaction;
806
+ return __generator(this, function (_a) {
807
+ switch (_a.label) {
808
+ case 0: return [4 /*yield*/, this.mint(recipient, value)];
809
+ case 1:
810
+ encodedTransaction = _a.sent();
811
+ return [2 /*return*/, this.wrapSaplingTransactions(publicKey, [encodedTransaction], fee, data === null || data === void 0 ? void 0 : data.overrideFees)];
812
+ }
813
+ });
814
+ });
815
+ };
816
+ TezosSaplingProtocol.prototype.prepareUnshieldTransaction = function (viewingKey, recipient, value, data) {
817
+ return __awaiter(this, void 0, void 0, function () {
818
+ var burnTransaction;
819
+ return __generator(this, function (_a) {
820
+ switch (_a.label) {
821
+ case 0:
822
+ if (!TezosAddress_1.TezosAddress.isTzAddress(recipient)) {
823
+ return [2 /*return*/, Promise.reject("Invalid recpient, expected a 'tz' address, got ".concat(recipient))];
824
+ }
825
+ return [4 /*yield*/, this.burn(viewingKey, value)];
826
+ case 1:
827
+ burnTransaction = _a.sent();
828
+ return [2 /*return*/, __assign(__assign({}, burnTransaction), { unshieldTarget: recipient })];
829
+ }
830
+ });
831
+ });
832
+ };
833
+ TezosSaplingProtocol.prototype.prepareSaplingTransaction = function (viewingKey, recipient, value, data) {
834
+ var _a, _b;
835
+ return __awaiter(this, void 0, void 0, function () {
836
+ var dummyInputsAmount, dummyOutputsAmount, _c, stateDiff, chainId, _d, inputs, toSpend, address, paymentOutput, _e, paybackOutput, _f, dummyInputs, dummyOutputs;
837
+ var _this = this;
838
+ return __generator(this, function (_g) {
839
+ switch (_g.label) {
840
+ case 0:
841
+ if (this.nodeClient === undefined || this.options.config.contractAddress === undefined) {
842
+ throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
843
+ }
844
+ if (!TezosSaplingAddress_1.TezosSaplingAddress.isZetAddress(recipient)) {
845
+ return [2 /*return*/, Promise.reject("Invalid recpient, expected a 'zet' address, got ".concat(recipient))];
846
+ }
847
+ dummyInputsAmount = Math.max(new bignumber_1.default((_a = data === null || data === void 0 ? void 0 : data.dummyInputs) !== null && _a !== void 0 ? _a : 0).toNumber(), 0);
848
+ dummyOutputsAmount = Math.max(new bignumber_1.default((_b = data === null || data === void 0 ? void 0 : data.dummyOutputs) !== null && _b !== void 0 ? _b : 0).toNumber(), 0);
849
+ return [4 /*yield*/, Promise.all([
850
+ this.nodeClient.getSaplingStateDiff(),
851
+ this.nodeClient.getChainId()
852
+ ])];
853
+ case 1:
854
+ _c = _g.sent(), stateDiff = _c[0], chainId = _c[1];
855
+ return [4 /*yield*/, this.chooseInputs(viewingKey, stateDiff.commitments_and_ciphertexts, stateDiff.nullifiers, value)];
856
+ case 2:
857
+ _d = _g.sent(), inputs = _d[0], toSpend = _d[1];
858
+ return [4 /*yield*/, this.getAddressFromPublicKey(viewingKey).then(function (address) {
859
+ return TezosSaplingAddress_1.TezosSaplingAddress.fromValue(address.address, address.cursor.diversifierIndex);
860
+ })];
861
+ case 3:
862
+ address = _g.sent();
863
+ _e = this.createPaymentOutput;
864
+ return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromValue(recipient)];
865
+ case 4:
866
+ paymentOutput = _e.apply(this, [_g.sent(), value]);
867
+ paybackOutput = this.createPaybackOutput(address, toSpend, value);
868
+ return [4 /*yield*/, Promise.all([
869
+ Promise.all(Array.from({ length: dummyInputsAmount }, function (_v, _k) { return _this.createDummyInput(address); })),
870
+ Promise.all(Array.from({ length: dummyOutputsAmount }, function (_v, _k) { return _this.createDummyOutput(); }))
871
+ ])];
872
+ case 5:
873
+ _f = _g.sent(), dummyInputs = _f[0], dummyOutputs = _f[1];
874
+ return [2 /*return*/, {
875
+ ins: inputs.concat(dummyInputs),
876
+ outs: __spreadArray([paymentOutput, paybackOutput], dummyOutputs, true).filter(function (output) { return output !== undefined; }),
877
+ contractAddress: this.options.config.contractAddress,
878
+ chainId: chainId,
879
+ stateDiff: stateDiff,
880
+ unshieldTarget: ''
881
+ }];
882
+ }
883
+ });
884
+ });
885
+ };
886
+ TezosSaplingProtocol.prototype.mint = function (recipient, value) {
887
+ return __awaiter(this, void 0, void 0, function () {
888
+ var _a, saplingStateDiff, chainId, output, stateTree, forgedTransaction;
889
+ var _b;
890
+ return __generator(this, function (_c) {
891
+ switch (_c.label) {
892
+ case 0:
893
+ if (this.nodeClient === undefined || this.options.config.contractAddress === undefined) {
894
+ throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
895
+ }
896
+ if (!TezosSaplingAddress_1.TezosSaplingAddress.isZetAddress(recipient)) {
897
+ return [2 /*return*/, Promise.reject("Invalid recipient, expected a 'zet' address, got ".concat(recipient))];
898
+ }
899
+ return [4 /*yield*/, Promise.all([
900
+ this.nodeClient.getSaplingStateDiff(),
901
+ this.nodeClient.getChainId()
902
+ ])];
903
+ case 1:
904
+ _a = _c.sent(), saplingStateDiff = _a[0], chainId = _a[1];
905
+ _b = {};
906
+ return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromValue(recipient)];
907
+ case 2:
908
+ output = (_b.address = (_c.sent()).asString(),
909
+ _b.value = value,
910
+ _b.memo = Buffer.alloc(this.options.config.memoSize).toString('hex'),
911
+ _b.browsable = true,
912
+ _b);
913
+ return [4 /*yield*/, this.state.getStateTreeFromStateDiff(saplingStateDiff, true)];
914
+ case 3:
915
+ stateTree = _c.sent();
916
+ return [4 /*yield*/, this.forger.forgeSaplingTransaction([], [output], stateTree, this.getAntiReplay(chainId, this.options.config.contractAddress))];
917
+ case 4:
918
+ forgedTransaction = _c.sent();
919
+ return [2 /*return*/, this.encoder.encodeTransaction(forgedTransaction).toString('hex')];
920
+ }
921
+ });
922
+ });
923
+ };
924
+ TezosSaplingProtocol.prototype.burn = function (viewingKey, value) {
925
+ return __awaiter(this, void 0, void 0, function () {
926
+ var _a, stateDiff, chainId, _b, inputs, toSpend, paybackOutput;
927
+ var _c;
928
+ return __generator(this, function (_d) {
929
+ switch (_d.label) {
930
+ case 0:
931
+ if (this.nodeClient === undefined || this.options.config.contractAddress === undefined) {
932
+ throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
933
+ }
934
+ return [4 /*yield*/, Promise.all([
935
+ this.nodeClient.getSaplingStateDiff(),
936
+ this.nodeClient.getChainId()
937
+ ])];
938
+ case 1:
939
+ _a = _d.sent(), stateDiff = _a[0], chainId = _a[1];
940
+ return [4 /*yield*/, this.chooseInputs(viewingKey, stateDiff.commitments_and_ciphertexts, stateDiff.nullifiers, value)];
941
+ case 2:
942
+ _b = _d.sent(), inputs = _b[0], toSpend = _b[1];
943
+ _c = {};
944
+ return [4 /*yield*/, this.getAddressFromPublicKey(viewingKey)];
945
+ case 3:
946
+ paybackOutput = (_c.address = (_d.sent()).address,
947
+ _c.value = toSpend.minus(value).toString(),
948
+ _c.memo = Buffer.alloc(this.options.config.memoSize).toString('hex'),
949
+ _c.browsable = true,
950
+ _c);
951
+ return [2 /*return*/, {
952
+ ins: inputs,
953
+ outs: [paybackOutput],
954
+ contractAddress: this.options.config.contractAddress,
955
+ chainId: chainId,
956
+ stateDiff: stateDiff,
957
+ unshieldTarget: ''
958
+ }];
959
+ }
960
+ });
961
+ });
962
+ };
963
+ TezosSaplingProtocol.prototype.chooseInputs = function (viewingKey, commitmentsWithCiphertext, nullifiers, value) {
964
+ return __awaiter(this, void 0, void 0, function () {
965
+ var unspends, balance, chosenUnspends, toSpend, _i, unspends_1, unspend;
966
+ return __generator(this, function (_a) {
967
+ switch (_a.label) {
968
+ case 0: return [4 /*yield*/, this.bookkeeper.getUnspends(viewingKey, commitmentsWithCiphertext, nullifiers)];
969
+ case 1:
970
+ unspends = _a.sent();
971
+ balance = this.bookkeeper.sumNotes(unspends);
972
+ if (balance.lt(value)) {
973
+ return [2 /*return*/, Promise.reject('Not enough balance')];
974
+ }
975
+ chosenUnspends = [];
976
+ toSpend = new bignumber_1.default(0);
977
+ for (_i = 0, unspends_1 = unspends; _i < unspends_1.length; _i++) {
978
+ unspend = unspends_1[_i];
979
+ if (toSpend.gte(value)) {
980
+ break;
981
+ }
982
+ toSpend = toSpend.plus(unspend.value);
983
+ chosenUnspends.push(unspend);
984
+ }
985
+ return [2 /*return*/, [chosenUnspends, toSpend]];
986
+ }
987
+ });
988
+ });
989
+ };
990
+ TezosSaplingProtocol.prototype.createPaymentOutput = function (address, value, memo) {
991
+ if (memo === void 0) { memo = Buffer.alloc(this.options.config.memoSize); }
555
992
  return {
556
993
  address: address.asString(),
557
994
  value: new bignumber_1.default(value).toString(),
558
995
  memo: memo.toString('hex'),
559
996
  browsable: true
560
997
  };
561
- }
562
- createPaybackOutput(address, toSpend, value, memo = Buffer.alloc(this.options.config.memoSize)) {
563
- const paybackValue = toSpend.minus(value);
998
+ };
999
+ TezosSaplingProtocol.prototype.createPaybackOutput = function (address, toSpend, value, memo) {
1000
+ if (memo === void 0) { memo = Buffer.alloc(this.options.config.memoSize); }
1001
+ var paybackValue = toSpend.minus(value);
564
1002
  return paybackValue.gt(0)
565
1003
  ? {
566
1004
  address: address.asString(),
@@ -569,94 +1007,183 @@ class TezosSaplingProtocol extends NonExtendedProtocol_1.NonExtendedProtocol {
569
1007
  browsable: true
570
1008
  }
571
1009
  : undefined;
572
- }
573
- async createDummyInput(address) {
574
- const rcm = await sapling.randR();
575
- return {
576
- rcm: rcm.toString('hex'),
577
- pos: '0',
578
- value: '0',
579
- address: address.asString()
580
- };
581
- }
582
- async createDummyOutput() {
583
- const address = await this.getDummyAddress();
584
- const memo = (0, random_1.randomBytes)(this.options.config.memoSize);
585
- return {
586
- address: address.address,
587
- value: '0',
588
- memo: Buffer.from(memo).toString('hex'),
589
- browsable: false
590
- };
591
- }
592
- async getDummyAddress() {
593
- const seed = (0, random_1.randomBytes)(32);
594
- const viewingKey = await this.getPublicKeyFromHexSecret(Buffer.from(seed).toString('hex'), this.standardDerivationPath);
595
- return this.getAddressFromPublicKey(viewingKey);
596
- }
597
- createAddressBoundData(address) {
598
- const michelson = MichelsonAddress_1.MichelsonAddress.from(TezosUtils_1.TezosUtils.encodeTzAddress(address));
1010
+ };
1011
+ TezosSaplingProtocol.prototype.createDummyInput = function (address) {
1012
+ return __awaiter(this, void 0, void 0, function () {
1013
+ var rcm;
1014
+ return __generator(this, function (_a) {
1015
+ switch (_a.label) {
1016
+ case 0: return [4 /*yield*/, sapling.randR()];
1017
+ case 1:
1018
+ rcm = _a.sent();
1019
+ return [2 /*return*/, {
1020
+ rcm: rcm.toString('hex'),
1021
+ pos: '0',
1022
+ value: '0',
1023
+ address: address.asString()
1024
+ }];
1025
+ }
1026
+ });
1027
+ });
1028
+ };
1029
+ TezosSaplingProtocol.prototype.createDummyOutput = function () {
1030
+ return __awaiter(this, void 0, void 0, function () {
1031
+ var address, memo;
1032
+ return __generator(this, function (_a) {
1033
+ switch (_a.label) {
1034
+ case 0: return [4 /*yield*/, this.getDummyAddress()];
1035
+ case 1:
1036
+ address = _a.sent();
1037
+ memo = (0, random_1.randomBytes)(this.options.config.memoSize);
1038
+ return [2 /*return*/, {
1039
+ address: address.address,
1040
+ value: '0',
1041
+ memo: Buffer.from(memo).toString('hex'),
1042
+ browsable: false
1043
+ }];
1044
+ }
1045
+ });
1046
+ });
1047
+ };
1048
+ TezosSaplingProtocol.prototype.getDummyAddress = function () {
1049
+ return __awaiter(this, void 0, void 0, function () {
1050
+ var seed, viewingKey;
1051
+ return __generator(this, function (_a) {
1052
+ switch (_a.label) {
1053
+ case 0:
1054
+ seed = (0, random_1.randomBytes)(32);
1055
+ return [4 /*yield*/, this.getPublicKeyFromHexSecret(Buffer.from(seed).toString('hex'), this.standardDerivationPath)];
1056
+ case 1:
1057
+ viewingKey = _a.sent();
1058
+ return [2 /*return*/, this.getAddressFromPublicKey(viewingKey)];
1059
+ }
1060
+ });
1061
+ });
1062
+ };
1063
+ TezosSaplingProtocol.prototype.createAddressBoundData = function (address) {
1064
+ var michelson = MichelsonAddress_1.MichelsonAddress.from(TezosUtils_1.TezosUtils.encodeTzAddress(address));
599
1065
  return TezosUtils_1.TezosUtils.packMichelsonType(michelson);
600
- }
601
- getAntiReplay(chainId, contractAddress) {
1066
+ };
1067
+ TezosSaplingProtocol.prototype.getAntiReplay = function (chainId, contractAddress) {
602
1068
  return contractAddress + chainId;
603
- }
604
- async broadcastTransaction(rawTransaction) {
605
- if (!this.injectorClient) {
606
- throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, "Can't broadcast a sapling transaction, an injector service URL or contract address has not be set.");
607
- }
608
- try {
609
- const hash = await this.injectorClient.injectTransaction(rawTransaction);
610
- return hash;
611
- }
612
- catch (error) {
613
- throw new errors_1.NetworkError(coinlib_error_1.Domain.TEZOS, error);
614
- }
615
- }
616
- async signMessage(message, keypair) {
617
- return this.tezosProtocol.signMessage(message, keypair);
618
- }
619
- async verifyMessage(message, signature, publicKey) {
620
- return this.tezosProtocol.verifyMessage(message, signature, publicKey);
621
- }
622
- async encryptAsymmetric(payload, publicKey) {
623
- return this.encryptAsymmetric(payload, publicKey);
624
- }
625
- async decryptAsymmetric(encryptedPayload, keypair) {
626
- return this.decryptAsymmetric(encryptedPayload, keypair);
627
- }
628
- async encryptAES(payload, privateKey) {
629
- return this.encryptAES(payload, privateKey);
630
- }
631
- async decryptAES(encryptedPayload, privateKey) {
632
- return this.decryptAES(encryptedPayload, privateKey);
633
- }
634
- async getBlockExplorerLinkForAddress(address) {
635
- throw new Error('Method `getBlockExplorerLinkForAddress` not supported.');
636
- }
637
- async getTransactionsFromAddresses(addresses, limit, cursor) {
638
- throw new Error('Method `getTransactionsFromAddresses` not supported.');
639
- }
640
- async getBalanceOfAddresses(addresses) {
641
- throw new Error('Method `getBalanceOfAddresses` not supported.');
642
- }
643
- async getAvailableBalanceOfAddresses(addresses) {
644
- throw new Error('Method `getAvailableBalanceOfAddresses` not supported.');
645
- }
646
- async getBalanceOfPublicKeyForSubProtocols(publicKey, subProtocols) {
647
- throw new Error('Method `getBalanceOfPublicKeyForSubProtocols` not supported.');
648
- }
649
- async estimateFeeDefaultsFromPublicKey(publicKey, recipients, values, data) {
650
- throw new Error('Method `estimateFeeDefaultsFromPublicKey` not supported.');
651
- }
652
- isRawTezosSaplingTransaction(transaction) {
1069
+ };
1070
+ TezosSaplingProtocol.prototype.broadcastTransaction = function (rawTransaction) {
1071
+ return __awaiter(this, void 0, void 0, function () {
1072
+ var hash, error_2;
1073
+ return __generator(this, function (_a) {
1074
+ switch (_a.label) {
1075
+ case 0:
1076
+ if (!this.injectorClient) {
1077
+ throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, "Can't broadcast a sapling transaction, an injector service URL or contract address has not be set.");
1078
+ }
1079
+ _a.label = 1;
1080
+ case 1:
1081
+ _a.trys.push([1, 3, , 4]);
1082
+ return [4 /*yield*/, this.injectorClient.injectTransaction(rawTransaction)];
1083
+ case 2:
1084
+ hash = _a.sent();
1085
+ return [2 /*return*/, hash];
1086
+ case 3:
1087
+ error_2 = _a.sent();
1088
+ throw new errors_1.NetworkError(coinlib_error_1.Domain.TEZOS, error_2);
1089
+ case 4: return [2 /*return*/];
1090
+ }
1091
+ });
1092
+ });
1093
+ };
1094
+ TezosSaplingProtocol.prototype.signMessage = function (message, keypair) {
1095
+ return __awaiter(this, void 0, void 0, function () {
1096
+ return __generator(this, function (_a) {
1097
+ return [2 /*return*/, this.tezosProtocol.signMessage(message, keypair)];
1098
+ });
1099
+ });
1100
+ };
1101
+ TezosSaplingProtocol.prototype.verifyMessage = function (message, signature, publicKey) {
1102
+ return __awaiter(this, void 0, void 0, function () {
1103
+ return __generator(this, function (_a) {
1104
+ return [2 /*return*/, this.tezosProtocol.verifyMessage(message, signature, publicKey)];
1105
+ });
1106
+ });
1107
+ };
1108
+ TezosSaplingProtocol.prototype.encryptAsymmetric = function (payload, publicKey) {
1109
+ return __awaiter(this, void 0, void 0, function () {
1110
+ return __generator(this, function (_a) {
1111
+ return [2 /*return*/, this.encryptAsymmetric(payload, publicKey)];
1112
+ });
1113
+ });
1114
+ };
1115
+ TezosSaplingProtocol.prototype.decryptAsymmetric = function (encryptedPayload, keypair) {
1116
+ return __awaiter(this, void 0, void 0, function () {
1117
+ return __generator(this, function (_a) {
1118
+ return [2 /*return*/, this.decryptAsymmetric(encryptedPayload, keypair)];
1119
+ });
1120
+ });
1121
+ };
1122
+ TezosSaplingProtocol.prototype.encryptAES = function (payload, privateKey) {
1123
+ return __awaiter(this, void 0, void 0, function () {
1124
+ return __generator(this, function (_a) {
1125
+ return [2 /*return*/, this.encryptAES(payload, privateKey)];
1126
+ });
1127
+ });
1128
+ };
1129
+ TezosSaplingProtocol.prototype.decryptAES = function (encryptedPayload, privateKey) {
1130
+ return __awaiter(this, void 0, void 0, function () {
1131
+ return __generator(this, function (_a) {
1132
+ return [2 /*return*/, this.decryptAES(encryptedPayload, privateKey)];
1133
+ });
1134
+ });
1135
+ };
1136
+ TezosSaplingProtocol.prototype.getBlockExplorerLinkForAddress = function (address) {
1137
+ return __awaiter(this, void 0, void 0, function () {
1138
+ return __generator(this, function (_a) {
1139
+ throw new Error('Method `getBlockExplorerLinkForAddress` not supported.');
1140
+ });
1141
+ });
1142
+ };
1143
+ TezosSaplingProtocol.prototype.getTransactionsFromAddresses = function (addresses, limit, cursor) {
1144
+ return __awaiter(this, void 0, void 0, function () {
1145
+ return __generator(this, function (_a) {
1146
+ throw new Error('Method `getTransactionsFromAddresses` not supported.');
1147
+ });
1148
+ });
1149
+ };
1150
+ TezosSaplingProtocol.prototype.getBalanceOfAddresses = function (addresses) {
1151
+ return __awaiter(this, void 0, void 0, function () {
1152
+ return __generator(this, function (_a) {
1153
+ throw new Error('Method `getBalanceOfAddresses` not supported.');
1154
+ });
1155
+ });
1156
+ };
1157
+ TezosSaplingProtocol.prototype.getAvailableBalanceOfAddresses = function (addresses) {
1158
+ return __awaiter(this, void 0, void 0, function () {
1159
+ return __generator(this, function (_a) {
1160
+ throw new Error('Method `getAvailableBalanceOfAddresses` not supported.');
1161
+ });
1162
+ });
1163
+ };
1164
+ TezosSaplingProtocol.prototype.getBalanceOfPublicKeyForSubProtocols = function (publicKey, subProtocols) {
1165
+ return __awaiter(this, void 0, void 0, function () {
1166
+ return __generator(this, function (_a) {
1167
+ throw new Error('Method `getBalanceOfPublicKeyForSubProtocols` not supported.');
1168
+ });
1169
+ });
1170
+ };
1171
+ TezosSaplingProtocol.prototype.estimateFeeDefaultsFromPublicKey = function (publicKey, recipients, values, data) {
1172
+ return __awaiter(this, void 0, void 0, function () {
1173
+ return __generator(this, function (_a) {
1174
+ throw new Error('Method `estimateFeeDefaultsFromPublicKey` not supported.');
1175
+ });
1176
+ });
1177
+ };
1178
+ TezosSaplingProtocol.prototype.isRawTezosSaplingTransaction = function (transaction) {
653
1179
  return (transaction instanceof Object &&
654
1180
  'ins' in transaction &&
655
1181
  'outs' in transaction &&
656
1182
  'contractAddress' in transaction &&
657
1183
  'chainId' in transaction &&
658
1184
  'stateDiff' in transaction);
659
- }
660
- }
1185
+ };
1186
+ return TezosSaplingProtocol;
1187
+ }(NonExtendedProtocol_1.NonExtendedProtocol));
661
1188
  exports.TezosSaplingProtocol = TezosSaplingProtocol;
662
1189
  //# sourceMappingURL=TezosSaplingProtocol.js.map