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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (421) hide show
  1. package/package.json +5 -5
  2. package/v0/actions/GetKtAccountsAction.js +11 -81
  3. package/v0/actions/GetKtAccountsAction.js.map +1 -1
  4. package/v0/constants.js +6 -6
  5. package/v0/constants.js.map +1 -1
  6. package/v0/index.js +38 -38
  7. package/v0/index.js.map +1 -1
  8. package/v0/protocol/TezosAddress.d.ts +0 -1
  9. package/v0/protocol/TezosAddress.js +41 -81
  10. package/v0/protocol/TezosAddress.js.map +1 -1
  11. package/v0/protocol/TezosCryptoClient.d.ts +0 -1
  12. package/v0/protocol/TezosCryptoClient.js +68 -123
  13. package/v0/protocol/TezosCryptoClient.js.map +1 -1
  14. package/v0/protocol/TezosProtocol.js +978 -1631
  15. package/v0/protocol/TezosProtocol.js.map +1 -1
  16. package/v0/protocol/TezosProtocolOptions.d.ts +1 -1
  17. package/v0/protocol/TezosProtocolOptions.js +26 -98
  18. package/v0/protocol/TezosProtocolOptions.js.map +1 -1
  19. package/v0/protocol/TezosUtils.d.ts +0 -1
  20. package/v0/protocol/TezosUtils.js +131 -165
  21. package/v0/protocol/TezosUtils.js.map +1 -1
  22. package/v0/protocol/contract/TezosContract.js +243 -472
  23. package/v0/protocol/contract/TezosContract.js.map +1 -1
  24. package/v0/protocol/contract/TezosContractCall.js +8 -10
  25. package/v0/protocol/contract/TezosContractCall.js.map +1 -1
  26. package/v0/protocol/contract/TezosContractEntrypoint.js +14 -19
  27. package/v0/protocol/contract/TezosContractEntrypoint.js.map +1 -1
  28. package/v0/protocol/contract/TezosContractStorage.js +8 -9
  29. package/v0/protocol/contract/TezosContractStorage.js.map +1 -1
  30. package/v0/protocol/contract/remote-data/TezosContractRemoteDataFactory.js +8 -25
  31. package/v0/protocol/contract/remote-data/TezosContractRemoteDataFactory.js.map +1 -1
  32. package/v0/protocol/contract/remote-data/TezosStorageRemoteData.js +39 -113
  33. package/v0/protocol/contract/remote-data/TezosStorageRemoteData.js.map +1 -1
  34. package/v0/protocol/domains/TezosDomains.js +165 -270
  35. package/v0/protocol/domains/TezosDomains.js.map +1 -1
  36. package/v0/protocol/fa/TezosBTC.js +19 -98
  37. package/v0/protocol/fa/TezosBTC.js.map +1 -1
  38. package/v0/protocol/fa/TezosBTCtez.js +17 -48
  39. package/v0/protocol/fa/TezosBTCtez.js.map +1 -1
  40. package/v0/protocol/fa/TezosCTez.js +17 -45
  41. package/v0/protocol/fa/TezosCTez.js.map +1 -1
  42. package/v0/protocol/fa/TezosDOGA.js +17 -45
  43. package/v0/protocol/fa/TezosDOGA.js.map +1 -1
  44. package/v0/protocol/fa/TezosETHtz.js +10 -68
  45. package/v0/protocol/fa/TezosETHtz.js.map +1 -1
  46. package/v0/protocol/fa/TezosFA1Protocol.js +119 -276
  47. package/v0/protocol/fa/TezosFA1Protocol.js.map +1 -1
  48. package/v0/protocol/fa/TezosFA1p2Protocol.js +22 -101
  49. package/v0/protocol/fa/TezosFA1p2Protocol.js.map +1 -1
  50. package/v0/protocol/fa/TezosFA2Protocol.js +213 -402
  51. package/v0/protocol/fa/TezosFA2Protocol.js.map +1 -1
  52. package/v0/protocol/fa/TezosFAProtocol.js +211 -418
  53. package/v0/protocol/fa/TezosFAProtocol.js.map +1 -1
  54. package/v0/protocol/fa/TezosFAProtocolOptions.d.ts +2 -2
  55. package/v0/protocol/fa/TezosFAProtocolOptions.js +92 -195
  56. package/v0/protocol/fa/TezosFAProtocolOptions.js.map +1 -1
  57. package/v0/protocol/fa/TezosKolibriUSD.js +11 -70
  58. package/v0/protocol/fa/TezosKolibriUSD.js.map +1 -1
  59. package/v0/protocol/fa/TezosPlanty.js +17 -45
  60. package/v0/protocol/fa/TezosPlanty.js.map +1 -1
  61. package/v0/protocol/fa/TezosQUIPU.js +17 -48
  62. package/v0/protocol/fa/TezosQUIPU.js.map +1 -1
  63. package/v0/protocol/fa/TezosSIRS.js +17 -45
  64. package/v0/protocol/fa/TezosSIRS.js.map +1 -1
  65. package/v0/protocol/fa/TezosStaker.js +11 -70
  66. package/v0/protocol/fa/TezosStaker.js.map +1 -1
  67. package/v0/protocol/fa/TezosUBTC.js +17 -48
  68. package/v0/protocol/fa/TezosUBTC.js.map +1 -1
  69. package/v0/protocol/fa/TezosUDEFI.js +17 -48
  70. package/v0/protocol/fa/TezosUDEFI.js.map +1 -1
  71. package/v0/protocol/fa/TezosUSD.js +11 -70
  72. package/v0/protocol/fa/TezosUSD.js.map +1 -1
  73. package/v0/protocol/fa/TezosUSDT.js +17 -48
  74. package/v0/protocol/fa/TezosUSDT.js.map +1 -1
  75. package/v0/protocol/fa/TezosUUSD.js +8 -27
  76. package/v0/protocol/fa/TezosUUSD.js.map +1 -1
  77. package/v0/protocol/fa/TezosUXTZ.js +17 -48
  78. package/v0/protocol/fa/TezosUXTZ.js.map +1 -1
  79. package/v0/protocol/fa/TezosWRAP.js +17 -48
  80. package/v0/protocol/fa/TezosWRAP.js.map +1 -1
  81. package/v0/protocol/fa/TezosWrapped.js +11 -70
  82. package/v0/protocol/fa/TezosWrapped.js.map +1 -1
  83. package/v0/protocol/fa/TezosYOU.js +8 -27
  84. package/v0/protocol/fa/TezosYOU.js.map +1 -1
  85. package/v0/protocol/fa/metadata/BigMapTokenMetadataIndexer.js +84 -162
  86. package/v0/protocol/fa/metadata/BigMapTokenMetadataIndexer.js.map +1 -1
  87. package/v0/protocol/fa/metadata/ObjktTokenMetadataIndexer.js +37 -87
  88. package/v0/protocol/fa/metadata/ObjktTokenMetadataIndexer.js.map +1 -1
  89. package/v0/protocol/indexerClient/TezosIndexerClient.js +115 -259
  90. package/v0/protocol/indexerClient/TezosIndexerClient.js.map +1 -1
  91. package/v0/protocol/kt/TezosKtAddress.js +7 -67
  92. package/v0/protocol/kt/TezosKtAddress.js.map +1 -1
  93. package/v0/protocol/kt/TezosKtProtocol.js +161 -309
  94. package/v0/protocol/kt/TezosKtProtocol.js.map +1 -1
  95. package/v0/protocol/sapling/TezosSaplingAddress.d.ts +0 -1
  96. package/v0/protocol/sapling/TezosSaplingAddress.js +46 -117
  97. package/v0/protocol/sapling/TezosSaplingAddress.js.map +1 -1
  98. package/v0/protocol/sapling/TezosSaplingCryptoClient.d.ts +0 -1
  99. package/v0/protocol/sapling/TezosSaplingCryptoClient.js +125 -220
  100. package/v0/protocol/sapling/TezosSaplingCryptoClient.js.map +1 -1
  101. package/v0/protocol/sapling/TezosSaplingProtocol.d.ts +0 -1
  102. package/v0/protocol/sapling/TezosSaplingProtocol.js +600 -1127
  103. package/v0/protocol/sapling/TezosSaplingProtocol.js.map +1 -1
  104. package/v0/protocol/sapling/TezosSaplingProtocolOptions.d.ts +0 -1
  105. package/v0/protocol/sapling/TezosSaplingProtocolOptions.js +32 -61
  106. package/v0/protocol/sapling/TezosSaplingProtocolOptions.js.map +1 -1
  107. package/v0/protocol/sapling/TezosShieldedTezProtocol.js +50 -134
  108. package/v0/protocol/sapling/TezosShieldedTezProtocol.js.map +1 -1
  109. package/v0/protocol/sapling/injector/TezosSaplingInjectorClient.js +10 -56
  110. package/v0/protocol/sapling/injector/TezosSaplingInjectorClient.js.map +1 -1
  111. package/v0/protocol/sapling/node/TezosSaplingNodeClient.js +12 -67
  112. package/v0/protocol/sapling/node/TezosSaplingNodeClient.js.map +1 -1
  113. package/v0/protocol/sapling/utils/TezosSaplingBookkeeper.d.ts +0 -1
  114. package/v0/protocol/sapling/utils/TezosSaplingBookkeeper.js +221 -539
  115. package/v0/protocol/sapling/utils/TezosSaplingBookkeeper.js.map +1 -1
  116. package/v0/protocol/sapling/utils/TezosSaplingEncoder.d.ts +0 -1
  117. package/v0/protocol/sapling/utils/TezosSaplingEncoder.js +101 -104
  118. package/v0/protocol/sapling/utils/TezosSaplingEncoder.js.map +1 -1
  119. package/v0/protocol/sapling/utils/TezosSaplingForger.d.ts +0 -1
  120. package/v0/protocol/sapling/utils/TezosSaplingForger.js +107 -266
  121. package/v0/protocol/sapling/utils/TezosSaplingForger.js.map +1 -1
  122. package/v0/protocol/sapling/utils/TezosSaplingState.js +110 -239
  123. package/v0/protocol/sapling/utils/TezosSaplingState.js.map +1 -1
  124. package/v0/protocol/types/TezosOperationType.js +1 -1
  125. package/v0/protocol/types/TezosOperationType.js.map +1 -1
  126. package/v0/protocol/types/contract/BigMapEntry.d.ts +1 -1
  127. package/v0/protocol/types/contract/TezosContractMetadata.d.ts +2 -2
  128. package/v0/protocol/types/micheline/MichelineNode.d.ts +7 -7
  129. package/v0/protocol/types/micheline/MichelineNodeUtils.js +9 -13
  130. package/v0/protocol/types/micheline/MichelineNodeUtils.js.map +1 -1
  131. package/v0/protocol/types/michelson/MichelsonType.d.ts +0 -1
  132. package/v0/protocol/types/michelson/MichelsonType.js +11 -12
  133. package/v0/protocol/types/michelson/MichelsonType.js.map +1 -1
  134. package/v0/protocol/types/michelson/MichelsonTypeMeta.js +45 -92
  135. package/v0/protocol/types/michelson/MichelsonTypeMeta.js.map +1 -1
  136. package/v0/protocol/types/michelson/MichelsonTypeUtils.d.ts +0 -1
  137. package/v0/protocol/types/michelson/MichelsonTypeUtils.js +58 -219
  138. package/v0/protocol/types/michelson/MichelsonTypeUtils.js.map +1 -1
  139. package/v0/protocol/types/michelson/generics/MichelsonList.js +24 -43
  140. package/v0/protocol/types/michelson/generics/MichelsonList.js.map +1 -1
  141. package/v0/protocol/types/michelson/generics/MichelsonMap.js +39 -61
  142. package/v0/protocol/types/michelson/generics/MichelsonMap.js.map +1 -1
  143. package/v0/protocol/types/michelson/generics/MichelsonOption.d.ts +1 -1
  144. package/v0/protocol/types/michelson/generics/MichelsonOption.js +46 -75
  145. package/v0/protocol/types/michelson/generics/MichelsonOption.js.map +1 -1
  146. package/v0/protocol/types/michelson/generics/MichelsonOr.d.ts +1 -1
  147. package/v0/protocol/types/michelson/generics/MichelsonOr.js +50 -76
  148. package/v0/protocol/types/michelson/generics/MichelsonOr.js.map +1 -1
  149. package/v0/protocol/types/michelson/generics/MichelsonPair.js +52 -85
  150. package/v0/protocol/types/michelson/generics/MichelsonPair.js.map +1 -1
  151. package/v0/protocol/types/michelson/grammar/MichelsonGrammarData.d.ts +1 -1
  152. package/v0/protocol/types/michelson/grammar/MichelsonGrammarInstruction.d.ts +1 -1
  153. package/v0/protocol/types/michelson/grammar/MichelsonGrammarType.d.ts +1 -1
  154. package/v0/protocol/types/michelson/primitives/MichelsonAddress.d.ts +0 -1
  155. package/v0/protocol/types/michelson/primitives/MichelsonAddress.js +28 -47
  156. package/v0/protocol/types/michelson/primitives/MichelsonAddress.js.map +1 -1
  157. package/v0/protocol/types/michelson/primitives/MichelsonBool.js +20 -39
  158. package/v0/protocol/types/michelson/primitives/MichelsonBool.js.map +1 -1
  159. package/v0/protocol/types/michelson/primitives/MichelsonBytes.d.ts +0 -1
  160. package/v0/protocol/types/michelson/primitives/MichelsonBytes.js +35 -54
  161. package/v0/protocol/types/michelson/primitives/MichelsonBytes.js.map +1 -1
  162. package/v0/protocol/types/michelson/primitives/MichelsonInt.d.ts +0 -1
  163. package/v0/protocol/types/michelson/primitives/MichelsonInt.js +30 -49
  164. package/v0/protocol/types/michelson/primitives/MichelsonInt.js.map +1 -1
  165. package/v0/protocol/types/michelson/primitives/MichelsonString.d.ts +0 -1
  166. package/v0/protocol/types/michelson/primitives/MichelsonString.js +33 -52
  167. package/v0/protocol/types/michelson/primitives/MichelsonString.js.map +1 -1
  168. package/v0/protocol/types/michelson/primitives/MichelsonUnit.js +14 -34
  169. package/v0/protocol/types/michelson/primitives/MichelsonUnit.js.map +1 -1
  170. package/v0/protocol/types/sapling/TezosSaplingStateTree.d.ts +1 -1
  171. package/v0/protocol/types/sapling/TezosSaplingTransaction.d.ts +0 -1
  172. package/v0/protocol/types/utils.js +8 -10
  173. package/v0/protocol/types/utils.js.map +1 -1
  174. package/v0/serializer/validators/transaction-validator.js +29 -78
  175. package/v0/serializer/validators/transaction-validator.js.map +1 -1
  176. package/v0/serializer/validators/transaction-xtz-btc-validator.js +55 -129
  177. package/v0/serializer/validators/transaction-xtz-btc-validator.js.map +1 -1
  178. package/v0/serializer/validators/validators.js +43 -103
  179. package/v0/serializer/validators/validators.js.map +1 -1
  180. package/v1/block-explorer/TzKTBlockExplorer.js +12 -61
  181. package/v1/block-explorer/TzKTBlockExplorer.js.map +1 -1
  182. package/v1/block-explorer/factory.js +4 -5
  183. package/v1/block-explorer/factory.js.map +1 -1
  184. package/v1/contract/TezosContract.js +242 -471
  185. package/v1/contract/TezosContract.js.map +1 -1
  186. package/v1/contract/TezosContractCall.js +8 -10
  187. package/v1/contract/TezosContractCall.js.map +1 -1
  188. package/v1/contract/TezosContractEntrypoint.d.ts +1 -1
  189. package/v1/contract/TezosContractEntrypoint.js +14 -19
  190. package/v1/contract/TezosContractEntrypoint.js.map +1 -1
  191. package/v1/contract/TezosContractStorage.js +8 -9
  192. package/v1/contract/TezosContractStorage.js.map +1 -1
  193. package/v1/contract/remote-data/TezosContractRemoteDataFactory.js +8 -25
  194. package/v1/contract/remote-data/TezosContractRemoteDataFactory.js.map +1 -1
  195. package/v1/contract/remote-data/TezosStorageRemoteData.js +39 -113
  196. package/v1/contract/remote-data/TezosStorageRemoteData.js.map +1 -1
  197. package/v1/crypto/TezosCryptoClient.d.ts +0 -1
  198. package/v1/crypto/TezosCryptoClient.js +64 -117
  199. package/v1/crypto/TezosCryptoClient.js.map +1 -1
  200. package/v1/crypto/TezosSaplingCryptoClient.d.ts +0 -1
  201. package/v1/crypto/TezosSaplingCryptoClient.js +116 -194
  202. package/v1/crypto/TezosSaplingCryptoClient.js.map +1 -1
  203. package/v1/data/TezosAddress.js +13 -14
  204. package/v1/data/TezosAddress.js.map +1 -1
  205. package/v1/data/TezosSaplingAddress.d.ts +0 -1
  206. package/v1/data/TezosSaplingAddress.js +29 -94
  207. package/v1/data/TezosSaplingAddress.js.map +1 -1
  208. package/v1/domains/TezosDomains.js +165 -270
  209. package/v1/domains/TezosDomains.js.map +1 -1
  210. package/v1/index.js +39 -39
  211. package/v1/index.js.map +1 -1
  212. package/v1/indexer/TzKTIndexerClient.js +126 -270
  213. package/v1/indexer/TzKTIndexerClient.js.map +1 -1
  214. package/v1/indexer/factory.js +4 -5
  215. package/v1/indexer/factory.js.map +1 -1
  216. package/v1/indexer/token-metadata/BigMapTokenMetadataIndexerClient.js +83 -161
  217. package/v1/indexer/token-metadata/BigMapTokenMetadataIndexerClient.js.map +1 -1
  218. package/v1/indexer/token-metadata/ObjktTokenMetadataIndexerClient.js +36 -85
  219. package/v1/indexer/token-metadata/ObjktTokenMetadataIndexerClient.js.map +1 -1
  220. package/v1/injector/TezosSaplingInjectorClient.js +10 -56
  221. package/v1/injector/TezosSaplingInjectorClient.js.map +1 -1
  222. package/v1/module/TezosModule.js +88 -155
  223. package/v1/module/TezosModule.js.map +1 -1
  224. package/v1/module.js +2 -3
  225. package/v1/module.js.map +1 -1
  226. package/v1/node/TezosSaplingNodeClient.js +12 -67
  227. package/v1/node/TezosSaplingNodeClient.js.map +1 -1
  228. package/v1/protocol/TezosProtocol.js +848 -1385
  229. package/v1/protocol/TezosProtocol.js.map +1 -1
  230. package/v1/protocol/fa/TezosFA1Protocol.js +81 -205
  231. package/v1/protocol/fa/TezosFA1Protocol.js.map +1 -1
  232. package/v1/protocol/fa/TezosFA1p2Protocol.js +32 -111
  233. package/v1/protocol/fa/TezosFA1p2Protocol.js.map +1 -1
  234. package/v1/protocol/fa/TezosFA2Protocol.js +174 -332
  235. package/v1/protocol/fa/TezosFA2Protocol.js.map +1 -1
  236. package/v1/protocol/fa/TezosFAProtocol.js +255 -528
  237. package/v1/protocol/fa/TezosFAProtocol.js.map +1 -1
  238. package/v1/protocol/fa/tokens/BTCTezProtocol.d.ts +2 -2
  239. package/v1/protocol/fa/tokens/BTCTezProtocol.js +30 -47
  240. package/v1/protocol/fa/tokens/BTCTezProtocol.js.map +1 -1
  241. package/v1/protocol/fa/tokens/CTezProtocol.d.ts +2 -2
  242. package/v1/protocol/fa/tokens/CTezProtocol.js +27 -47
  243. package/v1/protocol/fa/tokens/CTezProtocol.js.map +1 -1
  244. package/v1/protocol/fa/tokens/DogamiProtocol.d.ts +2 -2
  245. package/v1/protocol/fa/tokens/DogamiProtocol.js +27 -47
  246. package/v1/protocol/fa/tokens/DogamiProtocol.js.map +1 -1
  247. package/v1/protocol/fa/tokens/ETHTezProtocol.d.ts +2 -2
  248. package/v1/protocol/fa/tokens/ETHTezProtocol.js +30 -90
  249. package/v1/protocol/fa/tokens/ETHTezProtocol.js.map +1 -1
  250. package/v1/protocol/fa/tokens/KolibriUSDProtocol.d.ts +2 -2
  251. package/v1/protocol/fa/tokens/KolibriUSDProtocol.js +30 -90
  252. package/v1/protocol/fa/tokens/KolibriUSDProtocol.js.map +1 -1
  253. package/v1/protocol/fa/tokens/PlentyProtocol.d.ts +2 -2
  254. package/v1/protocol/fa/tokens/PlentyProtocol.js +30 -90
  255. package/v1/protocol/fa/tokens/PlentyProtocol.js.map +1 -1
  256. package/v1/protocol/fa/tokens/QuipuswapProtocol.d.ts +2 -2
  257. package/v1/protocol/fa/tokens/QuipuswapProtocol.js +30 -47
  258. package/v1/protocol/fa/tokens/QuipuswapProtocol.js.map +1 -1
  259. package/v1/protocol/fa/tokens/SiriusProtocol.d.ts +2 -2
  260. package/v1/protocol/fa/tokens/SiriusProtocol.js +27 -47
  261. package/v1/protocol/fa/tokens/SiriusProtocol.js.map +1 -1
  262. package/v1/protocol/fa/tokens/StakerProtocol.d.ts +2 -2
  263. package/v1/protocol/fa/tokens/StakerProtocol.js +30 -90
  264. package/v1/protocol/fa/tokens/StakerProtocol.js.map +1 -1
  265. package/v1/protocol/fa/tokens/TetherUSDProtocol.d.ts +2 -2
  266. package/v1/protocol/fa/tokens/TetherUSDProtocol.js +30 -47
  267. package/v1/protocol/fa/tokens/TetherUSDProtocol.js.map +1 -1
  268. package/v1/protocol/fa/tokens/TzBTCProtocol.d.ts +2 -2
  269. package/v1/protocol/fa/tokens/TzBTCProtocol.js +27 -47
  270. package/v1/protocol/fa/tokens/TzBTCProtocol.js.map +1 -1
  271. package/v1/protocol/fa/tokens/UBTCProtocol.d.ts +2 -2
  272. package/v1/protocol/fa/tokens/UBTCProtocol.js +30 -47
  273. package/v1/protocol/fa/tokens/UBTCProtocol.js.map +1 -1
  274. package/v1/protocol/fa/tokens/UDEFIProtocol.d.ts +2 -2
  275. package/v1/protocol/fa/tokens/UDEFIProtocol.js +30 -47
  276. package/v1/protocol/fa/tokens/UDEFIProtocol.js.map +1 -1
  277. package/v1/protocol/fa/tokens/USDTezProtocol.d.ts +2 -2
  278. package/v1/protocol/fa/tokens/USDTezProtocol.js +27 -47
  279. package/v1/protocol/fa/tokens/USDTezProtocol.js.map +1 -1
  280. package/v1/protocol/fa/tokens/UUSDProtocol.d.ts +2 -2
  281. package/v1/protocol/fa/tokens/UUSDProtocol.js +30 -47
  282. package/v1/protocol/fa/tokens/UUSDProtocol.js.map +1 -1
  283. package/v1/protocol/fa/tokens/UXTZProtocol.d.ts +2 -2
  284. package/v1/protocol/fa/tokens/UXTZProtocol.js +30 -47
  285. package/v1/protocol/fa/tokens/UXTZProtocol.js.map +1 -1
  286. package/v1/protocol/fa/tokens/WrapProtocol.d.ts +2 -2
  287. package/v1/protocol/fa/tokens/WrapProtocol.js +30 -47
  288. package/v1/protocol/fa/tokens/WrapProtocol.js.map +1 -1
  289. package/v1/protocol/fa/tokens/WrappedTezosProtocol.d.ts +2 -2
  290. package/v1/protocol/fa/tokens/WrappedTezosProtocol.js +27 -47
  291. package/v1/protocol/fa/tokens/WrappedTezosProtocol.js.map +1 -1
  292. package/v1/protocol/fa/tokens/YouProtocol.d.ts +2 -2
  293. package/v1/protocol/fa/tokens/YouProtocol.js +30 -47
  294. package/v1/protocol/fa/tokens/YouProtocol.js.map +1 -1
  295. package/v1/protocol/fa/tokens/stXTZProtocol.d.ts +2 -2
  296. package/v1/protocol/fa/tokens/stXTZProtocol.js +30 -47
  297. package/v1/protocol/fa/tokens/stXTZProtocol.js.map +1 -1
  298. package/v1/protocol/kt/TezosKtProtocol.js +254 -498
  299. package/v1/protocol/kt/TezosKtProtocol.js.map +1 -1
  300. package/v1/protocol/sapling/TezosSaplingProtocol.d.ts +0 -1
  301. package/v1/protocol/sapling/TezosSaplingProtocol.js +532 -933
  302. package/v1/protocol/sapling/TezosSaplingProtocol.js.map +1 -1
  303. package/v1/protocol/sapling/TezosShieldedTezProtocol.js +72 -164
  304. package/v1/protocol/sapling/TezosShieldedTezProtocol.js.map +1 -1
  305. package/v1/serializer/v3/schemas/converter/transaction-converter.js +14 -26
  306. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
  307. package/v1/serializer/v3/serializer-companion.js +103 -188
  308. package/v1/serializer/v3/serializer-companion.js.map +1 -1
  309. package/v1/serializer/v3/validators/transaction-validator.js +54 -143
  310. package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
  311. package/v1/serializer/v3/validators/validators.js +40 -100
  312. package/v1/serializer/v3/validators/validators.js.map +1 -1
  313. package/v1/types/block-explorer.d.ts +1 -1
  314. package/v1/types/contract/TezosContractMetadata.d.ts +2 -2
  315. package/v1/types/contract/bigmap/BigMapEntry.d.ts +1 -1
  316. package/v1/types/crypto.d.ts +2 -2
  317. package/v1/types/fa/TezosFA1ContractEntrypoint.d.ts +1 -1
  318. package/v1/types/fa/TezosFA1p2ContractEntrypoint.d.ts +1 -1
  319. package/v1/types/fa/TezosFA2ContractEntrypoint.d.ts +1 -1
  320. package/v1/types/indexer.d.ts +1 -1
  321. package/v1/types/micheline/MichelineNode.d.ts +7 -7
  322. package/v1/types/micheline/MichelineNodeUtils.js +9 -13
  323. package/v1/types/micheline/MichelineNodeUtils.js.map +1 -1
  324. package/v1/types/michelson/MichelsonType.d.ts +0 -1
  325. package/v1/types/michelson/MichelsonType.js +11 -12
  326. package/v1/types/michelson/MichelsonType.js.map +1 -1
  327. package/v1/types/michelson/MichelsonTypeMeta.js +45 -92
  328. package/v1/types/michelson/MichelsonTypeMeta.js.map +1 -1
  329. package/v1/types/michelson/MichelsonTypeUtils.d.ts +0 -1
  330. package/v1/types/michelson/MichelsonTypeUtils.js +58 -219
  331. package/v1/types/michelson/MichelsonTypeUtils.js.map +1 -1
  332. package/v1/types/michelson/generics/MichelsonList.js +24 -43
  333. package/v1/types/michelson/generics/MichelsonList.js.map +1 -1
  334. package/v1/types/michelson/generics/MichelsonMap.js +39 -61
  335. package/v1/types/michelson/generics/MichelsonMap.js.map +1 -1
  336. package/v1/types/michelson/generics/MichelsonOption.d.ts +1 -1
  337. package/v1/types/michelson/generics/MichelsonOption.js +46 -75
  338. package/v1/types/michelson/generics/MichelsonOption.js.map +1 -1
  339. package/v1/types/michelson/generics/MichelsonOr.d.ts +1 -1
  340. package/v1/types/michelson/generics/MichelsonOr.js +50 -76
  341. package/v1/types/michelson/generics/MichelsonOr.js.map +1 -1
  342. package/v1/types/michelson/generics/MichelsonPair.js +52 -85
  343. package/v1/types/michelson/generics/MichelsonPair.js.map +1 -1
  344. package/v1/types/michelson/grammar/MichelsonGrammarData.d.ts +1 -1
  345. package/v1/types/michelson/grammar/MichelsonGrammarInstruction.d.ts +1 -1
  346. package/v1/types/michelson/grammar/MichelsonGrammarType.d.ts +1 -1
  347. package/v1/types/michelson/primitives/MichelsonAddress.d.ts +0 -1
  348. package/v1/types/michelson/primitives/MichelsonAddress.js +28 -47
  349. package/v1/types/michelson/primitives/MichelsonAddress.js.map +1 -1
  350. package/v1/types/michelson/primitives/MichelsonBool.js +20 -39
  351. package/v1/types/michelson/primitives/MichelsonBool.js.map +1 -1
  352. package/v1/types/michelson/primitives/MichelsonBytes.d.ts +0 -1
  353. package/v1/types/michelson/primitives/MichelsonBytes.js +35 -54
  354. package/v1/types/michelson/primitives/MichelsonBytes.js.map +1 -1
  355. package/v1/types/michelson/primitives/MichelsonInt.d.ts +0 -1
  356. package/v1/types/michelson/primitives/MichelsonInt.js +30 -49
  357. package/v1/types/michelson/primitives/MichelsonInt.js.map +1 -1
  358. package/v1/types/michelson/primitives/MichelsonString.d.ts +0 -1
  359. package/v1/types/michelson/primitives/MichelsonString.js +33 -52
  360. package/v1/types/michelson/primitives/MichelsonString.js.map +1 -1
  361. package/v1/types/michelson/primitives/MichelsonUnit.js +14 -34
  362. package/v1/types/michelson/primitives/MichelsonUnit.js.map +1 -1
  363. package/v1/types/network.js +1 -1
  364. package/v1/types/network.js.map +1 -1
  365. package/v1/types/operations/TezosOperationType.js +1 -1
  366. package/v1/types/operations/TezosOperationType.js.map +1 -1
  367. package/v1/types/protocol.d.ts +3 -3
  368. package/v1/types/sapling/TezosSaplingExternalMethodProvider.d.ts +0 -1
  369. package/v1/types/sapling/TezosSaplingStateTree.d.ts +1 -1
  370. package/v1/types/sapling/TezosSaplingTransaction.d.ts +0 -1
  371. package/v1/types/staking/TezosDelegatorAction.js +1 -1
  372. package/v1/types/staking/TezosDelegatorAction.js.map +1 -1
  373. package/v1/utils/address.js +6 -7
  374. package/v1/utils/address.js.map +1 -1
  375. package/v1/utils/bip.d.ts +0 -1
  376. package/v1/utils/bip.js +6 -7
  377. package/v1/utils/bip.js.map +1 -1
  378. package/v1/utils/convert.js +7 -8
  379. package/v1/utils/convert.js.map +1 -1
  380. package/v1/utils/encoding.d.ts +0 -1
  381. package/v1/utils/encoding.js +74 -64
  382. package/v1/utils/encoding.js.map +1 -1
  383. package/v1/utils/fa.js +2 -3
  384. package/v1/utils/fa.js.map +1 -1
  385. package/v1/utils/key.js +9 -12
  386. package/v1/utils/key.js.map +1 -1
  387. package/v1/utils/micheline.js +8 -10
  388. package/v1/utils/micheline.js.map +1 -1
  389. package/v1/utils/operations.js +21 -22
  390. package/v1/utils/operations.js.map +1 -1
  391. package/v1/utils/pack.d.ts +0 -1
  392. package/v1/utils/pack.js +65 -107
  393. package/v1/utils/pack.js.map +1 -1
  394. package/v1/utils/protocol/fa/TezosFA1Accountant.js +24 -52
  395. package/v1/utils/protocol/fa/TezosFA1Accountant.js.map +1 -1
  396. package/v1/utils/protocol/fa/TezosFA2Accountant.js +40 -77
  397. package/v1/utils/protocol/fa/TezosFA2Accountant.js.map +1 -1
  398. package/v1/utils/protocol/fa/TezosFAAccountant.js +21 -89
  399. package/v1/utils/protocol/fa/TezosFAAccountant.js.map +1 -1
  400. package/v1/utils/protocol/instance.js +90 -26
  401. package/v1/utils/protocol/instance.js.map +1 -1
  402. package/v1/utils/protocol/sapling/TezosSaplingAccountant.d.ts +0 -1
  403. package/v1/utils/protocol/sapling/TezosSaplingAccountant.js +221 -539
  404. package/v1/utils/protocol/sapling/TezosSaplingAccountant.js.map +1 -1
  405. package/v1/utils/protocol/sapling/TezosSaplingEncoder.d.ts +0 -1
  406. package/v1/utils/protocol/sapling/TezosSaplingEncoder.js +101 -104
  407. package/v1/utils/protocol/sapling/TezosSaplingEncoder.js.map +1 -1
  408. package/v1/utils/protocol/sapling/TezosSaplingForger.d.ts +0 -1
  409. package/v1/utils/protocol/sapling/TezosSaplingForger.js +107 -266
  410. package/v1/utils/protocol/sapling/TezosSaplingForger.js.map +1 -1
  411. package/v1/utils/protocol/sapling/TezosSaplingState.js +110 -239
  412. package/v1/utils/protocol/sapling/TezosSaplingState.js.map +1 -1
  413. package/v1/utils/protocol/tezos/TezosAccountant.js +97 -166
  414. package/v1/utils/protocol/tezos/TezosAccountant.js.map +1 -1
  415. package/v1/utils/protocol/tezos/TezosForger.js +21 -76
  416. package/v1/utils/protocol/tezos/TezosForger.js.map +1 -1
  417. package/v1/utils/signature.js +5 -6
  418. package/v1/utils/signature.js.map +1 -1
  419. package/v1/utils/transaction.d.ts +4 -5
  420. package/v1/utils/transaction.js +3 -3
  421. package/v1/utils/transaction.js.map +1 -1
@@ -1,508 +1,279 @@
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
- };
38
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
39
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
40
4
  };
41
5
  Object.defineProperty(exports, "__esModule", { value: true });
42
6
  exports.TezosContract = void 0;
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) {
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) {
62
26
  this.address = address;
63
27
  this.network = network;
64
28
  this.remoteDataFactory = new TezosContractRemoteDataFactory_1.TezosContractRemoteDataFactory();
65
29
  this.indexerClient = (0, factory_1.createTezosIndexerClient)(this.network.indexerType, this.network.indexerApi);
66
30
  }
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) {
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) {
277
118
  try {
278
- var parameters = typeof data === 'string' ? JSON.parse(data) : data;
119
+ const parameters = typeof data === 'string' ? JSON.parse(data) : data;
279
120
  return parameters instanceof Object && 'entrypoint' in parameters && 'value' in parameters;
280
121
  }
281
- catch (_a) {
122
+ catch {
282
123
  return false;
283
124
  }
284
- };
285
- TezosContract.prototype.parseParameters = function (parameters) {
125
+ }
126
+ parseParameters(parameters) {
286
127
  if (!this.areValidParameters(parameters)) {
287
128
  throw new Error('Invalid parameters');
288
129
  }
289
130
  return JSON.parse(parameters);
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
- }];
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];
337
159
  }
338
- });
160
+ },
161
+ onNext: (_meta, _raw, michelsonValue) => {
162
+ if (michelsonValue instanceof MichelsonOr_1.MichelsonOr) {
163
+ michelsonValue.eval();
164
+ }
165
+ }
339
166
  });
340
- };
341
- TezosContract.prototype.createDefaultContractCall = function (value, amount) {
167
+ return {
168
+ entrypoint: normalizedEntrypoint ? normalizedEntrypoint[0] : fallbackEntrypoint ?? defaultEntrypoint.name,
169
+ value: normalizedEntrypoint ? normalizedEntrypoint[1] : value
170
+ };
171
+ }
172
+ createDefaultContractCall(value, amount) {
342
173
  return new TezosContractCall_1.TezosContractCall(DEFAULT_ENTRYPOINT, value instanceof MichelsonType_1.MichelsonType ? value : undefined, amount);
343
- };
344
- TezosContract.prototype.createEntrypointContractCall = function (entrypoint, value, configuration, amount) {
345
- if (configuration === void 0) { configuration = {}; }
174
+ }
175
+ createEntrypointContractCall(entrypoint, value, configuration = {}, amount) {
346
176
  return new TezosContractCall_1.TezosContractCall(entrypoint.name, entrypoint.type.createValue(value, configuration), amount);
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]];
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');
371
205
  }
206
+ this.bigMaps = response;
207
+ })
208
+ .finally(() => {
209
+ this.bigMapsPromise = undefined;
372
210
  });
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];
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'
396
221
  });
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*/];
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
+ }
406
231
  }
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
- });
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]);
435
240
  }
436
- return [2 /*return*/, this.codePromise];
241
+ })
242
+ .finally(() => {
243
+ this.codePromise = undefined;
437
244
  });
438
- });
439
- };
440
- TezosContract.prototype.normalizeContractCode = function (code) {
441
- var _a;
245
+ }
246
+ return this.codePromise;
247
+ }
248
+ normalizeContractCode(code) {
442
249
  return {
443
250
  prim: code.prim,
444
- args: (_a = code.args) === null || _a === void 0 ? void 0 : _a.map(function (arg) { return MichelineNodeUtils_1.MichelineNodeUtils.normalize(arg); })
251
+ args: code.args?.map((arg) => MichelineNodeUtils_1.MichelineNodeUtils.normalize(arg))
445
252
  };
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];
457
- }
458
- });
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];
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'
501
273
  }
502
274
  });
503
- });
504
- };
505
- return TezosContract;
506
- }());
275
+ return response.data;
276
+ }
277
+ }
507
278
  exports.TezosContract = TezosContract;
508
279
  //# sourceMappingURL=TezosContract.js.map