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