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

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,279 +1,508 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ 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;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
2
38
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
39
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
40
  };
5
41
  Object.defineProperty(exports, "__esModule", { value: true });
6
42
  exports.TezosContract = void 0;
7
- const index_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/axios-0.19.0/index"));
8
- const errors_1 = require("@airgap/coinlib-core/errors");
9
- const coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
10
- const object_1 = require("@airgap/coinlib-core/utils/object");
11
- const string_1 = require("@airgap/coinlib-core/utils/string");
12
- const factory_1 = require("../indexer/factory");
13
- const MichelineNodeUtils_1 = require("../types/micheline/MichelineNodeUtils");
14
- const MichelsonOr_1 = require("../types/michelson/generics/MichelsonOr");
15
- const MichelsonType_1 = require("../types/michelson/MichelsonType");
16
- const MichelsonTypeMeta_1 = require("../types/michelson/MichelsonTypeMeta");
17
- const micheline_1 = require("../utils/micheline");
18
- const pack_1 = require("../utils/pack");
19
- const TezosContractRemoteDataFactory_1 = require("./remote-data/TezosContractRemoteDataFactory");
20
- const TezosContractCall_1 = require("./TezosContractCall");
21
- const TezosContractEntrypoint_1 = require("./TezosContractEntrypoint");
22
- const TezosContractStorage_1 = require("./TezosContractStorage");
23
- const DEFAULT_ENTRYPOINT = 'default';
24
- class TezosContract {
25
- constructor(address, network) {
43
+ var index_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/axios-0.19.0/index"));
44
+ var errors_1 = require("@airgap/coinlib-core/errors");
45
+ var coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
46
+ var object_1 = require("@airgap/coinlib-core/utils/object");
47
+ var string_1 = require("@airgap/coinlib-core/utils/string");
48
+ var factory_1 = require("../indexer/factory");
49
+ var MichelineNodeUtils_1 = require("../types/micheline/MichelineNodeUtils");
50
+ var MichelsonOr_1 = require("../types/michelson/generics/MichelsonOr");
51
+ var MichelsonType_1 = require("../types/michelson/MichelsonType");
52
+ var MichelsonTypeMeta_1 = require("../types/michelson/MichelsonTypeMeta");
53
+ var micheline_1 = require("../utils/micheline");
54
+ var pack_1 = require("../utils/pack");
55
+ var TezosContractRemoteDataFactory_1 = require("./remote-data/TezosContractRemoteDataFactory");
56
+ var TezosContractCall_1 = require("./TezosContractCall");
57
+ var TezosContractEntrypoint_1 = require("./TezosContractEntrypoint");
58
+ var TezosContractStorage_1 = require("./TezosContractStorage");
59
+ var DEFAULT_ENTRYPOINT = 'default';
60
+ var TezosContract = /** @class */ (function () {
61
+ function TezosContract(address, network) {
26
62
  this.address = address;
27
63
  this.network = network;
28
64
  this.remoteDataFactory = new TezosContractRemoteDataFactory_1.TezosContractRemoteDataFactory();
29
65
  this.indexerClient = (0, factory_1.createTezosIndexerClient)(this.network.indexerType, this.network.indexerApi);
30
66
  }
31
- copy(values = {}) {
32
- return new TezosContract(values.address ?? this.address, values.network ?? this.network);
33
- }
34
- async findBigMap(name) {
35
- const storage = await this.readStorage();
36
- return (0, object_1.recursivelyFind)(storage?.asRawValue(), name)?.toNumber();
37
- }
38
- async bigMapValue(bigMapID, keyOrValueSchema, keySchemaOrUndefined, valueSchemaOrUndefined) {
39
- let expr;
40
- let valueSchema;
41
- if (keySchemaOrUndefined && valueSchemaOrUndefined) {
42
- const michelsonKey = MichelsonTypeMeta_1.MichelsonTypeMeta.fromMichelineNode(keySchemaOrUndefined)?.createValue(keyOrValueSchema);
43
- if (!michelsonKey) {
44
- return undefined;
45
- }
46
- expr = await (0, pack_1.encodeExpr)(michelsonKey);
47
- valueSchema = valueSchemaOrUndefined;
48
- }
49
- else if (!keySchemaOrUndefined && !valueSchemaOrUndefined) {
50
- valueSchema = keyOrValueSchema;
51
- }
52
- if (!valueSchema) {
53
- return undefined;
54
- }
55
- const value = await this.bigMapRequest(bigMapID, expr);
56
- return value ? MichelsonTypeMeta_1.MichelsonTypeMeta.fromMichelineNode(valueSchema)?.createValue(value) : undefined;
57
- }
58
- async bigMapValues(bigMapID, valueSchema) {
59
- const values = await this.bigMapRequest(bigMapID, '');
60
- if (!Array.isArray(values)) {
61
- return [];
62
- }
63
- return values
64
- ?.map((value) => MichelsonTypeMeta_1.MichelsonTypeMeta.fromMichelineNode(valueSchema)?.createValue(value))
65
- ?.filter((value) => value !== undefined);
66
- }
67
- async getBigMaps() {
68
- await this.waitForBigMaps();
69
- return this.bigMaps ?? [];
70
- }
71
- async getBigMapValues(request) {
72
- const bigMap = request?.bigMap ?? (await this.getBigMap(request.bigMap?.path));
73
- return this.indexerClient.getContractBigMapValues(this.address, bigMap, request.resultType, request.filters, request.limit ?? 10000);
74
- }
75
- async getBigMapValue(request) {
76
- const bigMap = request?.bigMap ?? (await this.getBigMap(request.bigMap?.path));
77
- if (request.key === undefined) {
78
- return undefined;
79
- }
80
- return this.indexerClient.getContractBigMapValue(this.address, bigMap, request.key, request.resultType, request.limit ?? 10000);
81
- }
82
- async readStorage() {
83
- await this.waitForContractCode();
84
- if (this.storage === undefined) {
85
- return undefined;
86
- }
87
- const storageContent = await this.contractRequest('/storage/normalized', { unparsing_mode: 'Optimized_legacy' });
88
- return this.storage.type.createValue(storageContent);
89
- }
90
- async metadata(networkResolver) {
91
- const bigMapID = await this.findBigMap('metadata');
92
- if (bigMapID === undefined) {
93
- return undefined;
94
- }
95
- const remoteData = await this.getMetadataRemoteData(bigMapID, networkResolver);
96
- return remoteData?.get();
97
- }
98
- async balance() {
99
- return this.contractRequest('/balance');
100
- }
101
- async createContractCall(entrypointName, value, amount) {
102
- await this.waitForContractCode();
103
- const entrypoint = this.entrypoints?.get(entrypointName);
104
- if (!entrypoint) {
105
- return this.createDefaultContractCall(value, amount);
106
- }
107
- return this.createEntrypointContractCall(entrypoint, value, undefined, amount);
108
- }
109
- async parseContractCall(json) {
110
- await this.waitForContractCode();
111
- const entrypoint = this.entrypoints?.get(json.entrypoint);
112
- if (!entrypoint) {
113
- return Promise.reject(`Couldn't parse the contract call, unknown entrypoint: ${json.entrypoint}`);
114
- }
115
- return this.createEntrypointContractCall(entrypoint, json.value, { lazyEval: false });
116
- }
117
- areValidParameters(data) {
67
+ TezosContract.prototype.copy = function (values) {
68
+ var _a, _b;
69
+ if (values === void 0) { values = {}; }
70
+ return new TezosContract((_a = values.address) !== null && _a !== void 0 ? _a : this.address, (_b = values.network) !== null && _b !== void 0 ? _b : this.network);
71
+ };
72
+ TezosContract.prototype.findBigMap = function (name) {
73
+ var _a;
74
+ return __awaiter(this, void 0, void 0, function () {
75
+ var storage;
76
+ return __generator(this, function (_b) {
77
+ switch (_b.label) {
78
+ case 0: return [4 /*yield*/, this.readStorage()];
79
+ case 1:
80
+ storage = _b.sent();
81
+ return [2 /*return*/, (_a = (0, object_1.recursivelyFind)(storage === null || storage === void 0 ? void 0 : storage.asRawValue(), name)) === null || _a === void 0 ? void 0 : _a.toNumber()];
82
+ }
83
+ });
84
+ });
85
+ };
86
+ TezosContract.prototype.bigMapValue = function (bigMapID, keyOrValueSchema, keySchemaOrUndefined, valueSchemaOrUndefined) {
87
+ var _a, _b;
88
+ return __awaiter(this, void 0, void 0, function () {
89
+ var expr, valueSchema, michelsonKey, value;
90
+ return __generator(this, function (_c) {
91
+ switch (_c.label) {
92
+ case 0:
93
+ if (!(keySchemaOrUndefined && valueSchemaOrUndefined)) return [3 /*break*/, 2];
94
+ michelsonKey = (_a = MichelsonTypeMeta_1.MichelsonTypeMeta.fromMichelineNode(keySchemaOrUndefined)) === null || _a === void 0 ? void 0 : _a.createValue(keyOrValueSchema);
95
+ if (!michelsonKey) {
96
+ return [2 /*return*/, undefined];
97
+ }
98
+ return [4 /*yield*/, (0, pack_1.encodeExpr)(michelsonKey)];
99
+ case 1:
100
+ expr = _c.sent();
101
+ valueSchema = valueSchemaOrUndefined;
102
+ return [3 /*break*/, 3];
103
+ case 2:
104
+ if (!keySchemaOrUndefined && !valueSchemaOrUndefined) {
105
+ valueSchema = keyOrValueSchema;
106
+ }
107
+ _c.label = 3;
108
+ case 3:
109
+ if (!valueSchema) {
110
+ return [2 /*return*/, undefined];
111
+ }
112
+ return [4 /*yield*/, this.bigMapRequest(bigMapID, expr)];
113
+ case 4:
114
+ value = _c.sent();
115
+ return [2 /*return*/, value ? (_b = MichelsonTypeMeta_1.MichelsonTypeMeta.fromMichelineNode(valueSchema)) === null || _b === void 0 ? void 0 : _b.createValue(value) : undefined];
116
+ }
117
+ });
118
+ });
119
+ };
120
+ TezosContract.prototype.bigMapValues = function (bigMapID, valueSchema) {
121
+ var _a;
122
+ return __awaiter(this, void 0, void 0, function () {
123
+ var values;
124
+ return __generator(this, function (_b) {
125
+ switch (_b.label) {
126
+ case 0: return [4 /*yield*/, this.bigMapRequest(bigMapID, '')];
127
+ case 1:
128
+ values = _b.sent();
129
+ if (!Array.isArray(values)) {
130
+ return [2 /*return*/, []];
131
+ }
132
+ return [2 /*return*/, (_a = values === null || values === void 0 ? void 0 : values.map(function (value) { var _a; return (_a = MichelsonTypeMeta_1.MichelsonTypeMeta.fromMichelineNode(valueSchema)) === null || _a === void 0 ? void 0 : _a.createValue(value); })) === null || _a === void 0 ? void 0 : _a.filter(function (value) { return value !== undefined; })];
133
+ }
134
+ });
135
+ });
136
+ };
137
+ TezosContract.prototype.getBigMaps = function () {
138
+ var _a;
139
+ return __awaiter(this, void 0, void 0, function () {
140
+ return __generator(this, function (_b) {
141
+ switch (_b.label) {
142
+ case 0: return [4 /*yield*/, this.waitForBigMaps()];
143
+ case 1:
144
+ _b.sent();
145
+ return [2 /*return*/, (_a = this.bigMaps) !== null && _a !== void 0 ? _a : []];
146
+ }
147
+ });
148
+ });
149
+ };
150
+ TezosContract.prototype.getBigMapValues = function (request) {
151
+ var _a, _b, _c;
152
+ return __awaiter(this, void 0, void 0, function () {
153
+ var bigMap, _d;
154
+ return __generator(this, function (_e) {
155
+ switch (_e.label) {
156
+ case 0:
157
+ if (!((_a = request === null || request === void 0 ? void 0 : request.bigMap) !== null && _a !== void 0)) return [3 /*break*/, 1];
158
+ _d = _a;
159
+ return [3 /*break*/, 3];
160
+ case 1: return [4 /*yield*/, this.getBigMap((_b = request.bigMap) === null || _b === void 0 ? void 0 : _b.path)];
161
+ case 2:
162
+ _d = (_e.sent());
163
+ _e.label = 3;
164
+ case 3:
165
+ bigMap = _d;
166
+ return [2 /*return*/, this.indexerClient.getContractBigMapValues(this.address, bigMap, request.resultType, request.filters, (_c = request.limit) !== null && _c !== void 0 ? _c : 10000)];
167
+ }
168
+ });
169
+ });
170
+ };
171
+ TezosContract.prototype.getBigMapValue = function (request) {
172
+ var _a, _b, _c;
173
+ return __awaiter(this, void 0, void 0, function () {
174
+ var bigMap, _d;
175
+ return __generator(this, function (_e) {
176
+ switch (_e.label) {
177
+ case 0:
178
+ if (!((_a = request === null || request === void 0 ? void 0 : request.bigMap) !== null && _a !== void 0)) return [3 /*break*/, 1];
179
+ _d = _a;
180
+ return [3 /*break*/, 3];
181
+ case 1: return [4 /*yield*/, this.getBigMap((_b = request.bigMap) === null || _b === void 0 ? void 0 : _b.path)];
182
+ case 2:
183
+ _d = (_e.sent());
184
+ _e.label = 3;
185
+ case 3:
186
+ bigMap = _d;
187
+ if (request.key === undefined) {
188
+ return [2 /*return*/, undefined];
189
+ }
190
+ return [2 /*return*/, this.indexerClient.getContractBigMapValue(this.address, bigMap, request.key, request.resultType, (_c = request.limit) !== null && _c !== void 0 ? _c : 10000)];
191
+ }
192
+ });
193
+ });
194
+ };
195
+ TezosContract.prototype.readStorage = function () {
196
+ return __awaiter(this, void 0, void 0, function () {
197
+ var storageContent;
198
+ return __generator(this, function (_a) {
199
+ switch (_a.label) {
200
+ case 0: return [4 /*yield*/, this.waitForContractCode()];
201
+ case 1:
202
+ _a.sent();
203
+ if (this.storage === undefined) {
204
+ return [2 /*return*/, undefined];
205
+ }
206
+ return [4 /*yield*/, this.contractRequest('/storage/normalized', { unparsing_mode: 'Optimized_legacy' })];
207
+ case 2:
208
+ storageContent = _a.sent();
209
+ return [2 /*return*/, this.storage.type.createValue(storageContent)];
210
+ }
211
+ });
212
+ });
213
+ };
214
+ TezosContract.prototype.metadata = function (networkResolver) {
215
+ return __awaiter(this, void 0, void 0, function () {
216
+ var bigMapID, remoteData;
217
+ return __generator(this, function (_a) {
218
+ switch (_a.label) {
219
+ case 0: return [4 /*yield*/, this.findBigMap('metadata')];
220
+ case 1:
221
+ bigMapID = _a.sent();
222
+ if (bigMapID === undefined) {
223
+ return [2 /*return*/, undefined];
224
+ }
225
+ return [4 /*yield*/, this.getMetadataRemoteData(bigMapID, networkResolver)];
226
+ case 2:
227
+ remoteData = _a.sent();
228
+ return [2 /*return*/, remoteData === null || remoteData === void 0 ? void 0 : remoteData.get()];
229
+ }
230
+ });
231
+ });
232
+ };
233
+ TezosContract.prototype.balance = function () {
234
+ return __awaiter(this, void 0, void 0, function () {
235
+ return __generator(this, function (_a) {
236
+ return [2 /*return*/, this.contractRequest('/balance')];
237
+ });
238
+ });
239
+ };
240
+ TezosContract.prototype.createContractCall = function (entrypointName, value, amount) {
241
+ var _a;
242
+ return __awaiter(this, void 0, void 0, function () {
243
+ var entrypoint;
244
+ return __generator(this, function (_b) {
245
+ switch (_b.label) {
246
+ case 0: return [4 /*yield*/, this.waitForContractCode()];
247
+ case 1:
248
+ _b.sent();
249
+ entrypoint = (_a = this.entrypoints) === null || _a === void 0 ? void 0 : _a.get(entrypointName);
250
+ if (!entrypoint) {
251
+ return [2 /*return*/, this.createDefaultContractCall(value, amount)];
252
+ }
253
+ return [2 /*return*/, this.createEntrypointContractCall(entrypoint, value, undefined, amount)];
254
+ }
255
+ });
256
+ });
257
+ };
258
+ TezosContract.prototype.parseContractCall = function (json) {
259
+ var _a;
260
+ return __awaiter(this, void 0, void 0, function () {
261
+ var entrypoint;
262
+ return __generator(this, function (_b) {
263
+ switch (_b.label) {
264
+ case 0: return [4 /*yield*/, this.waitForContractCode()];
265
+ case 1:
266
+ _b.sent();
267
+ entrypoint = (_a = this.entrypoints) === null || _a === void 0 ? void 0 : _a.get(json.entrypoint);
268
+ if (!entrypoint) {
269
+ return [2 /*return*/, Promise.reject("Couldn't parse the contract call, unknown entrypoint: ".concat(json.entrypoint))];
270
+ }
271
+ return [2 /*return*/, this.createEntrypointContractCall(entrypoint, json.value, { lazyEval: false })];
272
+ }
273
+ });
274
+ });
275
+ };
276
+ TezosContract.prototype.areValidParameters = function (data) {
118
277
  try {
119
- const parameters = typeof data === 'string' ? JSON.parse(data) : data;
278
+ var parameters = typeof data === 'string' ? JSON.parse(data) : data;
120
279
  return parameters instanceof Object && 'entrypoint' in parameters && 'value' in parameters;
121
280
  }
122
- catch {
281
+ catch (_a) {
123
282
  return false;
124
283
  }
125
- }
126
- parseParameters(parameters) {
284
+ };
285
+ TezosContract.prototype.parseParameters = function (parameters) {
127
286
  if (!this.areValidParameters(parameters)) {
128
287
  throw new Error('Invalid parameters');
129
288
  }
130
289
  return JSON.parse(parameters);
131
- }
132
- async normalizeContractCallParameters(json, fallbackEntrypoint) {
133
- const entrypoint = 'entrypoint' in json ? json.entrypoint : undefined;
134
- const value = 'value' in json ? json.value : json;
135
- if (entrypoint !== undefined && entrypoint !== DEFAULT_ENTRYPOINT) {
136
- return {
137
- entrypoint,
138
- value
139
- };
140
- }
141
- if (!MichelsonOr_1.MichelsonOr.isOr(value)) {
142
- return {
143
- entrypoint: fallbackEntrypoint ?? DEFAULT_ENTRYPOINT,
144
- value
145
- };
146
- }
147
- await this.waitForContractCode();
148
- const defaultEntrypoint = this.entrypoints?.get(DEFAULT_ENTRYPOINT);
149
- if (!defaultEntrypoint) {
150
- throw new errors_1.InvalidValueError(coinlib_error_1.Domain.TEZOS, 'Could not fetch default entrypoint.');
151
- }
152
- let normalizedEntrypoint;
153
- defaultEntrypoint.type.createValue(value, {
154
- readAnnots: false,
155
- beforeNext: (meta, raw) => {
156
- const entrypointName = meta.getAnnotation(MichelsonTypeMeta_1.MichelsonAnnotationPrefix.FIELD);
157
- if (entrypointName && (0, micheline_1.isMichelineNode)(raw)) {
158
- normalizedEntrypoint = [entrypointName, raw];
159
- }
160
- },
161
- onNext: (_meta, _raw, michelsonValue) => {
162
- if (michelsonValue instanceof MichelsonOr_1.MichelsonOr) {
163
- michelsonValue.eval();
290
+ };
291
+ TezosContract.prototype.normalizeContractCallParameters = function (json, fallbackEntrypoint) {
292
+ var _a;
293
+ return __awaiter(this, void 0, void 0, function () {
294
+ var entrypoint, value, defaultEntrypoint, normalizedEntrypoint;
295
+ return __generator(this, function (_b) {
296
+ switch (_b.label) {
297
+ case 0:
298
+ entrypoint = 'entrypoint' in json ? json.entrypoint : undefined;
299
+ value = 'value' in json ? json.value : json;
300
+ if (entrypoint !== undefined && entrypoint !== DEFAULT_ENTRYPOINT) {
301
+ return [2 /*return*/, {
302
+ entrypoint: entrypoint,
303
+ value: value
304
+ }];
305
+ }
306
+ if (!MichelsonOr_1.MichelsonOr.isOr(value)) {
307
+ return [2 /*return*/, {
308
+ entrypoint: fallbackEntrypoint !== null && fallbackEntrypoint !== void 0 ? fallbackEntrypoint : DEFAULT_ENTRYPOINT,
309
+ value: value
310
+ }];
311
+ }
312
+ return [4 /*yield*/, this.waitForContractCode()];
313
+ case 1:
314
+ _b.sent();
315
+ defaultEntrypoint = (_a = this.entrypoints) === null || _a === void 0 ? void 0 : _a.get(DEFAULT_ENTRYPOINT);
316
+ if (!defaultEntrypoint) {
317
+ throw new errors_1.InvalidValueError(coinlib_error_1.Domain.TEZOS, 'Could not fetch default entrypoint.');
318
+ }
319
+ defaultEntrypoint.type.createValue(value, {
320
+ readAnnots: false,
321
+ beforeNext: function (meta, raw) {
322
+ var entrypointName = meta.getAnnotation(MichelsonTypeMeta_1.MichelsonAnnotationPrefix.FIELD);
323
+ if (entrypointName && (0, micheline_1.isMichelineNode)(raw)) {
324
+ normalizedEntrypoint = [entrypointName, raw];
325
+ }
326
+ },
327
+ onNext: function (_meta, _raw, michelsonValue) {
328
+ if (michelsonValue instanceof MichelsonOr_1.MichelsonOr) {
329
+ michelsonValue.eval();
330
+ }
331
+ }
332
+ });
333
+ return [2 /*return*/, {
334
+ entrypoint: normalizedEntrypoint ? normalizedEntrypoint[0] : fallbackEntrypoint !== null && fallbackEntrypoint !== void 0 ? fallbackEntrypoint : defaultEntrypoint.name,
335
+ value: normalizedEntrypoint ? normalizedEntrypoint[1] : value
336
+ }];
164
337
  }
165
- }
338
+ });
166
339
  });
167
- return {
168
- entrypoint: normalizedEntrypoint ? normalizedEntrypoint[0] : fallbackEntrypoint ?? defaultEntrypoint.name,
169
- value: normalizedEntrypoint ? normalizedEntrypoint[1] : value
170
- };
171
- }
172
- createDefaultContractCall(value, amount) {
340
+ };
341
+ TezosContract.prototype.createDefaultContractCall = function (value, amount) {
173
342
  return new TezosContractCall_1.TezosContractCall(DEFAULT_ENTRYPOINT, value instanceof MichelsonType_1.MichelsonType ? value : undefined, amount);
174
- }
175
- createEntrypointContractCall(entrypoint, value, configuration = {}, amount) {
343
+ };
344
+ TezosContract.prototype.createEntrypointContractCall = function (entrypoint, value, configuration, amount) {
345
+ if (configuration === void 0) { configuration = {}; }
176
346
  return new TezosContractCall_1.TezosContractCall(entrypoint.name, entrypoint.type.createValue(value, configuration), amount);
177
- }
178
- async getBigMap(path) {
179
- await this.waitForBigMaps();
180
- if (this.bigMaps?.length === 1) {
181
- return this.bigMaps[0];
182
- }
183
- if (!path) {
184
- throw new errors_1.InvalidValueError(coinlib_error_1.Domain.TEZOS, 'Contract has more than one BigMap, provide ID or predicates to select one.');
185
- }
186
- const response = this.bigMaps?.filter((bigMap) => bigMap.path === path) ?? [];
187
- if (response.length === 0) {
188
- throw new errors_1.InvalidValueError(coinlib_error_1.Domain.TEZOS, 'BigMap ID not found');
189
- }
190
- if (response.length > 1) {
191
- throw new errors_1.InvalidValueError(coinlib_error_1.Domain.TEZOS, 'More than one BigMap ID has been found for the predicates.');
192
- }
193
- return response[0];
194
- }
195
- async waitForBigMaps() {
196
- if (this.bigMaps !== undefined) {
197
- return;
198
- }
199
- if (this.bigMapsPromise === undefined) {
200
- this.bigMapsPromise = this.indexerClient
201
- .getContractBigMaps(this.address, 1000)
202
- .then((response) => {
203
- if (response.length === 0) {
204
- throw new errors_1.NotFoundError(coinlib_error_1.Domain.TEZOS, 'BigMap IDs not found');
347
+ };
348
+ TezosContract.prototype.getBigMap = function (path) {
349
+ var _a, _b, _c;
350
+ return __awaiter(this, void 0, void 0, function () {
351
+ var response;
352
+ return __generator(this, function (_d) {
353
+ switch (_d.label) {
354
+ case 0: return [4 /*yield*/, this.waitForBigMaps()];
355
+ case 1:
356
+ _d.sent();
357
+ if (((_a = this.bigMaps) === null || _a === void 0 ? void 0 : _a.length) === 1) {
358
+ return [2 /*return*/, this.bigMaps[0]];
359
+ }
360
+ if (!path) {
361
+ throw new errors_1.InvalidValueError(coinlib_error_1.Domain.TEZOS, 'Contract has more than one BigMap, provide ID or predicates to select one.');
362
+ }
363
+ response = (_c = (_b = this.bigMaps) === null || _b === void 0 ? void 0 : _b.filter(function (bigMap) { return bigMap.path === path; })) !== null && _c !== void 0 ? _c : [];
364
+ if (response.length === 0) {
365
+ throw new errors_1.InvalidValueError(coinlib_error_1.Domain.TEZOS, 'BigMap ID not found');
366
+ }
367
+ if (response.length > 1) {
368
+ throw new errors_1.InvalidValueError(coinlib_error_1.Domain.TEZOS, 'More than one BigMap ID has been found for the predicates.');
369
+ }
370
+ return [2 /*return*/, response[0]];
205
371
  }
206
- this.bigMaps = response;
207
- })
208
- .finally(() => {
209
- this.bigMapsPromise = undefined;
210
372
  });
211
- }
212
- return this.bigMapsPromise;
213
- }
214
- async waitForContractCode() {
215
- if (this.entrypoints !== undefined && this.storage !== undefined) {
216
- return;
217
- }
218
- if (this.codePromise === undefined) {
219
- const scriptPromise = this.contractRequest('/script/normalized', {
220
- unparsing_mode: 'Optimized_legacy'
373
+ });
374
+ };
375
+ TezosContract.prototype.waitForBigMaps = function () {
376
+ return __awaiter(this, void 0, void 0, function () {
377
+ var _this = this;
378
+ return __generator(this, function (_a) {
379
+ if (this.bigMaps !== undefined) {
380
+ return [2 /*return*/];
381
+ }
382
+ if (this.bigMapsPromise === undefined) {
383
+ this.bigMapsPromise = this.indexerClient
384
+ .getContractBigMaps(this.address, 1000)
385
+ .then(function (response) {
386
+ if (response.length === 0) {
387
+ throw new errors_1.NotFoundError(coinlib_error_1.Domain.TEZOS, 'BigMap IDs not found');
388
+ }
389
+ _this.bigMaps = response;
390
+ })
391
+ .finally(function () {
392
+ _this.bigMapsPromise = undefined;
393
+ });
394
+ }
395
+ return [2 /*return*/, this.bigMapsPromise];
221
396
  });
222
- const entrypointsPromise = this.contractRequest('/entrypoints');
223
- this.codePromise = Promise.all([scriptPromise, entrypointsPromise])
224
- .then(([scriptResponse, entrypointsResponse]) => {
225
- if (entrypointsResponse.entrypoints[DEFAULT_ENTRYPOINT] === undefined) {
226
- const parameter = scriptResponse.code.find((primitiveApplication) => primitiveApplication.prim === 'parameter');
227
- if (parameter) {
228
- const normalizedParameter = parameter ? this.normalizeContractCode(parameter) : undefined;
229
- entrypointsResponse.entrypoints[DEFAULT_ENTRYPOINT] = normalizedParameter?.args ? normalizedParameter.args[0] : [];
230
- }
397
+ });
398
+ };
399
+ TezosContract.prototype.waitForContractCode = function () {
400
+ return __awaiter(this, void 0, void 0, function () {
401
+ var scriptPromise, entrypointsPromise;
402
+ var _this = this;
403
+ return __generator(this, function (_a) {
404
+ if (this.entrypoints !== undefined && this.storage !== undefined) {
405
+ return [2 /*return*/];
231
406
  }
232
- this.entrypoints = new Map(TezosContractEntrypoint_1.TezosContractEntrypoint.fromJSON(entrypointsResponse.entrypoints).map((entrypoint) => [
233
- entrypoint.name,
234
- entrypoint
235
- ]));
236
- const storage = scriptResponse.code.find((primitiveApplication) => primitiveApplication.prim === 'storage');
237
- if (storage) {
238
- const normalizedStorage = this.normalizeContractCode(storage);
239
- this.storage = TezosContractStorage_1.TezosContractStorage.fromJSON(normalizedStorage.args[0]);
407
+ if (this.codePromise === undefined) {
408
+ scriptPromise = this.contractRequest('/script/normalized', {
409
+ unparsing_mode: 'Optimized_legacy'
410
+ });
411
+ entrypointsPromise = this.contractRequest('/entrypoints');
412
+ this.codePromise = Promise.all([scriptPromise, entrypointsPromise])
413
+ .then(function (_a) {
414
+ var scriptResponse = _a[0], entrypointsResponse = _a[1];
415
+ if (entrypointsResponse.entrypoints[DEFAULT_ENTRYPOINT] === undefined) {
416
+ var parameter = scriptResponse.code.find(function (primitiveApplication) { return primitiveApplication.prim === 'parameter'; });
417
+ if (parameter) {
418
+ var normalizedParameter = parameter ? _this.normalizeContractCode(parameter) : undefined;
419
+ entrypointsResponse.entrypoints[DEFAULT_ENTRYPOINT] = (normalizedParameter === null || normalizedParameter === void 0 ? void 0 : normalizedParameter.args) ? normalizedParameter.args[0] : [];
420
+ }
421
+ }
422
+ _this.entrypoints = new Map(TezosContractEntrypoint_1.TezosContractEntrypoint.fromJSON(entrypointsResponse.entrypoints).map(function (entrypoint) { return [
423
+ entrypoint.name,
424
+ entrypoint
425
+ ]; }));
426
+ var storage = scriptResponse.code.find(function (primitiveApplication) { return primitiveApplication.prim === 'storage'; });
427
+ if (storage) {
428
+ var normalizedStorage = _this.normalizeContractCode(storage);
429
+ _this.storage = TezosContractStorage_1.TezosContractStorage.fromJSON(normalizedStorage.args[0]);
430
+ }
431
+ })
432
+ .finally(function () {
433
+ _this.codePromise = undefined;
434
+ });
240
435
  }
241
- })
242
- .finally(() => {
243
- this.codePromise = undefined;
436
+ return [2 /*return*/, this.codePromise];
244
437
  });
245
- }
246
- return this.codePromise;
247
- }
248
- normalizeContractCode(code) {
438
+ });
439
+ };
440
+ TezosContract.prototype.normalizeContractCode = function (code) {
441
+ var _a;
249
442
  return {
250
443
  prim: code.prim,
251
- args: code.args?.map((arg) => MichelineNodeUtils_1.MichelineNodeUtils.normalize(arg))
444
+ args: (_a = code.args) === null || _a === void 0 ? void 0 : _a.map(function (arg) { return MichelineNodeUtils_1.MichelineNodeUtils.normalize(arg); })
252
445
  };
253
- }
254
- async getMetadataRemoteData(bigMapID, networkResolver) {
255
- const uriEncoded = await this.bigMapValue(bigMapID, '', { prim: 'string' }, { prim: 'bytes' });
256
- const uri = uriEncoded ? uriEncoded.value.toString() : undefined;
257
- return uri ? this.remoteDataFactory.create(uri.trim(), { contract: this, networkResolver }) : undefined;
258
- }
259
- async bigMapRequest(bigMapID, expr) {
260
- const url = expr
261
- ? `${this.network.rpcUrl}/chains/main/blocks/head/context/big_maps/${bigMapID}/${expr}`
262
- : `${this.network.rpcUrl}/chains/main/blocks/head/context/big_maps/${bigMapID}`;
263
- const response = await index_1.default.get(url);
264
- return response.data;
265
- }
266
- async contractRequest(endpoint, body) {
267
- const url = `${this.network.rpcUrl}/chains/main/blocks/head/context/contracts/${this.address}/${(0, string_1.trimStart)(endpoint, '/')}`;
268
- const response = body === undefined
269
- ? await index_1.default.get(url)
270
- : await index_1.default.post(url, body, {
271
- headers: {
272
- 'Content-Type': 'application/json'
446
+ };
447
+ TezosContract.prototype.getMetadataRemoteData = function (bigMapID, networkResolver) {
448
+ return __awaiter(this, void 0, void 0, function () {
449
+ var uriEncoded, uri;
450
+ return __generator(this, function (_a) {
451
+ switch (_a.label) {
452
+ case 0: return [4 /*yield*/, this.bigMapValue(bigMapID, '', { prim: 'string' }, { prim: 'bytes' })];
453
+ case 1:
454
+ uriEncoded = _a.sent();
455
+ uri = uriEncoded ? uriEncoded.value.toString() : undefined;
456
+ return [2 /*return*/, uri ? this.remoteDataFactory.create(uri.trim(), { contract: this, networkResolver: networkResolver }) : undefined];
273
457
  }
274
458
  });
275
- return response.data;
276
- }
277
- }
459
+ });
460
+ };
461
+ TezosContract.prototype.bigMapRequest = function (bigMapID, expr) {
462
+ return __awaiter(this, void 0, void 0, function () {
463
+ var url, response;
464
+ return __generator(this, function (_a) {
465
+ switch (_a.label) {
466
+ case 0:
467
+ url = expr
468
+ ? "".concat(this.network.rpcUrl, "/chains/main/blocks/head/context/big_maps/").concat(bigMapID, "/").concat(expr)
469
+ : "".concat(this.network.rpcUrl, "/chains/main/blocks/head/context/big_maps/").concat(bigMapID);
470
+ return [4 /*yield*/, index_1.default.get(url)];
471
+ case 1:
472
+ response = _a.sent();
473
+ return [2 /*return*/, response.data];
474
+ }
475
+ });
476
+ });
477
+ };
478
+ TezosContract.prototype.contractRequest = function (endpoint, body) {
479
+ return __awaiter(this, void 0, void 0, function () {
480
+ var url, response, _a;
481
+ return __generator(this, function (_b) {
482
+ switch (_b.label) {
483
+ case 0:
484
+ url = "".concat(this.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(this.address, "/").concat((0, string_1.trimStart)(endpoint, '/'));
485
+ if (!(body === undefined)) return [3 /*break*/, 2];
486
+ return [4 /*yield*/, index_1.default.get(url)];
487
+ case 1:
488
+ _a = _b.sent();
489
+ return [3 /*break*/, 4];
490
+ case 2: return [4 /*yield*/, index_1.default.post(url, body, {
491
+ headers: {
492
+ 'Content-Type': 'application/json'
493
+ }
494
+ })];
495
+ case 3:
496
+ _a = _b.sent();
497
+ _b.label = 4;
498
+ case 4:
499
+ response = _a;
500
+ return [2 /*return*/, response.data];
501
+ }
502
+ });
503
+ });
504
+ };
505
+ return TezosContract;
506
+ }());
278
507
  exports.TezosContract = TezosContract;
279
508
  //# sourceMappingURL=TezosContract.js.map