@wallfree-dev/tezos 0.13.42
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.
- package/LICENSE.md +7 -0
- package/index.d.ts +1 -0
- package/index.js +18 -0
- package/index.js.map +1 -0
- package/package.json +70 -0
- package/readme.md +121 -0
- package/v0/actions/GetKtAccountsAction.d.ts +8 -0
- package/v0/actions/GetKtAccountsAction.js +87 -0
- package/v0/actions/GetKtAccountsAction.js.map +1 -0
- package/v0/constants.d.ts +18 -0
- package/v0/constants.js +28 -0
- package/v0/constants.js.map +1 -0
- package/v0/index.d.ts +47 -0
- package/v0/index.js +148 -0
- package/v0/index.js.map +1 -0
- package/v0/protocol/TezosAddress.d.ts +11 -0
- package/v0/protocol/TezosAddress.js +107 -0
- package/v0/protocol/TezosAddress.js.map +1 -0
- package/v0/protocol/TezosCryptoClient.d.ts +15 -0
- package/v0/protocol/TezosCryptoClient.js +160 -0
- package/v0/protocol/TezosCryptoClient.js.map +1 -0
- package/v0/protocol/TezosProtocol.d.ts +342 -0
- package/v0/protocol/TezosProtocol.js +1750 -0
- package/v0/protocol/TezosProtocol.js.map +1 -0
- package/v0/protocol/TezosProtocolOptions.d.ts +29 -0
- package/v0/protocol/TezosProtocolOptions.js +116 -0
- package/v0/protocol/TezosProtocolOptions.js.map +1 -0
- package/v0/protocol/TezosUtils.d.ts +40 -0
- package/v0/protocol/TezosUtils.js +301 -0
- package/v0/protocol/TezosUtils.js.map +1 -0
- package/v0/protocol/contract/TezosContract.d.ts +52 -0
- package/v0/protocol/contract/TezosContract.js +508 -0
- package/v0/protocol/contract/TezosContract.js.map +1 -0
- package/v0/protocol/contract/TezosContractCall.d.ts +11 -0
- package/v0/protocol/contract/TezosContractCall.js +23 -0
- package/v0/protocol/contract/TezosContractCall.js.map +1 -0
- package/v0/protocol/contract/TezosContractEntrypoint.d.ts +8 -0
- package/v0/protocol/contract/TezosContractEntrypoint.js +27 -0
- package/v0/protocol/contract/TezosContractEntrypoint.js.map +1 -0
- package/v0/protocol/contract/TezosContractStorage.d.ts +7 -0
- package/v0/protocol/contract/TezosContractStorage.js +16 -0
- package/v0/protocol/contract/TezosContractStorage.js.map +1 -0
- package/v0/protocol/contract/remote-data/TezosContractRemoteDataFactory.d.ts +11 -0
- package/v0/protocol/contract/remote-data/TezosContractRemoteDataFactory.js +36 -0
- package/v0/protocol/contract/remote-data/TezosContractRemoteDataFactory.js.map +1 -0
- package/v0/protocol/contract/remote-data/TezosStorageRemoteData.d.ts +12 -0
- package/v0/protocol/contract/remote-data/TezosStorageRemoteData.js +152 -0
- package/v0/protocol/contract/remote-data/TezosStorageRemoteData.js.map +1 -0
- package/v0/protocol/domains/TezosDomains.d.ts +20 -0
- package/v0/protocol/domains/TezosDomains.js +310 -0
- package/v0/protocol/domains/TezosDomains.js.map +1 -0
- package/v0/protocol/fa/TezosBTC.d.ts +12 -0
- package/v0/protocol/fa/TezosBTC.js +109 -0
- package/v0/protocol/fa/TezosBTC.js.map +1 -0
- package/v0/protocol/fa/TezosBTCtez.d.ts +10 -0
- package/v0/protocol/fa/TezosBTCtez.js +56 -0
- package/v0/protocol/fa/TezosBTCtez.js.map +1 -0
- package/v0/protocol/fa/TezosCTez.d.ts +10 -0
- package/v0/protocol/fa/TezosCTez.js +53 -0
- package/v0/protocol/fa/TezosCTez.js.map +1 -0
- package/v0/protocol/fa/TezosDOGA.d.ts +10 -0
- package/v0/protocol/fa/TezosDOGA.js +53 -0
- package/v0/protocol/fa/TezosDOGA.js.map +1 -0
- package/v0/protocol/fa/TezosETHtz.d.ts +9 -0
- package/v0/protocol/fa/TezosETHtz.js +74 -0
- package/v0/protocol/fa/TezosETHtz.js.map +1 -0
- package/v0/protocol/fa/TezosFA1Protocol.d.ts +27 -0
- package/v0/protocol/fa/TezosFA1Protocol.js +312 -0
- package/v0/protocol/fa/TezosFA1Protocol.js.map +1 -0
- package/v0/protocol/fa/TezosFA1p2Protocol.d.ts +8 -0
- package/v0/protocol/fa/TezosFA1p2Protocol.js +119 -0
- package/v0/protocol/fa/TezosFA1p2Protocol.js.map +1 -0
- package/v0/protocol/fa/TezosFA2Protocol.d.ts +58 -0
- package/v0/protocol/fa/TezosFA2Protocol.js +452 -0
- package/v0/protocol/fa/TezosFA2Protocol.js.map +1 -0
- package/v0/protocol/fa/TezosFAProtocol.d.ts +65 -0
- package/v0/protocol/fa/TezosFAProtocol.js +455 -0
- package/v0/protocol/fa/TezosFAProtocol.js.map +1 -0
- package/v0/protocol/fa/TezosFAProtocolOptions.d.ts +54 -0
- package/v0/protocol/fa/TezosFAProtocolOptions.js +230 -0
- package/v0/protocol/fa/TezosFAProtocolOptions.js.map +1 -0
- package/v0/protocol/fa/TezosKolibriUSD.d.ts +10 -0
- package/v0/protocol/fa/TezosKolibriUSD.js +76 -0
- package/v0/protocol/fa/TezosKolibriUSD.js.map +1 -0
- package/v0/protocol/fa/TezosPlanty.d.ts +10 -0
- package/v0/protocol/fa/TezosPlanty.js +53 -0
- package/v0/protocol/fa/TezosPlanty.js.map +1 -0
- package/v0/protocol/fa/TezosQUIPU.d.ts +10 -0
- package/v0/protocol/fa/TezosQUIPU.js +56 -0
- package/v0/protocol/fa/TezosQUIPU.js.map +1 -0
- package/v0/protocol/fa/TezosSIRS.d.ts +10 -0
- package/v0/protocol/fa/TezosSIRS.js +53 -0
- package/v0/protocol/fa/TezosSIRS.js.map +1 -0
- package/v0/protocol/fa/TezosStaker.d.ts +10 -0
- package/v0/protocol/fa/TezosStaker.js +76 -0
- package/v0/protocol/fa/TezosStaker.js.map +1 -0
- package/v0/protocol/fa/TezosUBTC.d.ts +10 -0
- package/v0/protocol/fa/TezosUBTC.js +56 -0
- package/v0/protocol/fa/TezosUBTC.js.map +1 -0
- package/v0/protocol/fa/TezosUDEFI.d.ts +10 -0
- package/v0/protocol/fa/TezosUDEFI.js +56 -0
- package/v0/protocol/fa/TezosUDEFI.js.map +1 -0
- package/v0/protocol/fa/TezosUSD.d.ts +10 -0
- package/v0/protocol/fa/TezosUSD.js +76 -0
- package/v0/protocol/fa/TezosUSD.js.map +1 -0
- package/v0/protocol/fa/TezosUSDT.d.ts +10 -0
- package/v0/protocol/fa/TezosUSDT.js +56 -0
- package/v0/protocol/fa/TezosUSDT.js.map +1 -0
- package/v0/protocol/fa/TezosUUSD.d.ts +6 -0
- package/v0/protocol/fa/TezosUUSD.js +33 -0
- package/v0/protocol/fa/TezosUUSD.js.map +1 -0
- package/v0/protocol/fa/TezosUXTZ.d.ts +10 -0
- package/v0/protocol/fa/TezosUXTZ.js +56 -0
- package/v0/protocol/fa/TezosUXTZ.js.map +1 -0
- package/v0/protocol/fa/TezosWRAP.d.ts +10 -0
- package/v0/protocol/fa/TezosWRAP.js +56 -0
- package/v0/protocol/fa/TezosWRAP.js.map +1 -0
- package/v0/protocol/fa/TezosWrapped.d.ts +10 -0
- package/v0/protocol/fa/TezosWrapped.js +76 -0
- package/v0/protocol/fa/TezosWrapped.js.map +1 -0
- package/v0/protocol/fa/TezosYOU.d.ts +6 -0
- package/v0/protocol/fa/TezosYOU.js +33 -0
- package/v0/protocol/fa/TezosYOU.js.map +1 -0
- package/v0/protocol/fa/metadata/BigMapTokenMetadataIndexer.d.ts +13 -0
- package/v0/protocol/fa/metadata/BigMapTokenMetadataIndexer.js +180 -0
- package/v0/protocol/fa/metadata/BigMapTokenMetadataIndexer.js.map +1 -0
- package/v0/protocol/fa/metadata/ObjktTokenMetadataIndexer.d.ts +8 -0
- package/v0/protocol/fa/metadata/ObjktTokenMetadataIndexer.js +97 -0
- package/v0/protocol/fa/metadata/ObjktTokenMetadataIndexer.js.map +1 -0
- package/v0/protocol/fa/metadata/TokenMetadataIndexer.d.ts +4 -0
- package/v0/protocol/fa/metadata/TokenMetadataIndexer.js +3 -0
- package/v0/protocol/fa/metadata/TokenMetadataIndexer.js.map +1 -0
- package/v0/protocol/indexerClient/TezosIndexerClient.d.ts +29 -0
- package/v0/protocol/indexerClient/TezosIndexerClient.js +269 -0
- package/v0/protocol/indexerClient/TezosIndexerClient.js.map +1 -0
- package/v0/protocol/indexerClient/TezosProtocolIndexerClient.d.ts +30 -0
- package/v0/protocol/indexerClient/TezosProtocolIndexerClient.js +3 -0
- package/v0/protocol/indexerClient/TezosProtocolIndexerClient.js.map +1 -0
- package/v0/protocol/kt/TezosKtAddress.d.ts +5 -0
- package/v0/protocol/kt/TezosKtAddress.js +74 -0
- package/v0/protocol/kt/TezosKtAddress.js.map +1 -0
- package/v0/protocol/kt/TezosKtProtocol.d.ts +30 -0
- package/v0/protocol/kt/TezosKtProtocol.js +320 -0
- package/v0/protocol/kt/TezosKtProtocol.js.map +1 -0
- package/v0/protocol/sapling/TezosSaplingAddress.d.ts +12 -0
- package/v0/protocol/sapling/TezosSaplingAddress.js +141 -0
- package/v0/protocol/sapling/TezosSaplingAddress.js.map +1 -0
- package/v0/protocol/sapling/TezosSaplingCryptoClient.d.ts +34 -0
- package/v0/protocol/sapling/TezosSaplingCryptoClient.js +248 -0
- package/v0/protocol/sapling/TezosSaplingCryptoClient.js.map +1 -0
- package/v0/protocol/sapling/TezosSaplingProtocol.d.ts +136 -0
- package/v0/protocol/sapling/TezosSaplingProtocol.js +1189 -0
- package/v0/protocol/sapling/TezosSaplingProtocol.js.map +1 -0
- package/v0/protocol/sapling/TezosSaplingProtocolOptions.d.ts +45 -0
- package/v0/protocol/sapling/TezosSaplingProtocolOptions.js +73 -0
- package/v0/protocol/sapling/TezosSaplingProtocolOptions.js.map +1 -0
- package/v0/protocol/sapling/TezosShieldedTezProtocol.d.ts +12 -0
- package/v0/protocol/sapling/TezosShieldedTezProtocol.js +144 -0
- package/v0/protocol/sapling/TezosShieldedTezProtocol.js.map +1 -0
- package/v0/protocol/sapling/injector/TezosSaplingInjectorClient.d.ts +6 -0
- package/v0/protocol/sapling/injector/TezosSaplingInjectorClient.js +68 -0
- package/v0/protocol/sapling/injector/TezosSaplingInjectorClient.js.map +1 -0
- package/v0/protocol/sapling/node/TezosSaplingNodeClient.d.ts +8 -0
- package/v0/protocol/sapling/node/TezosSaplingNodeClient.js +78 -0
- package/v0/protocol/sapling/node/TezosSaplingNodeClient.js.map +1 -0
- package/v0/protocol/sapling/utils/TezosSaplingBookkeeper.d.ts +34 -0
- package/v0/protocol/sapling/utils/TezosSaplingBookkeeper.js +591 -0
- package/v0/protocol/sapling/utils/TezosSaplingBookkeeper.js.map +1 -0
- package/v0/protocol/sapling/utils/TezosSaplingEncoder.d.ts +22 -0
- package/v0/protocol/sapling/utils/TezosSaplingEncoder.js +158 -0
- package/v0/protocol/sapling/utils/TezosSaplingEncoder.js.map +1 -0
- package/v0/protocol/sapling/utils/TezosSaplingForger.d.ts +27 -0
- package/v0/protocol/sapling/utils/TezosSaplingForger.js +304 -0
- package/v0/protocol/sapling/utils/TezosSaplingForger.js.map +1 -0
- package/v0/protocol/sapling/utils/TezosSaplingState.d.ts +17 -0
- package/v0/protocol/sapling/utils/TezosSaplingState.js +266 -0
- package/v0/protocol/sapling/utils/TezosSaplingState.js.map +1 -0
- package/v0/protocol/types/TezosAddressCursor.d.ts +3 -0
- package/v0/protocol/types/TezosAddressCursor.js +3 -0
- package/v0/protocol/types/TezosAddressCursor.js.map +1 -0
- package/v0/protocol/types/TezosAddressResult.d.ts +4 -0
- package/v0/protocol/types/TezosAddressResult.js +3 -0
- package/v0/protocol/types/TezosAddressResult.js.map +1 -0
- package/v0/protocol/types/TezosBlockHeader.d.ts +13 -0
- package/v0/protocol/types/TezosBlockHeader.js +3 -0
- package/v0/protocol/types/TezosBlockHeader.js.map +1 -0
- package/v0/protocol/types/TezosBlockMetadata.d.ts +7 -0
- package/v0/protocol/types/TezosBlockMetadata.js +3 -0
- package/v0/protocol/types/TezosBlockMetadata.js.map +1 -0
- package/v0/protocol/types/TezosContractCode.d.ts +5 -0
- package/v0/protocol/types/TezosContractCode.js +3 -0
- package/v0/protocol/types/TezosContractCode.js.map +1 -0
- package/v0/protocol/types/TezosOperationType.d.ts +13 -0
- package/v0/protocol/types/TezosOperationType.js +18 -0
- package/v0/protocol/types/TezosOperationType.js.map +1 -0
- package/v0/protocol/types/TezosTransactionCursor.d.ts +3 -0
- package/v0/protocol/types/TezosTransactionCursor.js +3 -0
- package/v0/protocol/types/TezosTransactionCursor.js.map +1 -0
- package/v0/protocol/types/TezosTransactionResult.d.ts +6 -0
- package/v0/protocol/types/TezosTransactionResult.js +3 -0
- package/v0/protocol/types/TezosTransactionResult.js.map +1 -0
- package/v0/protocol/types/TezosWrappedOperation.d.ts +5 -0
- package/v0/protocol/types/TezosWrappedOperation.js +3 -0
- package/v0/protocol/types/TezosWrappedOperation.js.map +1 -0
- package/v0/protocol/types/contract/BigMap.d.ts +7 -0
- package/v0/protocol/types/contract/BigMap.js +3 -0
- package/v0/protocol/types/contract/BigMap.js.map +1 -0
- package/v0/protocol/types/contract/BigMapEntry.d.ts +8 -0
- package/v0/protocol/types/contract/BigMapEntry.js +3 -0
- package/v0/protocol/types/contract/BigMapEntry.js.map +1 -0
- package/v0/protocol/types/contract/BigMapEntryFilter.d.ts +5 -0
- package/v0/protocol/types/contract/BigMapEntryFilter.js +3 -0
- package/v0/protocol/types/contract/BigMapEntryFilter.js.map +1 -0
- package/v0/protocol/types/contract/BigMapRequest.d.ts +10 -0
- package/v0/protocol/types/contract/BigMapRequest.js +3 -0
- package/v0/protocol/types/contract/BigMapRequest.js.map +1 -0
- package/v0/protocol/types/contract/TezosContractMetadata.d.ts +61 -0
- package/v0/protocol/types/contract/TezosContractMetadata.js +3 -0
- package/v0/protocol/types/contract/TezosContractMetadata.js.map +1 -0
- package/v0/protocol/types/domains/TezosDomainsRecord.d.ts +8 -0
- package/v0/protocol/types/domains/TezosDomainsRecord.js +3 -0
- package/v0/protocol/types/domains/TezosDomainsRecord.js.map +1 -0
- package/v0/protocol/types/domains/TezosDomainsReverseRecord.d.ts +5 -0
- package/v0/protocol/types/domains/TezosDomainsReverseRecord.js +3 -0
- package/v0/protocol/types/domains/TezosDomainsReverseRecord.js.map +1 -0
- package/v0/protocol/types/fa/TezosFA2BalanceOfRequest.d.ts +4 -0
- package/v0/protocol/types/fa/TezosFA2BalanceOfRequest.js +3 -0
- package/v0/protocol/types/fa/TezosFA2BalanceOfRequest.js.map +1 -0
- package/v0/protocol/types/fa/TezosFA2BalanceOfResponse.d.ts +5 -0
- package/v0/protocol/types/fa/TezosFA2BalanceOfResponse.js +3 -0
- package/v0/protocol/types/fa/TezosFA2BalanceOfResponse.js.map +1 -0
- package/v0/protocol/types/fa/TezosFA2TransferRequest.d.ts +8 -0
- package/v0/protocol/types/fa/TezosFA2TransferRequest.js +3 -0
- package/v0/protocol/types/fa/TezosFA2TransferRequest.js.map +1 -0
- package/v0/protocol/types/fa/TezosFA2UpdateOperatorRequest.d.ts +6 -0
- package/v0/protocol/types/fa/TezosFA2UpdateOperatorRequest.js +3 -0
- package/v0/protocol/types/fa/TezosFA2UpdateOperatorRequest.js.map +1 -0
- package/v0/protocol/types/fa/TezosFATokenMetadata.d.ts +6 -0
- package/v0/protocol/types/fa/TezosFATokenMetadata.js +3 -0
- package/v0/protocol/types/fa/TezosFATokenMetadata.js.map +1 -0
- package/v0/protocol/types/kt/TezosKtAddressCursor.d.ts +4 -0
- package/v0/protocol/types/kt/TezosKtAddressCursor.js +3 -0
- package/v0/protocol/types/kt/TezosKtAddressCursor.js.map +1 -0
- package/v0/protocol/types/kt/TezosKtAddressResult.d.ts +5 -0
- package/v0/protocol/types/kt/TezosKtAddressResult.js +3 -0
- package/v0/protocol/types/kt/TezosKtAddressResult.js.map +1 -0
- package/v0/protocol/types/micheline/MichelineNode.d.ts +15 -0
- package/v0/protocol/types/micheline/MichelineNode.js +5 -0
- package/v0/protocol/types/micheline/MichelineNode.js.map +1 -0
- package/v0/protocol/types/micheline/MichelineNodeUtils.d.ts +6 -0
- package/v0/protocol/types/micheline/MichelineNodeUtils.js +40 -0
- package/v0/protocol/types/micheline/MichelineNodeUtils.js.map +1 -0
- package/v0/protocol/types/michelson/MichelsonType.d.ts +11 -0
- package/v0/protocol/types/michelson/MichelsonType.js +22 -0
- package/v0/protocol/types/michelson/MichelsonType.js.map +1 -0
- package/v0/protocol/types/michelson/MichelsonTypeMeta.d.ts +33 -0
- package/v0/protocol/types/michelson/MichelsonTypeMeta.js +136 -0
- package/v0/protocol/types/michelson/MichelsonTypeMeta.js.map +1 -0
- package/v0/protocol/types/michelson/MichelsonTypeUtils.d.ts +19 -0
- package/v0/protocol/types/michelson/MichelsonTypeUtils.js +251 -0
- package/v0/protocol/types/michelson/MichelsonTypeUtils.js.map +1 -0
- package/v0/protocol/types/michelson/generics/MichelsonList.d.ts +11 -0
- package/v0/protocol/types/michelson/generics/MichelsonList.js +70 -0
- package/v0/protocol/types/michelson/generics/MichelsonList.js.map +1 -0
- package/v0/protocol/types/michelson/generics/MichelsonMap.d.ts +14 -0
- package/v0/protocol/types/michelson/generics/MichelsonMap.js +120 -0
- package/v0/protocol/types/michelson/generics/MichelsonMap.js.map +1 -0
- package/v0/protocol/types/michelson/generics/MichelsonOption.d.ts +25 -0
- package/v0/protocol/types/michelson/generics/MichelsonOption.js +121 -0
- package/v0/protocol/types/michelson/generics/MichelsonOption.js.map +1 -0
- package/v0/protocol/types/michelson/generics/MichelsonOr.d.ts +25 -0
- package/v0/protocol/types/michelson/generics/MichelsonOr.js +134 -0
- package/v0/protocol/types/michelson/generics/MichelsonOr.js.map +1 -0
- package/v0/protocol/types/michelson/generics/MichelsonPair.d.ts +17 -0
- package/v0/protocol/types/michelson/generics/MichelsonPair.js +139 -0
- package/v0/protocol/types/michelson/generics/MichelsonPair.js.map +1 -0
- package/v0/protocol/types/michelson/grammar/MichelsonGrammarData.d.ts +2 -0
- package/v0/protocol/types/michelson/grammar/MichelsonGrammarData.js +4 -0
- package/v0/protocol/types/michelson/grammar/MichelsonGrammarData.js.map +1 -0
- package/v0/protocol/types/michelson/grammar/MichelsonGrammarInstruction.d.ts +1 -0
- package/v0/protocol/types/michelson/grammar/MichelsonGrammarInstruction.js +4 -0
- package/v0/protocol/types/michelson/grammar/MichelsonGrammarInstruction.js.map +1 -0
- package/v0/protocol/types/michelson/grammar/MichelsonGrammarType.d.ts +1 -0
- package/v0/protocol/types/michelson/grammar/MichelsonGrammarType.js +4 -0
- package/v0/protocol/types/michelson/grammar/MichelsonGrammarType.js.map +1 -0
- package/v0/protocol/types/michelson/primitives/MichelsonAddress.d.ts +15 -0
- package/v0/protocol/types/michelson/primitives/MichelsonAddress.js +74 -0
- package/v0/protocol/types/michelson/primitives/MichelsonAddress.js.map +1 -0
- package/v0/protocol/types/michelson/primitives/MichelsonBool.d.ts +12 -0
- package/v0/protocol/types/michelson/primitives/MichelsonBool.js +59 -0
- package/v0/protocol/types/michelson/primitives/MichelsonBool.js.map +1 -0
- package/v0/protocol/types/michelson/primitives/MichelsonBytes.d.ts +14 -0
- package/v0/protocol/types/michelson/primitives/MichelsonBytes.js +77 -0
- package/v0/protocol/types/michelson/primitives/MichelsonBytes.js.map +1 -0
- package/v0/protocol/types/michelson/primitives/MichelsonInt.d.ts +14 -0
- package/v0/protocol/types/michelson/primitives/MichelsonInt.js +74 -0
- package/v0/protocol/types/michelson/primitives/MichelsonInt.js.map +1 -0
- package/v0/protocol/types/michelson/primitives/MichelsonString.d.ts +14 -0
- package/v0/protocol/types/michelson/primitives/MichelsonString.js +76 -0
- package/v0/protocol/types/michelson/primitives/MichelsonString.js.map +1 -0
- package/v0/protocol/types/michelson/primitives/MichelsonUnit.d.ts +9 -0
- package/v0/protocol/types/michelson/primitives/MichelsonUnit.js +55 -0
- package/v0/protocol/types/michelson/primitives/MichelsonUnit.js.map +1 -0
- package/v0/protocol/types/operations/ActivateAccount.d.ts +7 -0
- package/v0/protocol/types/operations/ActivateAccount.js +3 -0
- package/v0/protocol/types/operations/ActivateAccount.js.map +1 -0
- package/v0/protocol/types/operations/Ballot.d.ts +9 -0
- package/v0/protocol/types/operations/Ballot.js +3 -0
- package/v0/protocol/types/operations/Ballot.js.map +1 -0
- package/v0/protocol/types/operations/Delegation.d.ts +11 -0
- package/v0/protocol/types/operations/Delegation.js +3 -0
- package/v0/protocol/types/operations/Delegation.js.map +1 -0
- package/v0/protocol/types/operations/DoubleBakingEvidence.d.ts +8 -0
- package/v0/protocol/types/operations/DoubleBakingEvidence.js +3 -0
- package/v0/protocol/types/operations/DoubleBakingEvidence.js.map +1 -0
- package/v0/protocol/types/operations/DoubleEndorsementEvidence.d.ts +16 -0
- package/v0/protocol/types/operations/DoubleEndorsementEvidence.js +3 -0
- package/v0/protocol/types/operations/DoubleEndorsementEvidence.js.map +1 -0
- package/v0/protocol/types/operations/Endorsement.d.ts +6 -0
- package/v0/protocol/types/operations/Endorsement.js +3 -0
- package/v0/protocol/types/operations/Endorsement.js.map +1 -0
- package/v0/protocol/types/operations/Origination.d.ts +13 -0
- package/v0/protocol/types/operations/Origination.js +3 -0
- package/v0/protocol/types/operations/Origination.js.map +1 -0
- package/v0/protocol/types/operations/Proposal.d.ts +7 -0
- package/v0/protocol/types/operations/Proposal.js +3 -0
- package/v0/protocol/types/operations/Proposal.js.map +1 -0
- package/v0/protocol/types/operations/Reveal.d.ts +11 -0
- package/v0/protocol/types/operations/Reveal.js +3 -0
- package/v0/protocol/types/operations/Reveal.js.map +1 -0
- package/v0/protocol/types/operations/SeedNonceRevelation.d.ts +7 -0
- package/v0/protocol/types/operations/SeedNonceRevelation.js +3 -0
- package/v0/protocol/types/operations/SeedNonceRevelation.js.map +1 -0
- package/v0/protocol/types/operations/TezosOperation.d.ts +4 -0
- package/v0/protocol/types/operations/TezosOperation.js +3 -0
- package/v0/protocol/types/operations/TezosOperation.js.map +1 -0
- package/v0/protocol/types/operations/Transaction.d.ts +23 -0
- package/v0/protocol/types/operations/Transaction.js +3 -0
- package/v0/protocol/types/operations/Transaction.js.map +1 -0
- package/v0/protocol/types/sapling/TezosSaplingAddressCursor.d.ts +4 -0
- package/v0/protocol/types/sapling/TezosSaplingAddressCursor.js +3 -0
- package/v0/protocol/types/sapling/TezosSaplingAddressCursor.js.map +1 -0
- package/v0/protocol/types/sapling/TezosSaplingAddressResult.d.ts +4 -0
- package/v0/protocol/types/sapling/TezosSaplingAddressResult.js +3 -0
- package/v0/protocol/types/sapling/TezosSaplingAddressResult.js.map +1 -0
- package/v0/protocol/types/sapling/TezosSaplingCiphertext.d.ts +8 -0
- package/v0/protocol/types/sapling/TezosSaplingCiphertext.js +3 -0
- package/v0/protocol/types/sapling/TezosSaplingCiphertext.js.map +1 -0
- package/v0/protocol/types/sapling/TezosSaplingInput.d.ts +6 -0
- package/v0/protocol/types/sapling/TezosSaplingInput.js +3 -0
- package/v0/protocol/types/sapling/TezosSaplingInput.js.map +1 -0
- package/v0/protocol/types/sapling/TezosSaplingOutput.d.ts +6 -0
- package/v0/protocol/types/sapling/TezosSaplingOutput.js +3 -0
- package/v0/protocol/types/sapling/TezosSaplingOutput.js.map +1 -0
- package/v0/protocol/types/sapling/TezosSaplingStateDiff.d.ts +6 -0
- package/v0/protocol/types/sapling/TezosSaplingStateDiff.js +3 -0
- package/v0/protocol/types/sapling/TezosSaplingStateDiff.js.map +1 -0
- package/v0/protocol/types/sapling/TezosSaplingStateTree.d.ts +7 -0
- package/v0/protocol/types/sapling/TezosSaplingStateTree.js +3 -0
- package/v0/protocol/types/sapling/TezosSaplingStateTree.js.map +1 -0
- package/v0/protocol/types/sapling/TezosSaplingTransaction.d.ts +23 -0
- package/v0/protocol/types/sapling/TezosSaplingTransaction.js +3 -0
- package/v0/protocol/types/sapling/TezosSaplingTransaction.js.map +1 -0
- package/v0/protocol/types/sapling/TezosSaplingTransactionCursor.d.ts +3 -0
- package/v0/protocol/types/sapling/TezosSaplingTransactionCursor.js +3 -0
- package/v0/protocol/types/sapling/TezosSaplingTransactionCursor.js.map +1 -0
- package/v0/protocol/types/sapling/TezosSaplingTransactionResult.d.ts +6 -0
- package/v0/protocol/types/sapling/TezosSaplingTransactionResult.js +3 -0
- package/v0/protocol/types/sapling/TezosSaplingTransactionResult.js.map +1 -0
- package/v0/protocol/types/utils.d.ts +8 -0
- package/v0/protocol/types/utils.js +41 -0
- package/v0/protocol/types/utils.js.map +1 -0
- package/v0/serializer/schemas/v2/transaction-sign-request-tezos-sapling.json +127 -0
- package/v0/serializer/schemas/v2/transaction-sign-request-tezos.json +29 -0
- package/v0/serializer/schemas/v2/transaction-sign-response-tezos-sapling.json +19 -0
- package/v0/serializer/schemas/v2/transaction-sign-response-tezos.json +19 -0
- package/v0/serializer/schemas/v3/transaction-sign-request-tezos-sapling.json +133 -0
- package/v0/serializer/schemas/v3/transaction-sign-request-tezos.json +29 -0
- package/v0/serializer/schemas/v3/transaction-sign-response-tezos-sapling.json +19 -0
- package/v0/serializer/schemas/v3/transaction-sign-response-tezos.json +19 -0
- package/v0/serializer/validators/transaction-validator.d.ts +15 -0
- package/v0/serializer/validators/transaction-validator.js +107 -0
- package/v0/serializer/validators/transaction-validator.js.map +1 -0
- package/v0/serializer/validators/transaction-xtz-btc-validator.d.ts +18 -0
- package/v0/serializer/validators/transaction-xtz-btc-validator.js +170 -0
- package/v0/serializer/validators/transaction-xtz-btc-validator.js.map +1 -0
- package/v0/serializer/validators/validators.d.ts +1 -0
- package/v0/serializer/validators/validators.js +115 -0
- package/v0/serializer/validators/validators.js.map +1 -0
- package/v0/types/signed-transaction-tezos-sapling.d.ts +3 -0
- package/v0/types/signed-transaction-tezos-sapling.js +3 -0
- package/v0/types/signed-transaction-tezos-sapling.js.map +1 -0
- package/v0/types/signed-transaction-tezos.d.ts +5 -0
- package/v0/types/signed-transaction-tezos.js +3 -0
- package/v0/types/signed-transaction-tezos.js.map +1 -0
- package/v0/types/transaction-tezos.d.ts +14 -0
- package/v0/types/transaction-tezos.js +3 -0
- package/v0/types/transaction-tezos.js.map +1 -0
- package/v0/types/unsigned-transaction-tezos-sapling.d.ts +38 -0
- package/v0/types/unsigned-transaction-tezos-sapling.js +3 -0
- package/v0/types/unsigned-transaction-tezos-sapling.js.map +1 -0
- package/v0/types/unsigned-transaction-tezos.d.ts +8 -0
- package/v0/types/unsigned-transaction-tezos.js +3 -0
- package/v0/types/unsigned-transaction-tezos.js.map +1 -0
- package/v1/block-explorer/TzKTBlockExplorer.d.ts +9 -0
- package/v1/block-explorer/TzKTBlockExplorer.js +72 -0
- package/v1/block-explorer/TzKTBlockExplorer.js.map +1 -0
- package/v1/block-explorer/factory.d.ts +3 -0
- package/v1/block-explorer/factory.js +17 -0
- package/v1/block-explorer/factory.js.map +1 -0
- package/v1/contract/TezosContract.d.ts +52 -0
- package/v1/contract/TezosContract.js +508 -0
- package/v1/contract/TezosContract.js.map +1 -0
- package/v1/contract/TezosContractCall.d.ts +11 -0
- package/v1/contract/TezosContractCall.js +23 -0
- package/v1/contract/TezosContractCall.js.map +1 -0
- package/v1/contract/TezosContractEntrypoint.d.ts +9 -0
- package/v1/contract/TezosContractEntrypoint.js +27 -0
- package/v1/contract/TezosContractEntrypoint.js.map +1 -0
- package/v1/contract/TezosContractStorage.d.ts +7 -0
- package/v1/contract/TezosContractStorage.js +16 -0
- package/v1/contract/TezosContractStorage.js.map +1 -0
- package/v1/contract/remote-data/TezosContractRemoteDataFactory.d.ts +11 -0
- package/v1/contract/remote-data/TezosContractRemoteDataFactory.js +36 -0
- package/v1/contract/remote-data/TezosContractRemoteDataFactory.js.map +1 -0
- package/v1/contract/remote-data/TezosStorageRemoteData.d.ts +12 -0
- package/v1/contract/remote-data/TezosStorageRemoteData.js +152 -0
- package/v1/contract/remote-data/TezosStorageRemoteData.js.map +1 -0
- package/v1/crypto/TezosCryptoClient.d.ts +13 -0
- package/v1/crypto/TezosCryptoClient.js +153 -0
- package/v1/crypto/TezosCryptoClient.js.map +1 -0
- package/v1/crypto/TezosSaplingCryptoClient.d.ts +25 -0
- package/v1/crypto/TezosSaplingCryptoClient.js +222 -0
- package/v1/crypto/TezosSaplingCryptoClient.js.map +1 -0
- package/v1/data/TezosAddress.d.ts +9 -0
- package/v1/data/TezosAddress.js +27 -0
- package/v1/data/TezosAddress.js.map +1 -0
- package/v1/data/TezosSaplingAddress.d.ts +14 -0
- package/v1/data/TezosSaplingAddress.js +105 -0
- package/v1/data/TezosSaplingAddress.js.map +1 -0
- package/v1/domains/TezosDomains.d.ts +20 -0
- package/v1/domains/TezosDomains.js +309 -0
- package/v1/domains/TezosDomains.js.map +1 -0
- package/v1/index.d.ts +74 -0
- package/v1/index.js +110 -0
- package/v1/index.js.map +1 -0
- package/v1/indexer/TezosIndexerClient.d.ts +31 -0
- package/v1/indexer/TezosIndexerClient.js +3 -0
- package/v1/indexer/TezosIndexerClient.js.map +1 -0
- package/v1/indexer/TzKTIndexerClient.d.ts +31 -0
- package/v1/indexer/TzKTIndexerClient.js +283 -0
- package/v1/indexer/TzKTIndexerClient.js.map +1 -0
- package/v1/indexer/factory.d.ts +3 -0
- package/v1/indexer/factory.js +17 -0
- package/v1/indexer/factory.js.map +1 -0
- package/v1/indexer/token-metadata/BigMapTokenMetadataIndexerClient.d.ts +12 -0
- package/v1/indexer/token-metadata/BigMapTokenMetadataIndexerClient.js +178 -0
- package/v1/indexer/token-metadata/BigMapTokenMetadataIndexerClient.js.map +1 -0
- package/v1/indexer/token-metadata/ObjktTokenMetadataIndexerClient.d.ts +8 -0
- package/v1/indexer/token-metadata/ObjktTokenMetadataIndexerClient.js +95 -0
- package/v1/indexer/token-metadata/ObjktTokenMetadataIndexerClient.js.map +1 -0
- package/v1/indexer/token-metadata/TokenMetadataIndexerClient.d.ts +4 -0
- package/v1/indexer/token-metadata/TokenMetadataIndexerClient.js +3 -0
- package/v1/indexer/token-metadata/TokenMetadataIndexerClient.js.map +1 -0
- package/v1/injector/TezosSaplingInjectorClient.d.ts +6 -0
- package/v1/injector/TezosSaplingInjectorClient.js +68 -0
- package/v1/injector/TezosSaplingInjectorClient.js.map +1 -0
- package/v1/module/TezosModule.d.ts +14 -0
- package/v1/module/TezosModule.js +214 -0
- package/v1/module/TezosModule.js.map +1 -0
- package/v1/module.d.ts +3 -0
- package/v1/module.js +24 -0
- package/v1/module.js.map +1 -0
- package/v1/node/TezosSaplingNodeClient.d.ts +8 -0
- package/v1/node/TezosSaplingNodeClient.js +78 -0
- package/v1/node/TezosSaplingNodeClient.js.map +1 -0
- package/v1/protocol/TezosProtocol.d.ts +114 -0
- package/v1/protocol/TezosProtocol.js +1492 -0
- package/v1/protocol/TezosProtocol.js.map +1 -0
- package/v1/protocol/fa/TezosFA1Protocol.d.ts +43 -0
- package/v1/protocol/fa/TezosFA1Protocol.js +224 -0
- package/v1/protocol/fa/TezosFA1Protocol.js.map +1 -0
- package/v1/protocol/fa/TezosFA1p2Protocol.d.ts +32 -0
- package/v1/protocol/fa/TezosFA1p2Protocol.js +128 -0
- package/v1/protocol/fa/TezosFA1p2Protocol.js.map +1 -0
- package/v1/protocol/fa/TezosFA2Protocol.d.ts +56 -0
- package/v1/protocol/fa/TezosFA2Protocol.js +354 -0
- package/v1/protocol/fa/TezosFA2Protocol.js.map +1 -0
- package/v1/protocol/fa/TezosFAProtocol.d.ts +82 -0
- package/v1/protocol/fa/TezosFAProtocol.js +595 -0
- package/v1/protocol/fa/TezosFAProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/BTCTezProtocol.d.ts +14 -0
- package/v1/protocol/fa/tokens/BTCTezProtocol.js +74 -0
- package/v1/protocol/fa/tokens/BTCTezProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/CTezProtocol.d.ts +14 -0
- package/v1/protocol/fa/tokens/CTezProtocol.js +74 -0
- package/v1/protocol/fa/tokens/CTezProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/DogamiProtocol.d.ts +14 -0
- package/v1/protocol/fa/tokens/DogamiProtocol.js +74 -0
- package/v1/protocol/fa/tokens/DogamiProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/ETHTezProtocol.d.ts +18 -0
- package/v1/protocol/fa/tokens/ETHTezProtocol.js +117 -0
- package/v1/protocol/fa/tokens/ETHTezProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/KolibriUSDProtocol.d.ts +18 -0
- package/v1/protocol/fa/tokens/KolibriUSDProtocol.js +117 -0
- package/v1/protocol/fa/tokens/KolibriUSDProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/PlentyProtocol.d.ts +18 -0
- package/v1/protocol/fa/tokens/PlentyProtocol.js +117 -0
- package/v1/protocol/fa/tokens/PlentyProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/QuipuswapProtocol.d.ts +14 -0
- package/v1/protocol/fa/tokens/QuipuswapProtocol.js +74 -0
- package/v1/protocol/fa/tokens/QuipuswapProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/SiriusProtocol.d.ts +14 -0
- package/v1/protocol/fa/tokens/SiriusProtocol.js +74 -0
- package/v1/protocol/fa/tokens/SiriusProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/StakerProtocol.d.ts +18 -0
- package/v1/protocol/fa/tokens/StakerProtocol.js +117 -0
- package/v1/protocol/fa/tokens/StakerProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/TetherUSDProtocol.d.ts +14 -0
- package/v1/protocol/fa/tokens/TetherUSDProtocol.js +74 -0
- package/v1/protocol/fa/tokens/TetherUSDProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/TzBTCProtocol.d.ts +14 -0
- package/v1/protocol/fa/tokens/TzBTCProtocol.js +74 -0
- package/v1/protocol/fa/tokens/TzBTCProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/UBTCProtocol.d.ts +14 -0
- package/v1/protocol/fa/tokens/UBTCProtocol.js +74 -0
- package/v1/protocol/fa/tokens/UBTCProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/UDEFIProtocol.d.ts +14 -0
- package/v1/protocol/fa/tokens/UDEFIProtocol.js +74 -0
- package/v1/protocol/fa/tokens/UDEFIProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/USDTezProtocol.d.ts +14 -0
- package/v1/protocol/fa/tokens/USDTezProtocol.js +74 -0
- package/v1/protocol/fa/tokens/USDTezProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/UUSDProtocol.d.ts +14 -0
- package/v1/protocol/fa/tokens/UUSDProtocol.js +74 -0
- package/v1/protocol/fa/tokens/UUSDProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/UXTZProtocol.d.ts +14 -0
- package/v1/protocol/fa/tokens/UXTZProtocol.js +74 -0
- package/v1/protocol/fa/tokens/UXTZProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/WrapProtocol.d.ts +14 -0
- package/v1/protocol/fa/tokens/WrapProtocol.js +74 -0
- package/v1/protocol/fa/tokens/WrapProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/WrappedTezosProtocol.d.ts +14 -0
- package/v1/protocol/fa/tokens/WrappedTezosProtocol.js +74 -0
- package/v1/protocol/fa/tokens/WrappedTezosProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/YouProtocol.d.ts +14 -0
- package/v1/protocol/fa/tokens/YouProtocol.js +74 -0
- package/v1/protocol/fa/tokens/YouProtocol.js.map +1 -0
- package/v1/protocol/fa/tokens/stXTZProtocol.d.ts +14 -0
- package/v1/protocol/fa/tokens/stXTZProtocol.js +74 -0
- package/v1/protocol/fa/tokens/stXTZProtocol.js.map +1 -0
- package/v1/protocol/kt/TezosKtProtocol.d.ts +19 -0
- package/v1/protocol/kt/TezosKtProtocol.js +521 -0
- package/v1/protocol/kt/TezosKtProtocol.js.map +1 -0
- package/v1/protocol/sapling/TezosSaplingProtocol.d.ts +108 -0
- package/v1/protocol/sapling/TezosSaplingProtocol.js +1021 -0
- package/v1/protocol/sapling/TezosSaplingProtocol.js.map +1 -0
- package/v1/protocol/sapling/TezosShieldedTezProtocol.d.ts +17 -0
- package/v1/protocol/sapling/TezosShieldedTezProtocol.js +188 -0
- package/v1/protocol/sapling/TezosShieldedTezProtocol.js.map +1 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +13 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +59 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-tezos-sapling.d.ts +4 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-tezos-sapling.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-tezos-sapling.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-tezos.d.ts +8 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-tezos.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-tezos.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-tezos-sapling.d.ts +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-tezos-sapling.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-tezos-sapling.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-tezos.d.ts +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-tezos.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-tezos.js.map +1 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-tezos-sapling.json +145 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-tezos.json +29 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-response-tezos-sapling.json +19 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-response-tezos.json +19 -0
- package/v1/serializer/v3/serializer-companion.d.ts +15 -0
- package/v1/serializer/v3/serializer-companion.js +437 -0
- package/v1/serializer/v3/serializer-companion.js.map +1 -0
- package/v1/serializer/v3/validators/transaction-validator.d.ts +14 -0
- package/v1/serializer/v3/validators/transaction-validator.js +179 -0
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -0
- package/v1/serializer/v3/validators/validators.d.ts +4 -0
- package/v1/serializer/v3/validators/validators.js +108 -0
- package/v1/serializer/v3/validators/validators.js.map +1 -0
- package/v1/types/address.d.ts +7 -0
- package/v1/types/address.js +3 -0
- package/v1/types/address.js.map +1 -0
- package/v1/types/block/TezosBlockHeader.d.ts +13 -0
- package/v1/types/block/TezosBlockHeader.js +3 -0
- package/v1/types/block/TezosBlockHeader.js.map +1 -0
- package/v1/types/block-explorer.d.ts +1 -0
- package/v1/types/block-explorer.js +3 -0
- package/v1/types/block-explorer.js.map +1 -0
- package/v1/types/contract/TezosContractCode.d.ts +5 -0
- package/v1/types/contract/TezosContractCode.js +3 -0
- package/v1/types/contract/TezosContractCode.js.map +1 -0
- package/v1/types/contract/TezosContractMetadata.d.ts +61 -0
- package/v1/types/contract/TezosContractMetadata.js +3 -0
- package/v1/types/contract/TezosContractMetadata.js.map +1 -0
- package/v1/types/contract/bigmap/BigMap.d.ts +7 -0
- package/v1/types/contract/bigmap/BigMap.js +3 -0
- package/v1/types/contract/bigmap/BigMap.js.map +1 -0
- package/v1/types/contract/bigmap/BigMapEnrtyFilter.d.ts +5 -0
- package/v1/types/contract/bigmap/BigMapEnrtyFilter.js +3 -0
- package/v1/types/contract/bigmap/BigMapEnrtyFilter.js.map +1 -0
- package/v1/types/contract/bigmap/BigMapEntry.d.ts +8 -0
- package/v1/types/contract/bigmap/BigMapEntry.js +3 -0
- package/v1/types/contract/bigmap/BigMapEntry.js.map +1 -0
- package/v1/types/contract/bigmap/BigMapRequest.d.ts +10 -0
- package/v1/types/contract/bigmap/BigMapRequest.js +3 -0
- package/v1/types/contract/bigmap/BigMapRequest.js.map +1 -0
- package/v1/types/crypto.d.ts +3 -0
- package/v1/types/crypto.js +3 -0
- package/v1/types/crypto.js.map +1 -0
- package/v1/types/domains/TezosDomainsRecord.d.ts +8 -0
- package/v1/types/domains/TezosDomainsRecord.js +3 -0
- package/v1/types/domains/TezosDomainsRecord.js.map +1 -0
- package/v1/types/domains/TezosDomainsReverseRecord.d.ts +5 -0
- package/v1/types/domains/TezosDomainsReverseRecord.js +3 -0
- package/v1/types/domains/TezosDomainsReverseRecord.js.map +1 -0
- package/v1/types/fa/TezosFA1ContractEntrypoint.d.ts +1 -0
- package/v1/types/fa/TezosFA1ContractEntrypoint.js +3 -0
- package/v1/types/fa/TezosFA1ContractEntrypoint.js.map +1 -0
- package/v1/types/fa/TezosFA1p2ContractEntrypoint.d.ts +2 -0
- package/v1/types/fa/TezosFA1p2ContractEntrypoint.js +3 -0
- package/v1/types/fa/TezosFA1p2ContractEntrypoint.js.map +1 -0
- package/v1/types/fa/TezosFA2BalanceOfRequest.d.ts +4 -0
- package/v1/types/fa/TezosFA2BalanceOfRequest.js +3 -0
- package/v1/types/fa/TezosFA2BalanceOfRequest.js.map +1 -0
- package/v1/types/fa/TezosFA2BalanceOfResponse.d.ts +5 -0
- package/v1/types/fa/TezosFA2BalanceOfResponse.js +3 -0
- package/v1/types/fa/TezosFA2BalanceOfResponse.js.map +1 -0
- package/v1/types/fa/TezosFA2ContractEntrypoint.d.ts +1 -0
- package/v1/types/fa/TezosFA2ContractEntrypoint.js +3 -0
- package/v1/types/fa/TezosFA2ContractEntrypoint.js.map +1 -0
- package/v1/types/fa/TezosFA2TransferRequest.d.ts +8 -0
- package/v1/types/fa/TezosFA2TransferRequest.js +3 -0
- package/v1/types/fa/TezosFA2TransferRequest.js.map +1 -0
- package/v1/types/fa/TezosFA2UpdateOperatorRequest.d.ts +6 -0
- package/v1/types/fa/TezosFA2UpdateOperatorRequest.js +3 -0
- package/v1/types/fa/TezosFA2UpdateOperatorRequest.js.map +1 -0
- package/v1/types/fa/TezosFATokenMetadata.d.ts +6 -0
- package/v1/types/fa/TezosFATokenMetadata.js +3 -0
- package/v1/types/fa/TezosFATokenMetadata.js.map +1 -0
- package/v1/types/indexer.d.ts +1 -0
- package/v1/types/indexer.js +3 -0
- package/v1/types/indexer.js.map +1 -0
- package/v1/types/micheline/MichelineNode.d.ts +15 -0
- package/v1/types/micheline/MichelineNode.js +5 -0
- package/v1/types/micheline/MichelineNode.js.map +1 -0
- package/v1/types/micheline/MichelineNodeUtils.d.ts +6 -0
- package/v1/types/micheline/MichelineNodeUtils.js +40 -0
- package/v1/types/micheline/MichelineNodeUtils.js.map +1 -0
- package/v1/types/michelson/MichelsonType.d.ts +11 -0
- package/v1/types/michelson/MichelsonType.js +22 -0
- package/v1/types/michelson/MichelsonType.js.map +1 -0
- package/v1/types/michelson/MichelsonTypeMeta.d.ts +33 -0
- package/v1/types/michelson/MichelsonTypeMeta.js +136 -0
- package/v1/types/michelson/MichelsonTypeMeta.js.map +1 -0
- package/v1/types/michelson/MichelsonTypeUtils.d.ts +19 -0
- package/v1/types/michelson/MichelsonTypeUtils.js +251 -0
- package/v1/types/michelson/MichelsonTypeUtils.js.map +1 -0
- package/v1/types/michelson/generics/MichelsonList.d.ts +11 -0
- package/v1/types/michelson/generics/MichelsonList.js +70 -0
- package/v1/types/michelson/generics/MichelsonList.js.map +1 -0
- package/v1/types/michelson/generics/MichelsonMap.d.ts +14 -0
- package/v1/types/michelson/generics/MichelsonMap.js +120 -0
- package/v1/types/michelson/generics/MichelsonMap.js.map +1 -0
- package/v1/types/michelson/generics/MichelsonOption.d.ts +25 -0
- package/v1/types/michelson/generics/MichelsonOption.js +121 -0
- package/v1/types/michelson/generics/MichelsonOption.js.map +1 -0
- package/v1/types/michelson/generics/MichelsonOr.d.ts +25 -0
- package/v1/types/michelson/generics/MichelsonOr.js +134 -0
- package/v1/types/michelson/generics/MichelsonOr.js.map +1 -0
- package/v1/types/michelson/generics/MichelsonPair.d.ts +17 -0
- package/v1/types/michelson/generics/MichelsonPair.js +139 -0
- package/v1/types/michelson/generics/MichelsonPair.js.map +1 -0
- package/v1/types/michelson/grammar/MichelsonGrammarData.d.ts +2 -0
- package/v1/types/michelson/grammar/MichelsonGrammarData.js +4 -0
- package/v1/types/michelson/grammar/MichelsonGrammarData.js.map +1 -0
- package/v1/types/michelson/grammar/MichelsonGrammarInstruction.d.ts +1 -0
- package/v1/types/michelson/grammar/MichelsonGrammarInstruction.js +4 -0
- package/v1/types/michelson/grammar/MichelsonGrammarInstruction.js.map +1 -0
- package/v1/types/michelson/grammar/MichelsonGrammarType.d.ts +1 -0
- package/v1/types/michelson/grammar/MichelsonGrammarType.js +4 -0
- package/v1/types/michelson/grammar/MichelsonGrammarType.js.map +1 -0
- package/v1/types/michelson/primitives/MichelsonAddress.d.ts +15 -0
- package/v1/types/michelson/primitives/MichelsonAddress.js +74 -0
- package/v1/types/michelson/primitives/MichelsonAddress.js.map +1 -0
- package/v1/types/michelson/primitives/MichelsonBool.d.ts +12 -0
- package/v1/types/michelson/primitives/MichelsonBool.js +59 -0
- package/v1/types/michelson/primitives/MichelsonBool.js.map +1 -0
- package/v1/types/michelson/primitives/MichelsonBytes.d.ts +14 -0
- package/v1/types/michelson/primitives/MichelsonBytes.js +77 -0
- package/v1/types/michelson/primitives/MichelsonBytes.js.map +1 -0
- package/v1/types/michelson/primitives/MichelsonInt.d.ts +14 -0
- package/v1/types/michelson/primitives/MichelsonInt.js +74 -0
- package/v1/types/michelson/primitives/MichelsonInt.js.map +1 -0
- package/v1/types/michelson/primitives/MichelsonString.d.ts +14 -0
- package/v1/types/michelson/primitives/MichelsonString.js +76 -0
- package/v1/types/michelson/primitives/MichelsonString.js.map +1 -0
- package/v1/types/michelson/primitives/MichelsonUnit.d.ts +9 -0
- package/v1/types/michelson/primitives/MichelsonUnit.js +55 -0
- package/v1/types/michelson/primitives/MichelsonUnit.js.map +1 -0
- package/v1/types/network.d.ts +4 -0
- package/v1/types/network.js +9 -0
- package/v1/types/network.js.map +1 -0
- package/v1/types/node.d.ts +78 -0
- package/v1/types/node.js +3 -0
- package/v1/types/node.js.map +1 -0
- package/v1/types/operations/TezosOperationType.d.ts +13 -0
- package/v1/types/operations/TezosOperationType.js +18 -0
- package/v1/types/operations/TezosOperationType.js.map +1 -0
- package/v1/types/operations/TezosWrappedOperation.d.ts +5 -0
- package/v1/types/operations/TezosWrappedOperation.js +3 -0
- package/v1/types/operations/TezosWrappedOperation.js.map +1 -0
- package/v1/types/operations/kinds/ActivateAccount.d.ts +7 -0
- package/v1/types/operations/kinds/ActivateAccount.js +3 -0
- package/v1/types/operations/kinds/ActivateAccount.js.map +1 -0
- package/v1/types/operations/kinds/Ballot.d.ts +9 -0
- package/v1/types/operations/kinds/Ballot.js +3 -0
- package/v1/types/operations/kinds/Ballot.js.map +1 -0
- package/v1/types/operations/kinds/Delegation.d.ts +11 -0
- package/v1/types/operations/kinds/Delegation.js +3 -0
- package/v1/types/operations/kinds/Delegation.js.map +1 -0
- package/v1/types/operations/kinds/DoubleBakingEvidence.d.ts +8 -0
- package/v1/types/operations/kinds/DoubleBakingEvidence.js +3 -0
- package/v1/types/operations/kinds/DoubleBakingEvidence.js.map +1 -0
- package/v1/types/operations/kinds/DoubleEndorsementEvidence.d.ts +16 -0
- package/v1/types/operations/kinds/DoubleEndorsementEvidence.js +3 -0
- package/v1/types/operations/kinds/DoubleEndorsementEvidence.js.map +1 -0
- package/v1/types/operations/kinds/Endorsement.d.ts +6 -0
- package/v1/types/operations/kinds/Endorsement.js +3 -0
- package/v1/types/operations/kinds/Endorsement.js.map +1 -0
- package/v1/types/operations/kinds/Origination.d.ts +13 -0
- package/v1/types/operations/kinds/Origination.js +3 -0
- package/v1/types/operations/kinds/Origination.js.map +1 -0
- package/v1/types/operations/kinds/Proposal.d.ts +7 -0
- package/v1/types/operations/kinds/Proposal.js +3 -0
- package/v1/types/operations/kinds/Proposal.js.map +1 -0
- package/v1/types/operations/kinds/Reveal.d.ts +11 -0
- package/v1/types/operations/kinds/Reveal.js +3 -0
- package/v1/types/operations/kinds/Reveal.js.map +1 -0
- package/v1/types/operations/kinds/SeedNonceRevelation.d.ts +7 -0
- package/v1/types/operations/kinds/SeedNonceRevelation.js +3 -0
- package/v1/types/operations/kinds/SeedNonceRevelation.js.map +1 -0
- package/v1/types/operations/kinds/TezosOperation.d.ts +4 -0
- package/v1/types/operations/kinds/TezosOperation.js +3 -0
- package/v1/types/operations/kinds/TezosOperation.js.map +1 -0
- package/v1/types/operations/kinds/Transaction.d.ts +24 -0
- package/v1/types/operations/kinds/Transaction.js +3 -0
- package/v1/types/operations/kinds/Transaction.js.map +1 -0
- package/v1/types/protocol.d.ts +77 -0
- package/v1/types/protocol.js +3 -0
- package/v1/types/protocol.js.map +1 -0
- package/v1/types/sapling/TezosSaplingCiphertext.d.ts +8 -0
- package/v1/types/sapling/TezosSaplingCiphertext.js +3 -0
- package/v1/types/sapling/TezosSaplingCiphertext.js.map +1 -0
- package/v1/types/sapling/TezosSaplingExternalMethodProvider.d.ts +10 -0
- package/v1/types/sapling/TezosSaplingExternalMethodProvider.js +3 -0
- package/v1/types/sapling/TezosSaplingExternalMethodProvider.js.map +1 -0
- package/v1/types/sapling/TezosSaplingInput.d.ts +6 -0
- package/v1/types/sapling/TezosSaplingInput.js +3 -0
- package/v1/types/sapling/TezosSaplingInput.js.map +1 -0
- package/v1/types/sapling/TezosSaplingOutput.d.ts +6 -0
- package/v1/types/sapling/TezosSaplingOutput.js +3 -0
- package/v1/types/sapling/TezosSaplingOutput.js.map +1 -0
- package/v1/types/sapling/TezosSaplingStateDiff.d.ts +6 -0
- package/v1/types/sapling/TezosSaplingStateDiff.js +3 -0
- package/v1/types/sapling/TezosSaplingStateDiff.js.map +1 -0
- package/v1/types/sapling/TezosSaplingStateTree.d.ts +7 -0
- package/v1/types/sapling/TezosSaplingStateTree.js +3 -0
- package/v1/types/sapling/TezosSaplingStateTree.js.map +1 -0
- package/v1/types/sapling/TezosSaplingTransaction.d.ts +23 -0
- package/v1/types/sapling/TezosSaplingTransaction.js +3 -0
- package/v1/types/sapling/TezosSaplingTransaction.js.map +1 -0
- package/v1/types/sapling/TezosSaplingTransactionCursor.d.ts +3 -0
- package/v1/types/sapling/TezosSaplingTransactionCursor.js +3 -0
- package/v1/types/sapling/TezosSaplingTransactionCursor.js.map +1 -0
- package/v1/types/sapling/TezosSaplingTransactionResult.d.ts +6 -0
- package/v1/types/sapling/TezosSaplingTransactionResult.js +3 -0
- package/v1/types/sapling/TezosSaplingTransactionResult.js.map +1 -0
- package/v1/types/staking/BakerDetails.d.ts +11 -0
- package/v1/types/staking/BakerDetails.js +3 -0
- package/v1/types/staking/BakerDetails.js.map +1 -0
- package/v1/types/staking/TezosDelegatorAction.d.ts +8 -0
- package/v1/types/staking/TezosDelegatorAction.js +13 -0
- package/v1/types/staking/TezosDelegatorAction.js.map +1 -0
- package/v1/types/transaction.d.ts +30 -0
- package/v1/types/transaction.js +3 -0
- package/v1/types/transaction.js.map +1 -0
- package/v1/utils/address.d.ts +2 -0
- package/v1/utils/address.js +13 -0
- package/v1/utils/address.js.map +1 -0
- package/v1/utils/bip.d.ts +2 -0
- package/v1/utils/bip.js +14 -0
- package/v1/utils/bip.js.map +1 -0
- package/v1/utils/convert.d.ts +4 -0
- package/v1/utils/convert.js +33 -0
- package/v1/utils/convert.js.map +1 -0
- package/v1/utils/encoding.d.ts +52 -0
- package/v1/utils/encoding.js +104 -0
- package/v1/utils/encoding.js.map +1 -0
- package/v1/utils/fa.d.ts +2 -0
- package/v1/utils/fa.js +13 -0
- package/v1/utils/fa.js.map +1 -0
- package/v1/utils/key.d.ts +4 -0
- package/v1/utils/key.js +43 -0
- package/v1/utils/key.js.map +1 -0
- package/v1/utils/micheline.d.ts +8 -0
- package/v1/utils/micheline.js +41 -0
- package/v1/utils/micheline.js.map +1 -0
- package/v1/utils/operations.d.ts +12 -0
- package/v1/utils/operations.js +72 -0
- package/v1/utils/operations.js.map +1 -0
- package/v1/utils/pack.d.ts +10 -0
- package/v1/utils/pack.js +251 -0
- package/v1/utils/pack.js.map +1 -0
- package/v1/utils/protocol/fa/TezosFA1Accountant.d.ts +9 -0
- package/v1/utils/protocol/fa/TezosFA1Accountant.js +76 -0
- package/v1/utils/protocol/fa/TezosFA1Accountant.js.map +1 -0
- package/v1/utils/protocol/fa/TezosFA2Accountant.d.ts +12 -0
- package/v1/utils/protocol/fa/TezosFA2Accountant.js +113 -0
- package/v1/utils/protocol/fa/TezosFA2Accountant.js.map +1 -0
- package/v1/utils/protocol/fa/TezosFAAccountant.d.ts +8 -0
- package/v1/utils/protocol/fa/TezosFAAccountant.js +95 -0
- package/v1/utils/protocol/fa/TezosFAAccountant.js.map +1 -0
- package/v1/utils/protocol/instance.d.ts +19 -0
- package/v1/utils/protocol/instance.js +49 -0
- package/v1/utils/protocol/instance.js.map +1 -0
- package/v1/utils/protocol/sapling/TezosSaplingAccountant.d.ts +32 -0
- package/v1/utils/protocol/sapling/TezosSaplingAccountant.js +589 -0
- package/v1/utils/protocol/sapling/TezosSaplingAccountant.js.map +1 -0
- package/v1/utils/protocol/sapling/TezosSaplingEncoder.d.ts +22 -0
- package/v1/utils/protocol/sapling/TezosSaplingEncoder.js +158 -0
- package/v1/utils/protocol/sapling/TezosSaplingEncoder.js.map +1 -0
- package/v1/utils/protocol/sapling/TezosSaplingForger.d.ts +27 -0
- package/v1/utils/protocol/sapling/TezosSaplingForger.js +304 -0
- package/v1/utils/protocol/sapling/TezosSaplingForger.js.map +1 -0
- package/v1/utils/protocol/sapling/TezosSaplingState.d.ts +17 -0
- package/v1/utils/protocol/sapling/TezosSaplingState.js +266 -0
- package/v1/utils/protocol/sapling/TezosSaplingState.js.map +1 -0
- package/v1/utils/protocol/tezos/TezosAccountant.d.ts +14 -0
- package/v1/utils/protocol/tezos/TezosAccountant.js +177 -0
- package/v1/utils/protocol/tezos/TezosAccountant.js.map +1 -0
- package/v1/utils/protocol/tezos/TezosForger.d.ts +6 -0
- package/v1/utils/protocol/tezos/TezosForger.js +84 -0
- package/v1/utils/protocol/tezos/TezosForger.js.map +1 -0
- package/v1/utils/signature.d.ts +2 -0
- package/v1/utils/signature.js +23 -0
- package/v1/utils/signature.js.map +1 -0
- package/v1/utils/transaction.d.ts +9 -0
- package/v1/utils/transaction.js +26 -0
- package/v1/utils/transaction.js.map +1 -0
|
@@ -0,0 +1,1492 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.createTezosProtocolOptions = exports.TEZOS_GHOSTNET_PROTOCOL_NETWORK = exports.TEZOS_MAINNET_PROTOCOL_NETWORK = exports.createTezosProtocol = exports.TezosProtocolImpl = exports.TEZOS_ACCOUNT_METADATA = exports.TEZOS_DERIVATION_PATH = exports.TEZOS_UNITS = void 0;
|
|
54
|
+
var coinlib_core_1 = require("@wallfree-dev/coinlib-core");
|
|
55
|
+
var index_1 = __importDefault(require("@wallfree-dev/coinlib-core/dependencies/src/axios-0.19.0/index"));
|
|
56
|
+
var bignumber_1 = __importDefault(require("@wallfree-dev/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
57
|
+
var errors_1 = require("@wallfree-dev/coinlib-core/errors");
|
|
58
|
+
var module_kit_1 = require("@wallfree-dev/module-kit");
|
|
59
|
+
var TezosCryptoClient_1 = require("../crypto/TezosCryptoClient");
|
|
60
|
+
var TezosAddress_1 = require("../data/TezosAddress");
|
|
61
|
+
var factory_1 = require("../indexer/factory");
|
|
62
|
+
var network_1 = require("../types/network");
|
|
63
|
+
var TezosOperationType_1 = require("../types/operations/TezosOperationType");
|
|
64
|
+
var TezosDelegatorAction_1 = require("../types/staking/TezosDelegatorAction");
|
|
65
|
+
var key_1 = require("../utils/key");
|
|
66
|
+
var operations_1 = require("../utils/operations");
|
|
67
|
+
var TezosAccountant_1 = require("../utils/protocol/tezos/TezosAccountant");
|
|
68
|
+
var TezosForger_1 = require("../utils/protocol/tezos/TezosForger");
|
|
69
|
+
var signature_1 = require("../utils/signature");
|
|
70
|
+
// Implementation
|
|
71
|
+
var MAX_OPERATIONS_PER_GROUP = 200;
|
|
72
|
+
var MIN_CYCLE_DURATION = 4096 * 60 * 1000; // ms
|
|
73
|
+
// const MAX_GAS_PER_BLOCK: number = 2600000
|
|
74
|
+
var MAX_GAS_PER_BLOCK = 1386666;
|
|
75
|
+
var GAS_LIMIT_PLACEHOLDER = '1040000';
|
|
76
|
+
var STORAGE_LIMIT_PLACEHOLDER = '60000';
|
|
77
|
+
var FEE_PLACEHOLDER = '0';
|
|
78
|
+
var MINIMAL_FEE = 100;
|
|
79
|
+
var MINIMAL_FEE_PER_GAS_UNIT = 0.1;
|
|
80
|
+
var MINIMAL_FEE_PER_BYTE = 1;
|
|
81
|
+
var SELF_BOND_REQUIREMENT = 0.0825; // 8.25%
|
|
82
|
+
exports.TEZOS_UNITS = {
|
|
83
|
+
tez: {
|
|
84
|
+
symbol: { value: 'XTZ', market: 'xtz' },
|
|
85
|
+
decimals: 6
|
|
86
|
+
},
|
|
87
|
+
mutez: {
|
|
88
|
+
symbol: { value: 'mutez' },
|
|
89
|
+
decimals: 0
|
|
90
|
+
},
|
|
91
|
+
nanotez: {
|
|
92
|
+
symbol: { value: 'nanotez' },
|
|
93
|
+
decimals: -3
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
exports.TEZOS_DERIVATION_PATH = "m/44h/1729h/0h/0h";
|
|
97
|
+
exports.TEZOS_ACCOUNT_METADATA = {
|
|
98
|
+
standardDerivationPath: exports.TEZOS_DERIVATION_PATH,
|
|
99
|
+
address: {
|
|
100
|
+
isCaseSensitive: true,
|
|
101
|
+
placeholder: 'tz1...',
|
|
102
|
+
regex: '^((tz1|tz2|tz3|tz4|KT1)[1-9A-Za-z]{33}|zet1[1-9A-Za-z]{65})$'
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
var TezosProtocolImpl = /** @class */ (function () {
|
|
106
|
+
function TezosProtocolImpl(options) {
|
|
107
|
+
this.isTezosProtocol = true;
|
|
108
|
+
// Common
|
|
109
|
+
this.units = exports.TEZOS_UNITS;
|
|
110
|
+
this.feeDefaults = {
|
|
111
|
+
low: (0, module_kit_1.newAmount)(0.00142, 'tez').blockchain(this.units),
|
|
112
|
+
medium: (0, module_kit_1.newAmount)(0.00152, 'tez').blockchain(this.units),
|
|
113
|
+
high: (0, module_kit_1.newAmount)(0.003, 'tez').blockchain(this.units)
|
|
114
|
+
};
|
|
115
|
+
this.metadata = {
|
|
116
|
+
identifier: coinlib_core_1.MainProtocolSymbols.XTZ,
|
|
117
|
+
name: 'Tezos',
|
|
118
|
+
units: this.units,
|
|
119
|
+
mainUnit: 'tez',
|
|
120
|
+
fee: {
|
|
121
|
+
defaults: this.feeDefaults
|
|
122
|
+
},
|
|
123
|
+
account: exports.TEZOS_ACCOUNT_METADATA
|
|
124
|
+
};
|
|
125
|
+
// Offline
|
|
126
|
+
this.cryptoConfiguration = {
|
|
127
|
+
algorithm: 'ed25519'
|
|
128
|
+
};
|
|
129
|
+
this.options = createTezosProtocolOptions(options.network);
|
|
130
|
+
this.forger = new TezosForger_1.TezosForger();
|
|
131
|
+
this.accountant = new TezosAccountant_1.TezosAccountant(this.forger, this.options.network);
|
|
132
|
+
this.indexerClient = (0, factory_1.createTezosIndexerClient)(this.options.network.indexerType, this.options.network.indexerApi);
|
|
133
|
+
this.cryptoClient = new TezosCryptoClient_1.TezosCryptoClient();
|
|
134
|
+
}
|
|
135
|
+
TezosProtocolImpl.prototype.getMetadata = function () {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
+
return __generator(this, function (_a) {
|
|
138
|
+
return [2 /*return*/, this.metadata];
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
TezosProtocolImpl.prototype.getAddressFromPublicKey = function (publicKey) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
144
|
+
return __generator(this, function (_a) {
|
|
145
|
+
return [2 /*return*/, TezosAddress_1.TezosAddress.fromPublicKey(publicKey).asString()];
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
TezosProtocolImpl.prototype.getDetailsFromTransaction = function (transaction, _publicKey) {
|
|
150
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
151
|
+
return __generator(this, function (_a) {
|
|
152
|
+
return [2 /*return*/, this.accountant.getDetailsFromTransaction(transaction)];
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
};
|
|
156
|
+
TezosProtocolImpl.prototype.verifyMessageWithPublicKey = function (message, signature, publicKey) {
|
|
157
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
158
|
+
var encodedSignature, hexPublicKey;
|
|
159
|
+
return __generator(this, function (_a) {
|
|
160
|
+
encodedSignature = (0, signature_1.convertSignature)(signature, 'encoded');
|
|
161
|
+
hexPublicKey = (0, key_1.convertPublicKey)(publicKey, 'hex');
|
|
162
|
+
return [2 /*return*/, this.cryptoClient.verifyMessage(message, encodedSignature.value, hexPublicKey.value)];
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
TezosProtocolImpl.prototype.encryptAsymmetricWithPublicKey = function (payload, publicKey) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
168
|
+
var hexPublicKey;
|
|
169
|
+
return __generator(this, function (_a) {
|
|
170
|
+
hexPublicKey = (0, key_1.convertPublicKey)(publicKey, 'hex');
|
|
171
|
+
return [2 /*return*/, this.cryptoClient.encryptAsymmetric(payload, hexPublicKey.value)];
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
TezosProtocolImpl.prototype.getCryptoConfiguration = function () {
|
|
176
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
177
|
+
return __generator(this, function (_a) {
|
|
178
|
+
return [2 /*return*/, this.cryptoConfiguration];
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
TezosProtocolImpl.prototype.getKeyPairFromDerivative = function (derivative) {
|
|
183
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
184
|
+
return __generator(this, function (_a) {
|
|
185
|
+
// should we maybe return encoded keys, i.e. edsk... and edpk... strings?
|
|
186
|
+
return [2 /*return*/, {
|
|
187
|
+
secretKey: (0, module_kit_1.newSecretKey)(Buffer.concat([Buffer.from(derivative.secretKey, 'hex'), Buffer.from(derivative.publicKey, 'hex')]).toString('hex'), 'hex'),
|
|
188
|
+
publicKey: (0, module_kit_1.newPublicKey)(derivative.publicKey, 'hex')
|
|
189
|
+
}];
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
};
|
|
193
|
+
TezosProtocolImpl.prototype.signTransactionWithSecretKey = function (transaction, secretKey) {
|
|
194
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
195
|
+
var hexSecretKey, binaryTransaction, opSignature, signedOp;
|
|
196
|
+
return __generator(this, function (_a) {
|
|
197
|
+
hexSecretKey = (0, key_1.convertSecretKey)(secretKey, 'hex');
|
|
198
|
+
binaryTransaction = Buffer.from(transaction.binary, 'hex');
|
|
199
|
+
opSignature = this.cryptoClient.operationSignature(Buffer.from(hexSecretKey.value, 'hex'), binaryTransaction);
|
|
200
|
+
signedOp = Buffer.concat([binaryTransaction, opSignature]);
|
|
201
|
+
return [2 /*return*/, (0, module_kit_1.newSignedTransaction)({ binary: signedOp.toString('hex') })];
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
TezosProtocolImpl.prototype.signMessageWithKeyPair = function (message, keyPair) {
|
|
206
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
207
|
+
var hexSecretKey, signature;
|
|
208
|
+
return __generator(this, function (_a) {
|
|
209
|
+
switch (_a.label) {
|
|
210
|
+
case 0:
|
|
211
|
+
hexSecretKey = (0, key_1.convertSecretKey)(keyPair.secretKey, 'hex');
|
|
212
|
+
return [4 /*yield*/, this.cryptoClient.signMessage(message, { privateKey: hexSecretKey.value })];
|
|
213
|
+
case 1:
|
|
214
|
+
signature = _a.sent();
|
|
215
|
+
return [2 /*return*/, (0, module_kit_1.newSignature)(signature, 'encoded')];
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
};
|
|
220
|
+
TezosProtocolImpl.prototype.decryptAsymmetricWithKeyPair = function (payload, keyPair) {
|
|
221
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
222
|
+
var hexSecretKey, hexPublicKey;
|
|
223
|
+
return __generator(this, function (_a) {
|
|
224
|
+
hexSecretKey = (0, key_1.convertSecretKey)(keyPair.secretKey, 'hex');
|
|
225
|
+
hexPublicKey = (0, key_1.convertPublicKey)(keyPair.publicKey, 'hex');
|
|
226
|
+
return [2 /*return*/, this.cryptoClient.decryptAsymmetric(payload, { publicKey: hexPublicKey.value, privateKey: hexSecretKey.value })];
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
TezosProtocolImpl.prototype.encryptAESWithSecretKey = function (payload, secretKey) {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
232
|
+
var hexSecretKey;
|
|
233
|
+
return __generator(this, function (_a) {
|
|
234
|
+
hexSecretKey = (0, key_1.convertSecretKey)(secretKey, 'hex');
|
|
235
|
+
return [2 /*return*/, this.cryptoClient.encryptAES(payload, hexSecretKey.value)];
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
};
|
|
239
|
+
TezosProtocolImpl.prototype.decryptAESWithSecretKey = function (payload, secretKey) {
|
|
240
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
241
|
+
var hexSecretKey;
|
|
242
|
+
return __generator(this, function (_a) {
|
|
243
|
+
hexSecretKey = (0, key_1.convertSecretKey)(secretKey, 'hex');
|
|
244
|
+
return [2 /*return*/, this.cryptoClient.decryptAES(payload, hexSecretKey.value)];
|
|
245
|
+
});
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
// Online
|
|
249
|
+
TezosProtocolImpl.prototype.getNetwork = function () {
|
|
250
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
251
|
+
return __generator(this, function (_a) {
|
|
252
|
+
return [2 /*return*/, this.options.network];
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
};
|
|
256
|
+
TezosProtocolImpl.prototype.getTransactionsForPublicKey = function (publicKey, limit, cursor) {
|
|
257
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
258
|
+
var address;
|
|
259
|
+
return __generator(this, function (_a) {
|
|
260
|
+
switch (_a.label) {
|
|
261
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
262
|
+
case 1:
|
|
263
|
+
address = _a.sent();
|
|
264
|
+
return [2 /*return*/, this.getTransactionsForAddress(address, limit, cursor)];
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
};
|
|
269
|
+
TezosProtocolImpl.prototype.getTransactionsForAddress = function (address, limit, cursor) {
|
|
270
|
+
var _a;
|
|
271
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
272
|
+
var transactions;
|
|
273
|
+
var _this = this;
|
|
274
|
+
return __generator(this, function (_b) {
|
|
275
|
+
switch (_b.label) {
|
|
276
|
+
case 0: return [4 /*yield*/, this.indexerClient.getTransactions(address, limit, cursor === null || cursor === void 0 ? void 0 : cursor.offset)];
|
|
277
|
+
case 1:
|
|
278
|
+
transactions = _b.sent();
|
|
279
|
+
return [2 /*return*/, {
|
|
280
|
+
transactions: transactions.map(function (transaction) { return (__assign(__assign({}, transaction), { network: _this.options.network })); }),
|
|
281
|
+
cursor: {
|
|
282
|
+
hasNext: transactions.length >= limit,
|
|
283
|
+
offset: ((_a = cursor === null || cursor === void 0 ? void 0 : cursor.offset) !== null && _a !== void 0 ? _a : 0) + transactions.length
|
|
284
|
+
}
|
|
285
|
+
}];
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
});
|
|
289
|
+
};
|
|
290
|
+
TezosProtocolImpl.prototype.getBalanceOfPublicKey = function (publicKey) {
|
|
291
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
292
|
+
var address;
|
|
293
|
+
return __generator(this, function (_a) {
|
|
294
|
+
switch (_a.label) {
|
|
295
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
296
|
+
case 1:
|
|
297
|
+
address = _a.sent();
|
|
298
|
+
return [2 /*return*/, this.getBalanceOfAddress(address)];
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
});
|
|
302
|
+
};
|
|
303
|
+
TezosProtocolImpl.prototype.getstakeBalance = function (address) {
|
|
304
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
305
|
+
var data, stakeBalance;
|
|
306
|
+
return __generator(this, function (_a) {
|
|
307
|
+
switch (_a.label) {
|
|
308
|
+
case 0: return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(address, "/staked_balance"))];
|
|
309
|
+
case 1:
|
|
310
|
+
data = (_a.sent()).data;
|
|
311
|
+
stakeBalance = new bignumber_1.default(data ? data : '0');
|
|
312
|
+
return [2 /*return*/, { total: (0, module_kit_1.newAmount)(stakeBalance, 'blockchain') }];
|
|
313
|
+
}
|
|
314
|
+
});
|
|
315
|
+
});
|
|
316
|
+
};
|
|
317
|
+
TezosProtocolImpl.prototype.getUnstakeBalance = function (address) {
|
|
318
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
319
|
+
var data, unstakeBalance;
|
|
320
|
+
return __generator(this, function (_a) {
|
|
321
|
+
switch (_a.label) {
|
|
322
|
+
case 0: return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(address, "/unstaked_frozen_balance"))];
|
|
323
|
+
case 1:
|
|
324
|
+
data = (_a.sent()).data;
|
|
325
|
+
unstakeBalance = new bignumber_1.default(data ? data : '0');
|
|
326
|
+
return [2 /*return*/, { total: (0, module_kit_1.newAmount)(unstakeBalance, 'blockchain') }];
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
});
|
|
330
|
+
};
|
|
331
|
+
TezosProtocolImpl.prototype.getUnfinalizeRequest = function (address) {
|
|
332
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
333
|
+
var data, unfinalizable;
|
|
334
|
+
return __generator(this, function (_a) {
|
|
335
|
+
switch (_a.label) {
|
|
336
|
+
case 0: return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(address, "/unstake_requests"))];
|
|
337
|
+
case 1:
|
|
338
|
+
data = (_a.sent()).data;
|
|
339
|
+
unfinalizable = data
|
|
340
|
+
? data.unfinalizable
|
|
341
|
+
: {
|
|
342
|
+
requests: []
|
|
343
|
+
};
|
|
344
|
+
return [2 /*return*/, unfinalizable];
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
});
|
|
348
|
+
};
|
|
349
|
+
TezosProtocolImpl.prototype.getFinalizeableBalance = function (address) {
|
|
350
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
351
|
+
var data, stakeBalance;
|
|
352
|
+
return __generator(this, function (_a) {
|
|
353
|
+
switch (_a.label) {
|
|
354
|
+
case 0: return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(address, "/unstaked_finalizable_balance"))];
|
|
355
|
+
case 1:
|
|
356
|
+
data = (_a.sent()).data;
|
|
357
|
+
stakeBalance = new bignumber_1.default(data ? data : '0');
|
|
358
|
+
return [2 /*return*/, { total: (0, module_kit_1.newAmount)(stakeBalance, 'blockchain') }];
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
};
|
|
363
|
+
TezosProtocolImpl.prototype.getBalanceOfAddress = function (address) {
|
|
364
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
365
|
+
var transferableBalance, totalBalance, data, _a, stakeBalance, unstakeBalance, finalizeableBalance, error_1, error_2;
|
|
366
|
+
return __generator(this, function (_b) {
|
|
367
|
+
switch (_b.label) {
|
|
368
|
+
case 0:
|
|
369
|
+
transferableBalance = new bignumber_1.default(0);
|
|
370
|
+
totalBalance = new bignumber_1.default(0);
|
|
371
|
+
_b.label = 1;
|
|
372
|
+
case 1:
|
|
373
|
+
_b.trys.push([1, 7, , 8]);
|
|
374
|
+
return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(address, "/balance"))];
|
|
375
|
+
case 2:
|
|
376
|
+
data = (_b.sent()).data;
|
|
377
|
+
_b.label = 3;
|
|
378
|
+
case 3:
|
|
379
|
+
_b.trys.push([3, 5, , 6]);
|
|
380
|
+
return [4 /*yield*/, Promise.all([
|
|
381
|
+
this.getstakeBalance(address),
|
|
382
|
+
this.getUnstakeBalance(address),
|
|
383
|
+
this.getFinalizeableBalance(address)
|
|
384
|
+
])];
|
|
385
|
+
case 4:
|
|
386
|
+
_a = _b.sent(), stakeBalance = _a[0], unstakeBalance = _a[1], finalizeableBalance = _a[2];
|
|
387
|
+
transferableBalance = new bignumber_1.default(data);
|
|
388
|
+
totalBalance = transferableBalance
|
|
389
|
+
.plus(stakeBalance.total.value)
|
|
390
|
+
.plus(unstakeBalance.total.value)
|
|
391
|
+
.plus(finalizeableBalance.total.value);
|
|
392
|
+
return [3 /*break*/, 6];
|
|
393
|
+
case 5:
|
|
394
|
+
error_1 = _b.sent();
|
|
395
|
+
transferableBalance = new bignumber_1.default(data);
|
|
396
|
+
totalBalance = transferableBalance;
|
|
397
|
+
return [3 /*break*/, 6];
|
|
398
|
+
case 6: return [3 /*break*/, 8];
|
|
399
|
+
case 7:
|
|
400
|
+
error_2 = _b.sent();
|
|
401
|
+
// if node returns 404 (which means 'no account found'), go with 0 balance
|
|
402
|
+
if (error_2.response && error_2.response.status !== 404) {
|
|
403
|
+
throw new errors_1.NetworkError(coinlib_core_1.Domain.TEZOS, error_2);
|
|
404
|
+
}
|
|
405
|
+
return [3 /*break*/, 8];
|
|
406
|
+
case 8: return [2 /*return*/, { total: (0, module_kit_1.newAmount)(totalBalance, 'blockchain'), transferable: (0, module_kit_1.newAmount)(transferableBalance, 'blockchain') }];
|
|
407
|
+
}
|
|
408
|
+
});
|
|
409
|
+
});
|
|
410
|
+
};
|
|
411
|
+
TezosProtocolImpl.prototype.getTransactionMaxAmountWithPublicKey = function (publicKey, to, configuration) {
|
|
412
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
413
|
+
var total, adjustedTotal;
|
|
414
|
+
return __generator(this, function (_a) {
|
|
415
|
+
switch (_a.label) {
|
|
416
|
+
case 0: return [4 /*yield*/, this.getBalanceOfPublicKey(publicKey)];
|
|
417
|
+
case 1:
|
|
418
|
+
total = (_a.sent()).total;
|
|
419
|
+
adjustedTotal = new bignumber_1.default((0, module_kit_1.newAmount)(total).convert('mutez', this.units).value).minus(1) // Tezos accounts can never be empty. We must leave at least 1 mutez behind.
|
|
420
|
+
;
|
|
421
|
+
return [2 /*return*/, this.getTansactionMaxAmountWithBalance(publicKey, adjustedTotal, to, configuration === null || configuration === void 0 ? void 0 : configuration.fee)];
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
};
|
|
426
|
+
TezosProtocolImpl.prototype.getTansactionMaxAmountWithBalance = function (publicKey, balance, to, fee) {
|
|
427
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
428
|
+
var maxFee, estimatedFee, error_3, rpcErrors, balanceTooLowError, excess, newMaxBalance, amountWithoutFees;
|
|
429
|
+
return __generator(this, function (_a) {
|
|
430
|
+
switch (_a.label) {
|
|
431
|
+
case 0:
|
|
432
|
+
if (!(fee !== undefined)) return [3 /*break*/, 1];
|
|
433
|
+
maxFee = fee;
|
|
434
|
+
return [3 /*break*/, 4];
|
|
435
|
+
case 1:
|
|
436
|
+
_a.trys.push([1, 3, , 4]);
|
|
437
|
+
return [4 /*yield*/, this.getTransactionFeeWithPublicKey(publicKey, to.map(function (recipient) { return ({
|
|
438
|
+
to: recipient,
|
|
439
|
+
amount: (0, module_kit_1.newAmount)(balance.div(to.length).decimalPlaces(0, bignumber_1.default.ROUND_CEIL), 'blockchain')
|
|
440
|
+
}); }))];
|
|
441
|
+
case 2:
|
|
442
|
+
estimatedFee = _a.sent();
|
|
443
|
+
maxFee = (0, module_kit_1.newAmount)(estimatedFee.medium).blockchain(this.units);
|
|
444
|
+
if (balance.lte(maxFee.value)) {
|
|
445
|
+
maxFee = (0, module_kit_1.newAmount)(0, 'blockchain');
|
|
446
|
+
}
|
|
447
|
+
return [3 /*break*/, 4];
|
|
448
|
+
case 3:
|
|
449
|
+
error_3 = _a.sent();
|
|
450
|
+
if (error_3.code !== undefined && error_3.code === errors_1.ProtocolErrorType.TRANSACTION_FAILED && Array.isArray(error_3.data)) {
|
|
451
|
+
rpcErrors = error_3.data;
|
|
452
|
+
balanceTooLowError = rpcErrors.find(function (error) { return error.id.endsWith('.contract.balance_too_low'); });
|
|
453
|
+
if (balanceTooLowError !== undefined && balanceTooLowError.amount !== undefined && balanceTooLowError.balance !== undefined) {
|
|
454
|
+
excess = new bignumber_1.default(balanceTooLowError.amount).minus(new bignumber_1.default(balanceTooLowError.balance).minus(1));
|
|
455
|
+
newMaxBalance = balance.minus(excess);
|
|
456
|
+
if (newMaxBalance.gt(0)) {
|
|
457
|
+
return [2 /*return*/, this.getTansactionMaxAmountWithBalance(publicKey, newMaxBalance, to, fee)];
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
throw error_3;
|
|
462
|
+
case 4:
|
|
463
|
+
maxFee = (0, module_kit_1.newAmount)(maxFee).blockchain(this.units);
|
|
464
|
+
amountWithoutFees = balance.minus(maxFee.value);
|
|
465
|
+
if (amountWithoutFees.isNegative()) {
|
|
466
|
+
amountWithoutFees = new bignumber_1.default(0);
|
|
467
|
+
}
|
|
468
|
+
return [2 /*return*/, (0, module_kit_1.newAmount)(amountWithoutFees, 'blockchain')];
|
|
469
|
+
}
|
|
470
|
+
});
|
|
471
|
+
});
|
|
472
|
+
};
|
|
473
|
+
TezosProtocolImpl.prototype.getTransactionFeeWithPublicKey = function (publicKey, details, _configuration) {
|
|
474
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
475
|
+
return __generator(this, function (_a) {
|
|
476
|
+
switch (_a.label) {
|
|
477
|
+
case 0: return [4 /*yield*/, this.getTransactionFee(publicKey, details)];
|
|
478
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
479
|
+
}
|
|
480
|
+
});
|
|
481
|
+
});
|
|
482
|
+
};
|
|
483
|
+
TezosProtocolImpl.prototype.getTransactionFee = function (publicKey, details, parameters) {
|
|
484
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
485
|
+
var operations, i, recipient, transaction;
|
|
486
|
+
return __generator(this, function (_a) {
|
|
487
|
+
if (details.length === 0) {
|
|
488
|
+
return [2 /*return*/, this.feeDefaults];
|
|
489
|
+
}
|
|
490
|
+
operations = [];
|
|
491
|
+
for (i = 0; i < details.length; ++i) {
|
|
492
|
+
recipient = details[i].to;
|
|
493
|
+
transaction = {
|
|
494
|
+
kind: TezosOperationType_1.TezosOperationType.TRANSACTION,
|
|
495
|
+
amount: (0, module_kit_1.newAmount)(details[i].amount).blockchain(this.units).value,
|
|
496
|
+
destination: recipient,
|
|
497
|
+
fee: '0',
|
|
498
|
+
parameters: parameters
|
|
499
|
+
};
|
|
500
|
+
operations.push(transaction);
|
|
501
|
+
}
|
|
502
|
+
return [2 /*return*/, this.getOperationFeeDefaults(publicKey, operations)];
|
|
503
|
+
});
|
|
504
|
+
});
|
|
505
|
+
};
|
|
506
|
+
TezosProtocolImpl.prototype.getOperationFeeDefaults = function (publicKey, operations) {
|
|
507
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
508
|
+
var estimated, hasReveal, estimatedFee, feeStepFactor, lowFee, mediumFee, highFee;
|
|
509
|
+
return __generator(this, function (_a) {
|
|
510
|
+
switch (_a.label) {
|
|
511
|
+
case 0: return [4 /*yield*/, this.prepareOperations(publicKey, operations)];
|
|
512
|
+
case 1:
|
|
513
|
+
estimated = _a.sent();
|
|
514
|
+
hasReveal = estimated.contents.some(function (op) { return op.kind === TezosOperationType_1.TezosOperationType.REVEAL; });
|
|
515
|
+
estimatedFee = estimated.contents
|
|
516
|
+
.reduce(function (current, next) {
|
|
517
|
+
if (next.fee !== undefined) {
|
|
518
|
+
return current.plus(new bignumber_1.default(next.fee));
|
|
519
|
+
}
|
|
520
|
+
return current;
|
|
521
|
+
}, new bignumber_1.default(0))
|
|
522
|
+
.minus(hasReveal ? operations_1.REVEAL_FEE : 0)
|
|
523
|
+
.div(hasReveal ? estimated.contents.length - 1 : estimated.contents.length);
|
|
524
|
+
feeStepFactor = new bignumber_1.default(0.2);
|
|
525
|
+
lowFee = estimatedFee;
|
|
526
|
+
mediumFee = lowFee.plus(lowFee.times(feeStepFactor).integerValue(bignumber_1.default.ROUND_FLOOR));
|
|
527
|
+
highFee = mediumFee.plus(mediumFee.times(feeStepFactor).integerValue(bignumber_1.default.ROUND_FLOOR));
|
|
528
|
+
return [2 /*return*/, {
|
|
529
|
+
low: (0, module_kit_1.newAmount)(lowFee, 'blockchain'),
|
|
530
|
+
medium: (0, module_kit_1.newAmount)(mediumFee, 'blockchain'),
|
|
531
|
+
high: (0, module_kit_1.newAmount)(highFee, 'blockchain')
|
|
532
|
+
}];
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
});
|
|
536
|
+
};
|
|
537
|
+
TezosProtocolImpl.prototype.prepareTransactionWithPublicKey = function (publicKey, details, configuration) {
|
|
538
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
539
|
+
var transactions;
|
|
540
|
+
return __generator(this, function (_a) {
|
|
541
|
+
switch (_a.label) {
|
|
542
|
+
case 0:
|
|
543
|
+
if (details.length > MAX_OPERATIONS_PER_GROUP) {
|
|
544
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.TEZOS, "this transaction exceeds the maximum allowed number of transactions per operation (".concat(MAX_OPERATIONS_PER_GROUP, "). Please use the \"prepareTransactionsFromPublicKey\" method instead."));
|
|
545
|
+
}
|
|
546
|
+
return [4 /*yield*/, this.prepareTransactionsWithPublicKey(publicKey, details, configuration)];
|
|
547
|
+
case 1:
|
|
548
|
+
transactions = _a.sent();
|
|
549
|
+
if (transactions.length === 1) {
|
|
550
|
+
return [2 /*return*/, transactions[0]];
|
|
551
|
+
}
|
|
552
|
+
else {
|
|
553
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.TEZOS, 'Transaction could not be prepared. More or less than 1 operations have been generated.');
|
|
554
|
+
}
|
|
555
|
+
return [2 /*return*/];
|
|
556
|
+
}
|
|
557
|
+
});
|
|
558
|
+
});
|
|
559
|
+
};
|
|
560
|
+
TezosProtocolImpl.prototype.broadcastTransaction = function (transaction) {
|
|
561
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
562
|
+
var injectionResponse;
|
|
563
|
+
return __generator(this, function (_a) {
|
|
564
|
+
switch (_a.label) {
|
|
565
|
+
case 0: return [4 /*yield*/, index_1.default
|
|
566
|
+
.post("".concat(this.options.network.rpcUrl, "/injection/operation?chain=main"), JSON.stringify(transaction.binary), {
|
|
567
|
+
headers: { 'content-type': 'application/json' }
|
|
568
|
+
})
|
|
569
|
+
.catch(function (error) {
|
|
570
|
+
throw new errors_1.NetworkError(coinlib_core_1.Domain.TEZOS, error);
|
|
571
|
+
})
|
|
572
|
+
// returns hash if successful
|
|
573
|
+
];
|
|
574
|
+
case 1:
|
|
575
|
+
injectionResponse = (_a.sent()).data;
|
|
576
|
+
// returns hash if successful
|
|
577
|
+
return [2 /*return*/, injectionResponse];
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
});
|
|
581
|
+
};
|
|
582
|
+
// Staking
|
|
583
|
+
TezosProtocolImpl.prototype.getDefaultDelegatee = function () {
|
|
584
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
585
|
+
var activeBakers;
|
|
586
|
+
return __generator(this, function (_a) {
|
|
587
|
+
switch (_a.label) {
|
|
588
|
+
case 0: return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/delegates?active"))];
|
|
589
|
+
case 1:
|
|
590
|
+
activeBakers = (_a.sent()).data;
|
|
591
|
+
return [2 /*return*/, activeBakers[0] || ''];
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
});
|
|
595
|
+
};
|
|
596
|
+
TezosProtocolImpl.prototype.getCurrentDelegateesForPublicKey = function (publicKey) {
|
|
597
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
598
|
+
var address;
|
|
599
|
+
return __generator(this, function (_a) {
|
|
600
|
+
switch (_a.label) {
|
|
601
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
602
|
+
case 1:
|
|
603
|
+
address = _a.sent();
|
|
604
|
+
return [2 /*return*/, this.getCurrentDelegateesForAddress(address)];
|
|
605
|
+
}
|
|
606
|
+
});
|
|
607
|
+
});
|
|
608
|
+
};
|
|
609
|
+
TezosProtocolImpl.prototype.getCurrentDelegateesForAddress = function (address) {
|
|
610
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
611
|
+
var data;
|
|
612
|
+
return __generator(this, function (_a) {
|
|
613
|
+
switch (_a.label) {
|
|
614
|
+
case 0: return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(address))];
|
|
615
|
+
case 1:
|
|
616
|
+
data = (_a.sent()).data;
|
|
617
|
+
return [2 /*return*/, data.delegate ? [data.delegate] : []];
|
|
618
|
+
}
|
|
619
|
+
});
|
|
620
|
+
});
|
|
621
|
+
};
|
|
622
|
+
TezosProtocolImpl.prototype.getDelegateeDetails = function (address) {
|
|
623
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
624
|
+
var response, isBakingActive;
|
|
625
|
+
return __generator(this, function (_a) {
|
|
626
|
+
switch (_a.label) {
|
|
627
|
+
case 0: return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/delegates/").concat(address, "/deactivated"))];
|
|
628
|
+
case 1:
|
|
629
|
+
response = _a.sent();
|
|
630
|
+
isBakingActive = !response.data;
|
|
631
|
+
return [2 /*return*/, {
|
|
632
|
+
status: isBakingActive ? 'Active' : 'Inactive',
|
|
633
|
+
address: address
|
|
634
|
+
}];
|
|
635
|
+
}
|
|
636
|
+
});
|
|
637
|
+
});
|
|
638
|
+
};
|
|
639
|
+
TezosProtocolImpl.prototype.isPublicKeyDelegating = function (publicKey) {
|
|
640
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
641
|
+
var address;
|
|
642
|
+
return __generator(this, function (_a) {
|
|
643
|
+
switch (_a.label) {
|
|
644
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
645
|
+
case 1:
|
|
646
|
+
address = _a.sent();
|
|
647
|
+
return [2 /*return*/, this.isAddressDelegating(address)];
|
|
648
|
+
}
|
|
649
|
+
});
|
|
650
|
+
});
|
|
651
|
+
};
|
|
652
|
+
TezosProtocolImpl.prototype.isAddressDelegating = function (address) {
|
|
653
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
654
|
+
var data;
|
|
655
|
+
return __generator(this, function (_a) {
|
|
656
|
+
switch (_a.label) {
|
|
657
|
+
case 0: return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(address))];
|
|
658
|
+
case 1:
|
|
659
|
+
data = (_a.sent()).data;
|
|
660
|
+
return [2 /*return*/, !!data.delegate];
|
|
661
|
+
}
|
|
662
|
+
});
|
|
663
|
+
});
|
|
664
|
+
};
|
|
665
|
+
TezosProtocolImpl.prototype.getDelegatorDetailsFromPublicKey = function (publicKey) {
|
|
666
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
667
|
+
var address;
|
|
668
|
+
return __generator(this, function (_a) {
|
|
669
|
+
switch (_a.label) {
|
|
670
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
671
|
+
case 1:
|
|
672
|
+
address = _a.sent();
|
|
673
|
+
return [2 /*return*/, this.getDelegatorDetailsFromAddress(address)];
|
|
674
|
+
}
|
|
675
|
+
});
|
|
676
|
+
});
|
|
677
|
+
};
|
|
678
|
+
TezosProtocolImpl.prototype.getDelegatorDetailsFromAddress = function (address) {
|
|
679
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
680
|
+
return __generator(this, function (_a) {
|
|
681
|
+
return [2 /*return*/, this.getDelegatorDetails(address)];
|
|
682
|
+
});
|
|
683
|
+
});
|
|
684
|
+
};
|
|
685
|
+
TezosProtocolImpl.prototype.getDelegationDetailsFromPublicKey = function (publicKey, delegatees) {
|
|
686
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
687
|
+
var address;
|
|
688
|
+
return __generator(this, function (_a) {
|
|
689
|
+
switch (_a.label) {
|
|
690
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
691
|
+
case 1:
|
|
692
|
+
address = _a.sent();
|
|
693
|
+
return [2 /*return*/, this.getDelegationDetailsFromAddress(address, delegatees)];
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
});
|
|
697
|
+
};
|
|
698
|
+
TezosProtocolImpl.prototype.getDelegationDetailsFromAddress = function (address, delegatees) {
|
|
699
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
700
|
+
var bakerAddress, results, delegatorDetails, bakerDetails;
|
|
701
|
+
return __generator(this, function (_a) {
|
|
702
|
+
switch (_a.label) {
|
|
703
|
+
case 0:
|
|
704
|
+
if (delegatees.length > 1) {
|
|
705
|
+
return [2 /*return*/, Promise.reject('Multiple delegation is not supported.')];
|
|
706
|
+
}
|
|
707
|
+
bakerAddress = delegatees[0];
|
|
708
|
+
return [4 /*yield*/, Promise.all([this.getDelegatorDetails(address, bakerAddress), this.getDelegateeDetails(bakerAddress)])];
|
|
709
|
+
case 1:
|
|
710
|
+
results = _a.sent();
|
|
711
|
+
delegatorDetails = results[0];
|
|
712
|
+
bakerDetails = results[1];
|
|
713
|
+
return [2 /*return*/, {
|
|
714
|
+
delegator: delegatorDetails,
|
|
715
|
+
delegatees: [bakerDetails]
|
|
716
|
+
}];
|
|
717
|
+
}
|
|
718
|
+
});
|
|
719
|
+
});
|
|
720
|
+
};
|
|
721
|
+
TezosProtocolImpl.prototype.getDelegatorDetails = function (address, bakerAddress) {
|
|
722
|
+
var _a, _b;
|
|
723
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
724
|
+
var results, accountDetails, stakeBalance, unstakedFinalizableBalance, balance, isDelegating, availableActions;
|
|
725
|
+
return __generator(this, function (_c) {
|
|
726
|
+
switch (_c.label) {
|
|
727
|
+
case 0: return [4 /*yield*/, Promise.all([
|
|
728
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(address)),
|
|
729
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(address, "/staked_balance")),
|
|
730
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(address, "/unstaked_finalizable_balance"))
|
|
731
|
+
// axios.get(`${this.options.network.rpcUrl}/chains/main/blocks/head/context/contracts/${address}/unstaked_frozen_balance`)
|
|
732
|
+
])];
|
|
733
|
+
case 1:
|
|
734
|
+
results = _c.sent();
|
|
735
|
+
accountDetails = results[0].data;
|
|
736
|
+
stakeBalance = new bignumber_1.default((_a = results[1].data) !== null && _a !== void 0 ? _a : 0);
|
|
737
|
+
unstakedFinalizableBalance = new bignumber_1.default((_b = results[2].data) !== null && _b !== void 0 ? _b : 0);
|
|
738
|
+
balance = accountDetails.balance;
|
|
739
|
+
isDelegating = !!accountDetails.delegate;
|
|
740
|
+
availableActions = [];
|
|
741
|
+
if (!isDelegating) {
|
|
742
|
+
availableActions.push({
|
|
743
|
+
type: TezosDelegatorAction_1.TezosDelegatorAction.DELEGATE,
|
|
744
|
+
args: ['delegate']
|
|
745
|
+
});
|
|
746
|
+
if (unstakedFinalizableBalance.gt(0)) {
|
|
747
|
+
availableActions.push({
|
|
748
|
+
type: TezosDelegatorAction_1.TezosDelegatorAction.UNSTAKEFINALIZABLEBALANCE
|
|
749
|
+
});
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
else if (!bakerAddress || accountDetails.delegate === bakerAddress) {
|
|
753
|
+
availableActions.push({
|
|
754
|
+
type: TezosDelegatorAction_1.TezosDelegatorAction.UNDELEGATE
|
|
755
|
+
}, {
|
|
756
|
+
type: TezosDelegatorAction_1.TezosDelegatorAction.STAKE,
|
|
757
|
+
args: ['stake']
|
|
758
|
+
});
|
|
759
|
+
if (stakeBalance.gt(0)) {
|
|
760
|
+
availableActions.push({
|
|
761
|
+
type: TezosDelegatorAction_1.TezosDelegatorAction.UNSTAKE,
|
|
762
|
+
args: ['stake']
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
if (unstakedFinalizableBalance.gt(0)) {
|
|
766
|
+
availableActions.push({
|
|
767
|
+
type: TezosDelegatorAction_1.TezosDelegatorAction.UNSTAKEFINALIZABLEBALANCE
|
|
768
|
+
});
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
else {
|
|
772
|
+
availableActions.push({
|
|
773
|
+
type: TezosDelegatorAction_1.TezosDelegatorAction.CHANGE_BAKER,
|
|
774
|
+
args: ['delegate']
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
return [2 /*return*/, {
|
|
778
|
+
address: address,
|
|
779
|
+
balance: balance,
|
|
780
|
+
delegatees: [accountDetails.delegate],
|
|
781
|
+
availableActions: availableActions
|
|
782
|
+
}];
|
|
783
|
+
}
|
|
784
|
+
});
|
|
785
|
+
});
|
|
786
|
+
};
|
|
787
|
+
TezosProtocolImpl.prototype.prepareTransactions = function (publicKey, details, fee, parameters, operationsPerGroup) {
|
|
788
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
789
|
+
var estimatedFee, wrappedFee, address, operations, results, currentCounter, counter, branch, accountManager, _a, total, transferable, balance, transactions, allOperations, numberOfGroups, startingCounter, i, start, end, operationsGroup, wrappedOperationWithEstimatedGas, forged;
|
|
790
|
+
return __generator(this, function (_b) {
|
|
791
|
+
switch (_b.label) {
|
|
792
|
+
case 0:
|
|
793
|
+
if (!(fee === undefined)) return [3 /*break*/, 2];
|
|
794
|
+
return [4 /*yield*/, this.getTransactionFee(publicKey, details, parameters)];
|
|
795
|
+
case 1:
|
|
796
|
+
estimatedFee = _b.sent();
|
|
797
|
+
fee = estimatedFee.medium;
|
|
798
|
+
_b.label = 2;
|
|
799
|
+
case 2:
|
|
800
|
+
wrappedFee = new bignumber_1.default((0, module_kit_1.newAmount)(fee).blockchain(this.units).value);
|
|
801
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
802
|
+
case 3:
|
|
803
|
+
address = _b.sent();
|
|
804
|
+
operations = [];
|
|
805
|
+
return [4 /*yield*/, Promise.all([
|
|
806
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(address, "/counter")),
|
|
807
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head~2/hash")),
|
|
808
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(address, "/manager_key"))
|
|
809
|
+
]).catch(function (error) {
|
|
810
|
+
throw new errors_1.NetworkError(coinlib_core_1.Domain.TEZOS, error);
|
|
811
|
+
})];
|
|
812
|
+
case 4:
|
|
813
|
+
results = _b.sent();
|
|
814
|
+
currentCounter = new bignumber_1.default(results[0].data);
|
|
815
|
+
counter = currentCounter.plus(1);
|
|
816
|
+
branch = results[1].data;
|
|
817
|
+
accountManager = results[2].data;
|
|
818
|
+
// check if we have revealed the address already
|
|
819
|
+
if (!accountManager) {
|
|
820
|
+
operations.push((0, operations_1.createRevealOperation)(counter, publicKey, address));
|
|
821
|
+
counter = counter.plus(1);
|
|
822
|
+
}
|
|
823
|
+
return [4 /*yield*/, this.getBalanceOfPublicKey(publicKey)];
|
|
824
|
+
case 5:
|
|
825
|
+
_a = _b.sent(), total = _a.total, transferable = _a.transferable;
|
|
826
|
+
balance = new bignumber_1.default((0, module_kit_1.newAmount)(transferable !== null && transferable !== void 0 ? transferable : total).blockchain(this.units).value);
|
|
827
|
+
transactions = [];
|
|
828
|
+
return [4 /*yield*/, this.createTransactionOperations(operations, details, wrappedFee, address, counter, balance, parameters)];
|
|
829
|
+
case 6:
|
|
830
|
+
allOperations = _b.sent();
|
|
831
|
+
allOperations = operations.concat(allOperations); // if we have a reveal in operations, we need to make sure it is present in the allOperations array
|
|
832
|
+
operationsPerGroup = operationsPerGroup !== null && operationsPerGroup !== void 0 ? operationsPerGroup : MAX_OPERATIONS_PER_GROUP;
|
|
833
|
+
numberOfGroups = Math.ceil(allOperations.length / operationsPerGroup);
|
|
834
|
+
startingCounter = numberOfGroups > 1 ? currentCounter.plus(1) : undefined;
|
|
835
|
+
i = 0;
|
|
836
|
+
_b.label = 7;
|
|
837
|
+
case 7:
|
|
838
|
+
if (!(i < numberOfGroups)) return [3 /*break*/, 11];
|
|
839
|
+
start = i * operationsPerGroup;
|
|
840
|
+
end = start + operationsPerGroup;
|
|
841
|
+
operationsGroup = allOperations.slice(start, end);
|
|
842
|
+
return [4 /*yield*/, this.estimateAndReplaceLimitsAndFee({
|
|
843
|
+
branch: branch,
|
|
844
|
+
contents: operationsGroup
|
|
845
|
+
}, false, startingCounter)];
|
|
846
|
+
case 8:
|
|
847
|
+
wrappedOperationWithEstimatedGas = _b.sent();
|
|
848
|
+
return [4 /*yield*/, this.forgeOperation(wrappedOperationWithEstimatedGas)];
|
|
849
|
+
case 9:
|
|
850
|
+
forged = _b.sent();
|
|
851
|
+
transactions.push((0, module_kit_1.newUnsignedTransaction)({ binary: forged }));
|
|
852
|
+
_b.label = 10;
|
|
853
|
+
case 10:
|
|
854
|
+
i++;
|
|
855
|
+
return [3 /*break*/, 7];
|
|
856
|
+
case 11: return [2 /*return*/, transactions];
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
});
|
|
860
|
+
};
|
|
861
|
+
TezosProtocolImpl.prototype.stake = function (publicKey, amount) {
|
|
862
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
863
|
+
var address, details, parameters;
|
|
864
|
+
return __generator(this, function (_a) {
|
|
865
|
+
switch (_a.label) {
|
|
866
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
867
|
+
case 1:
|
|
868
|
+
address = _a.sent();
|
|
869
|
+
details = {
|
|
870
|
+
to: address,
|
|
871
|
+
amount: (0, module_kit_1.newAmount)(amount, 'blockchain')
|
|
872
|
+
};
|
|
873
|
+
parameters = {
|
|
874
|
+
entrypoint: 'stake',
|
|
875
|
+
value: {
|
|
876
|
+
prim: 'Unit'
|
|
877
|
+
}
|
|
878
|
+
};
|
|
879
|
+
return [4 /*yield*/, this.prepareTransactions(publicKey, [details], undefined, parameters)];
|
|
880
|
+
case 2: return [2 /*return*/, (_a.sent())[0]];
|
|
881
|
+
}
|
|
882
|
+
});
|
|
883
|
+
});
|
|
884
|
+
};
|
|
885
|
+
TezosProtocolImpl.prototype.unstake = function (publicKey, amount) {
|
|
886
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
887
|
+
var address, details, parameters;
|
|
888
|
+
return __generator(this, function (_a) {
|
|
889
|
+
switch (_a.label) {
|
|
890
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
891
|
+
case 1:
|
|
892
|
+
address = _a.sent();
|
|
893
|
+
details = {
|
|
894
|
+
to: address,
|
|
895
|
+
amount: (0, module_kit_1.newAmount)(amount, 'blockchain')
|
|
896
|
+
};
|
|
897
|
+
parameters = {
|
|
898
|
+
entrypoint: 'unstake',
|
|
899
|
+
value: {
|
|
900
|
+
prim: 'Unit'
|
|
901
|
+
}
|
|
902
|
+
};
|
|
903
|
+
return [4 /*yield*/, this.prepareTransactions(publicKey, [details], undefined, parameters)];
|
|
904
|
+
case 2: return [2 /*return*/, (_a.sent())[0]];
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
});
|
|
908
|
+
};
|
|
909
|
+
TezosProtocolImpl.prototype.finalizeUnstake = function (publicKey) {
|
|
910
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
911
|
+
var address, details, parameters;
|
|
912
|
+
return __generator(this, function (_a) {
|
|
913
|
+
switch (_a.label) {
|
|
914
|
+
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
915
|
+
case 1:
|
|
916
|
+
address = _a.sent();
|
|
917
|
+
details = {
|
|
918
|
+
to: address,
|
|
919
|
+
amount: (0, module_kit_1.newAmount)('0', 'blockchain')
|
|
920
|
+
};
|
|
921
|
+
parameters = {
|
|
922
|
+
entrypoint: 'finalize_unstake',
|
|
923
|
+
value: {
|
|
924
|
+
prim: 'Unit'
|
|
925
|
+
}
|
|
926
|
+
};
|
|
927
|
+
return [4 /*yield*/, this.prepareTransactions(publicKey, [details], undefined, parameters)];
|
|
928
|
+
case 2: return [2 /*return*/, (_a.sent())[0]];
|
|
929
|
+
}
|
|
930
|
+
});
|
|
931
|
+
});
|
|
932
|
+
};
|
|
933
|
+
TezosProtocolImpl.prototype.prepareDelegatorActionFromPublicKey = function (publicKey, type, data) {
|
|
934
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
935
|
+
var _a;
|
|
936
|
+
return __generator(this, function (_b) {
|
|
937
|
+
switch (_b.label) {
|
|
938
|
+
case 0:
|
|
939
|
+
_a = type;
|
|
940
|
+
switch (_a) {
|
|
941
|
+
case TezosDelegatorAction_1.TezosDelegatorAction.DELEGATE: return [3 /*break*/, 1];
|
|
942
|
+
case TezosDelegatorAction_1.TezosDelegatorAction.CHANGE_BAKER: return [3 /*break*/, 1];
|
|
943
|
+
case TezosDelegatorAction_1.TezosDelegatorAction.UNDELEGATE: return [3 /*break*/, 3];
|
|
944
|
+
case TezosDelegatorAction_1.TezosDelegatorAction.STAKE: return [3 /*break*/, 5];
|
|
945
|
+
case TezosDelegatorAction_1.TezosDelegatorAction.UNSTAKE: return [3 /*break*/, 7];
|
|
946
|
+
case TezosDelegatorAction_1.TezosDelegatorAction.UNSTAKEFINALIZABLEBALANCE: return [3 /*break*/, 9];
|
|
947
|
+
}
|
|
948
|
+
return [3 /*break*/, 11];
|
|
949
|
+
case 1:
|
|
950
|
+
if (!data || !data.delegate) {
|
|
951
|
+
return [2 /*return*/, Promise.reject("Invalid arguments passed for ".concat(type, " action, delegate is missing."))];
|
|
952
|
+
}
|
|
953
|
+
return [4 /*yield*/, this.delegate(publicKey, data.delegate)];
|
|
954
|
+
case 2: return [2 /*return*/, [_b.sent()]];
|
|
955
|
+
case 3: return [4 /*yield*/, this.undelegate(publicKey)];
|
|
956
|
+
case 4: return [2 /*return*/, [_b.sent()]];
|
|
957
|
+
case 5: return [4 /*yield*/, this.stake(publicKey, data.stake)];
|
|
958
|
+
case 6: return [2 /*return*/, [_b.sent()]];
|
|
959
|
+
case 7: return [4 /*yield*/, this.unstake(publicKey, data.stake)];
|
|
960
|
+
case 8: return [2 /*return*/, [_b.sent()]];
|
|
961
|
+
case 9: return [4 /*yield*/, this.finalizeUnstake(publicKey)];
|
|
962
|
+
case 10: return [2 /*return*/, [_b.sent()]];
|
|
963
|
+
case 11: return [2 /*return*/, Promise.reject('Unsupported delegator action.')];
|
|
964
|
+
}
|
|
965
|
+
});
|
|
966
|
+
});
|
|
967
|
+
};
|
|
968
|
+
TezosProtocolImpl.prototype.undelegate = function (publicKey) {
|
|
969
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
970
|
+
return __generator(this, function (_a) {
|
|
971
|
+
return [2 /*return*/, this.delegate(publicKey)];
|
|
972
|
+
});
|
|
973
|
+
});
|
|
974
|
+
};
|
|
975
|
+
TezosProtocolImpl.prototype.delegate = function (publicKey, delegate) {
|
|
976
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
977
|
+
var counter, branch, operations, tzAddress, results, accountManager, balance, totalBalance, fee, delegationOperation, tezosWrappedOperation, binary, error_4;
|
|
978
|
+
return __generator(this, function (_a) {
|
|
979
|
+
switch (_a.label) {
|
|
980
|
+
case 0:
|
|
981
|
+
counter = new bignumber_1.default(1);
|
|
982
|
+
branch = '';
|
|
983
|
+
operations = [];
|
|
984
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
985
|
+
case 1:
|
|
986
|
+
tzAddress = _a.sent();
|
|
987
|
+
return [4 /*yield*/, Promise.all([
|
|
988
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(tzAddress, "/counter")),
|
|
989
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head~2/hash")),
|
|
990
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(tzAddress, "/manager_key"))
|
|
991
|
+
]).catch(function (error) {
|
|
992
|
+
throw new errors_1.NetworkError(coinlib_core_1.Domain.TEZOS, error);
|
|
993
|
+
})];
|
|
994
|
+
case 2:
|
|
995
|
+
results = _a.sent();
|
|
996
|
+
counter = new bignumber_1.default(results[0].data).plus(1);
|
|
997
|
+
branch = results[1].data;
|
|
998
|
+
accountManager = results[2].data;
|
|
999
|
+
// check if we have revealed the address already
|
|
1000
|
+
if (!accountManager) {
|
|
1001
|
+
operations.push((0, operations_1.createRevealOperation)(counter, publicKey, tzAddress));
|
|
1002
|
+
counter = counter.plus(1);
|
|
1003
|
+
}
|
|
1004
|
+
return [4 /*yield*/, this.getBalanceOfAddress(tzAddress)];
|
|
1005
|
+
case 3:
|
|
1006
|
+
balance = _a.sent();
|
|
1007
|
+
totalBalance = new bignumber_1.default((0, module_kit_1.newAmount)(balance.total).blockchain(this.units).value);
|
|
1008
|
+
fee = new bignumber_1.default(1420);
|
|
1009
|
+
if (totalBalance.isLessThan(fee)) {
|
|
1010
|
+
throw new errors_1.BalanceError(coinlib_core_1.Domain.TEZOS, 'not enough balance');
|
|
1011
|
+
}
|
|
1012
|
+
delegationOperation = {
|
|
1013
|
+
kind: TezosOperationType_1.TezosOperationType.DELEGATION,
|
|
1014
|
+
source: tzAddress,
|
|
1015
|
+
fee: fee.toFixed(),
|
|
1016
|
+
counter: counter.toFixed(),
|
|
1017
|
+
gas_limit: '10000',
|
|
1018
|
+
storage_limit: '0',
|
|
1019
|
+
delegate: Array.isArray(delegate) ? delegate[0] : delegate
|
|
1020
|
+
};
|
|
1021
|
+
operations.push(delegationOperation);
|
|
1022
|
+
_a.label = 4;
|
|
1023
|
+
case 4:
|
|
1024
|
+
_a.trys.push([4, 6, , 7]);
|
|
1025
|
+
tezosWrappedOperation = {
|
|
1026
|
+
branch: branch,
|
|
1027
|
+
contents: operations
|
|
1028
|
+
};
|
|
1029
|
+
return [4 /*yield*/, this.forgeOperation(tezosWrappedOperation)];
|
|
1030
|
+
case 5:
|
|
1031
|
+
binary = _a.sent();
|
|
1032
|
+
return [2 /*return*/, (0, module_kit_1.newUnsignedTransaction)({ binary: binary })];
|
|
1033
|
+
case 6:
|
|
1034
|
+
error_4 = _a.sent();
|
|
1035
|
+
throw new errors_1.OperationFailedError(coinlib_core_1.Domain.TEZOS, "Forging Tezos TX failed with ".concat(JSON.stringify(error_4.message)));
|
|
1036
|
+
case 7: return [2 /*return*/];
|
|
1037
|
+
}
|
|
1038
|
+
});
|
|
1039
|
+
});
|
|
1040
|
+
};
|
|
1041
|
+
// Custom
|
|
1042
|
+
TezosProtocolImpl.prototype.getMinCycleDuration = function () {
|
|
1043
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1044
|
+
return __generator(this, function (_a) {
|
|
1045
|
+
return [2 /*return*/, MIN_CYCLE_DURATION];
|
|
1046
|
+
});
|
|
1047
|
+
});
|
|
1048
|
+
};
|
|
1049
|
+
TezosProtocolImpl.prototype.getDetailsFromWrappedOperation = function (wrappedOperation) {
|
|
1050
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1051
|
+
return __generator(this, function (_a) {
|
|
1052
|
+
return [2 /*return*/, this.accountant.getDetailsFromWrappedOperation(wrappedOperation)];
|
|
1053
|
+
});
|
|
1054
|
+
});
|
|
1055
|
+
};
|
|
1056
|
+
TezosProtocolImpl.prototype.forgeOperation = function (wrappedOperation) {
|
|
1057
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1058
|
+
return __generator(this, function (_a) {
|
|
1059
|
+
return [2 /*return*/, this.forger.forgeOperation(wrappedOperation)];
|
|
1060
|
+
});
|
|
1061
|
+
});
|
|
1062
|
+
};
|
|
1063
|
+
TezosProtocolImpl.prototype.unforgeOperation = function (forged, type) {
|
|
1064
|
+
if (type === void 0) { type = 'unsigned'; }
|
|
1065
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1066
|
+
return __generator(this, function (_a) {
|
|
1067
|
+
return [2 /*return*/, this.forger.unforgeOperation(forged, type)];
|
|
1068
|
+
});
|
|
1069
|
+
});
|
|
1070
|
+
};
|
|
1071
|
+
TezosProtocolImpl.prototype.prepareTransactionsWithPublicKey = function (publicKey, details, configuration) {
|
|
1072
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1073
|
+
return __generator(this, function (_a) {
|
|
1074
|
+
switch (_a.label) {
|
|
1075
|
+
case 0: return [4 /*yield*/, this.prepareTransactions(publicKey, details, configuration === null || configuration === void 0 ? void 0 : configuration.fee, undefined, configuration === null || configuration === void 0 ? void 0 : configuration.operationsPerGroup)];
|
|
1076
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
1077
|
+
}
|
|
1078
|
+
});
|
|
1079
|
+
});
|
|
1080
|
+
};
|
|
1081
|
+
TezosProtocolImpl.prototype.prepareOperations = function (publicKey, operationRequests, overrideParameters) {
|
|
1082
|
+
if (overrideParameters === void 0) { overrideParameters = true; }
|
|
1083
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1084
|
+
var counter, branch, operations, address, results, accountManager, hasRevealInOperationRequests, operationPromises, _a, _b, _c, wrappedOperation;
|
|
1085
|
+
var _this = this;
|
|
1086
|
+
return __generator(this, function (_d) {
|
|
1087
|
+
switch (_d.label) {
|
|
1088
|
+
case 0:
|
|
1089
|
+
counter = new bignumber_1.default(1);
|
|
1090
|
+
operations = [];
|
|
1091
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
1092
|
+
case 1:
|
|
1093
|
+
address = _d.sent();
|
|
1094
|
+
return [4 /*yield*/, Promise.all([
|
|
1095
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(address, "/counter")),
|
|
1096
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head~2/hash")),
|
|
1097
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/contracts/").concat(address, "/manager_key"))
|
|
1098
|
+
]).catch(function (error) {
|
|
1099
|
+
throw new errors_1.NetworkError(coinlib_core_1.Domain.TEZOS, error);
|
|
1100
|
+
})];
|
|
1101
|
+
case 2:
|
|
1102
|
+
results = _d.sent();
|
|
1103
|
+
counter = new bignumber_1.default(results[0].data).plus(1);
|
|
1104
|
+
branch = results[1].data;
|
|
1105
|
+
accountManager = results[2].data;
|
|
1106
|
+
hasRevealInOperationRequests = operationRequests.some(function (request) { return request.kind === TezosOperationType_1.TezosOperationType.REVEAL; });
|
|
1107
|
+
// check if we have revealed the address already
|
|
1108
|
+
if (!accountManager && !hasRevealInOperationRequests) {
|
|
1109
|
+
operations.push((0, operations_1.createRevealOperation)(counter, publicKey, address));
|
|
1110
|
+
counter = counter.plus(1);
|
|
1111
|
+
}
|
|
1112
|
+
operationPromises = operationRequests.map(function (operationRequest, index) { return __awaiter(_this, void 0, void 0, function () {
|
|
1113
|
+
var recipient, receivingBalance, total, defaultCounter, defaultFee, defaultGasLimit, defaultStorageLimit, revealOperation, delegationOperation, transactionOperation, originationOperation;
|
|
1114
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
1115
|
+
return __generator(this, function (_w) {
|
|
1116
|
+
switch (_w.label) {
|
|
1117
|
+
case 0:
|
|
1118
|
+
// TODO: Handle activation burn
|
|
1119
|
+
if (!operationRequest.kind) {
|
|
1120
|
+
throw new errors_1.PropertyUndefinedError(coinlib_core_1.Domain.TEZOS, 'property "kind" was not defined');
|
|
1121
|
+
}
|
|
1122
|
+
recipient = operationRequest.destination;
|
|
1123
|
+
if (!(recipient && recipient.toLowerCase().startsWith('tz'))) return [3 /*break*/, 2];
|
|
1124
|
+
return [4 /*yield*/, this.getBalanceOfAddress(recipient)];
|
|
1125
|
+
case 1:
|
|
1126
|
+
total = (_w.sent()).total;
|
|
1127
|
+
receivingBalance = new bignumber_1.default((0, module_kit_1.newAmount)(total).blockchain(this.units).value);
|
|
1128
|
+
_w.label = 2;
|
|
1129
|
+
case 2:
|
|
1130
|
+
defaultCounter = counter.plus(index).toFixed() // TODO: Handle counter if we have some operations without counters in the array
|
|
1131
|
+
;
|
|
1132
|
+
defaultFee = FEE_PLACEHOLDER;
|
|
1133
|
+
defaultGasLimit = '10300';
|
|
1134
|
+
defaultStorageLimit = receivingBalance && receivingBalance.isZero() && recipient && recipient.toLowerCase().startsWith('tz') ? '300' : '0' // taken from eztz
|
|
1135
|
+
;
|
|
1136
|
+
switch (operationRequest.kind) {
|
|
1137
|
+
// TODO: Handle if the dApp already provides a reveal operation
|
|
1138
|
+
case TezosOperationType_1.TezosOperationType.REVEAL:
|
|
1139
|
+
revealOperation = operationRequest;
|
|
1140
|
+
if (!revealOperation.public_key) {
|
|
1141
|
+
throw new errors_1.PropertyUndefinedError(coinlib_core_1.Domain.TEZOS, 'property "public_key" was not defined');
|
|
1142
|
+
}
|
|
1143
|
+
revealOperation.source = (_a = revealOperation.source) !== null && _a !== void 0 ? _a : address;
|
|
1144
|
+
revealOperation.counter = (_b = revealOperation.counter) !== null && _b !== void 0 ? _b : defaultCounter;
|
|
1145
|
+
revealOperation.fee = (_c = revealOperation.fee) !== null && _c !== void 0 ? _c : defaultFee;
|
|
1146
|
+
revealOperation.gas_limit = (_d = revealOperation.gas_limit) !== null && _d !== void 0 ? _d : defaultGasLimit;
|
|
1147
|
+
revealOperation.storage_limit = (_e = revealOperation.storage_limit) !== null && _e !== void 0 ? _e : defaultStorageLimit;
|
|
1148
|
+
return [2 /*return*/, revealOperation];
|
|
1149
|
+
case TezosOperationType_1.TezosOperationType.DELEGATION:
|
|
1150
|
+
delegationOperation = operationRequest;
|
|
1151
|
+
// The delegate property is optional, so we don't have any mandatory properties to check for
|
|
1152
|
+
delegationOperation.source = (_f = delegationOperation.source) !== null && _f !== void 0 ? _f : address;
|
|
1153
|
+
delegationOperation.counter = (_g = delegationOperation.counter) !== null && _g !== void 0 ? _g : defaultCounter;
|
|
1154
|
+
delegationOperation.fee = (_h = delegationOperation.fee) !== null && _h !== void 0 ? _h : defaultFee;
|
|
1155
|
+
delegationOperation.gas_limit = (_j = delegationOperation.gas_limit) !== null && _j !== void 0 ? _j : defaultGasLimit;
|
|
1156
|
+
delegationOperation.storage_limit = (_k = delegationOperation.storage_limit) !== null && _k !== void 0 ? _k : defaultStorageLimit;
|
|
1157
|
+
return [2 /*return*/, delegationOperation];
|
|
1158
|
+
case TezosOperationType_1.TezosOperationType.TRANSACTION:
|
|
1159
|
+
transactionOperation = operationRequest;
|
|
1160
|
+
if (!transactionOperation.amount) {
|
|
1161
|
+
throw new errors_1.PropertyUndefinedError(coinlib_core_1.Domain.TEZOS, 'property "amount" was not defined');
|
|
1162
|
+
}
|
|
1163
|
+
if (!transactionOperation.destination) {
|
|
1164
|
+
throw new errors_1.PropertyUndefinedError(coinlib_core_1.Domain.TEZOS, 'property "destination" was not defined');
|
|
1165
|
+
}
|
|
1166
|
+
transactionOperation.source = (_l = transactionOperation.source) !== null && _l !== void 0 ? _l : address;
|
|
1167
|
+
transactionOperation.counter = (_m = transactionOperation.counter) !== null && _m !== void 0 ? _m : defaultCounter;
|
|
1168
|
+
transactionOperation.fee = (_o = transactionOperation.fee) !== null && _o !== void 0 ? _o : defaultFee;
|
|
1169
|
+
transactionOperation.gas_limit = (_p = transactionOperation.gas_limit) !== null && _p !== void 0 ? _p : GAS_LIMIT_PLACEHOLDER;
|
|
1170
|
+
transactionOperation.storage_limit = (_q = transactionOperation.storage_limit) !== null && _q !== void 0 ? _q : STORAGE_LIMIT_PLACEHOLDER;
|
|
1171
|
+
return [2 /*return*/, transactionOperation];
|
|
1172
|
+
case TezosOperationType_1.TezosOperationType.ORIGINATION:
|
|
1173
|
+
originationOperation = operationRequest;
|
|
1174
|
+
if (!originationOperation.balance) {
|
|
1175
|
+
throw new errors_1.PropertyUndefinedError(coinlib_core_1.Domain.TEZOS, 'property "balance" was not defined');
|
|
1176
|
+
}
|
|
1177
|
+
if (!originationOperation.script) {
|
|
1178
|
+
throw new errors_1.PropertyUndefinedError(coinlib_core_1.Domain.TEZOS, 'property "script" was not defined');
|
|
1179
|
+
}
|
|
1180
|
+
originationOperation.source = (_r = originationOperation.source) !== null && _r !== void 0 ? _r : address;
|
|
1181
|
+
originationOperation.counter = (_s = originationOperation.counter) !== null && _s !== void 0 ? _s : defaultCounter;
|
|
1182
|
+
originationOperation.fee = (_t = originationOperation.fee) !== null && _t !== void 0 ? _t : defaultFee;
|
|
1183
|
+
originationOperation.gas_limit = (_u = originationOperation.gas_limit) !== null && _u !== void 0 ? _u : GAS_LIMIT_PLACEHOLDER;
|
|
1184
|
+
originationOperation.storage_limit = (_v = originationOperation.storage_limit) !== null && _v !== void 0 ? _v : STORAGE_LIMIT_PLACEHOLDER;
|
|
1185
|
+
return [2 /*return*/, originationOperation];
|
|
1186
|
+
case TezosOperationType_1.TezosOperationType.ENDORSEMENT:
|
|
1187
|
+
case TezosOperationType_1.TezosOperationType.SEED_NONCE_REVELATION:
|
|
1188
|
+
case TezosOperationType_1.TezosOperationType.DOUBLE_ENDORSEMENT_EVIDENCE:
|
|
1189
|
+
case TezosOperationType_1.TezosOperationType.DOUBLE_BAKING_EVIDENCE:
|
|
1190
|
+
case TezosOperationType_1.TezosOperationType.ACTIVATE_ACCOUNT:
|
|
1191
|
+
case TezosOperationType_1.TezosOperationType.PROPOSALS:
|
|
1192
|
+
case TezosOperationType_1.TezosOperationType.BALLOT:
|
|
1193
|
+
// Do not change anything
|
|
1194
|
+
return [2 /*return*/, operationRequest];
|
|
1195
|
+
default:
|
|
1196
|
+
(0, coinlib_core_1.assertNever)(operationRequest.kind);
|
|
1197
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.TEZOS, "unsupported operation type \"".concat(JSON.stringify(operationRequest.kind), "\""));
|
|
1198
|
+
}
|
|
1199
|
+
return [2 /*return*/];
|
|
1200
|
+
}
|
|
1201
|
+
});
|
|
1202
|
+
}); });
|
|
1203
|
+
_b = (_a = operations.push).apply;
|
|
1204
|
+
_c = [operations];
|
|
1205
|
+
return [4 /*yield*/, Promise.all(operationPromises)];
|
|
1206
|
+
case 3:
|
|
1207
|
+
_b.apply(_a, _c.concat([(_d.sent())]));
|
|
1208
|
+
wrappedOperation = {
|
|
1209
|
+
branch: branch,
|
|
1210
|
+
contents: operations
|
|
1211
|
+
};
|
|
1212
|
+
return [2 /*return*/, this.estimateAndReplaceLimitsAndFee(wrappedOperation, overrideParameters)];
|
|
1213
|
+
}
|
|
1214
|
+
});
|
|
1215
|
+
});
|
|
1216
|
+
};
|
|
1217
|
+
TezosProtocolImpl.prototype.estimateAndReplaceLimitsAndFee = function (wrappedOperation, overrideParameters, startingCounter) {
|
|
1218
|
+
if (overrideParameters === void 0) { overrideParameters = true; }
|
|
1219
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1220
|
+
var fakeSignature, opKinds, contents, block, body, forgedOperation, gasLimitTotal, response, fee, nonRevealOperations, feePerOperation_1;
|
|
1221
|
+
return __generator(this, function (_a) {
|
|
1222
|
+
switch (_a.label) {
|
|
1223
|
+
case 0:
|
|
1224
|
+
fakeSignature = 'sigUHx32f9wesZ1n2BWpixXz4AQaZggEtchaQNHYGRCoWNAXx45WGW2ua3apUUUAGMLPwAU41QoaFCzVSL61VaessLg4YbbP';
|
|
1225
|
+
opKinds = [
|
|
1226
|
+
TezosOperationType_1.TezosOperationType.TRANSACTION,
|
|
1227
|
+
TezosOperationType_1.TezosOperationType.REVEAL,
|
|
1228
|
+
TezosOperationType_1.TezosOperationType.ORIGINATION,
|
|
1229
|
+
TezosOperationType_1.TezosOperationType.DELEGATION
|
|
1230
|
+
];
|
|
1231
|
+
contents = wrappedOperation.contents.map(function (operation, i) {
|
|
1232
|
+
if (!opKinds.includes(operation.kind)) {
|
|
1233
|
+
return operation;
|
|
1234
|
+
}
|
|
1235
|
+
var op = operation;
|
|
1236
|
+
var gasValue = new bignumber_1.default(MAX_GAS_PER_BLOCK).dividedToIntegerBy(wrappedOperation.contents.length);
|
|
1237
|
+
var gas_limit = new bignumber_1.default(GAS_LIMIT_PLACEHOLDER).gt(gasValue) ? gasValue : GAS_LIMIT_PLACEHOLDER;
|
|
1238
|
+
var counter = startingCounter ? startingCounter.plus(i).toString() : op.counter;
|
|
1239
|
+
return __assign(__assign({}, operation), { gas_limit: gas_limit, counter: counter });
|
|
1240
|
+
});
|
|
1241
|
+
return [4 /*yield*/, index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/header"))];
|
|
1242
|
+
case 1:
|
|
1243
|
+
block = (_a.sent()).data;
|
|
1244
|
+
body = {
|
|
1245
|
+
chain_id: block.chain_id,
|
|
1246
|
+
operation: {
|
|
1247
|
+
branch: wrappedOperation.branch,
|
|
1248
|
+
contents: contents,
|
|
1249
|
+
signature: fakeSignature // signature will not be checked, so it is ok to always use this one
|
|
1250
|
+
}
|
|
1251
|
+
};
|
|
1252
|
+
return [4 /*yield*/, this.forgeOperation(wrappedOperation)];
|
|
1253
|
+
case 2:
|
|
1254
|
+
forgedOperation = _a.sent();
|
|
1255
|
+
gasLimitTotal = 0;
|
|
1256
|
+
return [4 /*yield*/, index_1.default
|
|
1257
|
+
.post("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/helpers/scripts/run_operation"), body, {
|
|
1258
|
+
headers: { 'Content-Type': 'application/json' }
|
|
1259
|
+
})
|
|
1260
|
+
.catch(function (runOperationError) {
|
|
1261
|
+
throw new errors_1.NetworkError(coinlib_core_1.Domain.TEZOS, runOperationError);
|
|
1262
|
+
})];
|
|
1263
|
+
case 3:
|
|
1264
|
+
response = _a.sent();
|
|
1265
|
+
if (wrappedOperation.contents.length !== response.data.contents.length) {
|
|
1266
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.TEZOS, "Run Operation did not return same number of operations. Locally we have ".concat(wrappedOperation.contents.length, ", but got back ").concat(response.data.contents.length));
|
|
1267
|
+
}
|
|
1268
|
+
wrappedOperation.contents.forEach(function (content, i) {
|
|
1269
|
+
var metadata = response.data.contents[i].metadata;
|
|
1270
|
+
if (metadata.operation_result) {
|
|
1271
|
+
var result = metadata.operation_result;
|
|
1272
|
+
var gasLimit_1 = 0;
|
|
1273
|
+
var storageLimit_1 = 0;
|
|
1274
|
+
// If there are internal operations, we first add gas and storage used of internal operations
|
|
1275
|
+
if (metadata.internal_operation_results) {
|
|
1276
|
+
metadata.internal_operation_results.forEach(function (internalOperation) {
|
|
1277
|
+
if (internalOperation === null || internalOperation === void 0 ? void 0 : internalOperation.result) {
|
|
1278
|
+
if (internalOperation.result.errors) {
|
|
1279
|
+
throw new errors_1.TransactionError(coinlib_core_1.Domain.TEZOS, 'An internal operation produced an error', internalOperation.result.errors);
|
|
1280
|
+
}
|
|
1281
|
+
gasLimit_1 += Math.ceil(Number(internalOperation.result.consumed_milligas) / 1000);
|
|
1282
|
+
if (internalOperation.result.paid_storage_size_diff) {
|
|
1283
|
+
storageLimit_1 += Number(internalOperation.result.paid_storage_size_diff);
|
|
1284
|
+
}
|
|
1285
|
+
if (internalOperation.result.originated_contracts) {
|
|
1286
|
+
storageLimit_1 += internalOperation.result.originated_contracts.length * 257;
|
|
1287
|
+
}
|
|
1288
|
+
if (internalOperation.result.allocated_destination_contract) {
|
|
1289
|
+
storageLimit_1 += 257;
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
});
|
|
1293
|
+
}
|
|
1294
|
+
if (result.errors) {
|
|
1295
|
+
throw new errors_1.TransactionError(coinlib_core_1.Domain.TEZOS, 'The operation produced an error', result.errors);
|
|
1296
|
+
}
|
|
1297
|
+
// Add gas and storage used by operation
|
|
1298
|
+
gasLimit_1 += Math.ceil(Number(result.consumed_milligas) / 1000);
|
|
1299
|
+
if (result.paid_storage_size_diff) {
|
|
1300
|
+
storageLimit_1 += Number(result.paid_storage_size_diff);
|
|
1301
|
+
}
|
|
1302
|
+
if (result.originated_contracts) {
|
|
1303
|
+
storageLimit_1 += result.originated_contracts.length * 257;
|
|
1304
|
+
}
|
|
1305
|
+
if (result.allocated_destination_contract) {
|
|
1306
|
+
storageLimit_1 += 257;
|
|
1307
|
+
}
|
|
1308
|
+
// in prepareTransactionsFromPublicKey() we invoke this method with overrideParameters = false
|
|
1309
|
+
if ((content.gas_limit && overrideParameters) || content.gas_limit === GAS_LIMIT_PLACEHOLDER) {
|
|
1310
|
+
;
|
|
1311
|
+
content.gas_limit = gasLimit_1.toString();
|
|
1312
|
+
}
|
|
1313
|
+
if ((content.storage_limit && overrideParameters) || content.storage_limit === STORAGE_LIMIT_PLACEHOLDER) {
|
|
1314
|
+
;
|
|
1315
|
+
content.storage_limit = storageLimit_1.toString();
|
|
1316
|
+
}
|
|
1317
|
+
gasLimitTotal += gasLimit_1;
|
|
1318
|
+
}
|
|
1319
|
+
});
|
|
1320
|
+
if (overrideParameters || wrappedOperation.contents.some(function (operation) { return (operation === null || operation === void 0 ? void 0 : operation.fee) === FEE_PLACEHOLDER; })) {
|
|
1321
|
+
fee = MINIMAL_FEE +
|
|
1322
|
+
MINIMAL_FEE_PER_BYTE * Math.ceil((forgedOperation.length + 128) / 2) + // 128 is the length of a hex signature
|
|
1323
|
+
MINIMAL_FEE_PER_GAS_UNIT * gasLimitTotal +
|
|
1324
|
+
100 // add 100 for safety
|
|
1325
|
+
;
|
|
1326
|
+
nonRevealOperations = wrappedOperation.contents.filter(function (operation) { return operation.kind !== 'reveal'; });
|
|
1327
|
+
feePerOperation_1 = Math.ceil(fee / nonRevealOperations.length);
|
|
1328
|
+
wrappedOperation.contents.forEach(function (content) {
|
|
1329
|
+
if (content.fee && content.kind !== 'reveal') {
|
|
1330
|
+
;
|
|
1331
|
+
content.fee = feePerOperation_1.toString();
|
|
1332
|
+
}
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1335
|
+
return [2 /*return*/, wrappedOperation];
|
|
1336
|
+
}
|
|
1337
|
+
});
|
|
1338
|
+
});
|
|
1339
|
+
};
|
|
1340
|
+
TezosProtocolImpl.prototype.createTransactionOperations = function (previousOperations, details, fee, address, counter, balance, parameters) {
|
|
1341
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1342
|
+
var amountUsedByPreviousOperations, operations, firstValue, i, recipient, value, _a, total, transferable, receivingBalance, spendOperation;
|
|
1343
|
+
return __generator(this, function (_b) {
|
|
1344
|
+
switch (_b.label) {
|
|
1345
|
+
case 0:
|
|
1346
|
+
amountUsedByPreviousOperations = (0, operations_1.getAmountUsedByPreviousOperations)(previousOperations);
|
|
1347
|
+
operations = [];
|
|
1348
|
+
if (!amountUsedByPreviousOperations.isZero()) {
|
|
1349
|
+
firstValue = new bignumber_1.default((0, module_kit_1.newAmount)(details[0].amount).blockchain(this.units).value);
|
|
1350
|
+
if (balance.isLessThan(firstValue.plus(fee).plus(amountUsedByPreviousOperations))) {
|
|
1351
|
+
// if not, make room for the init fee
|
|
1352
|
+
details[0] = __assign(__assign({}, details[0]), { amount: (0, module_kit_1.newAmount)(firstValue.minus(amountUsedByPreviousOperations), 'blockchain') // deduct fee from balance
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
i = 0;
|
|
1357
|
+
_b.label = 1;
|
|
1358
|
+
case 1:
|
|
1359
|
+
if (!(i < details.length)) return [3 /*break*/, 4];
|
|
1360
|
+
recipient = details[i].to;
|
|
1361
|
+
value = new bignumber_1.default((0, module_kit_1.newAmount)(details[i].amount).blockchain(this.units).value);
|
|
1362
|
+
return [4 /*yield*/, this.getBalanceOfAddress(recipient)];
|
|
1363
|
+
case 2:
|
|
1364
|
+
_a = _b.sent(), total = _a.total, transferable = _a.transferable;
|
|
1365
|
+
receivingBalance = new bignumber_1.default((0, module_kit_1.newAmount)(transferable !== null && transferable !== void 0 ? transferable : total).blockchain(this.units).value);
|
|
1366
|
+
// if our receiver has 0 balance, the account is not activated yet.
|
|
1367
|
+
if (receivingBalance.isZero() && recipient.toLowerCase().startsWith('tz')) {
|
|
1368
|
+
// We have to supply an additional 0.257 XTZ fee for storage_limit costs, which gets automatically deducted from the sender so we just have to make sure enough balance is around
|
|
1369
|
+
if (balance.isLessThan(fee.plus(operations_1.ACTIVATION_BURN))) {
|
|
1370
|
+
// If we don't have enough funds to pay the activation + fee, we throw an error
|
|
1371
|
+
throw new errors_1.BalanceError(coinlib_core_1.Domain.TEZOS, 'Insufficient balance to pay activation burn!');
|
|
1372
|
+
}
|
|
1373
|
+
else if (balance.isLessThan(value.plus(fee).plus(operations_1.ACTIVATION_BURN))) {
|
|
1374
|
+
// Check whether the sender has enough to cover the amount to send + fee + activation
|
|
1375
|
+
// If not, we deduct it from amount sent to make room for the activation burn
|
|
1376
|
+
value = value.minus(operations_1.ACTIVATION_BURN); // deduct fee from balance
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
console.log('createTransactionOperations', balance.toString());
|
|
1380
|
+
if (balance.isEqualTo(value.plus(fee))) {
|
|
1381
|
+
// Tezos accounts can never be empty. If user tries to send everything, we must leave 1 mutez behind.
|
|
1382
|
+
value = value.minus(1);
|
|
1383
|
+
}
|
|
1384
|
+
else if (parameters === undefined && balance.isLessThan(value.plus(fee))) {
|
|
1385
|
+
throw new errors_1.BalanceError(coinlib_core_1.Domain.TEZOS, 'not enough balance');
|
|
1386
|
+
}
|
|
1387
|
+
spendOperation = {
|
|
1388
|
+
kind: TezosOperationType_1.TezosOperationType.TRANSACTION,
|
|
1389
|
+
fee: fee.toFixed(),
|
|
1390
|
+
gas_limit: GAS_LIMIT_PLACEHOLDER,
|
|
1391
|
+
storage_limit: STORAGE_LIMIT_PLACEHOLDER,
|
|
1392
|
+
amount: value.toFixed(),
|
|
1393
|
+
counter: counter.plus(i).toFixed(),
|
|
1394
|
+
destination: recipient,
|
|
1395
|
+
source: address,
|
|
1396
|
+
parameters: parameters
|
|
1397
|
+
};
|
|
1398
|
+
operations.push(spendOperation);
|
|
1399
|
+
_b.label = 3;
|
|
1400
|
+
case 3:
|
|
1401
|
+
i++;
|
|
1402
|
+
return [3 /*break*/, 1];
|
|
1403
|
+
case 4: return [2 /*return*/, operations];
|
|
1404
|
+
}
|
|
1405
|
+
});
|
|
1406
|
+
});
|
|
1407
|
+
};
|
|
1408
|
+
TezosProtocolImpl.prototype.bakerDetails = function (address) {
|
|
1409
|
+
var _a, _b, _c, _d, _e;
|
|
1410
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
1411
|
+
var results, tzBalance, delegatedBalance, stakingBalance, totalDelegatedStake, selfBond, stakingCapacity, bakerDetails;
|
|
1412
|
+
return __generator(this, function (_f) {
|
|
1413
|
+
switch (_f.label) {
|
|
1414
|
+
case 0:
|
|
1415
|
+
if (!address ||
|
|
1416
|
+
!(address.toLowerCase().startsWith('tz1') ||
|
|
1417
|
+
address.toLowerCase().startsWith('tz2') ||
|
|
1418
|
+
address.toLowerCase().startsWith('tz3') ||
|
|
1419
|
+
address.toLowerCase().startsWith('tz4'))) {
|
|
1420
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.TEZOS, 'non tz-address supplied');
|
|
1421
|
+
}
|
|
1422
|
+
return [4 /*yield*/, Promise.all([
|
|
1423
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/delegates/").concat(address, "/balance")).catch(function (_error) { return undefined; }),
|
|
1424
|
+
index_1.default
|
|
1425
|
+
.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/delegates/").concat(address, "/full_balance"))
|
|
1426
|
+
.catch(function (_error) { return undefined; }),
|
|
1427
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/delegates/").concat(address, "/delegated_balance")),
|
|
1428
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/delegates/").concat(address, "/staking_balance")),
|
|
1429
|
+
index_1.default.get("".concat(this.options.network.rpcUrl, "/chains/main/blocks/head/context/delegates/").concat(address, "/total_delegated_stake"))
|
|
1430
|
+
]).catch(function (error) {
|
|
1431
|
+
throw new errors_1.NetworkError(coinlib_core_1.Domain.TEZOS, error);
|
|
1432
|
+
})];
|
|
1433
|
+
case 1:
|
|
1434
|
+
results = _f.sent();
|
|
1435
|
+
tzBalance = new bignumber_1.default((_b = ((_a = results[0]) !== null && _a !== void 0 ? _a : results[1])) === null || _b === void 0 ? void 0 : _b.data);
|
|
1436
|
+
delegatedBalance = new bignumber_1.default((_c = results[2]) === null || _c === void 0 ? void 0 : _c.data);
|
|
1437
|
+
stakingBalance = new bignumber_1.default((_d = results[3]) === null || _d === void 0 ? void 0 : _d.data);
|
|
1438
|
+
totalDelegatedStake = new bignumber_1.default((_e = results[4]) === null || _e === void 0 ? void 0 : _e.data);
|
|
1439
|
+
selfBond = stakingBalance.minus(delegatedBalance);
|
|
1440
|
+
stakingCapacity = stakingBalance.div(selfBond.div(SELF_BOND_REQUIREMENT));
|
|
1441
|
+
bakerDetails = {
|
|
1442
|
+
balance: (0, module_kit_1.newAmount)(tzBalance, 'blockchain'),
|
|
1443
|
+
delegatedBalance: (0, module_kit_1.newAmount)(delegatedBalance, 'blockchain'),
|
|
1444
|
+
stakingBalance: (0, module_kit_1.newAmount)(stakingBalance, 'blockchain'),
|
|
1445
|
+
selfBond: (0, module_kit_1.newAmount)(selfBond, 'blockchain'),
|
|
1446
|
+
bakerCapacity: stakingBalance.div(stakingCapacity).toString(),
|
|
1447
|
+
bakerUsage: stakingCapacity.toString(),
|
|
1448
|
+
totalDelegatedStake: (0, module_kit_1.newAmount)(totalDelegatedStake, 'blockchain')
|
|
1449
|
+
};
|
|
1450
|
+
return [2 /*return*/, bakerDetails];
|
|
1451
|
+
}
|
|
1452
|
+
});
|
|
1453
|
+
});
|
|
1454
|
+
};
|
|
1455
|
+
return TezosProtocolImpl;
|
|
1456
|
+
}());
|
|
1457
|
+
exports.TezosProtocolImpl = TezosProtocolImpl;
|
|
1458
|
+
// Factory
|
|
1459
|
+
function createTezosProtocol(options) {
|
|
1460
|
+
if (options === void 0) { options = {}; }
|
|
1461
|
+
return new TezosProtocolImpl(options);
|
|
1462
|
+
}
|
|
1463
|
+
exports.createTezosProtocol = createTezosProtocol;
|
|
1464
|
+
exports.TEZOS_MAINNET_PROTOCOL_NETWORK = {
|
|
1465
|
+
name: 'Mainnet',
|
|
1466
|
+
type: 'mainnet',
|
|
1467
|
+
rpcUrl: 'https://tezos-node.prod.gke.papers.tech',
|
|
1468
|
+
network: network_1.TezosNetwork.MAINNET,
|
|
1469
|
+
blockExplorerUrl: 'https://tzkt.io',
|
|
1470
|
+
blockExplorerType: 'tzkt',
|
|
1471
|
+
indexerApi: 'https://api.tzkt.io',
|
|
1472
|
+
indexerType: 'tzkt'
|
|
1473
|
+
};
|
|
1474
|
+
exports.TEZOS_GHOSTNET_PROTOCOL_NETWORK = {
|
|
1475
|
+
name: 'Ghostnet',
|
|
1476
|
+
type: 'testnet',
|
|
1477
|
+
rpcUrl: 'https://tezos-ghostnet-node.prod.gke.papers.tech',
|
|
1478
|
+
network: network_1.TezosNetwork.GHOSTNET,
|
|
1479
|
+
blockExplorerUrl: 'https://ghostnet.tzkt.io',
|
|
1480
|
+
blockExplorerType: 'tzkt',
|
|
1481
|
+
indexerApi: 'https://api.ghostnet.tzkt.io',
|
|
1482
|
+
indexerType: 'tzkt'
|
|
1483
|
+
};
|
|
1484
|
+
var DEFAULT_TEZOS_PROTOCOL_NETWORK = exports.TEZOS_MAINNET_PROTOCOL_NETWORK;
|
|
1485
|
+
function createTezosProtocolOptions(network) {
|
|
1486
|
+
if (network === void 0) { network = {}; }
|
|
1487
|
+
return {
|
|
1488
|
+
network: __assign(__assign({}, DEFAULT_TEZOS_PROTOCOL_NETWORK), network)
|
|
1489
|
+
};
|
|
1490
|
+
}
|
|
1491
|
+
exports.createTezosProtocolOptions = createTezosProtocolOptions;
|
|
1492
|
+
//# sourceMappingURL=TezosProtocol.js.map
|