@airgap/tezos 0.13.45-beta.1 → 0.13.45-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/v0/actions/GetKtAccountsAction.js +11 -81
- package/v0/actions/GetKtAccountsAction.js.map +1 -1
- package/v0/constants.js +6 -6
- package/v0/constants.js.map +1 -1
- package/v0/index.js +38 -38
- package/v0/index.js.map +1 -1
- package/v0/protocol/TezosAddress.d.ts +0 -1
- package/v0/protocol/TezosAddress.js +41 -81
- package/v0/protocol/TezosAddress.js.map +1 -1
- package/v0/protocol/TezosCryptoClient.d.ts +0 -1
- package/v0/protocol/TezosCryptoClient.js +68 -123
- package/v0/protocol/TezosCryptoClient.js.map +1 -1
- package/v0/protocol/TezosProtocol.js +978 -1631
- package/v0/protocol/TezosProtocol.js.map +1 -1
- package/v0/protocol/TezosProtocolOptions.d.ts +1 -1
- package/v0/protocol/TezosProtocolOptions.js +26 -98
- package/v0/protocol/TezosProtocolOptions.js.map +1 -1
- package/v0/protocol/TezosUtils.d.ts +0 -1
- package/v0/protocol/TezosUtils.js +131 -165
- package/v0/protocol/TezosUtils.js.map +1 -1
- package/v0/protocol/contract/TezosContract.js +243 -472
- package/v0/protocol/contract/TezosContract.js.map +1 -1
- package/v0/protocol/contract/TezosContractCall.js +8 -10
- package/v0/protocol/contract/TezosContractCall.js.map +1 -1
- package/v0/protocol/contract/TezosContractEntrypoint.js +14 -19
- package/v0/protocol/contract/TezosContractEntrypoint.js.map +1 -1
- package/v0/protocol/contract/TezosContractStorage.js +8 -9
- package/v0/protocol/contract/TezosContractStorage.js.map +1 -1
- package/v0/protocol/contract/remote-data/TezosContractRemoteDataFactory.js +8 -25
- package/v0/protocol/contract/remote-data/TezosContractRemoteDataFactory.js.map +1 -1
- package/v0/protocol/contract/remote-data/TezosStorageRemoteData.js +39 -113
- package/v0/protocol/contract/remote-data/TezosStorageRemoteData.js.map +1 -1
- package/v0/protocol/domains/TezosDomains.js +165 -270
- package/v0/protocol/domains/TezosDomains.js.map +1 -1
- package/v0/protocol/fa/TezosBTC.js +19 -98
- package/v0/protocol/fa/TezosBTC.js.map +1 -1
- package/v0/protocol/fa/TezosBTCtez.js +17 -48
- package/v0/protocol/fa/TezosBTCtez.js.map +1 -1
- package/v0/protocol/fa/TezosCTez.js +17 -45
- package/v0/protocol/fa/TezosCTez.js.map +1 -1
- package/v0/protocol/fa/TezosDOGA.js +17 -45
- package/v0/protocol/fa/TezosDOGA.js.map +1 -1
- package/v0/protocol/fa/TezosETHtz.js +10 -68
- package/v0/protocol/fa/TezosETHtz.js.map +1 -1
- package/v0/protocol/fa/TezosFA1Protocol.js +119 -276
- package/v0/protocol/fa/TezosFA1Protocol.js.map +1 -1
- package/v0/protocol/fa/TezosFA1p2Protocol.js +22 -101
- package/v0/protocol/fa/TezosFA1p2Protocol.js.map +1 -1
- package/v0/protocol/fa/TezosFA2Protocol.js +213 -402
- package/v0/protocol/fa/TezosFA2Protocol.js.map +1 -1
- package/v0/protocol/fa/TezosFAProtocol.js +211 -418
- package/v0/protocol/fa/TezosFAProtocol.js.map +1 -1
- package/v0/protocol/fa/TezosFAProtocolOptions.d.ts +2 -2
- package/v0/protocol/fa/TezosFAProtocolOptions.js +92 -195
- package/v0/protocol/fa/TezosFAProtocolOptions.js.map +1 -1
- package/v0/protocol/fa/TezosKolibriUSD.js +11 -70
- package/v0/protocol/fa/TezosKolibriUSD.js.map +1 -1
- package/v0/protocol/fa/TezosPlanty.js +17 -45
- package/v0/protocol/fa/TezosPlanty.js.map +1 -1
- package/v0/protocol/fa/TezosQUIPU.js +17 -48
- package/v0/protocol/fa/TezosQUIPU.js.map +1 -1
- package/v0/protocol/fa/TezosSIRS.js +17 -45
- package/v0/protocol/fa/TezosSIRS.js.map +1 -1
- package/v0/protocol/fa/TezosStaker.js +11 -70
- package/v0/protocol/fa/TezosStaker.js.map +1 -1
- package/v0/protocol/fa/TezosUBTC.js +17 -48
- package/v0/protocol/fa/TezosUBTC.js.map +1 -1
- package/v0/protocol/fa/TezosUDEFI.js +17 -48
- package/v0/protocol/fa/TezosUDEFI.js.map +1 -1
- package/v0/protocol/fa/TezosUSD.js +11 -70
- package/v0/protocol/fa/TezosUSD.js.map +1 -1
- package/v0/protocol/fa/TezosUSDT.js +17 -48
- package/v0/protocol/fa/TezosUSDT.js.map +1 -1
- package/v0/protocol/fa/TezosUUSD.js +8 -27
- package/v0/protocol/fa/TezosUUSD.js.map +1 -1
- package/v0/protocol/fa/TezosUXTZ.js +17 -48
- package/v0/protocol/fa/TezosUXTZ.js.map +1 -1
- package/v0/protocol/fa/TezosWRAP.js +17 -48
- package/v0/protocol/fa/TezosWRAP.js.map +1 -1
- package/v0/protocol/fa/TezosWrapped.js +11 -70
- package/v0/protocol/fa/TezosWrapped.js.map +1 -1
- package/v0/protocol/fa/TezosYOU.js +8 -27
- package/v0/protocol/fa/TezosYOU.js.map +1 -1
- package/v0/protocol/fa/metadata/BigMapTokenMetadataIndexer.js +84 -162
- package/v0/protocol/fa/metadata/BigMapTokenMetadataIndexer.js.map +1 -1
- package/v0/protocol/fa/metadata/ObjktTokenMetadataIndexer.js +37 -87
- package/v0/protocol/fa/metadata/ObjktTokenMetadataIndexer.js.map +1 -1
- package/v0/protocol/indexerClient/TezosIndexerClient.js +115 -259
- package/v0/protocol/indexerClient/TezosIndexerClient.js.map +1 -1
- package/v0/protocol/kt/TezosKtAddress.js +7 -67
- package/v0/protocol/kt/TezosKtAddress.js.map +1 -1
- package/v0/protocol/kt/TezosKtProtocol.js +161 -309
- package/v0/protocol/kt/TezosKtProtocol.js.map +1 -1
- package/v0/protocol/sapling/TezosSaplingAddress.d.ts +0 -1
- package/v0/protocol/sapling/TezosSaplingAddress.js +46 -117
- package/v0/protocol/sapling/TezosSaplingAddress.js.map +1 -1
- package/v0/protocol/sapling/TezosSaplingCryptoClient.d.ts +0 -1
- package/v0/protocol/sapling/TezosSaplingCryptoClient.js +125 -220
- package/v0/protocol/sapling/TezosSaplingCryptoClient.js.map +1 -1
- package/v0/protocol/sapling/TezosSaplingProtocol.d.ts +0 -1
- package/v0/protocol/sapling/TezosSaplingProtocol.js +600 -1127
- package/v0/protocol/sapling/TezosSaplingProtocol.js.map +1 -1
- package/v0/protocol/sapling/TezosSaplingProtocolOptions.d.ts +0 -1
- package/v0/protocol/sapling/TezosSaplingProtocolOptions.js +32 -61
- package/v0/protocol/sapling/TezosSaplingProtocolOptions.js.map +1 -1
- package/v0/protocol/sapling/TezosShieldedTezProtocol.js +50 -134
- package/v0/protocol/sapling/TezosShieldedTezProtocol.js.map +1 -1
- package/v0/protocol/sapling/injector/TezosSaplingInjectorClient.js +10 -56
- package/v0/protocol/sapling/injector/TezosSaplingInjectorClient.js.map +1 -1
- package/v0/protocol/sapling/node/TezosSaplingNodeClient.js +12 -67
- package/v0/protocol/sapling/node/TezosSaplingNodeClient.js.map +1 -1
- package/v0/protocol/sapling/utils/TezosSaplingBookkeeper.d.ts +0 -1
- package/v0/protocol/sapling/utils/TezosSaplingBookkeeper.js +221 -539
- package/v0/protocol/sapling/utils/TezosSaplingBookkeeper.js.map +1 -1
- package/v0/protocol/sapling/utils/TezosSaplingEncoder.d.ts +0 -1
- package/v0/protocol/sapling/utils/TezosSaplingEncoder.js +101 -104
- package/v0/protocol/sapling/utils/TezosSaplingEncoder.js.map +1 -1
- package/v0/protocol/sapling/utils/TezosSaplingForger.d.ts +0 -1
- package/v0/protocol/sapling/utils/TezosSaplingForger.js +107 -266
- package/v0/protocol/sapling/utils/TezosSaplingForger.js.map +1 -1
- package/v0/protocol/sapling/utils/TezosSaplingState.js +110 -239
- package/v0/protocol/sapling/utils/TezosSaplingState.js.map +1 -1
- package/v0/protocol/types/TezosOperationType.js +1 -1
- package/v0/protocol/types/TezosOperationType.js.map +1 -1
- package/v0/protocol/types/contract/BigMapEntry.d.ts +1 -1
- package/v0/protocol/types/contract/TezosContractMetadata.d.ts +2 -2
- package/v0/protocol/types/micheline/MichelineNode.d.ts +7 -7
- package/v0/protocol/types/micheline/MichelineNodeUtils.js +9 -13
- package/v0/protocol/types/micheline/MichelineNodeUtils.js.map +1 -1
- package/v0/protocol/types/michelson/MichelsonType.d.ts +0 -1
- package/v0/protocol/types/michelson/MichelsonType.js +11 -12
- package/v0/protocol/types/michelson/MichelsonType.js.map +1 -1
- package/v0/protocol/types/michelson/MichelsonTypeMeta.js +45 -92
- package/v0/protocol/types/michelson/MichelsonTypeMeta.js.map +1 -1
- package/v0/protocol/types/michelson/MichelsonTypeUtils.d.ts +0 -1
- package/v0/protocol/types/michelson/MichelsonTypeUtils.js +58 -219
- package/v0/protocol/types/michelson/MichelsonTypeUtils.js.map +1 -1
- package/v0/protocol/types/michelson/generics/MichelsonList.js +24 -43
- package/v0/protocol/types/michelson/generics/MichelsonList.js.map +1 -1
- package/v0/protocol/types/michelson/generics/MichelsonMap.js +39 -61
- package/v0/protocol/types/michelson/generics/MichelsonMap.js.map +1 -1
- package/v0/protocol/types/michelson/generics/MichelsonOption.d.ts +1 -1
- package/v0/protocol/types/michelson/generics/MichelsonOption.js +46 -75
- package/v0/protocol/types/michelson/generics/MichelsonOption.js.map +1 -1
- package/v0/protocol/types/michelson/generics/MichelsonOr.d.ts +1 -1
- package/v0/protocol/types/michelson/generics/MichelsonOr.js +50 -76
- package/v0/protocol/types/michelson/generics/MichelsonOr.js.map +1 -1
- package/v0/protocol/types/michelson/generics/MichelsonPair.js +52 -85
- package/v0/protocol/types/michelson/generics/MichelsonPair.js.map +1 -1
- package/v0/protocol/types/michelson/grammar/MichelsonGrammarData.d.ts +1 -1
- package/v0/protocol/types/michelson/grammar/MichelsonGrammarInstruction.d.ts +1 -1
- package/v0/protocol/types/michelson/grammar/MichelsonGrammarType.d.ts +1 -1
- package/v0/protocol/types/michelson/primitives/MichelsonAddress.d.ts +0 -1
- package/v0/protocol/types/michelson/primitives/MichelsonAddress.js +28 -47
- package/v0/protocol/types/michelson/primitives/MichelsonAddress.js.map +1 -1
- package/v0/protocol/types/michelson/primitives/MichelsonBool.js +20 -39
- package/v0/protocol/types/michelson/primitives/MichelsonBool.js.map +1 -1
- package/v0/protocol/types/michelson/primitives/MichelsonBytes.d.ts +0 -1
- package/v0/protocol/types/michelson/primitives/MichelsonBytes.js +35 -54
- package/v0/protocol/types/michelson/primitives/MichelsonBytes.js.map +1 -1
- package/v0/protocol/types/michelson/primitives/MichelsonInt.d.ts +0 -1
- package/v0/protocol/types/michelson/primitives/MichelsonInt.js +30 -49
- package/v0/protocol/types/michelson/primitives/MichelsonInt.js.map +1 -1
- package/v0/protocol/types/michelson/primitives/MichelsonString.d.ts +0 -1
- package/v0/protocol/types/michelson/primitives/MichelsonString.js +33 -52
- package/v0/protocol/types/michelson/primitives/MichelsonString.js.map +1 -1
- package/v0/protocol/types/michelson/primitives/MichelsonUnit.js +14 -34
- package/v0/protocol/types/michelson/primitives/MichelsonUnit.js.map +1 -1
- package/v0/protocol/types/sapling/TezosSaplingStateTree.d.ts +1 -1
- package/v0/protocol/types/sapling/TezosSaplingTransaction.d.ts +0 -1
- package/v0/protocol/types/utils.js +8 -10
- package/v0/protocol/types/utils.js.map +1 -1
- package/v0/serializer/validators/transaction-validator.js +29 -78
- package/v0/serializer/validators/transaction-validator.js.map +1 -1
- package/v0/serializer/validators/transaction-xtz-btc-validator.js +55 -129
- package/v0/serializer/validators/transaction-xtz-btc-validator.js.map +1 -1
- package/v0/serializer/validators/validators.js +43 -103
- package/v0/serializer/validators/validators.js.map +1 -1
- package/v1/block-explorer/TzKTBlockExplorer.js +12 -61
- package/v1/block-explorer/TzKTBlockExplorer.js.map +1 -1
- package/v1/block-explorer/factory.js +4 -5
- package/v1/block-explorer/factory.js.map +1 -1
- package/v1/contract/TezosContract.js +242 -471
- package/v1/contract/TezosContract.js.map +1 -1
- package/v1/contract/TezosContractCall.js +8 -10
- package/v1/contract/TezosContractCall.js.map +1 -1
- package/v1/contract/TezosContractEntrypoint.d.ts +1 -1
- package/v1/contract/TezosContractEntrypoint.js +14 -19
- package/v1/contract/TezosContractEntrypoint.js.map +1 -1
- package/v1/contract/TezosContractStorage.js +8 -9
- package/v1/contract/TezosContractStorage.js.map +1 -1
- package/v1/contract/remote-data/TezosContractRemoteDataFactory.js +8 -25
- package/v1/contract/remote-data/TezosContractRemoteDataFactory.js.map +1 -1
- package/v1/contract/remote-data/TezosStorageRemoteData.js +39 -113
- package/v1/contract/remote-data/TezosStorageRemoteData.js.map +1 -1
- package/v1/crypto/TezosCryptoClient.d.ts +0 -1
- package/v1/crypto/TezosCryptoClient.js +64 -117
- package/v1/crypto/TezosCryptoClient.js.map +1 -1
- package/v1/crypto/TezosSaplingCryptoClient.d.ts +0 -1
- package/v1/crypto/TezosSaplingCryptoClient.js +116 -194
- package/v1/crypto/TezosSaplingCryptoClient.js.map +1 -1
- package/v1/data/TezosAddress.js +13 -14
- package/v1/data/TezosAddress.js.map +1 -1
- package/v1/data/TezosSaplingAddress.d.ts +0 -1
- package/v1/data/TezosSaplingAddress.js +29 -94
- package/v1/data/TezosSaplingAddress.js.map +1 -1
- package/v1/domains/TezosDomains.js +165 -270
- package/v1/domains/TezosDomains.js.map +1 -1
- package/v1/index.js +39 -39
- package/v1/index.js.map +1 -1
- package/v1/indexer/TzKTIndexerClient.js +126 -270
- package/v1/indexer/TzKTIndexerClient.js.map +1 -1
- package/v1/indexer/factory.js +4 -5
- package/v1/indexer/factory.js.map +1 -1
- package/v1/indexer/token-metadata/BigMapTokenMetadataIndexerClient.js +83 -161
- package/v1/indexer/token-metadata/BigMapTokenMetadataIndexerClient.js.map +1 -1
- package/v1/indexer/token-metadata/ObjktTokenMetadataIndexerClient.js +36 -85
- package/v1/indexer/token-metadata/ObjktTokenMetadataIndexerClient.js.map +1 -1
- package/v1/injector/TezosSaplingInjectorClient.js +10 -56
- package/v1/injector/TezosSaplingInjectorClient.js.map +1 -1
- package/v1/module/TezosModule.js +88 -155
- package/v1/module/TezosModule.js.map +1 -1
- package/v1/module.js +2 -3
- package/v1/module.js.map +1 -1
- package/v1/node/TezosSaplingNodeClient.js +12 -67
- package/v1/node/TezosSaplingNodeClient.js.map +1 -1
- package/v1/protocol/TezosProtocol.js +851 -1388
- package/v1/protocol/TezosProtocol.js.map +1 -1
- package/v1/protocol/fa/TezosFA1Protocol.js +81 -205
- package/v1/protocol/fa/TezosFA1Protocol.js.map +1 -1
- package/v1/protocol/fa/TezosFA1p2Protocol.js +32 -111
- package/v1/protocol/fa/TezosFA1p2Protocol.js.map +1 -1
- package/v1/protocol/fa/TezosFA2Protocol.js +174 -332
- package/v1/protocol/fa/TezosFA2Protocol.js.map +1 -1
- package/v1/protocol/fa/TezosFAProtocol.js +255 -528
- package/v1/protocol/fa/TezosFAProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/BTCTezProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/BTCTezProtocol.js +30 -47
- package/v1/protocol/fa/tokens/BTCTezProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/CTezProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/CTezProtocol.js +27 -47
- package/v1/protocol/fa/tokens/CTezProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/DogamiProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/DogamiProtocol.js +27 -47
- package/v1/protocol/fa/tokens/DogamiProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/ETHTezProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/ETHTezProtocol.js +30 -90
- package/v1/protocol/fa/tokens/ETHTezProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/KolibriUSDProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/KolibriUSDProtocol.js +30 -90
- package/v1/protocol/fa/tokens/KolibriUSDProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/PlentyProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/PlentyProtocol.js +30 -90
- package/v1/protocol/fa/tokens/PlentyProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/QuipuswapProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/QuipuswapProtocol.js +30 -47
- package/v1/protocol/fa/tokens/QuipuswapProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/SiriusProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/SiriusProtocol.js +27 -47
- package/v1/protocol/fa/tokens/SiriusProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/StakerProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/StakerProtocol.js +30 -90
- package/v1/protocol/fa/tokens/StakerProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/TetherUSDProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/TetherUSDProtocol.js +30 -47
- package/v1/protocol/fa/tokens/TetherUSDProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/TzBTCProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/TzBTCProtocol.js +27 -47
- package/v1/protocol/fa/tokens/TzBTCProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/UBTCProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/UBTCProtocol.js +30 -47
- package/v1/protocol/fa/tokens/UBTCProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/UDEFIProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/UDEFIProtocol.js +30 -47
- package/v1/protocol/fa/tokens/UDEFIProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/USDTezProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/USDTezProtocol.js +27 -47
- package/v1/protocol/fa/tokens/USDTezProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/UUSDProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/UUSDProtocol.js +30 -47
- package/v1/protocol/fa/tokens/UUSDProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/UXTZProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/UXTZProtocol.js +30 -47
- package/v1/protocol/fa/tokens/UXTZProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/WrapProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/WrapProtocol.js +30 -47
- package/v1/protocol/fa/tokens/WrapProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/WrappedTezosProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/WrappedTezosProtocol.js +27 -47
- package/v1/protocol/fa/tokens/WrappedTezosProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/YouProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/YouProtocol.js +30 -47
- package/v1/protocol/fa/tokens/YouProtocol.js.map +1 -1
- package/v1/protocol/fa/tokens/stXTZProtocol.d.ts +2 -2
- package/v1/protocol/fa/tokens/stXTZProtocol.js +30 -47
- package/v1/protocol/fa/tokens/stXTZProtocol.js.map +1 -1
- package/v1/protocol/kt/TezosKtProtocol.js +254 -498
- package/v1/protocol/kt/TezosKtProtocol.js.map +1 -1
- package/v1/protocol/sapling/TezosSaplingProtocol.d.ts +0 -1
- package/v1/protocol/sapling/TezosSaplingProtocol.js +532 -933
- package/v1/protocol/sapling/TezosSaplingProtocol.js.map +1 -1
- package/v1/protocol/sapling/TezosShieldedTezProtocol.js +72 -164
- package/v1/protocol/sapling/TezosShieldedTezProtocol.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +14 -26
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +103 -188
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/serializer/v3/validators/transaction-validator.js +54 -143
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
- package/v1/serializer/v3/validators/validators.js +40 -100
- package/v1/serializer/v3/validators/validators.js.map +1 -1
- package/v1/types/block-explorer.d.ts +1 -1
- package/v1/types/contract/TezosContractMetadata.d.ts +2 -2
- package/v1/types/contract/bigmap/BigMapEntry.d.ts +1 -1
- package/v1/types/crypto.d.ts +2 -2
- package/v1/types/fa/TezosFA1ContractEntrypoint.d.ts +1 -1
- package/v1/types/fa/TezosFA1p2ContractEntrypoint.d.ts +1 -1
- package/v1/types/fa/TezosFA2ContractEntrypoint.d.ts +1 -1
- package/v1/types/indexer.d.ts +1 -1
- package/v1/types/micheline/MichelineNode.d.ts +7 -7
- package/v1/types/micheline/MichelineNodeUtils.js +9 -13
- package/v1/types/micheline/MichelineNodeUtils.js.map +1 -1
- package/v1/types/michelson/MichelsonType.d.ts +0 -1
- package/v1/types/michelson/MichelsonType.js +11 -12
- package/v1/types/michelson/MichelsonType.js.map +1 -1
- package/v1/types/michelson/MichelsonTypeMeta.js +45 -92
- package/v1/types/michelson/MichelsonTypeMeta.js.map +1 -1
- package/v1/types/michelson/MichelsonTypeUtils.d.ts +0 -1
- package/v1/types/michelson/MichelsonTypeUtils.js +58 -219
- package/v1/types/michelson/MichelsonTypeUtils.js.map +1 -1
- package/v1/types/michelson/generics/MichelsonList.js +24 -43
- package/v1/types/michelson/generics/MichelsonList.js.map +1 -1
- package/v1/types/michelson/generics/MichelsonMap.js +39 -61
- package/v1/types/michelson/generics/MichelsonMap.js.map +1 -1
- package/v1/types/michelson/generics/MichelsonOption.d.ts +1 -1
- package/v1/types/michelson/generics/MichelsonOption.js +46 -75
- package/v1/types/michelson/generics/MichelsonOption.js.map +1 -1
- package/v1/types/michelson/generics/MichelsonOr.d.ts +1 -1
- package/v1/types/michelson/generics/MichelsonOr.js +50 -76
- package/v1/types/michelson/generics/MichelsonOr.js.map +1 -1
- package/v1/types/michelson/generics/MichelsonPair.js +52 -85
- package/v1/types/michelson/generics/MichelsonPair.js.map +1 -1
- package/v1/types/michelson/grammar/MichelsonGrammarData.d.ts +1 -1
- package/v1/types/michelson/grammar/MichelsonGrammarInstruction.d.ts +1 -1
- package/v1/types/michelson/grammar/MichelsonGrammarType.d.ts +1 -1
- package/v1/types/michelson/primitives/MichelsonAddress.d.ts +0 -1
- package/v1/types/michelson/primitives/MichelsonAddress.js +28 -47
- package/v1/types/michelson/primitives/MichelsonAddress.js.map +1 -1
- package/v1/types/michelson/primitives/MichelsonBool.js +20 -39
- package/v1/types/michelson/primitives/MichelsonBool.js.map +1 -1
- package/v1/types/michelson/primitives/MichelsonBytes.d.ts +0 -1
- package/v1/types/michelson/primitives/MichelsonBytes.js +35 -54
- package/v1/types/michelson/primitives/MichelsonBytes.js.map +1 -1
- package/v1/types/michelson/primitives/MichelsonInt.d.ts +0 -1
- package/v1/types/michelson/primitives/MichelsonInt.js +30 -49
- package/v1/types/michelson/primitives/MichelsonInt.js.map +1 -1
- package/v1/types/michelson/primitives/MichelsonString.d.ts +0 -1
- package/v1/types/michelson/primitives/MichelsonString.js +33 -52
- package/v1/types/michelson/primitives/MichelsonString.js.map +1 -1
- package/v1/types/michelson/primitives/MichelsonUnit.js +14 -34
- package/v1/types/michelson/primitives/MichelsonUnit.js.map +1 -1
- package/v1/types/network.js +1 -1
- package/v1/types/network.js.map +1 -1
- package/v1/types/operations/TezosOperationType.js +1 -1
- package/v1/types/operations/TezosOperationType.js.map +1 -1
- package/v1/types/protocol.d.ts +3 -3
- package/v1/types/sapling/TezosSaplingExternalMethodProvider.d.ts +0 -1
- package/v1/types/sapling/TezosSaplingStateTree.d.ts +1 -1
- package/v1/types/sapling/TezosSaplingTransaction.d.ts +0 -1
- package/v1/types/staking/TezosDelegatorAction.js +1 -1
- package/v1/types/staking/TezosDelegatorAction.js.map +1 -1
- package/v1/utils/address.js +6 -7
- package/v1/utils/address.js.map +1 -1
- package/v1/utils/bip.d.ts +0 -1
- package/v1/utils/bip.js +6 -7
- package/v1/utils/bip.js.map +1 -1
- package/v1/utils/convert.js +7 -8
- package/v1/utils/convert.js.map +1 -1
- package/v1/utils/encoding.d.ts +0 -1
- package/v1/utils/encoding.js +74 -64
- package/v1/utils/encoding.js.map +1 -1
- package/v1/utils/fa.js +2 -3
- package/v1/utils/fa.js.map +1 -1
- package/v1/utils/key.js +9 -12
- package/v1/utils/key.js.map +1 -1
- package/v1/utils/micheline.js +8 -10
- package/v1/utils/micheline.js.map +1 -1
- package/v1/utils/operations.js +21 -22
- package/v1/utils/operations.js.map +1 -1
- package/v1/utils/pack.d.ts +0 -1
- package/v1/utils/pack.js +65 -107
- package/v1/utils/pack.js.map +1 -1
- package/v1/utils/protocol/fa/TezosFA1Accountant.js +24 -52
- package/v1/utils/protocol/fa/TezosFA1Accountant.js.map +1 -1
- package/v1/utils/protocol/fa/TezosFA2Accountant.js +40 -77
- package/v1/utils/protocol/fa/TezosFA2Accountant.js.map +1 -1
- package/v1/utils/protocol/fa/TezosFAAccountant.js +21 -89
- package/v1/utils/protocol/fa/TezosFAAccountant.js.map +1 -1
- package/v1/utils/protocol/instance.js +90 -26
- package/v1/utils/protocol/instance.js.map +1 -1
- package/v1/utils/protocol/sapling/TezosSaplingAccountant.d.ts +0 -1
- package/v1/utils/protocol/sapling/TezosSaplingAccountant.js +221 -539
- package/v1/utils/protocol/sapling/TezosSaplingAccountant.js.map +1 -1
- package/v1/utils/protocol/sapling/TezosSaplingEncoder.d.ts +0 -1
- package/v1/utils/protocol/sapling/TezosSaplingEncoder.js +101 -104
- package/v1/utils/protocol/sapling/TezosSaplingEncoder.js.map +1 -1
- package/v1/utils/protocol/sapling/TezosSaplingForger.d.ts +0 -1
- package/v1/utils/protocol/sapling/TezosSaplingForger.js +107 -266
- package/v1/utils/protocol/sapling/TezosSaplingForger.js.map +1 -1
- package/v1/utils/protocol/sapling/TezosSaplingState.js +110 -239
- package/v1/utils/protocol/sapling/TezosSaplingState.js.map +1 -1
- package/v1/utils/protocol/tezos/TezosAccountant.js +97 -166
- package/v1/utils/protocol/tezos/TezosAccountant.js.map +1 -1
- package/v1/utils/protocol/tezos/TezosForger.js +21 -76
- package/v1/utils/protocol/tezos/TezosForger.js.map +1 -1
- package/v1/utils/signature.js +5 -6
- package/v1/utils/signature.js.map +1 -1
- package/v1/utils/transaction.d.ts +4 -5
- package/v1/utils/transaction.js +3 -3
- package/v1/utils/transaction.js.map +1 -1
|
@@ -15,83 +15,56 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
36
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
37
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
38
|
-
function step(op) {
|
|
39
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
40
|
-
while (_) try {
|
|
41
|
-
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;
|
|
42
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
43
|
-
switch (op[0]) {
|
|
44
|
-
case 0: case 1: t = op; break;
|
|
45
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
46
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
47
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
48
|
-
default:
|
|
49
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
50
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
51
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
52
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
53
|
-
if (t[2]) _.ops.pop();
|
|
54
|
-
_.trys.pop(); continue;
|
|
55
|
-
}
|
|
56
|
-
op = body.call(thisArg, _);
|
|
57
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
58
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
|
-
}
|
|
60
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
61
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
62
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
63
37
|
};
|
|
64
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
39
|
exports.TezosSaplingAccountant = void 0;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
40
|
+
const bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
41
|
+
const array_1 = require("@airgap/coinlib-core/utils/array");
|
|
42
|
+
const hex_1 = require("@airgap/coinlib-core/utils/hex");
|
|
43
|
+
const module_kit_1 = require("@airgap/module-kit");
|
|
44
|
+
const sapling = __importStar(require("@airgap/sapling-wasm"));
|
|
45
|
+
const TezosSaplingAddress_1 = require("../../../data/TezosSaplingAddress");
|
|
46
|
+
const MichelsonBytes_1 = require("../../../types/michelson/primitives/MichelsonBytes");
|
|
47
|
+
const MichelsonString_1 = require("../../../types/michelson/primitives/MichelsonString");
|
|
48
|
+
const pack_1 = require("../../pack");
|
|
49
|
+
class TezosSaplingAccountant {
|
|
50
|
+
constructor(network, cryptoClient, encoder) {
|
|
77
51
|
this.network = network;
|
|
78
52
|
this.cryptoClient = cryptoClient;
|
|
79
53
|
this.encoder = encoder;
|
|
80
54
|
}
|
|
81
|
-
|
|
82
|
-
var _this = this;
|
|
55
|
+
getUnsignedTransactionDetails(sender, inputs, outputs, unshieldTarget) {
|
|
83
56
|
if (unshieldTarget === undefined) {
|
|
84
|
-
return outputs.map(
|
|
57
|
+
return outputs.map((out) => ({
|
|
85
58
|
from: [sender.asString()],
|
|
86
59
|
to: [out.address],
|
|
87
60
|
isInbound: false,
|
|
88
61
|
amount: (0, module_kit_1.newAmount)(out.value, 'blockchain'),
|
|
89
62
|
fee: (0, module_kit_1.newAmount)(0, 'blockchain'),
|
|
90
|
-
network:
|
|
91
|
-
})
|
|
63
|
+
network: this.network
|
|
64
|
+
}));
|
|
92
65
|
}
|
|
93
66
|
else {
|
|
94
|
-
|
|
67
|
+
const amount = this.sumNotes(inputs).minus(this.sumNotes(outputs));
|
|
95
68
|
return [
|
|
96
69
|
{
|
|
97
70
|
from: [sender.asString()],
|
|
@@ -103,487 +76,196 @@ var TezosSaplingAccountant = /** @class */ (function () {
|
|
|
103
76
|
}
|
|
104
77
|
];
|
|
105
78
|
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return __generator(this, function (_f) {
|
|
118
|
-
switch (_f.label) {
|
|
119
|
-
case 0:
|
|
120
|
-
signedBuffer = Buffer.isBuffer(tx) ? tx : Buffer.from(tx, 'hex');
|
|
121
|
-
transaction = this.encoder.decodeTransaction(signedBuffer);
|
|
122
|
-
return [4 /*yield*/, this.getTransactionPartialDetails(transaction, knownViewingKeys)];
|
|
123
|
-
case 1:
|
|
124
|
-
_a = _f.sent(), from = _a[0], details = _a[1];
|
|
125
|
-
if (!(transaction.boundData.length > 0)) return [3 /*break*/, 4];
|
|
126
|
-
boundDataMichelson = (0, pack_1.unpackMichelsonType)(transaction.boundData);
|
|
127
|
-
unshieldTarget = void 0;
|
|
128
|
-
if (boundDataMichelson instanceof MichelsonBytes_1.MichelsonBytes) {
|
|
129
|
-
unshieldTarget = (0, pack_1.parseTzAddress)(boundDataMichelson.value);
|
|
130
|
-
}
|
|
131
|
-
else if (boundDataMichelson instanceof MichelsonString_1.MichelsonString) {
|
|
132
|
-
unshieldTarget = boundDataMichelson.value;
|
|
133
|
-
}
|
|
134
|
-
if (!(unshieldTarget !== undefined)) return [3 /*break*/, 4];
|
|
135
|
-
unshieldDetails = {
|
|
136
|
-
to: [unshieldTarget],
|
|
137
|
-
amount: (0, module_kit_1.newAmount)(transaction.balance, 'blockchain')
|
|
138
|
-
};
|
|
139
|
-
if (!(from !== undefined)) return [3 /*break*/, 3];
|
|
140
|
-
_c = (_b = Object).assign;
|
|
141
|
-
_d = [unshieldDetails];
|
|
142
|
-
_e = {};
|
|
143
|
-
return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(from)];
|
|
144
|
-
case 2:
|
|
145
|
-
unshieldDetails = _c.apply(_b, _d.concat([(_e.from = [(_f.sent()).asString()], _e)]));
|
|
146
|
-
_f.label = 3;
|
|
147
|
-
case 3:
|
|
148
|
-
details.push(unshieldDetails);
|
|
149
|
-
_f.label = 4;
|
|
150
|
-
case 4: return [2 /*return*/, details];
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}); }))];
|
|
154
|
-
case 1:
|
|
155
|
-
partials = _a.sent();
|
|
156
|
-
return [2 /*return*/, (0, array_1.flattenArray)(partials)];
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
});
|
|
160
|
-
};
|
|
161
|
-
TezosSaplingAccountant.prototype.getTransactionPartialDetails = function (transaction, knownViewingKeys) {
|
|
162
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
163
|
-
var sender, _a, details;
|
|
164
|
-
var _this = this;
|
|
165
|
-
return __generator(this, function (_b) {
|
|
166
|
-
switch (_b.label) {
|
|
167
|
-
case 0:
|
|
168
|
-
if (!(transaction.spendDescriptions.length === 0)) return [3 /*break*/, 1];
|
|
169
|
-
_a = undefined;
|
|
170
|
-
return [3 /*break*/, 3];
|
|
171
|
-
case 1: return [4 /*yield*/, this.findSender(transaction, knownViewingKeys)];
|
|
172
|
-
case 2:
|
|
173
|
-
_a = _b.sent();
|
|
174
|
-
_b.label = 3;
|
|
175
|
-
case 3:
|
|
176
|
-
sender = _a;
|
|
177
|
-
return [4 /*yield*/, Promise.all(transaction.outputDescriptions.map(function (description) { return __awaiter(_this, void 0, void 0, function () {
|
|
178
|
-
var recipient, from, _a, _b, to, amount, outputDetails;
|
|
179
|
-
return __generator(this, function (_c) {
|
|
180
|
-
switch (_c.label) {
|
|
181
|
-
case 0: return [4 /*yield*/, this.findRecipient(description, knownViewingKeys)];
|
|
182
|
-
case 1:
|
|
183
|
-
recipient = _c.sent();
|
|
184
|
-
if (!(sender !== undefined)) return [3 /*break*/, 3];
|
|
185
|
-
return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(sender)];
|
|
186
|
-
case 2:
|
|
187
|
-
_a = _c.sent();
|
|
188
|
-
return [3 /*break*/, 4];
|
|
189
|
-
case 3:
|
|
190
|
-
_a = undefined;
|
|
191
|
-
_c.label = 4;
|
|
192
|
-
case 4:
|
|
193
|
-
from = _a;
|
|
194
|
-
return [4 /*yield*/, this.decodeDetailsFromOutputDescription(sender, recipient, description)];
|
|
195
|
-
case 5:
|
|
196
|
-
_b = _c.sent(), to = _b[0], amount = _b[1];
|
|
197
|
-
outputDetails = {};
|
|
198
|
-
if (from !== undefined) {
|
|
199
|
-
outputDetails = Object.assign(outputDetails, { from: [from.asString()] });
|
|
200
|
-
}
|
|
201
|
-
if (to !== undefined) {
|
|
202
|
-
outputDetails = Object.assign(outputDetails, { to: [to.asString()] });
|
|
203
|
-
}
|
|
204
|
-
if (amount !== undefined) {
|
|
205
|
-
outputDetails = Object.assign(outputDetails, { amount: (0, module_kit_1.newAmount)(amount, 'blockchain') });
|
|
206
|
-
}
|
|
207
|
-
return [2 /*return*/, outputDetails];
|
|
208
|
-
}
|
|
209
|
-
});
|
|
210
|
-
}); }))];
|
|
211
|
-
case 4:
|
|
212
|
-
details = _b.sent();
|
|
213
|
-
return [2 /*return*/, [sender, details]];
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
};
|
|
218
|
-
TezosSaplingAccountant.prototype.findSender = function (transaction, viewingKeys) {
|
|
219
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
220
|
-
var _this = this;
|
|
221
|
-
return __generator(this, function (_a) {
|
|
222
|
-
switch (_a.label) {
|
|
223
|
-
case 0: return [4 /*yield*/, Promise.all(viewingKeys.map(function (viewingKey) { return __awaiter(_this, void 0, void 0, function () {
|
|
224
|
-
var outputDescription, error_1;
|
|
225
|
-
return __generator(this, function (_a) {
|
|
226
|
-
switch (_a.label) {
|
|
227
|
-
case 0:
|
|
228
|
-
_a.trys.push([0, 2, , 3]);
|
|
229
|
-
outputDescription = transaction.outputDescriptions[0];
|
|
230
|
-
return [4 /*yield*/, this.cryptoClient.decryptCiphertextOut(viewingKey, outputDescription.ciphertext, outputDescription.cm)];
|
|
231
|
-
case 1:
|
|
232
|
-
_a.sent();
|
|
233
|
-
return [2 /*return*/, viewingKey];
|
|
234
|
-
case 2:
|
|
235
|
-
error_1 = _a.sent();
|
|
236
|
-
return [2 /*return*/, undefined];
|
|
237
|
-
case 3: return [2 /*return*/];
|
|
238
|
-
}
|
|
239
|
-
});
|
|
240
|
-
}); }))];
|
|
241
|
-
case 1: return [2 /*return*/, (_a.sent()).find(function (viewingKey) { return viewingKey !== undefined; })];
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
};
|
|
246
|
-
TezosSaplingAccountant.prototype.findRecipient = function (outputDescription, viewingKeys) {
|
|
247
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
248
|
-
var _this = this;
|
|
249
|
-
return __generator(this, function (_a) {
|
|
250
|
-
switch (_a.label) {
|
|
251
|
-
case 0: return [4 /*yield*/, Promise.all(viewingKeys.map(function (viewingKey) { return __awaiter(_this, void 0, void 0, function () {
|
|
252
|
-
var error_2;
|
|
253
|
-
return __generator(this, function (_a) {
|
|
254
|
-
switch (_a.label) {
|
|
255
|
-
case 0:
|
|
256
|
-
_a.trys.push([0, 2, , 3]);
|
|
257
|
-
// a viewing key is the recipient if it can decrypt the ciphertext payload enc from output description
|
|
258
|
-
return [4 /*yield*/, this.cryptoClient.decryptCiphertextEnc(viewingKey, outputDescription.ciphertext)];
|
|
259
|
-
case 1:
|
|
260
|
-
// a viewing key is the recipient if it can decrypt the ciphertext payload enc from output description
|
|
261
|
-
_a.sent();
|
|
262
|
-
return [2 /*return*/, viewingKey];
|
|
263
|
-
case 2:
|
|
264
|
-
error_2 = _a.sent();
|
|
265
|
-
return [2 /*return*/, undefined];
|
|
266
|
-
case 3: return [2 /*return*/];
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
}); }))];
|
|
270
|
-
case 1: return [2 /*return*/, (_a.sent()).find(function (viewingKey) { return viewingKey !== undefined; })];
|
|
271
|
-
}
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
};
|
|
275
|
-
TezosSaplingAccountant.prototype.decodeDetailsFromOutputDescription = function (sender, recipient, output) {
|
|
276
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
277
|
-
var viewingKey, _a, address, amount;
|
|
278
|
-
return __generator(this, function (_b) {
|
|
279
|
-
switch (_b.label) {
|
|
280
|
-
case 0:
|
|
281
|
-
viewingKey = sender !== null && sender !== void 0 ? sender : recipient;
|
|
282
|
-
if (!(viewingKey !== undefined)) return [3 /*break*/, 3];
|
|
283
|
-
return [4 /*yield*/, this.cryptoClient.decryptCiphertextEnc(viewingKey, output.ciphertext, viewingKey === sender ? 'sender' : 'receiver', output.cm)];
|
|
284
|
-
case 1:
|
|
285
|
-
_a = _b.sent(), address = _a.address, amount = _a.amount;
|
|
286
|
-
return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromRaw(address)];
|
|
287
|
-
case 2: return [2 /*return*/, [_b.sent(), amount]];
|
|
288
|
-
case 3: return [2 /*return*/, [undefined, undefined]];
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
};
|
|
293
|
-
TezosSaplingAccountant.prototype.sumNotes = function (notes) {
|
|
294
|
-
return notes.reduce(function (sum, next) { return sum.plus(next.value); }, new bignumber_1.default(0));
|
|
295
|
-
};
|
|
296
|
-
TezosSaplingAccountant.prototype.getIncomingInputs = function (viewingKey, commitmentsWithCiphertext) {
|
|
297
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
298
|
-
var inputs;
|
|
299
|
-
var _this = this;
|
|
300
|
-
return __generator(this, function (_a) {
|
|
301
|
-
switch (_a.label) {
|
|
302
|
-
case 0: return [4 /*yield*/, Promise.all(commitmentsWithCiphertext.map(function (_a) {
|
|
303
|
-
var commitment = _a[0], ciphertext = _a[1], position = _a[2];
|
|
304
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
305
|
-
var decrypted, _b;
|
|
306
|
-
return __generator(this, function (_c) {
|
|
307
|
-
switch (_c.label) {
|
|
308
|
-
case 0: return [4 /*yield*/, this.getIncomingInputFromCiphertext(viewingKey, ciphertext, commitment, position)];
|
|
309
|
-
case 1:
|
|
310
|
-
decrypted = _c.sent();
|
|
311
|
-
_b = decrypted === undefined;
|
|
312
|
-
if (_b) return [3 /*break*/, 3];
|
|
313
|
-
return [4 /*yield*/, this.verifyCommitment(decrypted[1], commitment)];
|
|
314
|
-
case 2:
|
|
315
|
-
_b = !(_c.sent());
|
|
316
|
-
_c.label = 3;
|
|
317
|
-
case 3:
|
|
318
|
-
if (_b) {
|
|
319
|
-
return [2 /*return*/, undefined];
|
|
320
|
-
}
|
|
321
|
-
return [2 /*return*/, decrypted[1]];
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
}))];
|
|
326
|
-
case 1:
|
|
327
|
-
inputs = (_a.sent()).filter(function (input) { return input !== undefined; });
|
|
328
|
-
return [2 /*return*/, inputs];
|
|
329
|
-
}
|
|
330
|
-
});
|
|
331
|
-
});
|
|
332
|
-
};
|
|
333
|
-
TezosSaplingAccountant.prototype.getOutgoingInputs = function (viewingKey, commitmentsWithCiphertext) {
|
|
334
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
335
|
-
var inputs;
|
|
336
|
-
var _this = this;
|
|
337
|
-
return __generator(this, function (_a) {
|
|
338
|
-
switch (_a.label) {
|
|
339
|
-
case 0: return [4 /*yield*/, Promise.all(commitmentsWithCiphertext.map(function (_a) {
|
|
340
|
-
var commitment = _a[0], ciphertext = _a[1], position = _a[2];
|
|
341
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
342
|
-
var decrypted, _b, _c;
|
|
343
|
-
return __generator(this, function (_d) {
|
|
344
|
-
switch (_d.label) {
|
|
345
|
-
case 0: return [4 /*yield*/, this.getOutgoingInputFromCiphertext(viewingKey, ciphertext, commitment, position)];
|
|
346
|
-
case 1:
|
|
347
|
-
decrypted = _d.sent();
|
|
348
|
-
_b = decrypted === undefined;
|
|
349
|
-
if (_b) return [3 /*break*/, 4];
|
|
350
|
-
_c = decrypted[1].address !== '';
|
|
351
|
-
if (!_c) return [3 /*break*/, 3];
|
|
352
|
-
return [4 /*yield*/, this.verifyCommitment(decrypted[1], commitment)];
|
|
353
|
-
case 2:
|
|
354
|
-
_c = !(_d.sent());
|
|
355
|
-
_d.label = 3;
|
|
356
|
-
case 3:
|
|
357
|
-
_b = (_c);
|
|
358
|
-
_d.label = 4;
|
|
359
|
-
case 4:
|
|
360
|
-
if (_b) {
|
|
361
|
-
return [2 /*return*/, undefined];
|
|
362
|
-
}
|
|
363
|
-
return [2 /*return*/, decrypted[1]];
|
|
364
|
-
}
|
|
365
|
-
});
|
|
366
|
-
});
|
|
367
|
-
}))];
|
|
368
|
-
case 1:
|
|
369
|
-
inputs = (_a.sent()).filter(function (input) { return input !== undefined; });
|
|
370
|
-
return [2 /*return*/, inputs];
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
});
|
|
374
|
-
};
|
|
375
|
-
TezosSaplingAccountant.prototype.getUnspends = function (viewingKey, commitmentsWithCiphertext, nullifiers) {
|
|
376
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
377
|
-
var nullifiersSet, inputs, unspends;
|
|
378
|
-
var _this = this;
|
|
379
|
-
return __generator(this, function (_a) {
|
|
380
|
-
switch (_a.label) {
|
|
381
|
-
case 0:
|
|
382
|
-
nullifiersSet = new Set(nullifiers.map(function (nullifier) { return (0, hex_1.stripHexPrefix)(nullifier); }));
|
|
383
|
-
return [4 /*yield*/, this.getInputs(viewingKey, commitmentsWithCiphertext)];
|
|
384
|
-
case 1:
|
|
385
|
-
inputs = _a.sent();
|
|
386
|
-
return [4 /*yield*/, Promise.all(inputs.map(function (input) { return __awaiter(_this, void 0, void 0, function () {
|
|
387
|
-
var nullifier, _a, _b, _c;
|
|
388
|
-
return __generator(this, function (_d) {
|
|
389
|
-
switch (_d.label) {
|
|
390
|
-
case 0:
|
|
391
|
-
_b = (_a = sapling).computeNullifier;
|
|
392
|
-
_c = [viewingKey];
|
|
393
|
-
return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromValue(input.address)];
|
|
394
|
-
case 1: return [4 /*yield*/, _b.apply(_a, _c.concat([(_d.sent()).raw,
|
|
395
|
-
input.value,
|
|
396
|
-
input.rcm,
|
|
397
|
-
input.pos]))];
|
|
398
|
-
case 2:
|
|
399
|
-
nullifier = _d.sent();
|
|
400
|
-
return [2 /*return*/, !nullifiersSet.has(nullifier.toString('hex')) ? input : undefined];
|
|
401
|
-
}
|
|
402
|
-
});
|
|
403
|
-
}); }))];
|
|
404
|
-
case 2:
|
|
405
|
-
unspends = (_a.sent()).filter(function (input) { return input !== undefined; });
|
|
406
|
-
return [2 /*return*/, unspends];
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
|
-
});
|
|
410
|
-
};
|
|
411
|
-
TezosSaplingAccountant.prototype.getInputs = function (viewingKey, commitmentsWithCiphertext) {
|
|
412
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
413
|
-
var inputs;
|
|
414
|
-
var _this = this;
|
|
415
|
-
return __generator(this, function (_a) {
|
|
416
|
-
switch (_a.label) {
|
|
417
|
-
case 0: return [4 /*yield*/, Promise.all(commitmentsWithCiphertext.map(function (_a, index) {
|
|
418
|
-
var commitment = _a[0], ciphertext = _a[1];
|
|
419
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
420
|
-
var decrypted, _b;
|
|
421
|
-
return __generator(this, function (_c) {
|
|
422
|
-
switch (_c.label) {
|
|
423
|
-
case 0: return [4 /*yield*/, this.getReceiverInputFromCiphertext(viewingKey, ciphertext, new bignumber_1.default(index))];
|
|
424
|
-
case 1:
|
|
425
|
-
decrypted = _c.sent();
|
|
426
|
-
_b = decrypted === undefined;
|
|
427
|
-
if (_b) return [3 /*break*/, 3];
|
|
428
|
-
return [4 /*yield*/, this.verifyCommitment(decrypted[1], commitment)];
|
|
429
|
-
case 2:
|
|
430
|
-
_b = !(_c.sent());
|
|
431
|
-
_c.label = 3;
|
|
432
|
-
case 3:
|
|
433
|
-
if (_b) {
|
|
434
|
-
return [2 /*return*/, undefined];
|
|
435
|
-
}
|
|
436
|
-
return [2 /*return*/, decrypted[1]];
|
|
437
|
-
}
|
|
438
|
-
});
|
|
439
|
-
});
|
|
440
|
-
}))];
|
|
441
|
-
case 1:
|
|
442
|
-
inputs = (_a.sent()).filter(function (input) { return input !== undefined; });
|
|
443
|
-
return [2 /*return*/, inputs];
|
|
444
|
-
}
|
|
445
|
-
});
|
|
446
|
-
});
|
|
447
|
-
};
|
|
448
|
-
TezosSaplingAccountant.prototype.getReceiverInputFromCiphertext = function (viewingKey, ciphertext, position) {
|
|
449
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
450
|
-
var _a, diversifier, amount, rcm, memo, ivk, address, input, _b;
|
|
451
|
-
var _c;
|
|
452
|
-
return __generator(this, function (_d) {
|
|
453
|
-
switch (_d.label) {
|
|
454
|
-
case 0:
|
|
455
|
-
_d.trys.push([0, 5, , 6]);
|
|
456
|
-
return [4 /*yield*/, this.cryptoClient.decryptCiphertextEnc(viewingKey, ciphertext, 'receiver')];
|
|
457
|
-
case 1:
|
|
458
|
-
_a = _d.sent(), diversifier = _a.diversifier, amount = _a.amount, rcm = _a.rcm, memo = _a.memo;
|
|
459
|
-
return [4 /*yield*/, sapling.getIncomingViewingKey(viewingKey)];
|
|
460
|
-
case 2:
|
|
461
|
-
ivk = _d.sent();
|
|
462
|
-
return [4 /*yield*/, sapling.getRawPaymentAddressFromIncomingViewingKey(ivk, diversifier)];
|
|
463
|
-
case 3:
|
|
464
|
-
address = _d.sent();
|
|
465
|
-
_c = {
|
|
466
|
-
rcm: rcm.toString('hex'),
|
|
467
|
-
pos: position.toString(),
|
|
468
|
-
value: amount.toString()
|
|
469
|
-
};
|
|
470
|
-
return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromRaw(address)];
|
|
471
|
-
case 4:
|
|
472
|
-
input = (_c.address = (_d.sent()).asString(),
|
|
473
|
-
_c);
|
|
474
|
-
return [2 /*return*/, [Buffer.from(memo), input]];
|
|
475
|
-
case 5:
|
|
476
|
-
_b = _d.sent();
|
|
477
|
-
return [2 /*return*/, undefined];
|
|
478
|
-
case 6: return [2 /*return*/];
|
|
79
|
+
}
|
|
80
|
+
async getTransactionsPartialDetails(txs, knownViewingKeys = []) {
|
|
81
|
+
const partials = await Promise.all(txs.map(async (tx) => {
|
|
82
|
+
const signedBuffer = Buffer.isBuffer(tx) ? tx : Buffer.from(tx, 'hex');
|
|
83
|
+
const transaction = this.encoder.decodeTransaction(signedBuffer);
|
|
84
|
+
const [from, details] = await this.getTransactionPartialDetails(transaction, knownViewingKeys);
|
|
85
|
+
if (transaction.boundData.length > 0) {
|
|
86
|
+
const boundDataMichelson = (0, pack_1.unpackMichelsonType)(transaction.boundData);
|
|
87
|
+
let unshieldTarget;
|
|
88
|
+
if (boundDataMichelson instanceof MichelsonBytes_1.MichelsonBytes) {
|
|
89
|
+
unshieldTarget = (0, pack_1.parseTzAddress)(boundDataMichelson.value);
|
|
479
90
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
};
|
|
483
|
-
TezosSaplingAccountant.prototype.getSenderInputFromCiphertext = function (viewingKey, ciphertext, commitment, position) {
|
|
484
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
485
|
-
var _a, amount, address, rcm, memo, input, _b;
|
|
486
|
-
var _c;
|
|
487
|
-
return __generator(this, function (_d) {
|
|
488
|
-
switch (_d.label) {
|
|
489
|
-
case 0:
|
|
490
|
-
_d.trys.push([0, 3, , 4]);
|
|
491
|
-
return [4 /*yield*/, this.cryptoClient.decryptCiphertextEnc(viewingKey, ciphertext, 'sender', commitment)];
|
|
492
|
-
case 1:
|
|
493
|
-
_a = _d.sent(), amount = _a.amount, address = _a.address, rcm = _a.rcm, memo = _a.memo;
|
|
494
|
-
_c = {
|
|
495
|
-
rcm: rcm.toString('hex'),
|
|
496
|
-
pos: position.toString(),
|
|
497
|
-
value: amount.toString()
|
|
498
|
-
};
|
|
499
|
-
return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromRaw(address)];
|
|
500
|
-
case 2:
|
|
501
|
-
input = (_c.address = (_d.sent()).asString(),
|
|
502
|
-
_c);
|
|
503
|
-
return [2 /*return*/, [Buffer.from(memo), input]];
|
|
504
|
-
case 3:
|
|
505
|
-
_b = _d.sent();
|
|
506
|
-
return [2 /*return*/, undefined];
|
|
507
|
-
case 4: return [2 /*return*/];
|
|
91
|
+
else if (boundDataMichelson instanceof MichelsonString_1.MichelsonString) {
|
|
92
|
+
unshieldTarget = boundDataMichelson.value;
|
|
508
93
|
}
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
case 1:
|
|
519
|
-
inputWithMemo = _a.sent();
|
|
520
|
-
if (inputWithMemo === undefined) {
|
|
521
|
-
return [2 /*return*/, undefined];
|
|
522
|
-
}
|
|
523
|
-
_a.label = 2;
|
|
524
|
-
case 2:
|
|
525
|
-
_a.trys.push([2, 4, , 5]);
|
|
526
|
-
return [4 /*yield*/, this.cryptoClient.decryptCiphertextEnc(viewingKey, ciphertext, 'sender', commitment)
|
|
527
|
-
// ciphertext can be decrypted, the receiver is also the sender
|
|
528
|
-
];
|
|
529
|
-
case 3:
|
|
530
|
-
_a.sent();
|
|
531
|
-
// ciphertext can be decrypted, the receiver is also the sender
|
|
532
|
-
return [2 /*return*/, undefined];
|
|
533
|
-
case 4:
|
|
534
|
-
error_3 = _a.sent();
|
|
535
|
-
// ciphertext could not be decrypted, the reciever is not the sender
|
|
536
|
-
return [2 /*return*/, inputWithMemo];
|
|
537
|
-
case 5: return [2 /*return*/];
|
|
538
|
-
}
|
|
539
|
-
});
|
|
540
|
-
});
|
|
541
|
-
};
|
|
542
|
-
TezosSaplingAccountant.prototype.getOutgoingInputFromCiphertext = function (viewingKey, ciphertext, commitment, position) {
|
|
543
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
544
|
-
var inputWithMemo, _a;
|
|
545
|
-
return __generator(this, function (_b) {
|
|
546
|
-
switch (_b.label) {
|
|
547
|
-
case 0: return [4 /*yield*/, this.getSenderInputFromCiphertext(viewingKey, ciphertext, commitment, position)];
|
|
548
|
-
case 1:
|
|
549
|
-
inputWithMemo = _b.sent();
|
|
550
|
-
if (inputWithMemo === undefined) {
|
|
551
|
-
return [2 /*return*/, undefined];
|
|
552
|
-
}
|
|
553
|
-
_b.label = 2;
|
|
554
|
-
case 2:
|
|
555
|
-
_b.trys.push([2, 4, , 5]);
|
|
556
|
-
return [4 /*yield*/, this.cryptoClient.decryptCiphertextEnc(viewingKey, ciphertext, 'receiver')
|
|
557
|
-
// ciphertext can be decrypted, the sender is also the receiver
|
|
558
|
-
];
|
|
559
|
-
case 3:
|
|
560
|
-
_b.sent();
|
|
561
|
-
// ciphertext can be decrypted, the sender is also the receiver
|
|
562
|
-
return [2 /*return*/, undefined];
|
|
563
|
-
case 4:
|
|
564
|
-
_a = _b.sent();
|
|
565
|
-
// ciphertext could not be decrypted, the sender is not the receiver
|
|
566
|
-
return [2 /*return*/, inputWithMemo];
|
|
567
|
-
case 5: return [2 /*return*/];
|
|
94
|
+
if (unshieldTarget !== undefined) {
|
|
95
|
+
let unshieldDetails = {
|
|
96
|
+
to: [unshieldTarget],
|
|
97
|
+
amount: (0, module_kit_1.newAmount)(transaction.balance, 'blockchain')
|
|
98
|
+
};
|
|
99
|
+
if (from !== undefined) {
|
|
100
|
+
unshieldDetails = Object.assign(unshieldDetails, { from: [(await TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(from)).asString()] });
|
|
101
|
+
}
|
|
102
|
+
details.push(unshieldDetails);
|
|
568
103
|
}
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
}
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
104
|
+
}
|
|
105
|
+
return details;
|
|
106
|
+
}));
|
|
107
|
+
return (0, array_1.flattenArray)(partials);
|
|
108
|
+
}
|
|
109
|
+
async getTransactionPartialDetails(transaction, knownViewingKeys) {
|
|
110
|
+
const sender = transaction.spendDescriptions.length === 0 ? undefined : await this.findSender(transaction, knownViewingKeys);
|
|
111
|
+
const details = await Promise.all(transaction.outputDescriptions.map(async (description) => {
|
|
112
|
+
const recipient = await this.findRecipient(description, knownViewingKeys);
|
|
113
|
+
const from = sender !== undefined ? await TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(sender) : undefined;
|
|
114
|
+
const [to, amount] = await this.decodeDetailsFromOutputDescription(sender, recipient, description);
|
|
115
|
+
let outputDetails = {};
|
|
116
|
+
if (from !== undefined) {
|
|
117
|
+
outputDetails = Object.assign(outputDetails, { from: [from.asString()] });
|
|
118
|
+
}
|
|
119
|
+
if (to !== undefined) {
|
|
120
|
+
outputDetails = Object.assign(outputDetails, { to: [to.asString()] });
|
|
121
|
+
}
|
|
122
|
+
if (amount !== undefined) {
|
|
123
|
+
outputDetails = Object.assign(outputDetails, { amount: (0, module_kit_1.newAmount)(amount, 'blockchain') });
|
|
124
|
+
}
|
|
125
|
+
return outputDetails;
|
|
126
|
+
}));
|
|
127
|
+
return [sender, details];
|
|
128
|
+
}
|
|
129
|
+
async findSender(transaction, viewingKeys) {
|
|
130
|
+
return (await Promise.all(viewingKeys.map(async (viewingKey) => {
|
|
131
|
+
try {
|
|
132
|
+
// a viewing key is the sender if it can decrypt any ciphertext payload out from the transaction
|
|
133
|
+
const outputDescription = transaction.outputDescriptions[0];
|
|
134
|
+
await this.cryptoClient.decryptCiphertextOut(viewingKey, outputDescription.ciphertext, outputDescription.cm);
|
|
135
|
+
return viewingKey;
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
|
+
}))).find((viewingKey) => viewingKey !== undefined);
|
|
141
|
+
}
|
|
142
|
+
async findRecipient(outputDescription, viewingKeys) {
|
|
143
|
+
return (await Promise.all(viewingKeys.map(async (viewingKey) => {
|
|
144
|
+
try {
|
|
145
|
+
// a viewing key is the recipient if it can decrypt the ciphertext payload enc from output description
|
|
146
|
+
await this.cryptoClient.decryptCiphertextEnc(viewingKey, outputDescription.ciphertext);
|
|
147
|
+
return viewingKey;
|
|
148
|
+
}
|
|
149
|
+
catch (error) {
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
}))).find((viewingKey) => viewingKey !== undefined);
|
|
153
|
+
}
|
|
154
|
+
async decodeDetailsFromOutputDescription(sender, recipient, output) {
|
|
155
|
+
const viewingKey = sender ?? recipient;
|
|
156
|
+
if (viewingKey !== undefined) {
|
|
157
|
+
const { address, amount } = await this.cryptoClient.decryptCiphertextEnc(viewingKey, output.ciphertext, viewingKey === sender ? 'sender' : 'receiver', output.cm);
|
|
158
|
+
return [await TezosSaplingAddress_1.TezosSaplingAddress.fromRaw(address), amount];
|
|
159
|
+
}
|
|
160
|
+
return [undefined, undefined];
|
|
161
|
+
}
|
|
162
|
+
sumNotes(notes) {
|
|
163
|
+
return notes.reduce((sum, next) => sum.plus(next.value), new bignumber_1.default(0));
|
|
164
|
+
}
|
|
165
|
+
async getIncomingInputs(viewingKey, commitmentsWithCiphertext) {
|
|
166
|
+
const inputs = (await Promise.all(commitmentsWithCiphertext.map(async ([commitment, ciphertext, position]) => {
|
|
167
|
+
const decrypted = await this.getIncomingInputFromCiphertext(viewingKey, ciphertext, commitment, position);
|
|
168
|
+
if (decrypted === undefined || !(await this.verifyCommitment(decrypted[1], commitment))) {
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
return decrypted[1];
|
|
172
|
+
}))).filter((input) => input !== undefined);
|
|
173
|
+
return inputs;
|
|
174
|
+
}
|
|
175
|
+
async getOutgoingInputs(viewingKey, commitmentsWithCiphertext) {
|
|
176
|
+
const inputs = (await Promise.all(commitmentsWithCiphertext.map(async ([commitment, ciphertext, position]) => {
|
|
177
|
+
const decrypted = await this.getOutgoingInputFromCiphertext(viewingKey, ciphertext, commitment, position);
|
|
178
|
+
if (decrypted === undefined || (decrypted[1].address !== '' && !(await this.verifyCommitment(decrypted[1], commitment)))) {
|
|
179
|
+
return undefined;
|
|
180
|
+
}
|
|
181
|
+
return decrypted[1];
|
|
182
|
+
}))).filter((input) => input !== undefined);
|
|
183
|
+
return inputs;
|
|
184
|
+
}
|
|
185
|
+
async getUnspends(viewingKey, commitmentsWithCiphertext, nullifiers) {
|
|
186
|
+
const nullifiersSet = new Set(nullifiers.map((nullifier) => (0, hex_1.stripHexPrefix)(nullifier)));
|
|
187
|
+
const inputs = await this.getInputs(viewingKey, commitmentsWithCiphertext);
|
|
188
|
+
const unspends = (await Promise.all(inputs.map(async (input) => {
|
|
189
|
+
const nullifier = await sapling.computeNullifier(viewingKey, (await TezosSaplingAddress_1.TezosSaplingAddress.fromValue(input.address)).raw, input.value, input.rcm, input.pos);
|
|
190
|
+
return !nullifiersSet.has(nullifier.toString('hex')) ? input : undefined;
|
|
191
|
+
}))).filter((input) => input !== undefined);
|
|
192
|
+
return unspends;
|
|
193
|
+
}
|
|
194
|
+
async getInputs(viewingKey, commitmentsWithCiphertext) {
|
|
195
|
+
const inputs = (await Promise.all(commitmentsWithCiphertext.map(async ([commitment, ciphertext], index) => {
|
|
196
|
+
const decrypted = await this.getReceiverInputFromCiphertext(viewingKey, ciphertext, new bignumber_1.default(index));
|
|
197
|
+
if (decrypted === undefined || !(await this.verifyCommitment(decrypted[1], commitment))) {
|
|
198
|
+
return undefined;
|
|
199
|
+
}
|
|
200
|
+
return decrypted[1];
|
|
201
|
+
}))).filter((input) => input !== undefined);
|
|
202
|
+
return inputs;
|
|
203
|
+
}
|
|
204
|
+
async getReceiverInputFromCiphertext(viewingKey, ciphertext, position) {
|
|
205
|
+
try {
|
|
206
|
+
const { diversifier, amount, rcm, memo } = await this.cryptoClient.decryptCiphertextEnc(viewingKey, ciphertext, 'receiver');
|
|
207
|
+
const ivk = await sapling.getIncomingViewingKey(viewingKey);
|
|
208
|
+
const address = await sapling.getRawPaymentAddressFromIncomingViewingKey(ivk, diversifier);
|
|
209
|
+
const input = {
|
|
210
|
+
rcm: rcm.toString('hex'),
|
|
211
|
+
pos: position.toString(),
|
|
212
|
+
value: amount.toString(),
|
|
213
|
+
address: (await TezosSaplingAddress_1.TezosSaplingAddress.fromRaw(address)).asString()
|
|
214
|
+
};
|
|
215
|
+
return [Buffer.from(memo), input];
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
return undefined;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
async getSenderInputFromCiphertext(viewingKey, ciphertext, commitment, position) {
|
|
222
|
+
try {
|
|
223
|
+
const { amount, address, rcm, memo } = await this.cryptoClient.decryptCiphertextEnc(viewingKey, ciphertext, 'sender', commitment);
|
|
224
|
+
const input = {
|
|
225
|
+
rcm: rcm.toString('hex'),
|
|
226
|
+
pos: position.toString(),
|
|
227
|
+
value: amount.toString(),
|
|
228
|
+
address: (await TezosSaplingAddress_1.TezosSaplingAddress.fromRaw(address)).asString()
|
|
229
|
+
};
|
|
230
|
+
return [Buffer.from(memo), input];
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
return undefined;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
async getIncomingInputFromCiphertext(viewingKey, ciphertext, commitment, position) {
|
|
237
|
+
const inputWithMemo = await this.getReceiverInputFromCiphertext(viewingKey, ciphertext, position);
|
|
238
|
+
if (inputWithMemo === undefined) {
|
|
239
|
+
return undefined;
|
|
240
|
+
}
|
|
241
|
+
try {
|
|
242
|
+
await this.cryptoClient.decryptCiphertextEnc(viewingKey, ciphertext, 'sender', commitment);
|
|
243
|
+
// ciphertext can be decrypted, the receiver is also the sender
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
// ciphertext could not be decrypted, the reciever is not the sender
|
|
248
|
+
return inputWithMemo;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
async getOutgoingInputFromCiphertext(viewingKey, ciphertext, commitment, position) {
|
|
252
|
+
const inputWithMemo = await this.getSenderInputFromCiphertext(viewingKey, ciphertext, commitment, position);
|
|
253
|
+
if (inputWithMemo === undefined) {
|
|
254
|
+
return undefined;
|
|
255
|
+
}
|
|
256
|
+
try {
|
|
257
|
+
await this.cryptoClient.decryptCiphertextEnc(viewingKey, ciphertext, 'receiver');
|
|
258
|
+
// ciphertext can be decrypted, the sender is also the receiver
|
|
259
|
+
return undefined;
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
// ciphertext could not be decrypted, the sender is not the receiver
|
|
263
|
+
return inputWithMemo;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
async verifyCommitment(input, expectedCommitment) {
|
|
267
|
+
return sapling.verifyCommitment(expectedCommitment, (await TezosSaplingAddress_1.TezosSaplingAddress.fromValue(input.address)).raw, input.value, input.rcm);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
588
270
|
exports.TezosSaplingAccountant = TezosSaplingAccountant;
|
|
589
271
|
//# sourceMappingURL=TezosSaplingAccountant.js.map
|