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

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 +11 -81
  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 +0 -1
  9. package/v0/protocol/TezosAddress.js +41 -81
  10. package/v0/protocol/TezosAddress.js.map +1 -1
  11. package/v0/protocol/TezosCryptoClient.d.ts +0 -1
  12. package/v0/protocol/TezosCryptoClient.js +68 -123
  13. package/v0/protocol/TezosCryptoClient.js.map +1 -1
  14. package/v0/protocol/TezosProtocol.js +978 -1631
  15. package/v0/protocol/TezosProtocol.js.map +1 -1
  16. package/v0/protocol/TezosProtocolOptions.d.ts +1 -1
  17. package/v0/protocol/TezosProtocolOptions.js +26 -98
  18. package/v0/protocol/TezosProtocolOptions.js.map +1 -1
  19. package/v0/protocol/TezosUtils.d.ts +0 -1
  20. package/v0/protocol/TezosUtils.js +131 -165
  21. package/v0/protocol/TezosUtils.js.map +1 -1
  22. package/v0/protocol/contract/TezosContract.js +243 -472
  23. package/v0/protocol/contract/TezosContract.js.map +1 -1
  24. package/v0/protocol/contract/TezosContractCall.js +8 -10
  25. package/v0/protocol/contract/TezosContractCall.js.map +1 -1
  26. package/v0/protocol/contract/TezosContractEntrypoint.js +14 -19
  27. package/v0/protocol/contract/TezosContractEntrypoint.js.map +1 -1
  28. package/v0/protocol/contract/TezosContractStorage.js +8 -9
  29. package/v0/protocol/contract/TezosContractStorage.js.map +1 -1
  30. package/v0/protocol/contract/remote-data/TezosContractRemoteDataFactory.js +8 -25
  31. package/v0/protocol/contract/remote-data/TezosContractRemoteDataFactory.js.map +1 -1
  32. package/v0/protocol/contract/remote-data/TezosStorageRemoteData.js +39 -113
  33. package/v0/protocol/contract/remote-data/TezosStorageRemoteData.js.map +1 -1
  34. package/v0/protocol/domains/TezosDomains.js +165 -270
  35. package/v0/protocol/domains/TezosDomains.js.map +1 -1
  36. package/v0/protocol/fa/TezosBTC.js +19 -98
  37. package/v0/protocol/fa/TezosBTC.js.map +1 -1
  38. package/v0/protocol/fa/TezosBTCtez.js +17 -48
  39. package/v0/protocol/fa/TezosBTCtez.js.map +1 -1
  40. package/v0/protocol/fa/TezosCTez.js +17 -45
  41. package/v0/protocol/fa/TezosCTez.js.map +1 -1
  42. package/v0/protocol/fa/TezosDOGA.js +17 -45
  43. package/v0/protocol/fa/TezosDOGA.js.map +1 -1
  44. package/v0/protocol/fa/TezosETHtz.js +10 -68
  45. package/v0/protocol/fa/TezosETHtz.js.map +1 -1
  46. package/v0/protocol/fa/TezosFA1Protocol.js +119 -276
  47. package/v0/protocol/fa/TezosFA1Protocol.js.map +1 -1
  48. package/v0/protocol/fa/TezosFA1p2Protocol.js +22 -101
  49. package/v0/protocol/fa/TezosFA1p2Protocol.js.map +1 -1
  50. package/v0/protocol/fa/TezosFA2Protocol.js +213 -402
  51. package/v0/protocol/fa/TezosFA2Protocol.js.map +1 -1
  52. package/v0/protocol/fa/TezosFAProtocol.js +211 -418
  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 +92 -195
  56. package/v0/protocol/fa/TezosFAProtocolOptions.js.map +1 -1
  57. package/v0/protocol/fa/TezosKolibriUSD.js +11 -70
  58. package/v0/protocol/fa/TezosKolibriUSD.js.map +1 -1
  59. package/v0/protocol/fa/TezosPlanty.js +17 -45
  60. package/v0/protocol/fa/TezosPlanty.js.map +1 -1
  61. package/v0/protocol/fa/TezosQUIPU.js +17 -48
  62. package/v0/protocol/fa/TezosQUIPU.js.map +1 -1
  63. package/v0/protocol/fa/TezosSIRS.js +17 -45
  64. package/v0/protocol/fa/TezosSIRS.js.map +1 -1
  65. package/v0/protocol/fa/TezosStaker.js +11 -70
  66. package/v0/protocol/fa/TezosStaker.js.map +1 -1
  67. package/v0/protocol/fa/TezosUBTC.js +17 -48
  68. package/v0/protocol/fa/TezosUBTC.js.map +1 -1
  69. package/v0/protocol/fa/TezosUDEFI.js +17 -48
  70. package/v0/protocol/fa/TezosUDEFI.js.map +1 -1
  71. package/v0/protocol/fa/TezosUSD.js +11 -70
  72. package/v0/protocol/fa/TezosUSD.js.map +1 -1
  73. package/v0/protocol/fa/TezosUSDT.js +17 -48
  74. package/v0/protocol/fa/TezosUSDT.js.map +1 -1
  75. package/v0/protocol/fa/TezosUUSD.js +8 -27
  76. package/v0/protocol/fa/TezosUUSD.js.map +1 -1
  77. package/v0/protocol/fa/TezosUXTZ.js +17 -48
  78. package/v0/protocol/fa/TezosUXTZ.js.map +1 -1
  79. package/v0/protocol/fa/TezosWRAP.js +17 -48
  80. package/v0/protocol/fa/TezosWRAP.js.map +1 -1
  81. package/v0/protocol/fa/TezosWrapped.js +11 -70
  82. package/v0/protocol/fa/TezosWrapped.js.map +1 -1
  83. package/v0/protocol/fa/TezosYOU.js +8 -27
  84. package/v0/protocol/fa/TezosYOU.js.map +1 -1
  85. package/v0/protocol/fa/metadata/BigMapTokenMetadataIndexer.js +84 -162
  86. package/v0/protocol/fa/metadata/BigMapTokenMetadataIndexer.js.map +1 -1
  87. package/v0/protocol/fa/metadata/ObjktTokenMetadataIndexer.js +37 -87
  88. package/v0/protocol/fa/metadata/ObjktTokenMetadataIndexer.js.map +1 -1
  89. package/v0/protocol/indexerClient/TezosIndexerClient.js +115 -259
  90. package/v0/protocol/indexerClient/TezosIndexerClient.js.map +1 -1
  91. package/v0/protocol/kt/TezosKtAddress.js +7 -67
  92. package/v0/protocol/kt/TezosKtAddress.js.map +1 -1
  93. package/v0/protocol/kt/TezosKtProtocol.js +161 -309
  94. package/v0/protocol/kt/TezosKtProtocol.js.map +1 -1
  95. package/v0/protocol/sapling/TezosSaplingAddress.d.ts +0 -1
  96. package/v0/protocol/sapling/TezosSaplingAddress.js +46 -117
  97. package/v0/protocol/sapling/TezosSaplingAddress.js.map +1 -1
  98. package/v0/protocol/sapling/TezosSaplingCryptoClient.d.ts +0 -1
  99. package/v0/protocol/sapling/TezosSaplingCryptoClient.js +125 -220
  100. package/v0/protocol/sapling/TezosSaplingCryptoClient.js.map +1 -1
  101. package/v0/protocol/sapling/TezosSaplingProtocol.d.ts +0 -1
  102. package/v0/protocol/sapling/TezosSaplingProtocol.js +600 -1127
  103. package/v0/protocol/sapling/TezosSaplingProtocol.js.map +1 -1
  104. package/v0/protocol/sapling/TezosSaplingProtocolOptions.d.ts +0 -1
  105. package/v0/protocol/sapling/TezosSaplingProtocolOptions.js +32 -61
  106. package/v0/protocol/sapling/TezosSaplingProtocolOptions.js.map +1 -1
  107. package/v0/protocol/sapling/TezosShieldedTezProtocol.js +50 -134
  108. package/v0/protocol/sapling/TezosShieldedTezProtocol.js.map +1 -1
  109. package/v0/protocol/sapling/injector/TezosSaplingInjectorClient.js +10 -56
  110. package/v0/protocol/sapling/injector/TezosSaplingInjectorClient.js.map +1 -1
  111. package/v0/protocol/sapling/node/TezosSaplingNodeClient.js +12 -67
  112. package/v0/protocol/sapling/node/TezosSaplingNodeClient.js.map +1 -1
  113. package/v0/protocol/sapling/utils/TezosSaplingBookkeeper.d.ts +0 -1
  114. package/v0/protocol/sapling/utils/TezosSaplingBookkeeper.js +221 -539
  115. package/v0/protocol/sapling/utils/TezosSaplingBookkeeper.js.map +1 -1
  116. package/v0/protocol/sapling/utils/TezosSaplingEncoder.d.ts +0 -1
  117. package/v0/protocol/sapling/utils/TezosSaplingEncoder.js +101 -104
  118. package/v0/protocol/sapling/utils/TezosSaplingEncoder.js.map +1 -1
  119. package/v0/protocol/sapling/utils/TezosSaplingForger.d.ts +0 -1
  120. package/v0/protocol/sapling/utils/TezosSaplingForger.js +107 -266
  121. package/v0/protocol/sapling/utils/TezosSaplingForger.js.map +1 -1
  122. package/v0/protocol/sapling/utils/TezosSaplingState.js +110 -239
  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 +9 -13
  130. package/v0/protocol/types/micheline/MichelineNodeUtils.js.map +1 -1
  131. package/v0/protocol/types/michelson/MichelsonType.d.ts +0 -1
  132. package/v0/protocol/types/michelson/MichelsonType.js +11 -12
  133. package/v0/protocol/types/michelson/MichelsonType.js.map +1 -1
  134. package/v0/protocol/types/michelson/MichelsonTypeMeta.js +45 -92
  135. package/v0/protocol/types/michelson/MichelsonTypeMeta.js.map +1 -1
  136. package/v0/protocol/types/michelson/MichelsonTypeUtils.d.ts +0 -1
  137. package/v0/protocol/types/michelson/MichelsonTypeUtils.js +58 -219
  138. package/v0/protocol/types/michelson/MichelsonTypeUtils.js.map +1 -1
  139. package/v0/protocol/types/michelson/generics/MichelsonList.js +24 -43
  140. package/v0/protocol/types/michelson/generics/MichelsonList.js.map +1 -1
  141. package/v0/protocol/types/michelson/generics/MichelsonMap.js +39 -61
  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 +46 -75
  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 +50 -76
  148. package/v0/protocol/types/michelson/generics/MichelsonOr.js.map +1 -1
  149. package/v0/protocol/types/michelson/generics/MichelsonPair.js +52 -85
  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 +0 -1
  155. package/v0/protocol/types/michelson/primitives/MichelsonAddress.js +28 -47
  156. package/v0/protocol/types/michelson/primitives/MichelsonAddress.js.map +1 -1
  157. package/v0/protocol/types/michelson/primitives/MichelsonBool.js +20 -39
  158. package/v0/protocol/types/michelson/primitives/MichelsonBool.js.map +1 -1
  159. package/v0/protocol/types/michelson/primitives/MichelsonBytes.d.ts +0 -1
  160. package/v0/protocol/types/michelson/primitives/MichelsonBytes.js +35 -54
  161. package/v0/protocol/types/michelson/primitives/MichelsonBytes.js.map +1 -1
  162. package/v0/protocol/types/michelson/primitives/MichelsonInt.d.ts +0 -1
  163. package/v0/protocol/types/michelson/primitives/MichelsonInt.js +30 -49
  164. package/v0/protocol/types/michelson/primitives/MichelsonInt.js.map +1 -1
  165. package/v0/protocol/types/michelson/primitives/MichelsonString.d.ts +0 -1
  166. package/v0/protocol/types/michelson/primitives/MichelsonString.js +33 -52
  167. package/v0/protocol/types/michelson/primitives/MichelsonString.js.map +1 -1
  168. package/v0/protocol/types/michelson/primitives/MichelsonUnit.js +14 -34
  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 +0 -1
  172. package/v0/protocol/types/utils.js +8 -10
  173. package/v0/protocol/types/utils.js.map +1 -1
  174. package/v0/serializer/validators/transaction-validator.js +29 -78
  175. package/v0/serializer/validators/transaction-validator.js.map +1 -1
  176. package/v0/serializer/validators/transaction-xtz-btc-validator.js +55 -129
  177. package/v0/serializer/validators/transaction-xtz-btc-validator.js.map +1 -1
  178. package/v0/serializer/validators/validators.js +43 -103
  179. package/v0/serializer/validators/validators.js.map +1 -1
  180. package/v1/block-explorer/TzKTBlockExplorer.js +12 -61
  181. package/v1/block-explorer/TzKTBlockExplorer.js.map +1 -1
  182. package/v1/block-explorer/factory.js +4 -5
  183. package/v1/block-explorer/factory.js.map +1 -1
  184. package/v1/contract/TezosContract.js +242 -471
  185. package/v1/contract/TezosContract.js.map +1 -1
  186. package/v1/contract/TezosContractCall.js +8 -10
  187. package/v1/contract/TezosContractCall.js.map +1 -1
  188. package/v1/contract/TezosContractEntrypoint.d.ts +1 -1
  189. package/v1/contract/TezosContractEntrypoint.js +14 -19
  190. package/v1/contract/TezosContractEntrypoint.js.map +1 -1
  191. package/v1/contract/TezosContractStorage.js +8 -9
  192. package/v1/contract/TezosContractStorage.js.map +1 -1
  193. package/v1/contract/remote-data/TezosContractRemoteDataFactory.js +8 -25
  194. package/v1/contract/remote-data/TezosContractRemoteDataFactory.js.map +1 -1
  195. package/v1/contract/remote-data/TezosStorageRemoteData.js +39 -113
  196. package/v1/contract/remote-data/TezosStorageRemoteData.js.map +1 -1
  197. package/v1/crypto/TezosCryptoClient.d.ts +0 -1
  198. package/v1/crypto/TezosCryptoClient.js +64 -117
  199. package/v1/crypto/TezosCryptoClient.js.map +1 -1
  200. package/v1/crypto/TezosSaplingCryptoClient.d.ts +0 -1
  201. package/v1/crypto/TezosSaplingCryptoClient.js +116 -194
  202. package/v1/crypto/TezosSaplingCryptoClient.js.map +1 -1
  203. package/v1/data/TezosAddress.js +13 -14
  204. package/v1/data/TezosAddress.js.map +1 -1
  205. package/v1/data/TezosSaplingAddress.d.ts +0 -1
  206. package/v1/data/TezosSaplingAddress.js +29 -94
  207. package/v1/data/TezosSaplingAddress.js.map +1 -1
  208. package/v1/domains/TezosDomains.js +165 -270
  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 +126 -270
  213. package/v1/indexer/TzKTIndexerClient.js.map +1 -1
  214. package/v1/indexer/factory.js +4 -5
  215. package/v1/indexer/factory.js.map +1 -1
  216. package/v1/indexer/token-metadata/BigMapTokenMetadataIndexerClient.js +83 -161
  217. package/v1/indexer/token-metadata/BigMapTokenMetadataIndexerClient.js.map +1 -1
  218. package/v1/indexer/token-metadata/ObjktTokenMetadataIndexerClient.js +36 -85
  219. package/v1/indexer/token-metadata/ObjktTokenMetadataIndexerClient.js.map +1 -1
  220. package/v1/injector/TezosSaplingInjectorClient.js +10 -56
  221. package/v1/injector/TezosSaplingInjectorClient.js.map +1 -1
  222. package/v1/module/TezosModule.js +88 -155
  223. package/v1/module/TezosModule.js.map +1 -1
  224. package/v1/module.js +2 -3
  225. package/v1/module.js.map +1 -1
  226. package/v1/node/TezosSaplingNodeClient.js +12 -67
  227. package/v1/node/TezosSaplingNodeClient.js.map +1 -1
  228. package/v1/protocol/TezosProtocol.js +848 -1385
  229. package/v1/protocol/TezosProtocol.js.map +1 -1
  230. package/v1/protocol/fa/TezosFA1Protocol.js +81 -205
  231. package/v1/protocol/fa/TezosFA1Protocol.js.map +1 -1
  232. package/v1/protocol/fa/TezosFA1p2Protocol.js +32 -111
  233. package/v1/protocol/fa/TezosFA1p2Protocol.js.map +1 -1
  234. package/v1/protocol/fa/TezosFA2Protocol.js +174 -332
  235. package/v1/protocol/fa/TezosFA2Protocol.js.map +1 -1
  236. package/v1/protocol/fa/TezosFAProtocol.js +255 -528
  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 +30 -47
  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 +27 -47
  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 +27 -47
  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 +30 -90
  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 +30 -90
  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 +30 -90
  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 +30 -47
  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 +27 -47
  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 +30 -90
  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 +30 -47
  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 +27 -47
  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 +30 -47
  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 +30 -47
  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 +27 -47
  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 +30 -47
  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 +30 -47
  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 +30 -47
  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 +27 -47
  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 +30 -47
  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 +30 -47
  297. package/v1/protocol/fa/tokens/stXTZProtocol.js.map +1 -1
  298. package/v1/protocol/kt/TezosKtProtocol.js +254 -498
  299. package/v1/protocol/kt/TezosKtProtocol.js.map +1 -1
  300. package/v1/protocol/sapling/TezosSaplingProtocol.d.ts +0 -1
  301. package/v1/protocol/sapling/TezosSaplingProtocol.js +532 -933
  302. package/v1/protocol/sapling/TezosSaplingProtocol.js.map +1 -1
  303. package/v1/protocol/sapling/TezosShieldedTezProtocol.js +72 -164
  304. package/v1/protocol/sapling/TezosShieldedTezProtocol.js.map +1 -1
  305. package/v1/serializer/v3/schemas/converter/transaction-converter.js +14 -26
  306. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
  307. package/v1/serializer/v3/serializer-companion.js +103 -188
  308. package/v1/serializer/v3/serializer-companion.js.map +1 -1
  309. package/v1/serializer/v3/validators/transaction-validator.js +54 -143
  310. package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
  311. package/v1/serializer/v3/validators/validators.js +40 -100
  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 +9 -13
  323. package/v1/types/micheline/MichelineNodeUtils.js.map +1 -1
  324. package/v1/types/michelson/MichelsonType.d.ts +0 -1
  325. package/v1/types/michelson/MichelsonType.js +11 -12
  326. package/v1/types/michelson/MichelsonType.js.map +1 -1
  327. package/v1/types/michelson/MichelsonTypeMeta.js +45 -92
  328. package/v1/types/michelson/MichelsonTypeMeta.js.map +1 -1
  329. package/v1/types/michelson/MichelsonTypeUtils.d.ts +0 -1
  330. package/v1/types/michelson/MichelsonTypeUtils.js +58 -219
  331. package/v1/types/michelson/MichelsonTypeUtils.js.map +1 -1
  332. package/v1/types/michelson/generics/MichelsonList.js +24 -43
  333. package/v1/types/michelson/generics/MichelsonList.js.map +1 -1
  334. package/v1/types/michelson/generics/MichelsonMap.js +39 -61
  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 +46 -75
  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 +50 -76
  341. package/v1/types/michelson/generics/MichelsonOr.js.map +1 -1
  342. package/v1/types/michelson/generics/MichelsonPair.js +52 -85
  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 +0 -1
  348. package/v1/types/michelson/primitives/MichelsonAddress.js +28 -47
  349. package/v1/types/michelson/primitives/MichelsonAddress.js.map +1 -1
  350. package/v1/types/michelson/primitives/MichelsonBool.js +20 -39
  351. package/v1/types/michelson/primitives/MichelsonBool.js.map +1 -1
  352. package/v1/types/michelson/primitives/MichelsonBytes.d.ts +0 -1
  353. package/v1/types/michelson/primitives/MichelsonBytes.js +35 -54
  354. package/v1/types/michelson/primitives/MichelsonBytes.js.map +1 -1
  355. package/v1/types/michelson/primitives/MichelsonInt.d.ts +0 -1
  356. package/v1/types/michelson/primitives/MichelsonInt.js +30 -49
  357. package/v1/types/michelson/primitives/MichelsonInt.js.map +1 -1
  358. package/v1/types/michelson/primitives/MichelsonString.d.ts +0 -1
  359. package/v1/types/michelson/primitives/MichelsonString.js +33 -52
  360. package/v1/types/michelson/primitives/MichelsonString.js.map +1 -1
  361. package/v1/types/michelson/primitives/MichelsonUnit.js +14 -34
  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 +0 -1
  369. package/v1/types/sapling/TezosSaplingStateTree.d.ts +1 -1
  370. package/v1/types/sapling/TezosSaplingTransaction.d.ts +0 -1
  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 +6 -7
  374. package/v1/utils/address.js.map +1 -1
  375. package/v1/utils/bip.d.ts +0 -1
  376. package/v1/utils/bip.js +6 -7
  377. package/v1/utils/bip.js.map +1 -1
  378. package/v1/utils/convert.js +7 -8
  379. package/v1/utils/convert.js.map +1 -1
  380. package/v1/utils/encoding.d.ts +0 -1
  381. package/v1/utils/encoding.js +74 -64
  382. package/v1/utils/encoding.js.map +1 -1
  383. package/v1/utils/fa.js +2 -3
  384. package/v1/utils/fa.js.map +1 -1
  385. package/v1/utils/key.js +9 -12
  386. package/v1/utils/key.js.map +1 -1
  387. package/v1/utils/micheline.js +8 -10
  388. package/v1/utils/micheline.js.map +1 -1
  389. package/v1/utils/operations.js +21 -22
  390. package/v1/utils/operations.js.map +1 -1
  391. package/v1/utils/pack.d.ts +0 -1
  392. package/v1/utils/pack.js +65 -107
  393. package/v1/utils/pack.js.map +1 -1
  394. package/v1/utils/protocol/fa/TezosFA1Accountant.js +24 -52
  395. package/v1/utils/protocol/fa/TezosFA1Accountant.js.map +1 -1
  396. package/v1/utils/protocol/fa/TezosFA2Accountant.js +40 -77
  397. package/v1/utils/protocol/fa/TezosFA2Accountant.js.map +1 -1
  398. package/v1/utils/protocol/fa/TezosFAAccountant.js +21 -89
  399. package/v1/utils/protocol/fa/TezosFAAccountant.js.map +1 -1
  400. package/v1/utils/protocol/instance.js +90 -26
  401. package/v1/utils/protocol/instance.js.map +1 -1
  402. package/v1/utils/protocol/sapling/TezosSaplingAccountant.d.ts +0 -1
  403. package/v1/utils/protocol/sapling/TezosSaplingAccountant.js +221 -539
  404. package/v1/utils/protocol/sapling/TezosSaplingAccountant.js.map +1 -1
  405. package/v1/utils/protocol/sapling/TezosSaplingEncoder.d.ts +0 -1
  406. package/v1/utils/protocol/sapling/TezosSaplingEncoder.js +101 -104
  407. package/v1/utils/protocol/sapling/TezosSaplingEncoder.js.map +1 -1
  408. package/v1/utils/protocol/sapling/TezosSaplingForger.d.ts +0 -1
  409. package/v1/utils/protocol/sapling/TezosSaplingForger.js +107 -266
  410. package/v1/utils/protocol/sapling/TezosSaplingForger.js.map +1 -1
  411. package/v1/utils/protocol/sapling/TezosSaplingState.js +110 -239
  412. package/v1/utils/protocol/sapling/TezosSaplingState.js.map +1 -1
  413. package/v1/utils/protocol/tezos/TezosAccountant.js +97 -166
  414. package/v1/utils/protocol/tezos/TezosAccountant.js.map +1 -1
  415. package/v1/utils/protocol/tezos/TezosForger.js +21 -76
  416. package/v1/utils/protocol/tezos/TezosForger.js.map +1 -1
  417. package/v1/utils/signature.js +5 -6
  418. package/v1/utils/signature.js.map +1 -1
  419. package/v1/utils/transaction.d.ts +4 -5
  420. package/v1/utils/transaction.js +3 -3
  421. package/v1/utils/transaction.js.map +1 -1
@@ -15,84 +15,57 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
15
15
  }) : function(o, v) {
16
16
  o["default"] = v;
17
17
  });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- var __generator = (this && this.__generator) || function (thisArg, body) {
35
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
- function verb(n) { return function (v) { return step([n, v]); }; }
38
- function step(op) {
39
- if (f) throw new TypeError("Generator is already executing.");
40
- while (_) try {
41
- 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;
42
- if (y = 0, t) op = [op[0] & 2, t.value];
43
- switch (op[0]) {
44
- case 0: case 1: t = op; break;
45
- case 4: _.label++; return { value: op[1], done: false };
46
- case 5: _.label++; y = op[1]; op = [0]; continue;
47
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
- default:
49
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
- if (t[2]) _.ops.pop();
54
- _.trys.pop(); continue;
55
- }
56
- op = body.call(thisArg, _);
57
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
- }
60
- };
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
+ })();
61
35
  var __importDefault = (this && this.__importDefault) || function (mod) {
62
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
63
37
  };
64
38
  Object.defineProperty(exports, "__esModule", { value: true });
65
39
  exports.TezosSaplingBookkeeper = void 0;
66
- var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
67
- var array_1 = require("@airgap/coinlib-core/utils/array");
68
- var hex_1 = require("@airgap/coinlib-core/utils/hex");
69
- var sapling = __importStar(require("@airgap/sapling-wasm"));
70
- var TezosUtils_1 = require("../../TezosUtils");
71
- var MichelsonBytes_1 = require("../../types/michelson/primitives/MichelsonBytes");
72
- var MichelsonString_1 = require("../../types/michelson/primitives/MichelsonString");
73
- var TezosSaplingAddress_1 = require("../TezosSaplingAddress");
74
- var TezosSaplingBookkeeper = /** @class */ (function () {
75
- function TezosSaplingBookkeeper(identifier, network, cryptoClient, encoder) {
40
+ const bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
41
+ const array_1 = require("@airgap/coinlib-core/utils/array");
42
+ const hex_1 = require("@airgap/coinlib-core/utils/hex");
43
+ const sapling = __importStar(require("@airgap/sapling-wasm"));
44
+ const TezosUtils_1 = require("../../TezosUtils");
45
+ const MichelsonBytes_1 = require("../../types/michelson/primitives/MichelsonBytes");
46
+ const MichelsonString_1 = require("../../types/michelson/primitives/MichelsonString");
47
+ const TezosSaplingAddress_1 = require("../TezosSaplingAddress");
48
+ class TezosSaplingBookkeeper {
49
+ constructor(identifier, network, cryptoClient, encoder) {
76
50
  this.identifier = identifier;
77
51
  this.network = network;
78
52
  this.cryptoClient = cryptoClient;
79
53
  this.encoder = encoder;
80
54
  }
81
- TezosSaplingBookkeeper.prototype.getUnsignedTransactionDetails = function (sender, inputs, outputs, unshieldTarget) {
82
- var _this = this;
55
+ getUnsignedTransactionDetails(sender, inputs, outputs, unshieldTarget) {
83
56
  if (unshieldTarget === undefined) {
84
- return outputs.map(function (out) { return ({
57
+ return outputs.map((out) => ({
85
58
  from: [sender.asString()],
86
59
  to: [out.address],
87
60
  isInbound: false,
88
61
  amount: out.value,
89
62
  fee: '0',
90
- protocolIdentifier: _this.identifier,
91
- network: _this.network
92
- }); });
63
+ protocolIdentifier: this.identifier,
64
+ network: this.network
65
+ }));
93
66
  }
94
67
  else {
95
- var amount = this.sumNotes(inputs).minus(this.sumNotes(outputs));
68
+ const amount = this.sumNotes(inputs).minus(this.sumNotes(outputs));
96
69
  return [
97
70
  {
98
71
  from: [sender.asString()],
@@ -105,487 +78,196 @@ var TezosSaplingBookkeeper = /** @class */ (function () {
105
78
  }
106
79
  ];
107
80
  }
108
- };
109
- TezosSaplingBookkeeper.prototype.getTransactionsPartialDetails = function (txs, knownViewingKeys) {
110
- if (knownViewingKeys === void 0) { knownViewingKeys = []; }
111
- return __awaiter(this, void 0, void 0, function () {
112
- var partials;
113
- var _this = this;
114
- return __generator(this, function (_a) {
115
- switch (_a.label) {
116
- case 0: return [4 /*yield*/, Promise.all(txs.map(function (tx) { return __awaiter(_this, void 0, void 0, function () {
117
- var signedBuffer, transaction, _a, from, details, boundDataMichelson, unshieldTarget, unshieldDetails, _b, _c, _d;
118
- var _e;
119
- return __generator(this, function (_f) {
120
- switch (_f.label) {
121
- case 0:
122
- signedBuffer = Buffer.isBuffer(tx) ? tx : Buffer.from(tx, 'hex');
123
- transaction = this.encoder.decodeTransaction(signedBuffer);
124
- return [4 /*yield*/, this.getTransactionPartialDetails(transaction, knownViewingKeys)];
125
- case 1:
126
- _a = _f.sent(), from = _a[0], details = _a[1];
127
- if (!(transaction.boundData.length > 0)) return [3 /*break*/, 4];
128
- boundDataMichelson = TezosUtils_1.TezosUtils.unpackMichelsonType(transaction.boundData);
129
- unshieldTarget = void 0;
130
- if (boundDataMichelson instanceof MichelsonBytes_1.MichelsonBytes) {
131
- unshieldTarget = TezosUtils_1.TezosUtils.parseTzAddress(boundDataMichelson.value);
132
- }
133
- else if (boundDataMichelson instanceof MichelsonString_1.MichelsonString) {
134
- unshieldTarget = boundDataMichelson.value;
135
- }
136
- if (!(unshieldTarget !== undefined)) return [3 /*break*/, 4];
137
- unshieldDetails = {
138
- to: [unshieldTarget],
139
- amount: transaction.balance.toFixed()
140
- };
141
- if (!(from !== undefined)) return [3 /*break*/, 3];
142
- _c = (_b = Object).assign;
143
- _d = [unshieldDetails];
144
- _e = {};
145
- return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(from)];
146
- case 2:
147
- unshieldDetails = _c.apply(_b, _d.concat([(_e.from = [(_f.sent()).asString()], _e)]));
148
- _f.label = 3;
149
- case 3:
150
- details.push(unshieldDetails);
151
- _f.label = 4;
152
- case 4: return [2 /*return*/, details];
153
- }
154
- });
155
- }); }))];
156
- case 1:
157
- partials = _a.sent();
158
- return [2 /*return*/, (0, array_1.flattenArray)(partials)];
159
- }
160
- });
161
- });
162
- };
163
- TezosSaplingBookkeeper.prototype.getTransactionPartialDetails = function (transaction, knownViewingKeys) {
164
- return __awaiter(this, void 0, void 0, function () {
165
- var sender, _a, details;
166
- var _this = this;
167
- return __generator(this, function (_b) {
168
- switch (_b.label) {
169
- case 0:
170
- if (!(transaction.spendDescriptions.length === 0)) return [3 /*break*/, 1];
171
- _a = undefined;
172
- return [3 /*break*/, 3];
173
- case 1: return [4 /*yield*/, this.findSender(transaction, knownViewingKeys)];
174
- case 2:
175
- _a = _b.sent();
176
- _b.label = 3;
177
- case 3:
178
- sender = _a;
179
- return [4 /*yield*/, Promise.all(transaction.outputDescriptions.map(function (description) { return __awaiter(_this, void 0, void 0, function () {
180
- var recipient, from, _a, _b, to, amount, outputDetails;
181
- return __generator(this, function (_c) {
182
- switch (_c.label) {
183
- case 0: return [4 /*yield*/, this.findRecipient(description, knownViewingKeys)];
184
- case 1:
185
- recipient = _c.sent();
186
- if (!(sender !== undefined)) return [3 /*break*/, 3];
187
- return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(sender)];
188
- case 2:
189
- _a = _c.sent();
190
- return [3 /*break*/, 4];
191
- case 3:
192
- _a = undefined;
193
- _c.label = 4;
194
- case 4:
195
- from = _a;
196
- return [4 /*yield*/, this.decodeDetailsFromOutputDescription(sender, recipient, description)];
197
- case 5:
198
- _b = _c.sent(), to = _b[0], amount = _b[1];
199
- outputDetails = {};
200
- if (from !== undefined) {
201
- outputDetails = Object.assign(outputDetails, { from: [from.asString()] });
202
- }
203
- if (to !== undefined) {
204
- outputDetails = Object.assign(outputDetails, { to: [to.asString()] });
205
- }
206
- if (amount !== undefined) {
207
- outputDetails = Object.assign(outputDetails, { amount: amount.toFixed() });
208
- }
209
- return [2 /*return*/, outputDetails];
210
- }
211
- });
212
- }); }))];
213
- case 4:
214
- details = _b.sent();
215
- return [2 /*return*/, [sender, details]];
216
- }
217
- });
218
- });
219
- };
220
- TezosSaplingBookkeeper.prototype.findSender = function (transaction, viewingKeys) {
221
- return __awaiter(this, void 0, void 0, function () {
222
- var _this = this;
223
- return __generator(this, function (_a) {
224
- switch (_a.label) {
225
- case 0: return [4 /*yield*/, Promise.all(viewingKeys.map(function (viewingKey) { return __awaiter(_this, void 0, void 0, function () {
226
- var outputDescription, error_1;
227
- return __generator(this, function (_a) {
228
- switch (_a.label) {
229
- case 0:
230
- _a.trys.push([0, 2, , 3]);
231
- outputDescription = transaction.outputDescriptions[0];
232
- return [4 /*yield*/, this.cryptoClient.decryptCiphertextOut(viewingKey, outputDescription.ciphertext, outputDescription.cm)];
233
- case 1:
234
- _a.sent();
235
- return [2 /*return*/, viewingKey];
236
- case 2:
237
- error_1 = _a.sent();
238
- return [2 /*return*/, undefined];
239
- case 3: return [2 /*return*/];
240
- }
241
- });
242
- }); }))];
243
- case 1: return [2 /*return*/, (_a.sent()).find(function (viewingKey) { return viewingKey !== undefined; })];
244
- }
245
- });
246
- });
247
- };
248
- TezosSaplingBookkeeper.prototype.findRecipient = function (outputDescription, viewingKeys) {
249
- return __awaiter(this, void 0, void 0, function () {
250
- var _this = this;
251
- return __generator(this, function (_a) {
252
- switch (_a.label) {
253
- case 0: return [4 /*yield*/, Promise.all(viewingKeys.map(function (viewingKey) { return __awaiter(_this, void 0, void 0, function () {
254
- var error_2;
255
- return __generator(this, function (_a) {
256
- switch (_a.label) {
257
- case 0:
258
- _a.trys.push([0, 2, , 3]);
259
- // a viewing key is the recipient if it can decrypt the ciphertext payload enc from output description
260
- return [4 /*yield*/, this.cryptoClient.decryptCiphertextEnc(viewingKey, outputDescription.ciphertext)];
261
- case 1:
262
- // a viewing key is the recipient if it can decrypt the ciphertext payload enc from output description
263
- _a.sent();
264
- return [2 /*return*/, viewingKey];
265
- case 2:
266
- error_2 = _a.sent();
267
- return [2 /*return*/, undefined];
268
- case 3: return [2 /*return*/];
269
- }
270
- });
271
- }); }))];
272
- case 1: return [2 /*return*/, (_a.sent()).find(function (viewingKey) { return viewingKey !== undefined; })];
273
- }
274
- });
275
- });
276
- };
277
- TezosSaplingBookkeeper.prototype.decodeDetailsFromOutputDescription = function (sender, recipient, output) {
278
- return __awaiter(this, void 0, void 0, function () {
279
- var viewingKey, _a, address, amount;
280
- return __generator(this, function (_b) {
281
- switch (_b.label) {
282
- case 0:
283
- viewingKey = sender !== null && sender !== void 0 ? sender : recipient;
284
- if (!(viewingKey !== undefined)) return [3 /*break*/, 3];
285
- return [4 /*yield*/, this.cryptoClient.decryptCiphertextEnc(viewingKey, output.ciphertext, viewingKey === sender ? 'sender' : 'receiver', output.cm)];
286
- case 1:
287
- _a = _b.sent(), address = _a.address, amount = _a.amount;
288
- return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromRaw(address)];
289
- case 2: return [2 /*return*/, [_b.sent(), amount]];
290
- case 3: return [2 /*return*/, [undefined, undefined]];
291
- }
292
- });
293
- });
294
- };
295
- TezosSaplingBookkeeper.prototype.sumNotes = function (notes) {
296
- return notes.reduce(function (sum, next) { return sum.plus(next.value); }, new bignumber_1.default(0));
297
- };
298
- TezosSaplingBookkeeper.prototype.getIncomingInputs = function (viewingKey, commitmentsWithCiphertext) {
299
- return __awaiter(this, void 0, void 0, function () {
300
- var inputs;
301
- var _this = this;
302
- return __generator(this, function (_a) {
303
- switch (_a.label) {
304
- case 0: return [4 /*yield*/, Promise.all(commitmentsWithCiphertext.map(function (_a) {
305
- var commitment = _a[0], ciphertext = _a[1], position = _a[2];
306
- return __awaiter(_this, void 0, void 0, function () {
307
- var decrypted, _b;
308
- return __generator(this, function (_c) {
309
- switch (_c.label) {
310
- case 0: return [4 /*yield*/, this.getIncomingInputFromCiphertext(viewingKey, ciphertext, commitment, position)];
311
- case 1:
312
- decrypted = _c.sent();
313
- _b = decrypted === undefined;
314
- if (_b) return [3 /*break*/, 3];
315
- return [4 /*yield*/, this.verifyCommitment(decrypted[1], commitment)];
316
- case 2:
317
- _b = !(_c.sent());
318
- _c.label = 3;
319
- case 3:
320
- if (_b) {
321
- return [2 /*return*/, undefined];
322
- }
323
- return [2 /*return*/, decrypted[1]];
324
- }
325
- });
326
- });
327
- }))];
328
- case 1:
329
- inputs = (_a.sent()).filter(function (input) { return input !== undefined; });
330
- return [2 /*return*/, inputs];
331
- }
332
- });
333
- });
334
- };
335
- TezosSaplingBookkeeper.prototype.getOutgoingInputs = function (viewingKey, commitmentsWithCiphertext) {
336
- return __awaiter(this, void 0, void 0, function () {
337
- var inputs;
338
- var _this = this;
339
- return __generator(this, function (_a) {
340
- switch (_a.label) {
341
- case 0: return [4 /*yield*/, Promise.all(commitmentsWithCiphertext.map(function (_a) {
342
- var commitment = _a[0], ciphertext = _a[1], position = _a[2];
343
- return __awaiter(_this, void 0, void 0, function () {
344
- var decrypted, _b, _c;
345
- return __generator(this, function (_d) {
346
- switch (_d.label) {
347
- case 0: return [4 /*yield*/, this.getOutgoingInputFromCiphertext(viewingKey, ciphertext, commitment, position)];
348
- case 1:
349
- decrypted = _d.sent();
350
- _b = decrypted === undefined;
351
- if (_b) return [3 /*break*/, 4];
352
- _c = decrypted[1].address !== '';
353
- if (!_c) return [3 /*break*/, 3];
354
- return [4 /*yield*/, this.verifyCommitment(decrypted[1], commitment)];
355
- case 2:
356
- _c = !(_d.sent());
357
- _d.label = 3;
358
- case 3:
359
- _b = (_c);
360
- _d.label = 4;
361
- case 4:
362
- if (_b) {
363
- return [2 /*return*/, undefined];
364
- }
365
- return [2 /*return*/, decrypted[1]];
366
- }
367
- });
368
- });
369
- }))];
370
- case 1:
371
- inputs = (_a.sent()).filter(function (input) { return input !== undefined; });
372
- return [2 /*return*/, inputs];
373
- }
374
- });
375
- });
376
- };
377
- TezosSaplingBookkeeper.prototype.getUnspends = function (viewingKey, commitmentsWithCiphertext, nullifiers) {
378
- return __awaiter(this, void 0, void 0, function () {
379
- var nullifiersSet, inputs, unspends;
380
- var _this = this;
381
- return __generator(this, function (_a) {
382
- switch (_a.label) {
383
- case 0:
384
- nullifiersSet = new Set(nullifiers.map(function (nullifier) { return (0, hex_1.stripHexPrefix)(nullifier); }));
385
- return [4 /*yield*/, this.getInputs(viewingKey, commitmentsWithCiphertext)];
386
- case 1:
387
- inputs = _a.sent();
388
- return [4 /*yield*/, Promise.all(inputs.map(function (input) { return __awaiter(_this, void 0, void 0, function () {
389
- var nullifier, _a, _b, _c;
390
- return __generator(this, function (_d) {
391
- switch (_d.label) {
392
- case 0:
393
- _b = (_a = sapling).computeNullifier;
394
- _c = [viewingKey];
395
- return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromValue(input.address)];
396
- case 1: return [4 /*yield*/, _b.apply(_a, _c.concat([(_d.sent()).raw,
397
- input.value,
398
- input.rcm,
399
- input.pos]))];
400
- case 2:
401
- nullifier = _d.sent();
402
- return [2 /*return*/, !nullifiersSet.has(nullifier.toString('hex')) ? input : undefined];
403
- }
404
- });
405
- }); }))];
406
- case 2:
407
- unspends = (_a.sent()).filter(function (input) { return input !== undefined; });
408
- return [2 /*return*/, unspends];
409
- }
410
- });
411
- });
412
- };
413
- TezosSaplingBookkeeper.prototype.getInputs = function (viewingKey, commitmentsWithCiphertext) {
414
- return __awaiter(this, void 0, void 0, function () {
415
- var inputs;
416
- var _this = this;
417
- return __generator(this, function (_a) {
418
- switch (_a.label) {
419
- case 0: return [4 /*yield*/, Promise.all(commitmentsWithCiphertext.map(function (_a, index) {
420
- var commitment = _a[0], ciphertext = _a[1];
421
- return __awaiter(_this, void 0, void 0, function () {
422
- var decrypted, _b;
423
- return __generator(this, function (_c) {
424
- switch (_c.label) {
425
- case 0: return [4 /*yield*/, this.getReceiverInputFromCiphertext(viewingKey, ciphertext, new bignumber_1.default(index))];
426
- case 1:
427
- decrypted = _c.sent();
428
- _b = decrypted === undefined;
429
- if (_b) return [3 /*break*/, 3];
430
- return [4 /*yield*/, this.verifyCommitment(decrypted[1], commitment)];
431
- case 2:
432
- _b = !(_c.sent());
433
- _c.label = 3;
434
- case 3:
435
- if (_b) {
436
- return [2 /*return*/, undefined];
437
- }
438
- return [2 /*return*/, decrypted[1]];
439
- }
440
- });
441
- });
442
- }))];
443
- case 1:
444
- inputs = (_a.sent()).filter(function (input) { return input !== undefined; });
445
- return [2 /*return*/, inputs];
446
- }
447
- });
448
- });
449
- };
450
- TezosSaplingBookkeeper.prototype.getReceiverInputFromCiphertext = function (viewingKey, ciphertext, position) {
451
- return __awaiter(this, void 0, void 0, function () {
452
- var _a, diversifier, amount, rcm, memo, ivk, address, input, _b;
453
- var _c;
454
- return __generator(this, function (_d) {
455
- switch (_d.label) {
456
- case 0:
457
- _d.trys.push([0, 5, , 6]);
458
- return [4 /*yield*/, this.cryptoClient.decryptCiphertextEnc(viewingKey, ciphertext, 'receiver')];
459
- case 1:
460
- _a = _d.sent(), diversifier = _a.diversifier, amount = _a.amount, rcm = _a.rcm, memo = _a.memo;
461
- return [4 /*yield*/, sapling.getIncomingViewingKey(viewingKey)];
462
- case 2:
463
- ivk = _d.sent();
464
- return [4 /*yield*/, sapling.getRawPaymentAddressFromIncomingViewingKey(ivk, diversifier)];
465
- case 3:
466
- address = _d.sent();
467
- _c = {
468
- rcm: rcm.toString('hex'),
469
- pos: position.toString(),
470
- value: amount.toString()
471
- };
472
- return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromRaw(address)];
473
- case 4:
474
- input = (_c.address = (_d.sent()).asString(),
475
- _c);
476
- return [2 /*return*/, [Buffer.from(memo), input]];
477
- case 5:
478
- _b = _d.sent();
479
- return [2 /*return*/, undefined];
480
- case 6: return [2 /*return*/];
81
+ }
82
+ async getTransactionsPartialDetails(txs, knownViewingKeys = []) {
83
+ const partials = await Promise.all(txs.map(async (tx) => {
84
+ const signedBuffer = Buffer.isBuffer(tx) ? tx : Buffer.from(tx, 'hex');
85
+ const transaction = this.encoder.decodeTransaction(signedBuffer);
86
+ const [from, details] = await this.getTransactionPartialDetails(transaction, knownViewingKeys);
87
+ if (transaction.boundData.length > 0) {
88
+ const boundDataMichelson = TezosUtils_1.TezosUtils.unpackMichelsonType(transaction.boundData);
89
+ let unshieldTarget;
90
+ if (boundDataMichelson instanceof MichelsonBytes_1.MichelsonBytes) {
91
+ unshieldTarget = TezosUtils_1.TezosUtils.parseTzAddress(boundDataMichelson.value);
481
92
  }
482
- });
483
- });
484
- };
485
- TezosSaplingBookkeeper.prototype.getSenderInputFromCiphertext = function (viewingKey, ciphertext, commitment, position) {
486
- return __awaiter(this, void 0, void 0, function () {
487
- var _a, amount, address, rcm, memo, input, _b;
488
- var _c;
489
- return __generator(this, function (_d) {
490
- switch (_d.label) {
491
- case 0:
492
- _d.trys.push([0, 3, , 4]);
493
- return [4 /*yield*/, this.cryptoClient.decryptCiphertextEnc(viewingKey, ciphertext, 'sender', commitment)];
494
- case 1:
495
- _a = _d.sent(), amount = _a.amount, address = _a.address, rcm = _a.rcm, memo = _a.memo;
496
- _c = {
497
- rcm: rcm.toString('hex'),
498
- pos: position.toString(),
499
- value: amount.toString()
500
- };
501
- return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromRaw(address)];
502
- case 2:
503
- input = (_c.address = (_d.sent()).asString(),
504
- _c);
505
- return [2 /*return*/, [Buffer.from(memo), input]];
506
- case 3:
507
- _b = _d.sent();
508
- return [2 /*return*/, undefined];
509
- case 4: return [2 /*return*/];
93
+ else if (boundDataMichelson instanceof MichelsonString_1.MichelsonString) {
94
+ unshieldTarget = boundDataMichelson.value;
510
95
  }
511
- });
512
- });
513
- };
514
- TezosSaplingBookkeeper.prototype.getIncomingInputFromCiphertext = function (viewingKey, ciphertext, commitment, position) {
515
- return __awaiter(this, void 0, void 0, function () {
516
- var inputWithMemo, error_3;
517
- return __generator(this, function (_a) {
518
- switch (_a.label) {
519
- case 0: return [4 /*yield*/, this.getReceiverInputFromCiphertext(viewingKey, ciphertext, position)];
520
- case 1:
521
- inputWithMemo = _a.sent();
522
- if (inputWithMemo === undefined) {
523
- return [2 /*return*/, undefined];
524
- }
525
- _a.label = 2;
526
- case 2:
527
- _a.trys.push([2, 4, , 5]);
528
- return [4 /*yield*/, this.cryptoClient.decryptCiphertextEnc(viewingKey, ciphertext, 'sender', commitment)
529
- // ciphertext can be decrypted, the receiver is also the sender
530
- ];
531
- case 3:
532
- _a.sent();
533
- // ciphertext can be decrypted, the receiver is also the sender
534
- return [2 /*return*/, undefined];
535
- case 4:
536
- error_3 = _a.sent();
537
- // ciphertext could not be decrypted, the reciever is not the sender
538
- return [2 /*return*/, inputWithMemo];
539
- case 5: return [2 /*return*/];
540
- }
541
- });
542
- });
543
- };
544
- TezosSaplingBookkeeper.prototype.getOutgoingInputFromCiphertext = function (viewingKey, ciphertext, commitment, position) {
545
- return __awaiter(this, void 0, void 0, function () {
546
- var inputWithMemo, _a;
547
- return __generator(this, function (_b) {
548
- switch (_b.label) {
549
- case 0: return [4 /*yield*/, this.getSenderInputFromCiphertext(viewingKey, ciphertext, commitment, position)];
550
- case 1:
551
- inputWithMemo = _b.sent();
552
- if (inputWithMemo === undefined) {
553
- return [2 /*return*/, undefined];
554
- }
555
- _b.label = 2;
556
- case 2:
557
- _b.trys.push([2, 4, , 5]);
558
- return [4 /*yield*/, this.cryptoClient.decryptCiphertextEnc(viewingKey, ciphertext, 'receiver')
559
- // ciphertext can be decrypted, the sender is also the receiver
560
- ];
561
- case 3:
562
- _b.sent();
563
- // ciphertext can be decrypted, the sender is also the receiver
564
- return [2 /*return*/, undefined];
565
- case 4:
566
- _a = _b.sent();
567
- // ciphertext could not be decrypted, the sender is not the receiver
568
- return [2 /*return*/, inputWithMemo];
569
- case 5: return [2 /*return*/];
96
+ if (unshieldTarget !== undefined) {
97
+ let unshieldDetails = {
98
+ to: [unshieldTarget],
99
+ amount: transaction.balance.toFixed()
100
+ };
101
+ if (from !== undefined) {
102
+ unshieldDetails = Object.assign(unshieldDetails, { from: [(await TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(from)).asString()] });
103
+ }
104
+ details.push(unshieldDetails);
570
105
  }
571
- });
572
- });
573
- };
574
- TezosSaplingBookkeeper.prototype.verifyCommitment = function (input, expectedCommitment) {
575
- return __awaiter(this, void 0, void 0, function () {
576
- var _a, _b, _c;
577
- return __generator(this, function (_d) {
578
- switch (_d.label) {
579
- case 0:
580
- _b = (_a = sapling).verifyCommitment;
581
- _c = [expectedCommitment];
582
- return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromValue(input.address)];
583
- case 1: return [2 /*return*/, _b.apply(_a, _c.concat([(_d.sent()).raw, input.value, input.rcm]))];
584
- }
585
- });
586
- });
587
- };
588
- return TezosSaplingBookkeeper;
589
- }());
106
+ }
107
+ return details;
108
+ }));
109
+ return (0, array_1.flattenArray)(partials);
110
+ }
111
+ async getTransactionPartialDetails(transaction, knownViewingKeys) {
112
+ const sender = transaction.spendDescriptions.length === 0 ? undefined : await this.findSender(transaction, knownViewingKeys);
113
+ const details = await Promise.all(transaction.outputDescriptions.map(async (description) => {
114
+ const recipient = await this.findRecipient(description, knownViewingKeys);
115
+ const from = sender !== undefined ? await TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(sender) : undefined;
116
+ const [to, amount] = await this.decodeDetailsFromOutputDescription(sender, recipient, description);
117
+ let outputDetails = {};
118
+ if (from !== undefined) {
119
+ outputDetails = Object.assign(outputDetails, { from: [from.asString()] });
120
+ }
121
+ if (to !== undefined) {
122
+ outputDetails = Object.assign(outputDetails, { to: [to.asString()] });
123
+ }
124
+ if (amount !== undefined) {
125
+ outputDetails = Object.assign(outputDetails, { amount: amount.toFixed() });
126
+ }
127
+ return outputDetails;
128
+ }));
129
+ return [sender, details];
130
+ }
131
+ async findSender(transaction, viewingKeys) {
132
+ return (await Promise.all(viewingKeys.map(async (viewingKey) => {
133
+ try {
134
+ // a viewing key is the sender if it can decrypt any ciphertext payload out from the transaction
135
+ const outputDescription = transaction.outputDescriptions[0];
136
+ await this.cryptoClient.decryptCiphertextOut(viewingKey, outputDescription.ciphertext, outputDescription.cm);
137
+ return viewingKey;
138
+ }
139
+ catch (error) {
140
+ return undefined;
141
+ }
142
+ }))).find((viewingKey) => viewingKey !== undefined);
143
+ }
144
+ async findRecipient(outputDescription, viewingKeys) {
145
+ return (await Promise.all(viewingKeys.map(async (viewingKey) => {
146
+ try {
147
+ // a viewing key is the recipient if it can decrypt the ciphertext payload enc from output description
148
+ await this.cryptoClient.decryptCiphertextEnc(viewingKey, outputDescription.ciphertext);
149
+ return viewingKey;
150
+ }
151
+ catch (error) {
152
+ return undefined;
153
+ }
154
+ }))).find((viewingKey) => viewingKey !== undefined);
155
+ }
156
+ async decodeDetailsFromOutputDescription(sender, recipient, output) {
157
+ const viewingKey = sender ?? recipient;
158
+ if (viewingKey !== undefined) {
159
+ const { address, amount } = await this.cryptoClient.decryptCiphertextEnc(viewingKey, output.ciphertext, viewingKey === sender ? 'sender' : 'receiver', output.cm);
160
+ return [await TezosSaplingAddress_1.TezosSaplingAddress.fromRaw(address), amount];
161
+ }
162
+ return [undefined, undefined];
163
+ }
164
+ sumNotes(notes) {
165
+ return notes.reduce((sum, next) => sum.plus(next.value), new bignumber_1.default(0));
166
+ }
167
+ async getIncomingInputs(viewingKey, commitmentsWithCiphertext) {
168
+ const inputs = (await Promise.all(commitmentsWithCiphertext.map(async ([commitment, ciphertext, position]) => {
169
+ const decrypted = await this.getIncomingInputFromCiphertext(viewingKey, ciphertext, commitment, position);
170
+ if (decrypted === undefined || !(await this.verifyCommitment(decrypted[1], commitment))) {
171
+ return undefined;
172
+ }
173
+ return decrypted[1];
174
+ }))).filter((input) => input !== undefined);
175
+ return inputs;
176
+ }
177
+ async getOutgoingInputs(viewingKey, commitmentsWithCiphertext) {
178
+ const inputs = (await Promise.all(commitmentsWithCiphertext.map(async ([commitment, ciphertext, position]) => {
179
+ const decrypted = await this.getOutgoingInputFromCiphertext(viewingKey, ciphertext, commitment, position);
180
+ if (decrypted === undefined || (decrypted[1].address !== '' && !(await this.verifyCommitment(decrypted[1], commitment)))) {
181
+ return undefined;
182
+ }
183
+ return decrypted[1];
184
+ }))).filter((input) => input !== undefined);
185
+ return inputs;
186
+ }
187
+ async getUnspends(viewingKey, commitmentsWithCiphertext, nullifiers) {
188
+ const nullifiersSet = new Set(nullifiers.map((nullifier) => (0, hex_1.stripHexPrefix)(nullifier)));
189
+ const inputs = await this.getInputs(viewingKey, commitmentsWithCiphertext);
190
+ const unspends = (await Promise.all(inputs.map(async (input) => {
191
+ const nullifier = await sapling.computeNullifier(viewingKey, (await TezosSaplingAddress_1.TezosSaplingAddress.fromValue(input.address)).raw, input.value, input.rcm, input.pos);
192
+ return !nullifiersSet.has(nullifier.toString('hex')) ? input : undefined;
193
+ }))).filter((input) => input !== undefined);
194
+ return unspends;
195
+ }
196
+ async getInputs(viewingKey, commitmentsWithCiphertext) {
197
+ const inputs = (await Promise.all(commitmentsWithCiphertext.map(async ([commitment, ciphertext], index) => {
198
+ const decrypted = await this.getReceiverInputFromCiphertext(viewingKey, ciphertext, new bignumber_1.default(index));
199
+ if (decrypted === undefined || !(await this.verifyCommitment(decrypted[1], commitment))) {
200
+ return undefined;
201
+ }
202
+ return decrypted[1];
203
+ }))).filter((input) => input !== undefined);
204
+ return inputs;
205
+ }
206
+ async getReceiverInputFromCiphertext(viewingKey, ciphertext, position) {
207
+ try {
208
+ const { diversifier, amount, rcm, memo } = await this.cryptoClient.decryptCiphertextEnc(viewingKey, ciphertext, 'receiver');
209
+ const ivk = await sapling.getIncomingViewingKey(viewingKey);
210
+ const address = await sapling.getRawPaymentAddressFromIncomingViewingKey(ivk, diversifier);
211
+ const input = {
212
+ rcm: rcm.toString('hex'),
213
+ pos: position.toString(),
214
+ value: amount.toString(),
215
+ address: (await TezosSaplingAddress_1.TezosSaplingAddress.fromRaw(address)).asString()
216
+ };
217
+ return [Buffer.from(memo), input];
218
+ }
219
+ catch {
220
+ return undefined;
221
+ }
222
+ }
223
+ async getSenderInputFromCiphertext(viewingKey, ciphertext, commitment, position) {
224
+ try {
225
+ const { amount, address, rcm, memo } = await this.cryptoClient.decryptCiphertextEnc(viewingKey, ciphertext, 'sender', commitment);
226
+ const input = {
227
+ rcm: rcm.toString('hex'),
228
+ pos: position.toString(),
229
+ value: amount.toString(),
230
+ address: (await TezosSaplingAddress_1.TezosSaplingAddress.fromRaw(address)).asString()
231
+ };
232
+ return [Buffer.from(memo), input];
233
+ }
234
+ catch {
235
+ return undefined;
236
+ }
237
+ }
238
+ async getIncomingInputFromCiphertext(viewingKey, ciphertext, commitment, position) {
239
+ const inputWithMemo = await this.getReceiverInputFromCiphertext(viewingKey, ciphertext, position);
240
+ if (inputWithMemo === undefined) {
241
+ return undefined;
242
+ }
243
+ try {
244
+ await this.cryptoClient.decryptCiphertextEnc(viewingKey, ciphertext, 'sender', commitment);
245
+ // ciphertext can be decrypted, the receiver is also the sender
246
+ return undefined;
247
+ }
248
+ catch (error) {
249
+ // ciphertext could not be decrypted, the reciever is not the sender
250
+ return inputWithMemo;
251
+ }
252
+ }
253
+ async getOutgoingInputFromCiphertext(viewingKey, ciphertext, commitment, position) {
254
+ const inputWithMemo = await this.getSenderInputFromCiphertext(viewingKey, ciphertext, commitment, position);
255
+ if (inputWithMemo === undefined) {
256
+ return undefined;
257
+ }
258
+ try {
259
+ await this.cryptoClient.decryptCiphertextEnc(viewingKey, ciphertext, 'receiver');
260
+ // ciphertext can be decrypted, the sender is also the receiver
261
+ return undefined;
262
+ }
263
+ catch {
264
+ // ciphertext could not be decrypted, the sender is not the receiver
265
+ return inputWithMemo;
266
+ }
267
+ }
268
+ async verifyCommitment(input, expectedCommitment) {
269
+ return sapling.verifyCommitment(expectedCommitment, (await TezosSaplingAddress_1.TezosSaplingAddress.fromValue(input.address)).raw, input.value, input.rcm);
270
+ }
271
+ }
590
272
  exports.TezosSaplingBookkeeper = TezosSaplingBookkeeper;
591
273
  //# sourceMappingURL=TezosSaplingBookkeeper.js.map