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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (421) hide show
  1. package/package.json +5 -5
  2. package/v0/actions/GetKtAccountsAction.js +81 -11
  3. package/v0/actions/GetKtAccountsAction.js.map +1 -1
  4. package/v0/constants.js +6 -6
  5. package/v0/constants.js.map +1 -1
  6. package/v0/index.js +38 -38
  7. package/v0/index.js.map +1 -1
  8. package/v0/protocol/TezosAddress.d.ts +1 -0
  9. package/v0/protocol/TezosAddress.js +81 -41
  10. package/v0/protocol/TezosAddress.js.map +1 -1
  11. package/v0/protocol/TezosCryptoClient.d.ts +1 -0
  12. package/v0/protocol/TezosCryptoClient.js +123 -68
  13. package/v0/protocol/TezosCryptoClient.js.map +1 -1
  14. package/v0/protocol/TezosProtocol.js +1631 -978
  15. package/v0/protocol/TezosProtocol.js.map +1 -1
  16. package/v0/protocol/TezosProtocolOptions.d.ts +1 -1
  17. package/v0/protocol/TezosProtocolOptions.js +98 -26
  18. package/v0/protocol/TezosProtocolOptions.js.map +1 -1
  19. package/v0/protocol/TezosUtils.d.ts +1 -0
  20. package/v0/protocol/TezosUtils.js +165 -131
  21. package/v0/protocol/TezosUtils.js.map +1 -1
  22. package/v0/protocol/contract/TezosContract.js +472 -243
  23. package/v0/protocol/contract/TezosContract.js.map +1 -1
  24. package/v0/protocol/contract/TezosContractCall.js +10 -8
  25. package/v0/protocol/contract/TezosContractCall.js.map +1 -1
  26. package/v0/protocol/contract/TezosContractEntrypoint.js +19 -14
  27. package/v0/protocol/contract/TezosContractEntrypoint.js.map +1 -1
  28. package/v0/protocol/contract/TezosContractStorage.js +9 -8
  29. package/v0/protocol/contract/TezosContractStorage.js.map +1 -1
  30. package/v0/protocol/contract/remote-data/TezosContractRemoteDataFactory.js +25 -8
  31. package/v0/protocol/contract/remote-data/TezosContractRemoteDataFactory.js.map +1 -1
  32. package/v0/protocol/contract/remote-data/TezosStorageRemoteData.js +113 -39
  33. package/v0/protocol/contract/remote-data/TezosStorageRemoteData.js.map +1 -1
  34. package/v0/protocol/domains/TezosDomains.js +270 -165
  35. package/v0/protocol/domains/TezosDomains.js.map +1 -1
  36. package/v0/protocol/fa/TezosBTC.js +98 -19
  37. package/v0/protocol/fa/TezosBTC.js.map +1 -1
  38. package/v0/protocol/fa/TezosBTCtez.js +48 -17
  39. package/v0/protocol/fa/TezosBTCtez.js.map +1 -1
  40. package/v0/protocol/fa/TezosCTez.js +45 -17
  41. package/v0/protocol/fa/TezosCTez.js.map +1 -1
  42. package/v0/protocol/fa/TezosDOGA.js +45 -17
  43. package/v0/protocol/fa/TezosDOGA.js.map +1 -1
  44. package/v0/protocol/fa/TezosETHtz.js +68 -10
  45. package/v0/protocol/fa/TezosETHtz.js.map +1 -1
  46. package/v0/protocol/fa/TezosFA1Protocol.js +276 -119
  47. package/v0/protocol/fa/TezosFA1Protocol.js.map +1 -1
  48. package/v0/protocol/fa/TezosFA1p2Protocol.js +101 -22
  49. package/v0/protocol/fa/TezosFA1p2Protocol.js.map +1 -1
  50. package/v0/protocol/fa/TezosFA2Protocol.js +402 -213
  51. package/v0/protocol/fa/TezosFA2Protocol.js.map +1 -1
  52. package/v0/protocol/fa/TezosFAProtocol.js +418 -211
  53. package/v0/protocol/fa/TezosFAProtocol.js.map +1 -1
  54. package/v0/protocol/fa/TezosFAProtocolOptions.d.ts +2 -2
  55. package/v0/protocol/fa/TezosFAProtocolOptions.js +195 -92
  56. package/v0/protocol/fa/TezosFAProtocolOptions.js.map +1 -1
  57. package/v0/protocol/fa/TezosKolibriUSD.js +70 -11
  58. package/v0/protocol/fa/TezosKolibriUSD.js.map +1 -1
  59. package/v0/protocol/fa/TezosPlanty.js +45 -17
  60. package/v0/protocol/fa/TezosPlanty.js.map +1 -1
  61. package/v0/protocol/fa/TezosQUIPU.js +48 -17
  62. package/v0/protocol/fa/TezosQUIPU.js.map +1 -1
  63. package/v0/protocol/fa/TezosSIRS.js +45 -17
  64. package/v0/protocol/fa/TezosSIRS.js.map +1 -1
  65. package/v0/protocol/fa/TezosStaker.js +70 -11
  66. package/v0/protocol/fa/TezosStaker.js.map +1 -1
  67. package/v0/protocol/fa/TezosUBTC.js +48 -17
  68. package/v0/protocol/fa/TezosUBTC.js.map +1 -1
  69. package/v0/protocol/fa/TezosUDEFI.js +48 -17
  70. package/v0/protocol/fa/TezosUDEFI.js.map +1 -1
  71. package/v0/protocol/fa/TezosUSD.js +70 -11
  72. package/v0/protocol/fa/TezosUSD.js.map +1 -1
  73. package/v0/protocol/fa/TezosUSDT.js +48 -17
  74. package/v0/protocol/fa/TezosUSDT.js.map +1 -1
  75. package/v0/protocol/fa/TezosUUSD.js +27 -8
  76. package/v0/protocol/fa/TezosUUSD.js.map +1 -1
  77. package/v0/protocol/fa/TezosUXTZ.js +48 -17
  78. package/v0/protocol/fa/TezosUXTZ.js.map +1 -1
  79. package/v0/protocol/fa/TezosWRAP.js +48 -17
  80. package/v0/protocol/fa/TezosWRAP.js.map +1 -1
  81. package/v0/protocol/fa/TezosWrapped.js +70 -11
  82. package/v0/protocol/fa/TezosWrapped.js.map +1 -1
  83. package/v0/protocol/fa/TezosYOU.js +27 -8
  84. package/v0/protocol/fa/TezosYOU.js.map +1 -1
  85. package/v0/protocol/fa/metadata/BigMapTokenMetadataIndexer.js +162 -84
  86. package/v0/protocol/fa/metadata/BigMapTokenMetadataIndexer.js.map +1 -1
  87. package/v0/protocol/fa/metadata/ObjktTokenMetadataIndexer.js +87 -37
  88. package/v0/protocol/fa/metadata/ObjktTokenMetadataIndexer.js.map +1 -1
  89. package/v0/protocol/indexerClient/TezosIndexerClient.js +259 -115
  90. package/v0/protocol/indexerClient/TezosIndexerClient.js.map +1 -1
  91. package/v0/protocol/kt/TezosKtAddress.js +67 -7
  92. package/v0/protocol/kt/TezosKtAddress.js.map +1 -1
  93. package/v0/protocol/kt/TezosKtProtocol.js +309 -161
  94. package/v0/protocol/kt/TezosKtProtocol.js.map +1 -1
  95. package/v0/protocol/sapling/TezosSaplingAddress.d.ts +1 -0
  96. package/v0/protocol/sapling/TezosSaplingAddress.js +117 -46
  97. package/v0/protocol/sapling/TezosSaplingAddress.js.map +1 -1
  98. package/v0/protocol/sapling/TezosSaplingCryptoClient.d.ts +1 -0
  99. package/v0/protocol/sapling/TezosSaplingCryptoClient.js +220 -125
  100. package/v0/protocol/sapling/TezosSaplingCryptoClient.js.map +1 -1
  101. package/v0/protocol/sapling/TezosSaplingProtocol.d.ts +1 -0
  102. package/v0/protocol/sapling/TezosSaplingProtocol.js +1127 -600
  103. package/v0/protocol/sapling/TezosSaplingProtocol.js.map +1 -1
  104. package/v0/protocol/sapling/TezosSaplingProtocolOptions.d.ts +1 -0
  105. package/v0/protocol/sapling/TezosSaplingProtocolOptions.js +61 -32
  106. package/v0/protocol/sapling/TezosSaplingProtocolOptions.js.map +1 -1
  107. package/v0/protocol/sapling/TezosShieldedTezProtocol.js +134 -50
  108. package/v0/protocol/sapling/TezosShieldedTezProtocol.js.map +1 -1
  109. package/v0/protocol/sapling/injector/TezosSaplingInjectorClient.js +56 -10
  110. package/v0/protocol/sapling/injector/TezosSaplingInjectorClient.js.map +1 -1
  111. package/v0/protocol/sapling/node/TezosSaplingNodeClient.js +67 -12
  112. package/v0/protocol/sapling/node/TezosSaplingNodeClient.js.map +1 -1
  113. package/v0/protocol/sapling/utils/TezosSaplingBookkeeper.d.ts +1 -0
  114. package/v0/protocol/sapling/utils/TezosSaplingBookkeeper.js +539 -221
  115. package/v0/protocol/sapling/utils/TezosSaplingBookkeeper.js.map +1 -1
  116. package/v0/protocol/sapling/utils/TezosSaplingEncoder.d.ts +1 -0
  117. package/v0/protocol/sapling/utils/TezosSaplingEncoder.js +104 -101
  118. package/v0/protocol/sapling/utils/TezosSaplingEncoder.js.map +1 -1
  119. package/v0/protocol/sapling/utils/TezosSaplingForger.d.ts +1 -0
  120. package/v0/protocol/sapling/utils/TezosSaplingForger.js +266 -107
  121. package/v0/protocol/sapling/utils/TezosSaplingForger.js.map +1 -1
  122. package/v0/protocol/sapling/utils/TezosSaplingState.js +239 -110
  123. package/v0/protocol/sapling/utils/TezosSaplingState.js.map +1 -1
  124. package/v0/protocol/types/TezosOperationType.js +1 -1
  125. package/v0/protocol/types/TezosOperationType.js.map +1 -1
  126. package/v0/protocol/types/contract/BigMapEntry.d.ts +1 -1
  127. package/v0/protocol/types/contract/TezosContractMetadata.d.ts +2 -2
  128. package/v0/protocol/types/micheline/MichelineNode.d.ts +7 -7
  129. package/v0/protocol/types/micheline/MichelineNodeUtils.js +13 -9
  130. package/v0/protocol/types/micheline/MichelineNodeUtils.js.map +1 -1
  131. package/v0/protocol/types/michelson/MichelsonType.d.ts +1 -0
  132. package/v0/protocol/types/michelson/MichelsonType.js +12 -11
  133. package/v0/protocol/types/michelson/MichelsonType.js.map +1 -1
  134. package/v0/protocol/types/michelson/MichelsonTypeMeta.js +92 -45
  135. package/v0/protocol/types/michelson/MichelsonTypeMeta.js.map +1 -1
  136. package/v0/protocol/types/michelson/MichelsonTypeUtils.d.ts +1 -0
  137. package/v0/protocol/types/michelson/MichelsonTypeUtils.js +219 -58
  138. package/v0/protocol/types/michelson/MichelsonTypeUtils.js.map +1 -1
  139. package/v0/protocol/types/michelson/generics/MichelsonList.js +43 -24
  140. package/v0/protocol/types/michelson/generics/MichelsonList.js.map +1 -1
  141. package/v0/protocol/types/michelson/generics/MichelsonMap.js +61 -39
  142. package/v0/protocol/types/michelson/generics/MichelsonMap.js.map +1 -1
  143. package/v0/protocol/types/michelson/generics/MichelsonOption.d.ts +1 -1
  144. package/v0/protocol/types/michelson/generics/MichelsonOption.js +75 -46
  145. package/v0/protocol/types/michelson/generics/MichelsonOption.js.map +1 -1
  146. package/v0/protocol/types/michelson/generics/MichelsonOr.d.ts +1 -1
  147. package/v0/protocol/types/michelson/generics/MichelsonOr.js +76 -50
  148. package/v0/protocol/types/michelson/generics/MichelsonOr.js.map +1 -1
  149. package/v0/protocol/types/michelson/generics/MichelsonPair.js +85 -52
  150. package/v0/protocol/types/michelson/generics/MichelsonPair.js.map +1 -1
  151. package/v0/protocol/types/michelson/grammar/MichelsonGrammarData.d.ts +1 -1
  152. package/v0/protocol/types/michelson/grammar/MichelsonGrammarInstruction.d.ts +1 -1
  153. package/v0/protocol/types/michelson/grammar/MichelsonGrammarType.d.ts +1 -1
  154. package/v0/protocol/types/michelson/primitives/MichelsonAddress.d.ts +1 -0
  155. package/v0/protocol/types/michelson/primitives/MichelsonAddress.js +47 -28
  156. package/v0/protocol/types/michelson/primitives/MichelsonAddress.js.map +1 -1
  157. package/v0/protocol/types/michelson/primitives/MichelsonBool.js +39 -20
  158. package/v0/protocol/types/michelson/primitives/MichelsonBool.js.map +1 -1
  159. package/v0/protocol/types/michelson/primitives/MichelsonBytes.d.ts +1 -0
  160. package/v0/protocol/types/michelson/primitives/MichelsonBytes.js +54 -35
  161. package/v0/protocol/types/michelson/primitives/MichelsonBytes.js.map +1 -1
  162. package/v0/protocol/types/michelson/primitives/MichelsonInt.d.ts +1 -0
  163. package/v0/protocol/types/michelson/primitives/MichelsonInt.js +49 -30
  164. package/v0/protocol/types/michelson/primitives/MichelsonInt.js.map +1 -1
  165. package/v0/protocol/types/michelson/primitives/MichelsonString.d.ts +1 -0
  166. package/v0/protocol/types/michelson/primitives/MichelsonString.js +52 -33
  167. package/v0/protocol/types/michelson/primitives/MichelsonString.js.map +1 -1
  168. package/v0/protocol/types/michelson/primitives/MichelsonUnit.js +34 -14
  169. package/v0/protocol/types/michelson/primitives/MichelsonUnit.js.map +1 -1
  170. package/v0/protocol/types/sapling/TezosSaplingStateTree.d.ts +1 -1
  171. package/v0/protocol/types/sapling/TezosSaplingTransaction.d.ts +1 -0
  172. package/v0/protocol/types/utils.js +10 -8
  173. package/v0/protocol/types/utils.js.map +1 -1
  174. package/v0/serializer/validators/transaction-validator.js +78 -29
  175. package/v0/serializer/validators/transaction-validator.js.map +1 -1
  176. package/v0/serializer/validators/transaction-xtz-btc-validator.js +129 -55
  177. package/v0/serializer/validators/transaction-xtz-btc-validator.js.map +1 -1
  178. package/v0/serializer/validators/validators.js +103 -43
  179. package/v0/serializer/validators/validators.js.map +1 -1
  180. package/v1/block-explorer/TzKTBlockExplorer.js +61 -12
  181. package/v1/block-explorer/TzKTBlockExplorer.js.map +1 -1
  182. package/v1/block-explorer/factory.js +5 -4
  183. package/v1/block-explorer/factory.js.map +1 -1
  184. package/v1/contract/TezosContract.js +471 -242
  185. package/v1/contract/TezosContract.js.map +1 -1
  186. package/v1/contract/TezosContractCall.js +10 -8
  187. package/v1/contract/TezosContractCall.js.map +1 -1
  188. package/v1/contract/TezosContractEntrypoint.d.ts +1 -1
  189. package/v1/contract/TezosContractEntrypoint.js +19 -14
  190. package/v1/contract/TezosContractEntrypoint.js.map +1 -1
  191. package/v1/contract/TezosContractStorage.js +9 -8
  192. package/v1/contract/TezosContractStorage.js.map +1 -1
  193. package/v1/contract/remote-data/TezosContractRemoteDataFactory.js +25 -8
  194. package/v1/contract/remote-data/TezosContractRemoteDataFactory.js.map +1 -1
  195. package/v1/contract/remote-data/TezosStorageRemoteData.js +113 -39
  196. package/v1/contract/remote-data/TezosStorageRemoteData.js.map +1 -1
  197. package/v1/crypto/TezosCryptoClient.d.ts +1 -0
  198. package/v1/crypto/TezosCryptoClient.js +117 -64
  199. package/v1/crypto/TezosCryptoClient.js.map +1 -1
  200. package/v1/crypto/TezosSaplingCryptoClient.d.ts +1 -0
  201. package/v1/crypto/TezosSaplingCryptoClient.js +194 -116
  202. package/v1/crypto/TezosSaplingCryptoClient.js.map +1 -1
  203. package/v1/data/TezosAddress.js +14 -13
  204. package/v1/data/TezosAddress.js.map +1 -1
  205. package/v1/data/TezosSaplingAddress.d.ts +1 -0
  206. package/v1/data/TezosSaplingAddress.js +94 -29
  207. package/v1/data/TezosSaplingAddress.js.map +1 -1
  208. package/v1/domains/TezosDomains.js +270 -165
  209. package/v1/domains/TezosDomains.js.map +1 -1
  210. package/v1/index.js +39 -39
  211. package/v1/index.js.map +1 -1
  212. package/v1/indexer/TzKTIndexerClient.js +270 -126
  213. package/v1/indexer/TzKTIndexerClient.js.map +1 -1
  214. package/v1/indexer/factory.js +5 -4
  215. package/v1/indexer/factory.js.map +1 -1
  216. package/v1/indexer/token-metadata/BigMapTokenMetadataIndexerClient.js +161 -83
  217. package/v1/indexer/token-metadata/BigMapTokenMetadataIndexerClient.js.map +1 -1
  218. package/v1/indexer/token-metadata/ObjktTokenMetadataIndexerClient.js +85 -36
  219. package/v1/indexer/token-metadata/ObjktTokenMetadataIndexerClient.js.map +1 -1
  220. package/v1/injector/TezosSaplingInjectorClient.js +56 -10
  221. package/v1/injector/TezosSaplingInjectorClient.js.map +1 -1
  222. package/v1/module/TezosModule.js +155 -88
  223. package/v1/module/TezosModule.js.map +1 -1
  224. package/v1/module.js +3 -2
  225. package/v1/module.js.map +1 -1
  226. package/v1/node/TezosSaplingNodeClient.js +67 -12
  227. package/v1/node/TezosSaplingNodeClient.js.map +1 -1
  228. package/v1/protocol/TezosProtocol.js +1385 -848
  229. package/v1/protocol/TezosProtocol.js.map +1 -1
  230. package/v1/protocol/fa/TezosFA1Protocol.js +205 -81
  231. package/v1/protocol/fa/TezosFA1Protocol.js.map +1 -1
  232. package/v1/protocol/fa/TezosFA1p2Protocol.js +111 -32
  233. package/v1/protocol/fa/TezosFA1p2Protocol.js.map +1 -1
  234. package/v1/protocol/fa/TezosFA2Protocol.js +332 -174
  235. package/v1/protocol/fa/TezosFA2Protocol.js.map +1 -1
  236. package/v1/protocol/fa/TezosFAProtocol.js +528 -255
  237. package/v1/protocol/fa/TezosFAProtocol.js.map +1 -1
  238. package/v1/protocol/fa/tokens/BTCTezProtocol.d.ts +2 -2
  239. package/v1/protocol/fa/tokens/BTCTezProtocol.js +47 -30
  240. package/v1/protocol/fa/tokens/BTCTezProtocol.js.map +1 -1
  241. package/v1/protocol/fa/tokens/CTezProtocol.d.ts +2 -2
  242. package/v1/protocol/fa/tokens/CTezProtocol.js +47 -27
  243. package/v1/protocol/fa/tokens/CTezProtocol.js.map +1 -1
  244. package/v1/protocol/fa/tokens/DogamiProtocol.d.ts +2 -2
  245. package/v1/protocol/fa/tokens/DogamiProtocol.js +47 -27
  246. package/v1/protocol/fa/tokens/DogamiProtocol.js.map +1 -1
  247. package/v1/protocol/fa/tokens/ETHTezProtocol.d.ts +2 -2
  248. package/v1/protocol/fa/tokens/ETHTezProtocol.js +90 -30
  249. package/v1/protocol/fa/tokens/ETHTezProtocol.js.map +1 -1
  250. package/v1/protocol/fa/tokens/KolibriUSDProtocol.d.ts +2 -2
  251. package/v1/protocol/fa/tokens/KolibriUSDProtocol.js +90 -30
  252. package/v1/protocol/fa/tokens/KolibriUSDProtocol.js.map +1 -1
  253. package/v1/protocol/fa/tokens/PlentyProtocol.d.ts +2 -2
  254. package/v1/protocol/fa/tokens/PlentyProtocol.js +90 -30
  255. package/v1/protocol/fa/tokens/PlentyProtocol.js.map +1 -1
  256. package/v1/protocol/fa/tokens/QuipuswapProtocol.d.ts +2 -2
  257. package/v1/protocol/fa/tokens/QuipuswapProtocol.js +47 -30
  258. package/v1/protocol/fa/tokens/QuipuswapProtocol.js.map +1 -1
  259. package/v1/protocol/fa/tokens/SiriusProtocol.d.ts +2 -2
  260. package/v1/protocol/fa/tokens/SiriusProtocol.js +47 -27
  261. package/v1/protocol/fa/tokens/SiriusProtocol.js.map +1 -1
  262. package/v1/protocol/fa/tokens/StakerProtocol.d.ts +2 -2
  263. package/v1/protocol/fa/tokens/StakerProtocol.js +90 -30
  264. package/v1/protocol/fa/tokens/StakerProtocol.js.map +1 -1
  265. package/v1/protocol/fa/tokens/TetherUSDProtocol.d.ts +2 -2
  266. package/v1/protocol/fa/tokens/TetherUSDProtocol.js +47 -30
  267. package/v1/protocol/fa/tokens/TetherUSDProtocol.js.map +1 -1
  268. package/v1/protocol/fa/tokens/TzBTCProtocol.d.ts +2 -2
  269. package/v1/protocol/fa/tokens/TzBTCProtocol.js +47 -27
  270. package/v1/protocol/fa/tokens/TzBTCProtocol.js.map +1 -1
  271. package/v1/protocol/fa/tokens/UBTCProtocol.d.ts +2 -2
  272. package/v1/protocol/fa/tokens/UBTCProtocol.js +47 -30
  273. package/v1/protocol/fa/tokens/UBTCProtocol.js.map +1 -1
  274. package/v1/protocol/fa/tokens/UDEFIProtocol.d.ts +2 -2
  275. package/v1/protocol/fa/tokens/UDEFIProtocol.js +47 -30
  276. package/v1/protocol/fa/tokens/UDEFIProtocol.js.map +1 -1
  277. package/v1/protocol/fa/tokens/USDTezProtocol.d.ts +2 -2
  278. package/v1/protocol/fa/tokens/USDTezProtocol.js +47 -27
  279. package/v1/protocol/fa/tokens/USDTezProtocol.js.map +1 -1
  280. package/v1/protocol/fa/tokens/UUSDProtocol.d.ts +2 -2
  281. package/v1/protocol/fa/tokens/UUSDProtocol.js +47 -30
  282. package/v1/protocol/fa/tokens/UUSDProtocol.js.map +1 -1
  283. package/v1/protocol/fa/tokens/UXTZProtocol.d.ts +2 -2
  284. package/v1/protocol/fa/tokens/UXTZProtocol.js +47 -30
  285. package/v1/protocol/fa/tokens/UXTZProtocol.js.map +1 -1
  286. package/v1/protocol/fa/tokens/WrapProtocol.d.ts +2 -2
  287. package/v1/protocol/fa/tokens/WrapProtocol.js +47 -30
  288. package/v1/protocol/fa/tokens/WrapProtocol.js.map +1 -1
  289. package/v1/protocol/fa/tokens/WrappedTezosProtocol.d.ts +2 -2
  290. package/v1/protocol/fa/tokens/WrappedTezosProtocol.js +47 -27
  291. package/v1/protocol/fa/tokens/WrappedTezosProtocol.js.map +1 -1
  292. package/v1/protocol/fa/tokens/YouProtocol.d.ts +2 -2
  293. package/v1/protocol/fa/tokens/YouProtocol.js +47 -30
  294. package/v1/protocol/fa/tokens/YouProtocol.js.map +1 -1
  295. package/v1/protocol/fa/tokens/stXTZProtocol.d.ts +2 -2
  296. package/v1/protocol/fa/tokens/stXTZProtocol.js +47 -30
  297. package/v1/protocol/fa/tokens/stXTZProtocol.js.map +1 -1
  298. package/v1/protocol/kt/TezosKtProtocol.js +498 -254
  299. package/v1/protocol/kt/TezosKtProtocol.js.map +1 -1
  300. package/v1/protocol/sapling/TezosSaplingProtocol.d.ts +1 -0
  301. package/v1/protocol/sapling/TezosSaplingProtocol.js +933 -532
  302. package/v1/protocol/sapling/TezosSaplingProtocol.js.map +1 -1
  303. package/v1/protocol/sapling/TezosShieldedTezProtocol.js +164 -72
  304. package/v1/protocol/sapling/TezosShieldedTezProtocol.js.map +1 -1
  305. package/v1/serializer/v3/schemas/converter/transaction-converter.js +26 -14
  306. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
  307. package/v1/serializer/v3/serializer-companion.js +188 -103
  308. package/v1/serializer/v3/serializer-companion.js.map +1 -1
  309. package/v1/serializer/v3/validators/transaction-validator.js +143 -54
  310. package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
  311. package/v1/serializer/v3/validators/validators.js +100 -40
  312. package/v1/serializer/v3/validators/validators.js.map +1 -1
  313. package/v1/types/block-explorer.d.ts +1 -1
  314. package/v1/types/contract/TezosContractMetadata.d.ts +2 -2
  315. package/v1/types/contract/bigmap/BigMapEntry.d.ts +1 -1
  316. package/v1/types/crypto.d.ts +2 -2
  317. package/v1/types/fa/TezosFA1ContractEntrypoint.d.ts +1 -1
  318. package/v1/types/fa/TezosFA1p2ContractEntrypoint.d.ts +1 -1
  319. package/v1/types/fa/TezosFA2ContractEntrypoint.d.ts +1 -1
  320. package/v1/types/indexer.d.ts +1 -1
  321. package/v1/types/micheline/MichelineNode.d.ts +7 -7
  322. package/v1/types/micheline/MichelineNodeUtils.js +13 -9
  323. package/v1/types/micheline/MichelineNodeUtils.js.map +1 -1
  324. package/v1/types/michelson/MichelsonType.d.ts +1 -0
  325. package/v1/types/michelson/MichelsonType.js +12 -11
  326. package/v1/types/michelson/MichelsonType.js.map +1 -1
  327. package/v1/types/michelson/MichelsonTypeMeta.js +92 -45
  328. package/v1/types/michelson/MichelsonTypeMeta.js.map +1 -1
  329. package/v1/types/michelson/MichelsonTypeUtils.d.ts +1 -0
  330. package/v1/types/michelson/MichelsonTypeUtils.js +219 -58
  331. package/v1/types/michelson/MichelsonTypeUtils.js.map +1 -1
  332. package/v1/types/michelson/generics/MichelsonList.js +43 -24
  333. package/v1/types/michelson/generics/MichelsonList.js.map +1 -1
  334. package/v1/types/michelson/generics/MichelsonMap.js +61 -39
  335. package/v1/types/michelson/generics/MichelsonMap.js.map +1 -1
  336. package/v1/types/michelson/generics/MichelsonOption.d.ts +1 -1
  337. package/v1/types/michelson/generics/MichelsonOption.js +75 -46
  338. package/v1/types/michelson/generics/MichelsonOption.js.map +1 -1
  339. package/v1/types/michelson/generics/MichelsonOr.d.ts +1 -1
  340. package/v1/types/michelson/generics/MichelsonOr.js +76 -50
  341. package/v1/types/michelson/generics/MichelsonOr.js.map +1 -1
  342. package/v1/types/michelson/generics/MichelsonPair.js +85 -52
  343. package/v1/types/michelson/generics/MichelsonPair.js.map +1 -1
  344. package/v1/types/michelson/grammar/MichelsonGrammarData.d.ts +1 -1
  345. package/v1/types/michelson/grammar/MichelsonGrammarInstruction.d.ts +1 -1
  346. package/v1/types/michelson/grammar/MichelsonGrammarType.d.ts +1 -1
  347. package/v1/types/michelson/primitives/MichelsonAddress.d.ts +1 -0
  348. package/v1/types/michelson/primitives/MichelsonAddress.js +47 -28
  349. package/v1/types/michelson/primitives/MichelsonAddress.js.map +1 -1
  350. package/v1/types/michelson/primitives/MichelsonBool.js +39 -20
  351. package/v1/types/michelson/primitives/MichelsonBool.js.map +1 -1
  352. package/v1/types/michelson/primitives/MichelsonBytes.d.ts +1 -0
  353. package/v1/types/michelson/primitives/MichelsonBytes.js +54 -35
  354. package/v1/types/michelson/primitives/MichelsonBytes.js.map +1 -1
  355. package/v1/types/michelson/primitives/MichelsonInt.d.ts +1 -0
  356. package/v1/types/michelson/primitives/MichelsonInt.js +49 -30
  357. package/v1/types/michelson/primitives/MichelsonInt.js.map +1 -1
  358. package/v1/types/michelson/primitives/MichelsonString.d.ts +1 -0
  359. package/v1/types/michelson/primitives/MichelsonString.js +52 -33
  360. package/v1/types/michelson/primitives/MichelsonString.js.map +1 -1
  361. package/v1/types/michelson/primitives/MichelsonUnit.js +34 -14
  362. package/v1/types/michelson/primitives/MichelsonUnit.js.map +1 -1
  363. package/v1/types/network.js +1 -1
  364. package/v1/types/network.js.map +1 -1
  365. package/v1/types/operations/TezosOperationType.js +1 -1
  366. package/v1/types/operations/TezosOperationType.js.map +1 -1
  367. package/v1/types/protocol.d.ts +3 -3
  368. package/v1/types/sapling/TezosSaplingExternalMethodProvider.d.ts +1 -0
  369. package/v1/types/sapling/TezosSaplingStateTree.d.ts +1 -1
  370. package/v1/types/sapling/TezosSaplingTransaction.d.ts +1 -0
  371. package/v1/types/staking/TezosDelegatorAction.js +1 -1
  372. package/v1/types/staking/TezosDelegatorAction.js.map +1 -1
  373. package/v1/utils/address.js +7 -6
  374. package/v1/utils/address.js.map +1 -1
  375. package/v1/utils/bip.d.ts +1 -0
  376. package/v1/utils/bip.js +7 -6
  377. package/v1/utils/bip.js.map +1 -1
  378. package/v1/utils/convert.js +8 -7
  379. package/v1/utils/convert.js.map +1 -1
  380. package/v1/utils/encoding.d.ts +1 -0
  381. package/v1/utils/encoding.js +64 -74
  382. package/v1/utils/encoding.js.map +1 -1
  383. package/v1/utils/fa.js +3 -2
  384. package/v1/utils/fa.js.map +1 -1
  385. package/v1/utils/key.js +12 -9
  386. package/v1/utils/key.js.map +1 -1
  387. package/v1/utils/micheline.js +10 -8
  388. package/v1/utils/micheline.js.map +1 -1
  389. package/v1/utils/operations.js +22 -21
  390. package/v1/utils/operations.js.map +1 -1
  391. package/v1/utils/pack.d.ts +1 -0
  392. package/v1/utils/pack.js +107 -65
  393. package/v1/utils/pack.js.map +1 -1
  394. package/v1/utils/protocol/fa/TezosFA1Accountant.js +52 -24
  395. package/v1/utils/protocol/fa/TezosFA1Accountant.js.map +1 -1
  396. package/v1/utils/protocol/fa/TezosFA2Accountant.js +77 -40
  397. package/v1/utils/protocol/fa/TezosFA2Accountant.js.map +1 -1
  398. package/v1/utils/protocol/fa/TezosFAAccountant.js +89 -21
  399. package/v1/utils/protocol/fa/TezosFAAccountant.js.map +1 -1
  400. package/v1/utils/protocol/instance.js +26 -90
  401. package/v1/utils/protocol/instance.js.map +1 -1
  402. package/v1/utils/protocol/sapling/TezosSaplingAccountant.d.ts +1 -0
  403. package/v1/utils/protocol/sapling/TezosSaplingAccountant.js +539 -221
  404. package/v1/utils/protocol/sapling/TezosSaplingAccountant.js.map +1 -1
  405. package/v1/utils/protocol/sapling/TezosSaplingEncoder.d.ts +1 -0
  406. package/v1/utils/protocol/sapling/TezosSaplingEncoder.js +104 -101
  407. package/v1/utils/protocol/sapling/TezosSaplingEncoder.js.map +1 -1
  408. package/v1/utils/protocol/sapling/TezosSaplingForger.d.ts +1 -0
  409. package/v1/utils/protocol/sapling/TezosSaplingForger.js +266 -107
  410. package/v1/utils/protocol/sapling/TezosSaplingForger.js.map +1 -1
  411. package/v1/utils/protocol/sapling/TezosSaplingState.js +239 -110
  412. package/v1/utils/protocol/sapling/TezosSaplingState.js.map +1 -1
  413. package/v1/utils/protocol/tezos/TezosAccountant.js +166 -97
  414. package/v1/utils/protocol/tezos/TezosAccountant.js.map +1 -1
  415. package/v1/utils/protocol/tezos/TezosForger.js +76 -21
  416. package/v1/utils/protocol/tezos/TezosForger.js.map +1 -1
  417. package/v1/utils/signature.js +6 -5
  418. package/v1/utils/signature.js.map +1 -1
  419. package/v1/utils/transaction.d.ts +5 -4
  420. package/v1/utils/transaction.js +3 -3
  421. package/v1/utils/transaction.js.map +1 -1
@@ -1,83 +1,196 @@
1
1
  "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __assign = (this && this.__assign) || function () {
18
+ __assign = Object.assign || function(t) {
19
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
20
+ s = arguments[i];
21
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
+ t[p] = s[p];
23
+ }
24
+ return t;
25
+ };
26
+ return __assign.apply(this, arguments);
27
+ };
28
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
+ return new (P || (P = Promise))(function (resolve, reject) {
31
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
35
+ });
36
+ };
37
+ var __generator = (this && this.__generator) || function (thisArg, body) {
38
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
39
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
40
+ function verb(n) { return function (v) { return step([n, v]); }; }
41
+ function step(op) {
42
+ if (f) throw new TypeError("Generator is already executing.");
43
+ while (_) try {
44
+ 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;
45
+ if (y = 0, t) op = [op[0] & 2, t.value];
46
+ switch (op[0]) {
47
+ case 0: case 1: t = op; break;
48
+ case 4: _.label++; return { value: op[1], done: false };
49
+ case 5: _.label++; y = op[1]; op = [0]; continue;
50
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
51
+ default:
52
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
53
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
54
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
55
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
56
+ if (t[2]) _.ops.pop();
57
+ _.trys.pop(); continue;
58
+ }
59
+ op = body.call(thisArg, _);
60
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
61
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
+ }
63
+ };
2
64
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
65
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
66
  };
5
67
  Object.defineProperty(exports, "__esModule", { value: true });
6
68
  exports.TezosFA2Protocol = void 0;
7
- const bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
8
- const errors_1 = require("@airgap/coinlib-core/errors");
9
- const coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
10
- const hex_1 = require("@airgap/coinlib-core/utils/hex");
11
- const TezosProtocol_1 = require("../TezosProtocol");
12
- const TezosUtils_1 = require("../TezosUtils");
13
- const MichelsonList_1 = require("../types/michelson/generics/MichelsonList");
14
- const MichelsonPair_1 = require("../types/michelson/generics/MichelsonPair");
15
- const MichelsonAddress_1 = require("../types/michelson/primitives/MichelsonAddress");
16
- const MichelsonInt_1 = require("../types/michelson/primitives/MichelsonInt");
17
- const MichelsonString_1 = require("../types/michelson/primitives/MichelsonString");
18
- const TezosOperationType_1 = require("../types/TezosOperationType");
19
- const utils_1 = require("../types/utils");
20
- const TezosFAProtocol_1 = require("./TezosFAProtocol");
69
+ var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
70
+ var errors_1 = require("@airgap/coinlib-core/errors");
71
+ var coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
72
+ var hex_1 = require("@airgap/coinlib-core/utils/hex");
73
+ var TezosProtocol_1 = require("../TezosProtocol");
74
+ var TezosUtils_1 = require("../TezosUtils");
75
+ var MichelsonList_1 = require("../types/michelson/generics/MichelsonList");
76
+ var MichelsonPair_1 = require("../types/michelson/generics/MichelsonPair");
77
+ var MichelsonAddress_1 = require("../types/michelson/primitives/MichelsonAddress");
78
+ var MichelsonInt_1 = require("../types/michelson/primitives/MichelsonInt");
79
+ var MichelsonString_1 = require("../types/michelson/primitives/MichelsonString");
80
+ var TezosOperationType_1 = require("../types/TezosOperationType");
81
+ var utils_1 = require("../types/utils");
82
+ var TezosFAProtocol_1 = require("./TezosFAProtocol");
21
83
  var TezosFA2ContractEntrypoint;
22
84
  (function (TezosFA2ContractEntrypoint) {
23
85
  TezosFA2ContractEntrypoint["BALANCE"] = "balance_of";
24
86
  TezosFA2ContractEntrypoint["TRANSFER"] = "transfer";
25
87
  TezosFA2ContractEntrypoint["UPDATE_OPERATORS"] = "update_operators";
26
88
  })(TezosFA2ContractEntrypoint || (TezosFA2ContractEntrypoint = {}));
27
- class TezosFA2Protocol extends TezosFAProtocol_1.TezosFAProtocol {
28
- constructor(options) {
29
- super(options);
30
- this.options = options;
31
- this.tokenID = options.config.defaultTokenID;
32
- this.defaultCallbackContract = {
33
- [TezosProtocol_1.TezosNetwork.MAINNET]: {
34
- [TezosFA2ContractEntrypoint.BALANCE]: 'KT1LyHDYnML5eCuTEVCTynUpivwG6ns6khiG'
35
- },
36
- [TezosProtocol_1.TezosNetwork.GHOSTNET]: {
37
- [TezosFA2ContractEntrypoint.BALANCE]: 'KT1D1vHAyMVqfVJoufp6eYTJcJWEFigR3yjr'
38
- }
39
- };
40
- }
41
- async getOptions() {
42
- return this.options;
43
- }
44
- async getBalanceOfPublicKey(publicKey, data) {
45
- const address = await this.getAddressFromPublicKey(publicKey);
46
- return this.getBalanceOfAddresses([address.address], data);
47
- }
48
- async getAvailableBalanceOfAddresses(addresses, data) {
49
- return this.getBalanceOfAddresses(addresses, data);
50
- }
51
- async getBalanceOfAddresses(addresses, data) {
52
- const results = await this.balanceOf(addresses.map((address) => {
53
- return {
54
- address,
55
- tokenID: data?.assetID ?? this.tokenID ?? 0
56
- };
57
- }, this.defaultSourceAddress));
58
- return results.reduce((sum, next) => sum.plus(next.amount), new bignumber_1.default(0)).toFixed();
59
- }
60
- async estimateFeeDefaultsFromPublicKey(publicKey, recipients, values, data) {
61
- // return this.feeDefaults
62
- if (recipients.length !== values.length) {
63
- throw new errors_1.ConditionViolationError(coinlib_error_1.Domain.TEZOS, 'length of recipients and values does not match!');
64
- }
65
- const transferCall = await this.createTransferCall(publicKey, recipients, values, this.feeDefaults.medium, data);
66
- const operation = {
67
- kind: TezosOperationType_1.TezosOperationType.TRANSACTION,
68
- amount: '0',
69
- destination: this.contractAddress,
70
- parameters: transferCall.toJSON(),
71
- fee: '0'
72
- };
73
- return this.estimateFeeDefaultsForOperations(publicKey, [operation]);
74
- }
75
- async prepareTransactionFromPublicKey(publicKey, recipients, values, fee, data) {
76
- const transferCall = await this.createTransferCall(publicKey, recipients, values, fee, data);
77
- return this.prepareContractCall([transferCall], fee, publicKey);
89
+ var TezosFA2Protocol = /** @class */ (function (_super) {
90
+ __extends(TezosFA2Protocol, _super);
91
+ function TezosFA2Protocol(options) {
92
+ var _a, _b, _c;
93
+ var _this = _super.call(this, options) || this;
94
+ _this.options = options;
95
+ _this.tokenID = options.config.defaultTokenID;
96
+ _this.defaultCallbackContract = (_a = {},
97
+ _a[TezosProtocol_1.TezosNetwork.MAINNET] = (_b = {},
98
+ _b[TezosFA2ContractEntrypoint.BALANCE] = 'KT1LyHDYnML5eCuTEVCTynUpivwG6ns6khiG',
99
+ _b),
100
+ _a[TezosProtocol_1.TezosNetwork.GHOSTNET] = (_c = {},
101
+ _c[TezosFA2ContractEntrypoint.BALANCE] = 'KT1D1vHAyMVqfVJoufp6eYTJcJWEFigR3yjr',
102
+ _c),
103
+ _a);
104
+ return _this;
78
105
  }
79
- transactionDetailsFromParameters(parameters) {
80
- const defaultDetails = {
106
+ TezosFA2Protocol.prototype.getOptions = function () {
107
+ return __awaiter(this, void 0, void 0, function () {
108
+ return __generator(this, function (_a) {
109
+ return [2 /*return*/, this.options];
110
+ });
111
+ });
112
+ };
113
+ TezosFA2Protocol.prototype.getBalanceOfPublicKey = function (publicKey, data) {
114
+ return __awaiter(this, void 0, void 0, function () {
115
+ var address;
116
+ return __generator(this, function (_a) {
117
+ switch (_a.label) {
118
+ case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
119
+ case 1:
120
+ address = _a.sent();
121
+ return [2 /*return*/, this.getBalanceOfAddresses([address.address], data)];
122
+ }
123
+ });
124
+ });
125
+ };
126
+ TezosFA2Protocol.prototype.getAvailableBalanceOfAddresses = function (addresses, data) {
127
+ return __awaiter(this, void 0, void 0, function () {
128
+ return __generator(this, function (_a) {
129
+ return [2 /*return*/, this.getBalanceOfAddresses(addresses, data)];
130
+ });
131
+ });
132
+ };
133
+ TezosFA2Protocol.prototype.getBalanceOfAddresses = function (addresses, data) {
134
+ return __awaiter(this, void 0, void 0, function () {
135
+ var results;
136
+ var _this = this;
137
+ return __generator(this, function (_a) {
138
+ switch (_a.label) {
139
+ case 0: return [4 /*yield*/, this.balanceOf(addresses.map(function (address) {
140
+ var _a, _b;
141
+ return {
142
+ address: address,
143
+ tokenID: (_b = (_a = data === null || data === void 0 ? void 0 : data.assetID) !== null && _a !== void 0 ? _a : _this.tokenID) !== null && _b !== void 0 ? _b : 0
144
+ };
145
+ }, this.defaultSourceAddress))];
146
+ case 1:
147
+ results = _a.sent();
148
+ return [2 /*return*/, results.reduce(function (sum, next) { return sum.plus(next.amount); }, new bignumber_1.default(0)).toFixed()];
149
+ }
150
+ });
151
+ });
152
+ };
153
+ TezosFA2Protocol.prototype.estimateFeeDefaultsFromPublicKey = function (publicKey, recipients, values, data) {
154
+ return __awaiter(this, void 0, void 0, function () {
155
+ var transferCall, operation;
156
+ return __generator(this, function (_a) {
157
+ switch (_a.label) {
158
+ case 0:
159
+ // return this.feeDefaults
160
+ if (recipients.length !== values.length) {
161
+ throw new errors_1.ConditionViolationError(coinlib_error_1.Domain.TEZOS, 'length of recipients and values does not match!');
162
+ }
163
+ return [4 /*yield*/, this.createTransferCall(publicKey, recipients, values, this.feeDefaults.medium, data)];
164
+ case 1:
165
+ transferCall = _a.sent();
166
+ operation = {
167
+ kind: TezosOperationType_1.TezosOperationType.TRANSACTION,
168
+ amount: '0',
169
+ destination: this.contractAddress,
170
+ parameters: transferCall.toJSON(),
171
+ fee: '0'
172
+ };
173
+ return [2 /*return*/, this.estimateFeeDefaultsForOperations(publicKey, [operation])];
174
+ }
175
+ });
176
+ });
177
+ };
178
+ TezosFA2Protocol.prototype.prepareTransactionFromPublicKey = function (publicKey, recipients, values, fee, data) {
179
+ return __awaiter(this, void 0, void 0, function () {
180
+ var transferCall;
181
+ return __generator(this, function (_a) {
182
+ switch (_a.label) {
183
+ case 0: return [4 /*yield*/, this.createTransferCall(publicKey, recipients, values, fee, data)];
184
+ case 1:
185
+ transferCall = _a.sent();
186
+ return [2 /*return*/, this.prepareContractCall([transferCall], fee, publicKey)];
187
+ }
188
+ });
189
+ });
190
+ };
191
+ TezosFA2Protocol.prototype.transactionDetailsFromParameters = function (parameters) {
192
+ var _this = this;
193
+ var defaultDetails = {
81
194
  extra: {
82
195
  type: parameters.entrypoint
83
196
  }
@@ -87,177 +200,253 @@ class TezosFA2Protocol extends TezosFAProtocol_1.TezosFAProtocol {
87
200
  return [defaultDetails];
88
201
  }
89
202
  try {
90
- const callArgumentsList = MichelsonList_1.MichelsonList.from(parameters.value, (pairJSON) => MichelsonPair_1.MichelsonPair.from(pairJSON, undefined, (fromJSON) => MichelsonAddress_1.MichelsonAddress.from(fromJSON, 'from_'), (txsJSON) => MichelsonList_1.MichelsonList.from(txsJSON, (pairJSON) => MichelsonPair_1.MichelsonPair.from(pairJSON, undefined, (toJSON) => MichelsonAddress_1.MichelsonAddress.from(toJSON, 'to_'), (pairJSON) => MichelsonPair_1.MichelsonPair.from(pairJSON, undefined, (tokenJSON) => MichelsonInt_1.MichelsonInt.from(tokenJSON, 'token_id'), (amountJSON) => MichelsonInt_1.MichelsonInt.from(amountJSON, 'amount'))), 'txs'))).asRawValue();
203
+ var callArgumentsList = MichelsonList_1.MichelsonList.from(parameters.value, function (pairJSON) {
204
+ return MichelsonPair_1.MichelsonPair.from(pairJSON, undefined, function (fromJSON) { return MichelsonAddress_1.MichelsonAddress.from(fromJSON, 'from_'); }, function (txsJSON) {
205
+ return MichelsonList_1.MichelsonList.from(txsJSON, function (pairJSON) {
206
+ return MichelsonPair_1.MichelsonPair.from(pairJSON, undefined, function (toJSON) { return MichelsonAddress_1.MichelsonAddress.from(toJSON, 'to_'); }, function (pairJSON) {
207
+ return MichelsonPair_1.MichelsonPair.from(pairJSON, undefined, function (tokenJSON) { return MichelsonInt_1.MichelsonInt.from(tokenJSON, 'token_id'); }, function (amountJSON) { return MichelsonInt_1.MichelsonInt.from(amountJSON, 'amount'); });
208
+ });
209
+ }, 'txs');
210
+ });
211
+ }).asRawValue();
91
212
  return Array.isArray(callArgumentsList)
92
213
  ? callArgumentsList
93
- .map((callArguments) => {
94
- if (!this.isTransferRequest(callArguments)) {
214
+ .map(function (callArguments) {
215
+ if (!_this.isTransferRequest(callArguments)) {
95
216
  return [];
96
217
  }
97
- const from = (0, hex_1.isHex)(callArguments.from_) ? TezosUtils_1.TezosUtils.parseAddress(callArguments.from_) : callArguments.from_;
98
- const transferDetails = callArguments.txs.map((tx) => {
99
- const to = (0, hex_1.isHex)(tx.to_) ? TezosUtils_1.TezosUtils.parseAddress(tx.to_) : tx.to_;
218
+ var from = (0, hex_1.isHex)(callArguments.from_) ? TezosUtils_1.TezosUtils.parseAddress(callArguments.from_) : callArguments.from_;
219
+ var transferDetails = callArguments.txs.map(function (tx) {
220
+ var to = (0, hex_1.isHex)(tx.to_) ? TezosUtils_1.TezosUtils.parseAddress(tx.to_) : tx.to_;
100
221
  return [to, tx.token_id, tx.amount];
101
222
  });
102
223
  return transferDetails
103
- .map(([to, tokenID, amount]) => {
104
- if (this.tokenID !== undefined && !tokenID.eq(this.tokenID)) {
224
+ .map(function (_a) {
225
+ var to = _a[0], tokenID = _a[1], amount = _a[2];
226
+ if (_this.tokenID !== undefined && !tokenID.eq(_this.tokenID)) {
105
227
  return undefined;
106
228
  }
107
- return {
108
- ...defaultDetails,
109
- amount: amount.toFixed(),
110
- from: [from],
111
- to: [to],
112
- extra: {
229
+ return __assign(__assign({}, defaultDetails), { amount: amount.toFixed(), from: [from], to: [to], extra: {
113
230
  type: parameters.entrypoint,
114
231
  assetID: tokenID.toNumber()
115
- }
116
- };
232
+ } });
117
233
  })
118
- .filter((partialDetails) => partialDetails !== undefined);
234
+ .filter(function (partialDetails) { return partialDetails !== undefined; });
119
235
  })
120
- .reduce((flatten, next) => flatten.concat(next), [])
236
+ .reduce(function (flatten, next) { return flatten.concat(next); }, [])
121
237
  : [defaultDetails];
122
238
  }
123
- catch {
239
+ catch (_a) {
124
240
  return [defaultDetails];
125
241
  }
126
- }
127
- async balanceOf(balanceRequests, source, callbackContract = this.callbackContract(TezosFA2ContractEntrypoint.BALANCE)) {
128
- const balanceOfCall = await this.contract.createContractCall(TezosFA2ContractEntrypoint.BALANCE, {
129
- requests: balanceRequests.map((request) => {
130
- return {
131
- owner: request.address,
132
- token_id: typeof request.tokenID === 'string' ? parseInt(request.tokenID, 10) : request.tokenID
133
- };
134
- }),
135
- callback: callbackContract
242
+ };
243
+ TezosFA2Protocol.prototype.balanceOf = function (balanceRequests, source, callbackContract) {
244
+ if (callbackContract === void 0) { callbackContract = this.callbackContract(TezosFA2ContractEntrypoint.BALANCE); }
245
+ return __awaiter(this, void 0, void 0, function () {
246
+ var balanceOfCall, results;
247
+ return __generator(this, function (_a) {
248
+ switch (_a.label) {
249
+ case 0: return [4 /*yield*/, this.contract.createContractCall(TezosFA2ContractEntrypoint.BALANCE, {
250
+ requests: balanceRequests.map(function (request) {
251
+ return {
252
+ owner: request.address,
253
+ token_id: typeof request.tokenID === 'string' ? parseInt(request.tokenID, 10) : request.tokenID
254
+ };
255
+ }),
256
+ callback: callbackContract
257
+ })];
258
+ case 1:
259
+ balanceOfCall = _a.sent();
260
+ return [4 /*yield*/, this.runContractCall(balanceOfCall, this.requireSource(source))];
261
+ case 2:
262
+ results = _a.sent();
263
+ if ((0, utils_1.isMichelineSequence)(results)) {
264
+ return [2 /*return*/, results
265
+ .map(function (node) {
266
+ try {
267
+ var pair = MichelsonPair_1.MichelsonPair.from(node, undefined, function (value) { return MichelsonPair_1.MichelsonPair.from(value, undefined, MichelsonAddress_1.MichelsonAddress.from, MichelsonInt_1.MichelsonInt.from); }, MichelsonInt_1.MichelsonInt.from);
268
+ var accountWithTokenID = MichelsonPair_1.MichelsonPair.from(pair.items[0].get());
269
+ var account = MichelsonAddress_1.MichelsonAddress.from(accountWithTokenID.items[0].get());
270
+ var tokenID = MichelsonInt_1.MichelsonInt.from(accountWithTokenID.items[1].get());
271
+ var amount = MichelsonInt_1.MichelsonInt.from(pair.items[1].get());
272
+ return {
273
+ address: account.address instanceof MichelsonString_1.MichelsonString ? account.address.value : TezosUtils_1.TezosUtils.parseAddress(account.address.value),
274
+ tokenID: tokenID.value.toNumber(),
275
+ amount: amount.value.toFixed()
276
+ };
277
+ }
278
+ catch (error) {
279
+ console.warn(error);
280
+ return undefined;
281
+ }
282
+ })
283
+ .filter(function (balanceOfResults) { return balanceOfResults !== undefined; })];
284
+ }
285
+ else {
286
+ return [2 /*return*/, []];
287
+ }
288
+ return [2 /*return*/];
289
+ }
290
+ });
136
291
  });
137
- const results = await this.runContractCall(balanceOfCall, this.requireSource(source));
138
- if ((0, utils_1.isMichelineSequence)(results)) {
139
- return results
140
- .map((node) => {
141
- try {
142
- const pair = MichelsonPair_1.MichelsonPair.from(node, undefined, (value) => MichelsonPair_1.MichelsonPair.from(value, undefined, MichelsonAddress_1.MichelsonAddress.from, MichelsonInt_1.MichelsonInt.from), MichelsonInt_1.MichelsonInt.from);
143
- const accountWithTokenID = MichelsonPair_1.MichelsonPair.from(pair.items[0].get());
144
- const account = MichelsonAddress_1.MichelsonAddress.from(accountWithTokenID.items[0].get());
145
- const tokenID = MichelsonInt_1.MichelsonInt.from(accountWithTokenID.items[1].get());
146
- const amount = MichelsonInt_1.MichelsonInt.from(pair.items[1].get());
147
- return {
148
- address: account.address instanceof MichelsonString_1.MichelsonString ? account.address.value : TezosUtils_1.TezosUtils.parseAddress(account.address.value),
149
- tokenID: tokenID.value.toNumber(),
150
- amount: amount.value.toFixed()
151
- };
292
+ };
293
+ TezosFA2Protocol.prototype.transfer = function (transferRequests, fee, publicKey) {
294
+ return __awaiter(this, void 0, void 0, function () {
295
+ var transferCall;
296
+ return __generator(this, function (_a) {
297
+ switch (_a.label) {
298
+ case 0: return [4 /*yield*/, this.contract.createContractCall(TezosFA2ContractEntrypoint.TRANSFER, transferRequests.map(function (request) {
299
+ return {
300
+ from_: request.from,
301
+ txs: request.txs.map(function (tx) {
302
+ return {
303
+ to_: tx.to,
304
+ token_id: tx.tokenID,
305
+ amount: tx.amount
306
+ };
307
+ })
308
+ };
309
+ }))];
310
+ case 1:
311
+ transferCall = _a.sent();
312
+ return [2 /*return*/, this.prepareContractCall([transferCall], fee, publicKey)];
152
313
  }
153
- catch (error) {
154
- console.warn(error);
155
- return undefined;
314
+ });
315
+ });
316
+ };
317
+ TezosFA2Protocol.prototype.updateOperators = function (updateRequests, fee, publicKey) {
318
+ return __awaiter(this, void 0, void 0, function () {
319
+ var updateCall;
320
+ return __generator(this, function (_a) {
321
+ switch (_a.label) {
322
+ case 0: return [4 /*yield*/, this.contract.createContractCall(TezosFA2ContractEntrypoint.UPDATE_OPERATORS, updateRequests.map(function (request) {
323
+ var _a;
324
+ var args = (_a = {},
325
+ _a["".concat(request.operation, "_operator")] = {
326
+ owner: request.owner,
327
+ operator: request.operator,
328
+ token_id: request.tokenId
329
+ },
330
+ _a);
331
+ return [request.operation === 'add' ? 'Left' : 'Right', args];
332
+ }))];
333
+ case 1:
334
+ updateCall = _a.sent();
335
+ return [2 /*return*/, this.prepareContractCall([updateCall], fee, publicKey)];
156
336
  }
157
- })
158
- .filter((balanceOfResults) => balanceOfResults !== undefined);
159
- }
160
- else {
161
- return [];
162
- }
163
- }
164
- async transfer(transferRequests, fee, publicKey) {
165
- const transferCall = await this.contract.createContractCall(TezosFA2ContractEntrypoint.TRANSFER, transferRequests.map((request) => {
166
- return {
167
- from_: request.from,
168
- txs: request.txs.map((tx) => {
169
- return {
170
- to_: tx.to,
171
- token_id: tx.tokenID,
172
- amount: tx.amount
173
- };
174
- })
175
- };
176
- }));
177
- return this.prepareContractCall([transferCall], fee, publicKey);
178
- }
179
- async updateOperators(updateRequests, fee, publicKey) {
180
- const updateCall = await this.contract.createContractCall(TezosFA2ContractEntrypoint.UPDATE_OPERATORS, updateRequests.map((request) => {
181
- const args = {
182
- [`${request.operation}_operator`]: {
183
- owner: request.owner,
184
- operator: request.operator,
185
- token_id: request.tokenId
337
+ });
338
+ });
339
+ };
340
+ TezosFA2Protocol.prototype.getTokenMetadata = function (tokenID) {
341
+ var _a;
342
+ return __awaiter(this, void 0, void 0, function () {
343
+ return __generator(this, function (_b) {
344
+ return [2 /*return*/, this.getTokenMetadataForTokenID((_a = tokenID !== null && tokenID !== void 0 ? tokenID : this.tokenID) !== null && _a !== void 0 ? _a : 0)];
345
+ });
346
+ });
347
+ };
348
+ TezosFA2Protocol.prototype.fetchTokenHolders = function (tokenID) {
349
+ var _a;
350
+ return __awaiter(this, void 0, void 0, function () {
351
+ return __generator(this, function (_b) {
352
+ return [2 /*return*/, this.contract.network.extras.indexerClient.getTokenBalances({
353
+ contractAddress: this.contract.address,
354
+ id: (_a = tokenID !== null && tokenID !== void 0 ? tokenID : this.tokenID) !== null && _a !== void 0 ? _a : 0
355
+ })];
356
+ });
357
+ });
358
+ };
359
+ TezosFA2Protocol.prototype.getTotalSupply = function (tokenID) {
360
+ var _a;
361
+ return __awaiter(this, void 0, void 0, function () {
362
+ var bigMaps, bigMapIndex, bigMap, result;
363
+ return __generator(this, function (_b) {
364
+ switch (_b.label) {
365
+ case 0: return [4 /*yield*/, this.contract.getBigMaps()];
366
+ case 1:
367
+ bigMaps = _b.sent();
368
+ bigMapIndex = this.options.config.totalSupplyBigMapID;
369
+ bigMap = undefined;
370
+ if (bigMapIndex !== undefined) {
371
+ bigMap = bigMaps.find(function (bigMap) { return bigMap.id === bigMapIndex; });
372
+ }
373
+ else {
374
+ bigMap = bigMaps.find(function (bigMap) {
375
+ return (bigMap.path === 'total_supply' || bigMap.path.endsWith('.total_supply')) &&
376
+ (0, utils_1.isMichelinePrimitiveApplication)('nat', bigMap.keyType) &&
377
+ (0, utils_1.isMichelinePrimitiveApplication)('nat', bigMap.valueType);
378
+ });
379
+ }
380
+ return [4 /*yield*/, this.contract.getBigMapValue({
381
+ bigMap: bigMap,
382
+ key: "".concat((_a = tokenID !== null && tokenID !== void 0 ? tokenID : this.tokenID) !== null && _a !== void 0 ? _a : 0),
383
+ resultType: 'micheline'
384
+ })];
385
+ case 2:
386
+ result = _b.sent();
387
+ if (result !== undefined && (0, utils_1.isMichelinePrimitive)('int', result.value)) {
388
+ return [2 /*return*/, result.value.int];
389
+ }
390
+ return [2 /*return*/, '0'];
186
391
  }
187
- };
188
- return [request.operation === 'add' ? 'Left' : 'Right', args];
189
- }));
190
- return this.prepareContractCall([updateCall], fee, publicKey);
191
- }
192
- async getTokenMetadata(tokenID) {
193
- return this.getTokenMetadataForTokenID(tokenID ?? this.tokenID ?? 0);
194
- }
195
- async fetchTokenHolders(tokenID) {
196
- return this.contract.network.extras.indexerClient.getTokenBalances({
197
- contractAddress: this.contract.address,
198
- id: tokenID ?? this.tokenID ?? 0
392
+ });
199
393
  });
200
- }
201
- async getTotalSupply(tokenID) {
202
- const bigMaps = await this.contract.getBigMaps();
203
- const bigMapIndex = this.options.config.totalSupplyBigMapID;
204
- let bigMap = undefined;
205
- if (bigMapIndex !== undefined) {
206
- bigMap = bigMaps.find((bigMap) => bigMap.id === bigMapIndex);
207
- }
208
- else {
209
- bigMap = bigMaps.find((bigMap) => (bigMap.path === 'total_supply' || bigMap.path.endsWith('.total_supply')) &&
210
- (0, utils_1.isMichelinePrimitiveApplication)('nat', bigMap.keyType) &&
211
- (0, utils_1.isMichelinePrimitiveApplication)('nat', bigMap.valueType));
212
- }
213
- const result = await this.contract.getBigMapValue({
214
- bigMap,
215
- key: `${tokenID ?? this.tokenID ?? 0}`,
216
- resultType: 'micheline'
394
+ };
395
+ TezosFA2Protocol.prototype.createTransferCall = function (publicKey, recipients, values, fee, data) {
396
+ var _a, _b, _c;
397
+ return __awaiter(this, void 0, void 0, function () {
398
+ var addressIndex, tokenID, addresses, fromAddress, recipientsWithValues, transferCall;
399
+ return __generator(this, function (_d) {
400
+ switch (_d.label) {
401
+ case 0:
402
+ if (recipients.length !== values.length) {
403
+ throw new errors_1.ConditionViolationError(coinlib_error_1.Domain.TEZOSFA, 'length of recipients and values does not match!');
404
+ }
405
+ addressIndex = (_a = data === null || data === void 0 ? void 0 : data.addressIndex) !== null && _a !== void 0 ? _a : 0;
406
+ tokenID = (_c = (_b = data === null || data === void 0 ? void 0 : data.assetID) !== null && _b !== void 0 ? _b : this.tokenID) !== null && _c !== void 0 ? _c : 0;
407
+ return [4 /*yield*/, this.getAddressesFromPublicKey(publicKey)];
408
+ case 1:
409
+ addresses = (_d.sent()).map(function (address) { return address.address; });
410
+ if (!addresses[addressIndex]) {
411
+ throw new errors_1.NotFoundError(coinlib_error_1.Domain.TEZOSFA, "no kt-address with index ".concat(addressIndex, " exists"));
412
+ }
413
+ fromAddress = addresses[addressIndex];
414
+ recipientsWithValues = recipients.map(function (recipient, index) { return [recipient, values[index]]; });
415
+ return [4 /*yield*/, this.contract.createContractCall(TezosFA2ContractEntrypoint.TRANSFER, [
416
+ {
417
+ from_: fromAddress,
418
+ txs: recipientsWithValues.map(function (_a) {
419
+ var recipient = _a[0], value = _a[1];
420
+ return {
421
+ to_: recipient,
422
+ token_id: tokenID,
423
+ amount: value
424
+ };
425
+ })
426
+ }
427
+ ])];
428
+ case 2:
429
+ transferCall = _d.sent();
430
+ return [2 /*return*/, transferCall];
431
+ }
432
+ });
217
433
  });
218
- if (result !== undefined && (0, utils_1.isMichelinePrimitive)('int', result.value)) {
219
- return result.value.int;
220
- }
221
- return '0';
222
- }
223
- async createTransferCall(publicKey, recipients, values, fee, data) {
224
- if (recipients.length !== values.length) {
225
- throw new errors_1.ConditionViolationError(coinlib_error_1.Domain.TEZOSFA, 'length of recipients and values does not match!');
226
- }
227
- const addressIndex = data?.addressIndex ?? 0;
228
- const tokenID = data?.assetID ?? this.tokenID ?? 0;
229
- const addresses = (await this.getAddressesFromPublicKey(publicKey)).map((address) => address.address);
230
- if (!addresses[addressIndex]) {
231
- throw new errors_1.NotFoundError(coinlib_error_1.Domain.TEZOSFA, `no kt-address with index ${addressIndex} exists`);
232
- }
233
- const fromAddress = addresses[addressIndex];
234
- const recipientsWithValues = recipients.map((recipient, index) => [recipient, values[index]]);
235
- const transferCall = await this.contract.createContractCall(TezosFA2ContractEntrypoint.TRANSFER, [
236
- {
237
- from_: fromAddress,
238
- txs: recipientsWithValues.map(([recipient, value]) => {
239
- return {
240
- to_: recipient,
241
- token_id: tokenID,
242
- amount: value
243
- };
244
- })
245
- }
246
- ]);
247
- return transferCall;
248
- }
249
- callbackContract(entrypoint) {
250
- const networkCallbacks = this.defaultCallbackContract[this.options.network.extras.network];
251
- const callback = networkCallbacks ? networkCallbacks[entrypoint] : undefined;
252
- return callback ?? '';
253
- }
254
- isTransferRequest(obj) {
255
- const anyObj = obj;
434
+ };
435
+ TezosFA2Protocol.prototype.callbackContract = function (entrypoint) {
436
+ var networkCallbacks = this.defaultCallbackContract[this.options.network.extras.network];
437
+ var callback = networkCallbacks ? networkCallbacks[entrypoint] : undefined;
438
+ return callback !== null && callback !== void 0 ? callback : '';
439
+ };
440
+ TezosFA2Protocol.prototype.isTransferRequest = function (obj) {
441
+ var anyObj = obj;
256
442
  return (anyObj instanceof Object &&
257
443
  typeof anyObj.from_ === 'string' &&
258
444
  Array.isArray(anyObj.txs) &&
259
- anyObj.txs.every((tx) => tx instanceof Object && typeof tx.to_ === 'string' && bignumber_1.default.isBigNumber(tx.token_id) && bignumber_1.default.isBigNumber(tx.amount)));
260
- }
261
- }
445
+ anyObj.txs.every(function (tx) {
446
+ return tx instanceof Object && typeof tx.to_ === 'string' && bignumber_1.default.isBigNumber(tx.token_id) && bignumber_1.default.isBigNumber(tx.amount);
447
+ }));
448
+ };
449
+ return TezosFA2Protocol;
450
+ }(TezosFAProtocol_1.TezosFAProtocol));
262
451
  exports.TezosFA2Protocol = TezosFA2Protocol;
263
452
  //# sourceMappingURL=TezosFA2Protocol.js.map