@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
|
@@ -1,15 +1,4 @@
|
|
|
1
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
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -26,105 +15,77 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
26
15
|
}) : function(o, v) {
|
|
27
16
|
o["default"] = v;
|
|
28
17
|
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
47
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
-
function step(op) {
|
|
50
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
-
while (_) try {
|
|
52
|
-
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;
|
|
53
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
-
switch (op[0]) {
|
|
55
|
-
case 0: case 1: t = op; break;
|
|
56
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
-
default:
|
|
60
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
-
if (t[2]) _.ops.pop();
|
|
65
|
-
_.trys.pop(); continue;
|
|
66
|
-
}
|
|
67
|
-
op = body.call(thisArg, _);
|
|
68
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
73
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
74
|
-
if (ar || !(i in from)) {
|
|
75
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
76
|
-
ar[i] = from[i];
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
80
|
-
};
|
|
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
|
+
})();
|
|
81
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
82
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
83
37
|
};
|
|
84
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
85
39
|
exports.TezosSaplingProtocolImpl = void 0;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
40
|
+
const coinlib_core_1 = require("@airgap/coinlib-core");
|
|
41
|
+
const bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
42
|
+
const errors_1 = require("@airgap/coinlib-core/errors");
|
|
43
|
+
const array_1 = require("@airgap/coinlib-core/utils/array");
|
|
44
|
+
const crypto_1 = require("@airgap/crypto");
|
|
45
|
+
const module_kit_1 = require("@airgap/module-kit");
|
|
46
|
+
const sapling = __importStar(require("@airgap/sapling-wasm"));
|
|
47
|
+
const random_1 = require("@stablelib/random");
|
|
48
|
+
const TezosContract_1 = require("../../contract/TezosContract");
|
|
49
|
+
const TezosSaplingCryptoClient_1 = require("../../crypto/TezosSaplingCryptoClient");
|
|
50
|
+
const TezosAddress_1 = require("../../data/TezosAddress");
|
|
51
|
+
const TezosSaplingAddress_1 = require("../../data/TezosSaplingAddress");
|
|
52
|
+
const TezosSaplingInjectorClient_1 = require("../../injector/TezosSaplingInjectorClient");
|
|
53
|
+
const TezosSaplingNodeClient_1 = require("../../node/TezosSaplingNodeClient");
|
|
54
|
+
const MichelsonAddress_1 = require("../../types/michelson/primitives/MichelsonAddress");
|
|
55
|
+
const TezosOperationType_1 = require("../../types/operations/TezosOperationType");
|
|
56
|
+
const key_1 = require("../../utils/key");
|
|
57
|
+
const pack_1 = require("../../utils/pack");
|
|
58
|
+
const TezosSaplingAccountant_1 = require("../../utils/protocol/sapling/TezosSaplingAccountant");
|
|
59
|
+
const TezosSaplingEncoder_1 = require("../../utils/protocol/sapling/TezosSaplingEncoder");
|
|
60
|
+
const TezosSaplingForger_1 = require("../../utils/protocol/sapling/TezosSaplingForger");
|
|
61
|
+
const TezosSaplingState_1 = require("../../utils/protocol/sapling/TezosSaplingState");
|
|
62
|
+
const transaction_1 = require("../../utils/transaction");
|
|
63
|
+
const TezosProtocol_1 = require("../TezosProtocol");
|
|
110
64
|
// Implementation
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
var _a;
|
|
65
|
+
class TezosSaplingProtocolImpl {
|
|
66
|
+
constructor(options) {
|
|
114
67
|
this.isTezosSaplingProtocol = true;
|
|
115
68
|
// Offline
|
|
116
69
|
this.cryptoConfiguration = {
|
|
117
70
|
algorithm: 'sapling',
|
|
118
71
|
secretType: 'miniSecretXor'
|
|
119
72
|
};
|
|
120
|
-
this.metadata =
|
|
73
|
+
this.metadata = {
|
|
74
|
+
...options.metadata,
|
|
75
|
+
fee: {
|
|
76
|
+
...(options.metadata.fee ?? {}),
|
|
77
|
+
units: TezosProtocol_1.TEZOS_UNITS,
|
|
78
|
+
mainUnit: 'tez'
|
|
79
|
+
},
|
|
80
|
+
account: {
|
|
121
81
|
standardDerivationPath: options.metadata.account.standardDerivationPath,
|
|
122
82
|
address: {
|
|
123
83
|
isCaseSensitive: true,
|
|
124
84
|
placeholder: 'zet1...',
|
|
125
85
|
regex: '^(zet1[1-9A-Za-z]{65}|tz1[1-9A-Za-z]{33})$'
|
|
126
86
|
}
|
|
127
|
-
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
128
89
|
this.network = options.network;
|
|
129
90
|
this.memoSize = options.memoSize;
|
|
130
91
|
this.tezos = (0, TezosProtocol_1.createTezosProtocol)({ network: options.network });
|
|
@@ -143,799 +104,467 @@ var TezosSaplingProtocolImpl = /** @class */ (function () {
|
|
|
143
104
|
? new TezosSaplingInjectorClient_1.TezosSaplingInjectorClient(this.network.injectorUrl, this.network.contractAddress)
|
|
144
105
|
: undefined;
|
|
145
106
|
}
|
|
146
|
-
|
|
147
|
-
return
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
this.
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
return
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
TezosSaplingProtocolImpl.prototype.getDetailsFromSignedTransaction = function (transaction, knownViewingKeys) {
|
|
245
|
-
var _a;
|
|
246
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
247
|
-
var airGapTxs, binary, defaultDetails, partialDetails, wrappedOperation, _b, _c, _d, _e, partialDetails;
|
|
248
|
-
return __generator(this, function (_f) {
|
|
249
|
-
switch (_f.label) {
|
|
250
|
-
case 0:
|
|
251
|
-
airGapTxs = [];
|
|
252
|
-
binary = transaction.binary;
|
|
253
|
-
defaultDetails = {
|
|
254
|
-
from: ['Shielded Pool'],
|
|
255
|
-
to: ['Shielded Pool'],
|
|
256
|
-
isInbound: false,
|
|
257
|
-
amount: (0, module_kit_1.newAmount)(0, 'blockchain'),
|
|
258
|
-
fee: (0, module_kit_1.newAmount)(0, 'blockchain'),
|
|
259
|
-
network: this.network
|
|
260
|
-
};
|
|
261
|
-
if (!((_a = this.contract) === null || _a === void 0 ? void 0 : _a.areValidParameters(binary))) return [3 /*break*/, 2];
|
|
262
|
-
return [4 /*yield*/, this.getPartialDetailsFromContractParameters(binary, knownViewingKeys)];
|
|
263
|
-
case 1:
|
|
264
|
-
partialDetails = _f.sent();
|
|
265
|
-
airGapTxs.push.apply(airGapTxs, partialDetails.map(function (partial) { return (__assign(__assign({}, defaultDetails), partial)); }));
|
|
266
|
-
return [3 /*break*/, 7];
|
|
267
|
-
case 2:
|
|
268
|
-
_f.trys.push([2, 5, , 7]);
|
|
269
|
-
return [4 /*yield*/, this.tezos.unforgeOperation(binary, 'signed')];
|
|
270
|
-
case 3:
|
|
271
|
-
wrappedOperation = _f.sent();
|
|
272
|
-
_c = (_b = airGapTxs.push).apply;
|
|
273
|
-
_d = [airGapTxs];
|
|
274
|
-
return [4 /*yield*/, this.getDetailsFromWrappedOperation(wrappedOperation, knownViewingKeys)];
|
|
275
|
-
case 4:
|
|
276
|
-
_c.apply(_b, _d.concat([(_f.sent())]));
|
|
277
|
-
return [3 /*break*/, 7];
|
|
278
|
-
case 5:
|
|
279
|
-
_e = _f.sent();
|
|
280
|
-
return [4 /*yield*/, this.accountant.getTransactionsPartialDetails([binary], knownViewingKeys)];
|
|
281
|
-
case 6:
|
|
282
|
-
partialDetails = _f.sent();
|
|
283
|
-
airGapTxs.push.apply(airGapTxs, partialDetails.map(function (partial) { return (__assign(__assign({}, defaultDetails), partial)); }));
|
|
284
|
-
return [3 /*break*/, 7];
|
|
285
|
-
case 7: return [2 /*return*/, this.filterOutPaybacks(airGapTxs)];
|
|
286
|
-
}
|
|
287
|
-
});
|
|
288
|
-
});
|
|
289
|
-
};
|
|
290
|
-
TezosSaplingProtocolImpl.prototype.getDetailsFromUnsignedTransaction = function (transaction, viewingKey, knownViewingKeys) {
|
|
291
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
292
|
-
var airGapTxs, unshieldTarget, from, details, wrappedOperation, _a, _b, _c;
|
|
293
|
-
return __generator(this, function (_d) {
|
|
294
|
-
switch (_d.label) {
|
|
295
|
-
case 0:
|
|
296
|
-
airGapTxs = [];
|
|
297
|
-
if (!(0, transaction_1.isUnsignedSaplingTransaction)(transaction)) return [3 /*break*/, 2];
|
|
298
|
-
unshieldTarget = transaction.unshieldTarget.length > 0 ? transaction.unshieldTarget : undefined;
|
|
299
|
-
return [4 /*yield*/, this.getAddressFromPublicKey(viewingKey).then(function (address) {
|
|
300
|
-
return TezosSaplingAddress_1.TezosSaplingAddress.fromValue(address.address, address.cursor.diversifierIndex);
|
|
301
|
-
})];
|
|
302
|
-
case 1:
|
|
303
|
-
from = _d.sent();
|
|
304
|
-
details = this.accountant
|
|
305
|
-
.getUnsignedTransactionDetails(from, transaction.ins, transaction.outs, unshieldTarget)
|
|
306
|
-
.map(function (details) {
|
|
307
|
-
var _a;
|
|
308
|
-
return (__assign(__assign({}, details), { extra: __assign(__assign({}, ((_a = details.extra) !== null && _a !== void 0 ? _a : {})), { destination: transaction.contractAddress, chainId: transaction.chainId }) }));
|
|
309
|
-
});
|
|
310
|
-
airGapTxs.push.apply(airGapTxs, details);
|
|
311
|
-
return [3 /*break*/, 5];
|
|
312
|
-
case 2: return [4 /*yield*/, this.tezos.unforgeOperation(transaction.binary, 'unsigned')];
|
|
313
|
-
case 3:
|
|
314
|
-
wrappedOperation = _d.sent();
|
|
315
|
-
_b = (_a = airGapTxs.push).apply;
|
|
316
|
-
_c = [airGapTxs];
|
|
317
|
-
return [4 /*yield*/, this.getDetailsFromWrappedOperation(wrappedOperation, knownViewingKeys)];
|
|
318
|
-
case 4:
|
|
319
|
-
_b.apply(_a, _c.concat([(_d.sent())]));
|
|
320
|
-
_d.label = 5;
|
|
321
|
-
case 5: return [2 /*return*/, this.filterOutPaybacks(airGapTxs)];
|
|
322
|
-
}
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
};
|
|
326
|
-
TezosSaplingProtocolImpl.prototype.getDetailsFromWrappedOperation = function (operation, knownViewingKeys) {
|
|
327
|
-
if (knownViewingKeys === void 0) { knownViewingKeys = []; }
|
|
328
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
329
|
-
var contractOperations, details;
|
|
330
|
-
var _this = this;
|
|
331
|
-
return __generator(this, function (_a) {
|
|
332
|
-
switch (_a.label) {
|
|
333
|
-
case 0:
|
|
334
|
-
contractOperations = operation.contents.filter(function (content) {
|
|
335
|
-
return content.kind === TezosOperationType_1.TezosOperationType.TRANSACTION && content.parameters !== undefined;
|
|
336
|
-
});
|
|
337
|
-
return [4 /*yield*/, Promise.all(contractOperations.map(function (operation) { return __awaiter(_this, void 0, void 0, function () {
|
|
338
|
-
var saplingDetails;
|
|
339
|
-
var _this = this;
|
|
340
|
-
return __generator(this, function (_a) {
|
|
341
|
-
switch (_a.label) {
|
|
342
|
-
case 0: return [4 /*yield*/, this.getPartialDetailsFromContractParameters(operation.parameters, knownViewingKeys)];
|
|
343
|
-
case 1:
|
|
344
|
-
saplingDetails = _a.sent();
|
|
345
|
-
return [2 /*return*/, saplingDetails.map(function (partials) { return (__assign(__assign({ from: [operation.source], to: ['Shielded Pool'], isInbound: false, amount: (0, module_kit_1.newAmount)(operation.amount, 'blockchain'), fee: (0, module_kit_1.newAmount)(operation.fee, 'blockchain'), network: _this.network }, partials), { transactionDetails: operation })); })];
|
|
346
|
-
}
|
|
347
|
-
});
|
|
348
|
-
}); }))];
|
|
349
|
-
case 1:
|
|
350
|
-
details = _a.sent();
|
|
351
|
-
return [2 /*return*/, (0, array_1.flattenArray)(details)];
|
|
352
|
-
}
|
|
353
|
-
});
|
|
354
|
-
});
|
|
355
|
-
};
|
|
356
|
-
TezosSaplingProtocolImpl.prototype.getPartialDetailsFromContractParameters = function (rawOrParsed, knownViewingKeys) {
|
|
357
|
-
if (knownViewingKeys === void 0) { knownViewingKeys = []; }
|
|
358
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
359
|
-
var parameters, txs;
|
|
360
|
-
return __generator(this, function (_a) {
|
|
361
|
-
switch (_a.label) {
|
|
362
|
-
case 0:
|
|
363
|
-
parameters = typeof rawOrParsed === 'string' ? (this.contract ? this.contract.parseParameters(rawOrParsed) : JSON.parse(rawOrParsed)) : rawOrParsed;
|
|
364
|
-
return [4 /*yield*/, this.parseParameters(parameters)];
|
|
365
|
-
case 1:
|
|
366
|
-
txs = _a.sent();
|
|
367
|
-
return [2 /*return*/, this.accountant.getTransactionsPartialDetails(txs, knownViewingKeys)];
|
|
107
|
+
async getMetadata() {
|
|
108
|
+
return this.metadata;
|
|
109
|
+
}
|
|
110
|
+
async getAddressFromPublicKey(publicKey) {
|
|
111
|
+
const address = await TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(publicKey);
|
|
112
|
+
return {
|
|
113
|
+
address: address.asString(),
|
|
114
|
+
cursor: {
|
|
115
|
+
hasNext: address.diversifierIndex !== undefined,
|
|
116
|
+
diversifierIndex: address.diversifierIndex
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
async getInitialAddressesFromPublicKey(publicKey) {
|
|
121
|
+
return [await this.getAddressFromPublicKey(publicKey)];
|
|
122
|
+
}
|
|
123
|
+
async getNextAddressFromPublicKey(publicKey, cursor) {
|
|
124
|
+
if (!cursor.hasNext) {
|
|
125
|
+
return undefined;
|
|
126
|
+
}
|
|
127
|
+
const current = await TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(publicKey, cursor.diversifierIndex);
|
|
128
|
+
const next = await TezosSaplingAddress_1.TezosSaplingAddress.next(publicKey, current);
|
|
129
|
+
return {
|
|
130
|
+
address: next.asString(),
|
|
131
|
+
cursor: {
|
|
132
|
+
hasNext: next.diversifierIndex !== undefined,
|
|
133
|
+
diversifierIndex: next.diversifierIndex
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
async getContractAddress() {
|
|
138
|
+
return this.network.contractAddress;
|
|
139
|
+
}
|
|
140
|
+
async setContractAddress(address) {
|
|
141
|
+
this.network.contractAddress = address;
|
|
142
|
+
this.contract = new TezosContract_1.TezosContract(address, this.network);
|
|
143
|
+
this.nodeClient = new TezosSaplingNodeClient_1.TezosSaplingNodeClient(this.network.rpcUrl, address);
|
|
144
|
+
if (this.network.injectorUrl !== undefined) {
|
|
145
|
+
this.injectorClient = new TezosSaplingInjectorClient_1.TezosSaplingInjectorClient(this.network.injectorUrl, address);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
async getDetailsFromTransaction(transaction, publicKey, knownViewingKeys) {
|
|
149
|
+
switch (transaction.type) {
|
|
150
|
+
case 'signed':
|
|
151
|
+
return this.getDetailsFromSignedTransaction(transaction, knownViewingKeys);
|
|
152
|
+
case 'unsigned':
|
|
153
|
+
return this.getDetailsFromUnsignedTransaction(transaction, publicKey, knownViewingKeys);
|
|
154
|
+
default:
|
|
155
|
+
(0, coinlib_core_1.assertNever)(transaction);
|
|
156
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.TEZOS, 'Unsupported transaction type.');
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
async getDetailsFromSignedTransaction(transaction, knownViewingKeys) {
|
|
160
|
+
const airGapTxs = [];
|
|
161
|
+
const binary = transaction.binary;
|
|
162
|
+
const defaultDetails = {
|
|
163
|
+
from: ['Shielded Pool'],
|
|
164
|
+
to: ['Shielded Pool'],
|
|
165
|
+
isInbound: false,
|
|
166
|
+
amount: (0, module_kit_1.newAmount)(0, 'blockchain'),
|
|
167
|
+
fee: (0, module_kit_1.newAmount)(0, 'blockchain'),
|
|
168
|
+
network: this.network
|
|
169
|
+
};
|
|
170
|
+
if (this.contract?.areValidParameters(binary)) {
|
|
171
|
+
const partialDetails = await this.getPartialDetailsFromContractParameters(binary, knownViewingKeys);
|
|
172
|
+
airGapTxs.push(...partialDetails.map((partial) => ({
|
|
173
|
+
...defaultDetails,
|
|
174
|
+
...partial
|
|
175
|
+
})));
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
try {
|
|
179
|
+
const wrappedOperation = await this.tezos.unforgeOperation(binary, 'signed');
|
|
180
|
+
airGapTxs.push(...(await this.getDetailsFromWrappedOperation(wrappedOperation, knownViewingKeys)));
|
|
181
|
+
}
|
|
182
|
+
catch {
|
|
183
|
+
const partialDetails = await this.accountant.getTransactionsPartialDetails([binary], knownViewingKeys);
|
|
184
|
+
airGapTxs.push(...partialDetails.map((partial) => ({
|
|
185
|
+
...defaultDetails,
|
|
186
|
+
...partial
|
|
187
|
+
})));
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return this.filterOutPaybacks(airGapTxs);
|
|
191
|
+
}
|
|
192
|
+
async getDetailsFromUnsignedTransaction(transaction, viewingKey, knownViewingKeys) {
|
|
193
|
+
const airGapTxs = [];
|
|
194
|
+
if ((0, transaction_1.isUnsignedSaplingTransaction)(transaction)) {
|
|
195
|
+
const unshieldTarget = transaction.unshieldTarget.length > 0 ? transaction.unshieldTarget : undefined;
|
|
196
|
+
const from = await this.getAddressFromPublicKey(viewingKey).then((address) => TezosSaplingAddress_1.TezosSaplingAddress.fromValue(address.address, address.cursor.diversifierIndex));
|
|
197
|
+
const details = this.accountant
|
|
198
|
+
.getUnsignedTransactionDetails(from, transaction.ins, transaction.outs, unshieldTarget)
|
|
199
|
+
.map((details) => ({
|
|
200
|
+
...details,
|
|
201
|
+
extra: {
|
|
202
|
+
...(details.extra ?? {}),
|
|
203
|
+
destination: transaction.contractAddress,
|
|
204
|
+
chainId: transaction.chainId
|
|
368
205
|
}
|
|
369
|
-
});
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
206
|
+
}));
|
|
207
|
+
airGapTxs.push(...details);
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
const wrappedOperation = await this.tezos.unforgeOperation(transaction.binary, 'unsigned');
|
|
211
|
+
airGapTxs.push(...(await this.getDetailsFromWrappedOperation(wrappedOperation, knownViewingKeys)));
|
|
212
|
+
}
|
|
213
|
+
return this.filterOutPaybacks(airGapTxs);
|
|
214
|
+
}
|
|
215
|
+
async getDetailsFromWrappedOperation(operation, knownViewingKeys = []) {
|
|
216
|
+
const contractOperations = operation.contents.filter((content) => content.kind === TezosOperationType_1.TezosOperationType.TRANSACTION && content.parameters !== undefined);
|
|
217
|
+
const details = await Promise.all(contractOperations.map(async (operation) => {
|
|
218
|
+
const saplingDetails = await this.getPartialDetailsFromContractParameters(operation.parameters, knownViewingKeys);
|
|
219
|
+
return saplingDetails.map((partials) => ({
|
|
220
|
+
from: [operation.source],
|
|
221
|
+
to: ['Shielded Pool'],
|
|
222
|
+
isInbound: false,
|
|
223
|
+
amount: (0, module_kit_1.newAmount)(operation.amount, 'blockchain'),
|
|
224
|
+
fee: (0, module_kit_1.newAmount)(operation.fee, 'blockchain'),
|
|
225
|
+
network: this.network,
|
|
226
|
+
...partials,
|
|
227
|
+
transactionDetails: operation
|
|
228
|
+
}));
|
|
229
|
+
}));
|
|
230
|
+
return (0, array_1.flattenArray)(details);
|
|
231
|
+
}
|
|
232
|
+
async getPartialDetailsFromContractParameters(rawOrParsed, knownViewingKeys = []) {
|
|
233
|
+
const parameters = typeof rawOrParsed === 'string' ? (this.contract ? this.contract.parseParameters(rawOrParsed) : JSON.parse(rawOrParsed)) : rawOrParsed;
|
|
234
|
+
const txs = await this.parseParameters(parameters);
|
|
235
|
+
return this.accountant.getTransactionsPartialDetails(txs, knownViewingKeys);
|
|
236
|
+
}
|
|
237
|
+
filterOutPaybacks(airGapTxs) {
|
|
238
|
+
const filtered = airGapTxs.filter((details) => {
|
|
374
239
|
if (details.from.length !== details.to.length) {
|
|
375
240
|
return true;
|
|
376
241
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
return Array.from(fromSet).some(
|
|
242
|
+
const fromSet = new Set(details.from);
|
|
243
|
+
const toSet = new Set(details.to);
|
|
244
|
+
return Array.from(fromSet).some((address) => !toSet.has(address));
|
|
380
245
|
});
|
|
381
246
|
return filtered.length > 0 ? filtered : airGapTxs;
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
return
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
TezosSaplingProtocolImpl.prototype.signTransactionWithSecretKey = function (transaction, secretKey) {
|
|
403
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
404
|
-
var hexSecretKey, stateTree, boundData, forgedTransaction;
|
|
405
|
-
return __generator(this, function (_a) {
|
|
406
|
-
switch (_a.label) {
|
|
407
|
-
case 0:
|
|
408
|
-
hexSecretKey = (0, key_1.convertSecretKey)(secretKey, 'hex', 'saplingSpendingKey');
|
|
409
|
-
return [4 /*yield*/, this.state.getStateTreeFromStateDiff(transaction.stateDiff)];
|
|
410
|
-
case 1:
|
|
411
|
-
stateTree = _a.sent();
|
|
412
|
-
boundData = transaction.unshieldTarget && transaction.unshieldTarget.length > 0
|
|
413
|
-
? this.createAddressBoundData(transaction.unshieldTarget)
|
|
414
|
-
: undefined;
|
|
415
|
-
return [4 /*yield*/, this.forger.forgeSaplingTransaction(transaction.ins, transaction.outs, stateTree, this.getAntiReplay(transaction.chainId, transaction.contractAddress), boundData, Buffer.from(hexSecretKey.value, 'hex'))];
|
|
416
|
-
case 2:
|
|
417
|
-
forgedTransaction = _a.sent();
|
|
418
|
-
return [2 /*return*/, (0, module_kit_1.newSignedTransaction)({
|
|
419
|
-
binary: this.encoder.encodeTransaction(forgedTransaction).toString('hex')
|
|
420
|
-
})];
|
|
421
|
-
}
|
|
422
|
-
});
|
|
247
|
+
}
|
|
248
|
+
async getCryptoConfiguration() {
|
|
249
|
+
return this.cryptoConfiguration;
|
|
250
|
+
}
|
|
251
|
+
async getKeyPairFromDerivative(derivative) {
|
|
252
|
+
const zip32Node = (0, crypto_1.encodeDerivative)('zip32', derivative);
|
|
253
|
+
return {
|
|
254
|
+
secretKey: (0, module_kit_1.newSecretKey)(zip32Node.secretKey, 'hex'),
|
|
255
|
+
publicKey: (0, module_kit_1.newPublicKey)(zip32Node.publicKey, 'hex')
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
async signTransactionWithSecretKey(transaction, secretKey) {
|
|
259
|
+
const hexSecretKey = (0, key_1.convertSecretKey)(secretKey, 'hex', 'saplingSpendingKey');
|
|
260
|
+
const stateTree = await this.state.getStateTreeFromStateDiff(transaction.stateDiff);
|
|
261
|
+
const boundData = transaction.unshieldTarget && transaction.unshieldTarget.length > 0
|
|
262
|
+
? this.createAddressBoundData(transaction.unshieldTarget)
|
|
263
|
+
: undefined;
|
|
264
|
+
const forgedTransaction = await this.forger.forgeSaplingTransaction(transaction.ins, transaction.outs, stateTree, this.getAntiReplay(transaction.chainId, transaction.contractAddress), boundData, Buffer.from(hexSecretKey.value, 'hex'));
|
|
265
|
+
return (0, module_kit_1.newSignedTransaction)({
|
|
266
|
+
binary: this.encoder.encodeTransaction(forgedTransaction).toString('hex')
|
|
423
267
|
});
|
|
424
|
-
}
|
|
268
|
+
}
|
|
425
269
|
// Online
|
|
426
|
-
|
|
427
|
-
return
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
436
|
-
var hexPublicKey, saplingStateDiff, incoming, outgoing, page, pageStart, pageEnd, hasNext, commitmentsAndCiphertexts, inputs, airGapIncoming, airGapOutgoing;
|
|
437
|
-
var _this = this;
|
|
438
|
-
return __generator(this, function (_b) {
|
|
439
|
-
switch (_b.label) {
|
|
440
|
-
case 0:
|
|
441
|
-
if (this.nodeClient === undefined) {
|
|
442
|
-
return [2 /*return*/, {
|
|
443
|
-
transactions: [],
|
|
444
|
-
cursor: {
|
|
445
|
-
hasNext: false
|
|
446
|
-
}
|
|
447
|
-
}];
|
|
448
|
-
}
|
|
449
|
-
hexPublicKey = (0, key_1.convertPublicKey)(publicKey, 'hex', 'saplingViewingKey');
|
|
450
|
-
return [4 /*yield*/, this.nodeClient.getSaplingStateDiff()];
|
|
451
|
-
case 1:
|
|
452
|
-
saplingStateDiff = _b.sent();
|
|
453
|
-
incoming = [];
|
|
454
|
-
outgoing = [];
|
|
455
|
-
page = (_a = cursor === null || cursor === void 0 ? void 0 : cursor.page) !== null && _a !== void 0 ? _a : 0;
|
|
456
|
-
pageStart = page * limit;
|
|
457
|
-
pageEnd = pageStart + limit;
|
|
458
|
-
hasNext = pageStart < saplingStateDiff.commitments_and_ciphertexts.length;
|
|
459
|
-
_b.label = 2;
|
|
460
|
-
case 2:
|
|
461
|
-
if (!(incoming.length + outgoing.length < limit && hasNext)) return [3 /*break*/, 4];
|
|
462
|
-
commitmentsAndCiphertexts = saplingStateDiff.commitments_and_ciphertexts
|
|
463
|
-
.map(function (_a, index) {
|
|
464
|
-
var commitment = _a[0], ciphertext = _a[1];
|
|
465
|
-
return [commitment, ciphertext, new bignumber_1.default(index)];
|
|
466
|
-
})
|
|
467
|
-
.reverse()
|
|
468
|
-
.slice(pageStart, pageEnd);
|
|
469
|
-
return [4 /*yield*/, Promise.all([
|
|
470
|
-
this.accountant.getIncomingInputs(hexPublicKey.value, commitmentsAndCiphertexts),
|
|
471
|
-
this.accountant.getOutgoingInputs(hexPublicKey.value, commitmentsAndCiphertexts)
|
|
472
|
-
])];
|
|
473
|
-
case 3:
|
|
474
|
-
inputs = _b.sent();
|
|
475
|
-
incoming.push.apply(incoming, inputs[0]);
|
|
476
|
-
outgoing.push.apply(outgoing, inputs[1]);
|
|
477
|
-
page += 1;
|
|
478
|
-
pageStart += limit;
|
|
479
|
-
pageEnd += limit;
|
|
480
|
-
hasNext = pageStart < saplingStateDiff.commitments_and_ciphertexts.length;
|
|
481
|
-
return [3 /*break*/, 2];
|
|
482
|
-
case 4: return [4 /*yield*/, Promise.all(incoming.map(function (input) { return __awaiter(_this, void 0, void 0, function () {
|
|
483
|
-
return __generator(this, function (_a) {
|
|
484
|
-
return [2 /*return*/, ({
|
|
485
|
-
from: ['Shielded Pool'],
|
|
486
|
-
to: [input.address],
|
|
487
|
-
isInbound: true,
|
|
488
|
-
amount: (0, module_kit_1.newAmount)(input.value, 'blockchain'),
|
|
489
|
-
fee: (0, module_kit_1.newAmount)(0, 'blockchain'),
|
|
490
|
-
network: this.network
|
|
491
|
-
})];
|
|
492
|
-
});
|
|
493
|
-
}); }))];
|
|
494
|
-
case 5:
|
|
495
|
-
airGapIncoming = _b.sent();
|
|
496
|
-
return [4 /*yield*/, Promise.all(outgoing.map(function (input) { return __awaiter(_this, void 0, void 0, function () {
|
|
497
|
-
var _a;
|
|
498
|
-
return __generator(this, function (_b) {
|
|
499
|
-
switch (_b.label) {
|
|
500
|
-
case 0:
|
|
501
|
-
_a = {};
|
|
502
|
-
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
503
|
-
case 1: return [2 /*return*/, (_a.from = [(_b.sent()).address],
|
|
504
|
-
_a.to = [input.address],
|
|
505
|
-
_a.isInbound = false,
|
|
506
|
-
_a.amount = (0, module_kit_1.newAmount)(input.value, 'blockchain'),
|
|
507
|
-
_a.fee = (0, module_kit_1.newAmount)(0, 'blockchain'),
|
|
508
|
-
_a.network = this.network,
|
|
509
|
-
_a)];
|
|
510
|
-
}
|
|
511
|
-
});
|
|
512
|
-
}); }))];
|
|
513
|
-
case 6:
|
|
514
|
-
airGapOutgoing = _b.sent();
|
|
515
|
-
return [2 /*return*/, {
|
|
516
|
-
transactions: airGapIncoming.concat(airGapOutgoing),
|
|
517
|
-
cursor: {
|
|
518
|
-
hasNext: hasNext,
|
|
519
|
-
page: hasNext ? page + 1 : undefined
|
|
520
|
-
}
|
|
521
|
-
}];
|
|
522
|
-
}
|
|
523
|
-
});
|
|
524
|
-
});
|
|
525
|
-
};
|
|
526
|
-
TezosSaplingProtocolImpl.prototype.getBalanceOfPublicKey = function (publicKey) {
|
|
527
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
528
|
-
var hexPublicKey, saplingStateDiff, unspends, balance;
|
|
529
|
-
return __generator(this, function (_a) {
|
|
530
|
-
switch (_a.label) {
|
|
531
|
-
case 0:
|
|
532
|
-
if (this.nodeClient === undefined) {
|
|
533
|
-
return [2 /*return*/, { total: (0, module_kit_1.newAmount)(0, 'blockchain') }];
|
|
534
|
-
}
|
|
535
|
-
hexPublicKey = (0, key_1.convertPublicKey)(publicKey, 'hex', 'saplingViewingKey');
|
|
536
|
-
return [4 /*yield*/, this.nodeClient.getSaplingStateDiff()];
|
|
537
|
-
case 1:
|
|
538
|
-
saplingStateDiff = _a.sent();
|
|
539
|
-
return [4 /*yield*/, this.accountant.getUnspends(hexPublicKey.value, saplingStateDiff.commitments_and_ciphertexts, saplingStateDiff.nullifiers)];
|
|
540
|
-
case 2:
|
|
541
|
-
unspends = _a.sent();
|
|
542
|
-
balance = unspends.reduce(function (sum, next) { return sum.plus(next.value); }, new bignumber_1.default(0));
|
|
543
|
-
return [2 /*return*/, { total: (0, module_kit_1.newAmount)(balance, 'blockchain') }];
|
|
544
|
-
}
|
|
545
|
-
});
|
|
546
|
-
});
|
|
547
|
-
};
|
|
548
|
-
TezosSaplingProtocolImpl.prototype.getTransactionMaxAmountWithPublicKey = function (publicKey, _to, _configuration) {
|
|
549
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
550
|
-
var balance;
|
|
551
|
-
return __generator(this, function (_a) {
|
|
552
|
-
switch (_a.label) {
|
|
553
|
-
case 0: return [4 /*yield*/, this.getBalanceOfPublicKey(publicKey)];
|
|
554
|
-
case 1:
|
|
555
|
-
balance = _a.sent();
|
|
556
|
-
return [2 /*return*/, balance.total];
|
|
557
|
-
}
|
|
558
|
-
});
|
|
559
|
-
});
|
|
560
|
-
};
|
|
561
|
-
TezosSaplingProtocolImpl.prototype.getTransactionFeeWithPublicKey = function (_publicKey, _details, _configuration) {
|
|
562
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
563
|
-
return __generator(this, function (_a) {
|
|
564
|
-
return [2 /*return*/, undefined];
|
|
565
|
-
});
|
|
566
|
-
});
|
|
567
|
-
};
|
|
568
|
-
TezosSaplingProtocolImpl.prototype.prepareTransactionWithPublicKey = function (publicKey, details, configuration) {
|
|
569
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
570
|
-
var recipient;
|
|
571
|
-
return __generator(this, function (_a) {
|
|
572
|
-
if (details.length > 1) {
|
|
573
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.TEZOS, 'Multiple sapling transactions are not supported yet');
|
|
574
|
-
}
|
|
575
|
-
recipient = details[0].to;
|
|
576
|
-
if (TezosAddress_1.TezosAddress.isTzAddress(recipient)) {
|
|
577
|
-
return [2 /*return*/, this.prepareUnshieldTransaction(publicKey, details, configuration)];
|
|
578
|
-
}
|
|
579
|
-
else if (TezosSaplingAddress_1.TezosSaplingAddress.isZetAddress(recipient)) {
|
|
580
|
-
return [2 /*return*/, this.prepareSaplingTransaction(publicKey, details, configuration)];
|
|
581
|
-
}
|
|
582
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.TEZOS, "Invalid recpient, expected a 'tz' or 'zet' address, got ".concat(recipient));
|
|
583
|
-
});
|
|
584
|
-
});
|
|
585
|
-
};
|
|
586
|
-
TezosSaplingProtocolImpl.prototype.broadcastTransaction = function (transaction) {
|
|
587
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
588
|
-
var hash, error_1;
|
|
589
|
-
return __generator(this, function (_a) {
|
|
590
|
-
switch (_a.label) {
|
|
591
|
-
case 0:
|
|
592
|
-
if (!this.injectorClient) {
|
|
593
|
-
throw new errors_1.PropertyUndefinedError(coinlib_core_1.Domain.TEZOS, "Can't broadcast a sapling transaction, an injector service URL or contract address has not be set.");
|
|
594
|
-
}
|
|
595
|
-
_a.label = 1;
|
|
596
|
-
case 1:
|
|
597
|
-
_a.trys.push([1, 3, , 4]);
|
|
598
|
-
return [4 /*yield*/, this.injectorClient.injectTransaction(transaction.binary)];
|
|
599
|
-
case 2:
|
|
600
|
-
hash = _a.sent();
|
|
601
|
-
return [2 /*return*/, hash];
|
|
602
|
-
case 3:
|
|
603
|
-
error_1 = _a.sent();
|
|
604
|
-
throw new errors_1.NetworkError(coinlib_core_1.Domain.TEZOS, error_1);
|
|
605
|
-
case 4: return [2 /*return*/];
|
|
606
|
-
}
|
|
607
|
-
});
|
|
608
|
-
});
|
|
609
|
-
};
|
|
610
|
-
TezosSaplingProtocolImpl.prototype.getInjectorUrl = function () {
|
|
611
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
612
|
-
return __generator(this, function (_a) {
|
|
613
|
-
return [2 /*return*/, this.network.injectorUrl];
|
|
614
|
-
});
|
|
615
|
-
});
|
|
616
|
-
};
|
|
617
|
-
TezosSaplingProtocolImpl.prototype.setInjectorUrl = function (url) {
|
|
618
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
619
|
-
return __generator(this, function (_a) {
|
|
620
|
-
this.network.injectorUrl = url;
|
|
621
|
-
if (this.network.contractAddress !== undefined) {
|
|
622
|
-
this.injectorClient = new TezosSaplingInjectorClient_1.TezosSaplingInjectorClient(url, this.network.contractAddress);
|
|
623
|
-
}
|
|
624
|
-
return [2 /*return*/];
|
|
625
|
-
});
|
|
626
|
-
});
|
|
627
|
-
};
|
|
628
|
-
TezosSaplingProtocolImpl.prototype.initParameters = function (spendParams, outputParams) {
|
|
629
|
-
var _a;
|
|
630
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
631
|
-
var externalInitParameters;
|
|
632
|
-
return __generator(this, function (_b) {
|
|
633
|
-
switch (_b.label) {
|
|
634
|
-
case 0:
|
|
635
|
-
externalInitParameters = this.externalProvider ? (_a = this.externalProvider.initParameters) === null || _a === void 0 ? void 0 : _a.bind(this.externalProvider) : undefined;
|
|
636
|
-
if (!(externalInitParameters !== undefined)) return [3 /*break*/, 2];
|
|
637
|
-
return [4 /*yield*/, externalInitParameters(spendParams, outputParams)];
|
|
638
|
-
case 1:
|
|
639
|
-
_b.sent();
|
|
640
|
-
return [3 /*break*/, 4];
|
|
641
|
-
case 2: return [4 /*yield*/, sapling.initParameters(spendParams, outputParams)];
|
|
642
|
-
case 3:
|
|
643
|
-
_b.sent();
|
|
644
|
-
_b.label = 4;
|
|
645
|
-
case 4: return [2 /*return*/];
|
|
646
|
-
}
|
|
647
|
-
});
|
|
648
|
-
});
|
|
649
|
-
};
|
|
650
|
-
TezosSaplingProtocolImpl.prototype.getAddressFromViewingKey = function (viewingKey, index) {
|
|
651
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
652
|
-
var address;
|
|
653
|
-
return __generator(this, function (_a) {
|
|
654
|
-
switch (_a.label) {
|
|
655
|
-
case 0: return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(viewingKey, index)];
|
|
656
|
-
case 1:
|
|
657
|
-
address = _a.sent();
|
|
658
|
-
return [2 /*return*/, {
|
|
659
|
-
address: address.asString(),
|
|
660
|
-
cursor: {
|
|
661
|
-
hasNext: address.diversifierIndex !== undefined,
|
|
662
|
-
diversifierIndex: address.diversifierIndex
|
|
663
|
-
}
|
|
664
|
-
}];
|
|
665
|
-
}
|
|
666
|
-
});
|
|
667
|
-
});
|
|
668
|
-
};
|
|
669
|
-
TezosSaplingProtocolImpl.prototype.prepareShieldTransaction = function (publicKey, details, configuration) {
|
|
670
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
671
|
-
var recipient, value, encodedTransaction;
|
|
672
|
-
return __generator(this, function (_a) {
|
|
673
|
-
switch (_a.label) {
|
|
674
|
-
case 0:
|
|
675
|
-
if (details.length > 1) {
|
|
676
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.TEZOS, 'Multiple sapling transactions are not supported yet');
|
|
677
|
-
}
|
|
678
|
-
recipient = details[0].to;
|
|
679
|
-
value = (0, module_kit_1.newAmount)(details[0].amount).blockchain(this.metadata.units).value;
|
|
680
|
-
return [4 /*yield*/, this.mint(recipient, value)];
|
|
681
|
-
case 1:
|
|
682
|
-
encodedTransaction = _a.sent();
|
|
683
|
-
return [2 /*return*/, this.wrapSaplingTransactions(publicKey, [encodedTransaction], configuration)];
|
|
684
|
-
}
|
|
685
|
-
});
|
|
686
|
-
});
|
|
687
|
-
};
|
|
688
|
-
TezosSaplingProtocolImpl.prototype.prepareSaplingTransaction = function (viewingKey, details, configuration) {
|
|
689
|
-
var _a, _b;
|
|
690
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
691
|
-
var recipient, value, dummyInputsAmount, dummyOutputsAmount, _c, stateDiff, chainId, hexViewingKey, _d, inputs, toSpend, address, paymentOutput, _e, paybackOutput, _f, dummyInputs, dummyOutputs;
|
|
692
|
-
var _this = this;
|
|
693
|
-
return __generator(this, function (_g) {
|
|
694
|
-
switch (_g.label) {
|
|
695
|
-
case 0:
|
|
696
|
-
if (details.length > 1) {
|
|
697
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.TEZOS, 'Multiple sapling transactions are not supported yet');
|
|
698
|
-
}
|
|
699
|
-
if (this.nodeClient === undefined || this.network.contractAddress === undefined) {
|
|
700
|
-
throw new errors_1.PropertyUndefinedError(coinlib_core_1.Domain.TEZOS, 'Contract address not set.');
|
|
701
|
-
}
|
|
702
|
-
recipient = details[0].to;
|
|
703
|
-
value = (0, module_kit_1.newAmount)(details[0].amount).blockchain(this.metadata.units).value;
|
|
704
|
-
if (!TezosSaplingAddress_1.TezosSaplingAddress.isZetAddress(recipient)) {
|
|
705
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.TEZOS, "Invalid recpient, expected a 'zet' address, got ".concat(recipient));
|
|
706
|
-
}
|
|
707
|
-
dummyInputsAmount = Math.max(new bignumber_1.default((_a = configuration === null || configuration === void 0 ? void 0 : configuration.dummyInputs) !== null && _a !== void 0 ? _a : 0).toNumber(), 0);
|
|
708
|
-
dummyOutputsAmount = Math.max(new bignumber_1.default((_b = configuration === null || configuration === void 0 ? void 0 : configuration.dummyOutputs) !== null && _b !== void 0 ? _b : 0).toNumber(), 0);
|
|
709
|
-
return [4 /*yield*/, Promise.all([
|
|
710
|
-
this.nodeClient.getSaplingStateDiff(),
|
|
711
|
-
this.nodeClient.getChainId()
|
|
712
|
-
])];
|
|
713
|
-
case 1:
|
|
714
|
-
_c = _g.sent(), stateDiff = _c[0], chainId = _c[1];
|
|
715
|
-
hexViewingKey = (0, key_1.convertPublicKey)(viewingKey, 'hex', 'saplingViewingKey');
|
|
716
|
-
return [4 /*yield*/, this.chooseInputs(hexViewingKey.value, stateDiff.commitments_and_ciphertexts, stateDiff.nullifiers, value)];
|
|
717
|
-
case 2:
|
|
718
|
-
_d = _g.sent(), inputs = _d[0], toSpend = _d[1];
|
|
719
|
-
return [4 /*yield*/, this.getAddressFromPublicKey(viewingKey).then(function (address) {
|
|
720
|
-
return TezosSaplingAddress_1.TezosSaplingAddress.fromValue(address.address, address.cursor.diversifierIndex);
|
|
721
|
-
})];
|
|
722
|
-
case 3:
|
|
723
|
-
address = _g.sent();
|
|
724
|
-
_e = this.createPaymentOutput;
|
|
725
|
-
return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromValue(recipient)];
|
|
726
|
-
case 4:
|
|
727
|
-
paymentOutput = _e.apply(this, [_g.sent(), value]);
|
|
728
|
-
paybackOutput = this.createPaybackOutput(address, toSpend, value);
|
|
729
|
-
return [4 /*yield*/, Promise.all([
|
|
730
|
-
Promise.all(Array.from({ length: dummyInputsAmount }, function (_v, _k) { return _this.createDummyInput(address); })),
|
|
731
|
-
Promise.all(Array.from({ length: dummyOutputsAmount }, function (_v, _k) { return _this.createDummyOutput(); }))
|
|
732
|
-
])];
|
|
733
|
-
case 5:
|
|
734
|
-
_f = _g.sent(), dummyInputs = _f[0], dummyOutputs = _f[1];
|
|
735
|
-
return [2 /*return*/, (0, module_kit_1.newUnsignedTransaction)({
|
|
736
|
-
ins: inputs.concat(dummyInputs),
|
|
737
|
-
outs: __spreadArray([paymentOutput, paybackOutput], dummyOutputs, true).filter(function (output) { return output !== undefined; }),
|
|
738
|
-
contractAddress: this.network.contractAddress,
|
|
739
|
-
chainId: chainId,
|
|
740
|
-
stateDiff: stateDiff,
|
|
741
|
-
unshieldTarget: ''
|
|
742
|
-
})];
|
|
743
|
-
}
|
|
744
|
-
});
|
|
745
|
-
});
|
|
746
|
-
};
|
|
747
|
-
TezosSaplingProtocolImpl.prototype.prepareUnshieldTransaction = function (viewingKey, details, _configuration) {
|
|
748
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
749
|
-
var recipient, value, burnTransaction;
|
|
750
|
-
return __generator(this, function (_a) {
|
|
751
|
-
switch (_a.label) {
|
|
752
|
-
case 0:
|
|
753
|
-
if (details.length > 1) {
|
|
754
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.TEZOS, 'Multiple sapling transactions are not supported yet');
|
|
755
|
-
}
|
|
756
|
-
recipient = details[0].to;
|
|
757
|
-
value = (0, module_kit_1.newAmount)(details[0].amount).blockchain(this.metadata.units).value;
|
|
758
|
-
return [4 /*yield*/, this.burn(viewingKey, value)];
|
|
759
|
-
case 1:
|
|
760
|
-
burnTransaction = _a.sent();
|
|
761
|
-
return [2 /*return*/, __assign(__assign({}, burnTransaction), { unshieldTarget: recipient })];
|
|
762
|
-
}
|
|
763
|
-
});
|
|
764
|
-
});
|
|
765
|
-
};
|
|
766
|
-
TezosSaplingProtocolImpl.prototype.wrapSaplingTransactions = function (publicKey, transactions, configuration) {
|
|
767
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
768
|
-
var tezosMetadata, fee, overrideFees, operations, parameters, normalizedTransactions, contractCalls, tezosWrappedOperation, binaryTx, error_2, rpcErrors, cannotPayStorageFee, balanceTooLowError;
|
|
769
|
-
var _this = this;
|
|
770
|
-
return __generator(this, function (_a) {
|
|
771
|
-
switch (_a.label) {
|
|
772
|
-
case 0:
|
|
773
|
-
if (this.contract === undefined) {
|
|
774
|
-
throw new errors_1.PropertyUndefinedError(coinlib_core_1.Domain.TEZOS, 'Contract address not set.');
|
|
775
|
-
}
|
|
776
|
-
return [4 /*yield*/, this.tezos.getMetadata()];
|
|
777
|
-
case 1:
|
|
778
|
-
tezosMetadata = _a.sent();
|
|
779
|
-
fee = (configuration === null || configuration === void 0 ? void 0 : configuration.fee) ? (0, module_kit_1.newAmount)(configuration.fee).blockchain(tezosMetadata.units).value : '0';
|
|
780
|
-
overrideFees = (configuration === null || configuration === void 0 ? void 0 : configuration.fee) === undefined;
|
|
781
|
-
operations = [];
|
|
782
|
-
if (!(typeof transactions === 'string' && this.contract.areValidParameters(transactions))) return [3 /*break*/, 2];
|
|
783
|
-
parameters = this.contract.parseParameters(transactions);
|
|
784
|
-
operations = [this.prepareTezosOperation(parameters, fee)];
|
|
785
|
-
return [3 /*break*/, 4];
|
|
786
|
-
case 2:
|
|
787
|
-
normalizedTransactions = Array.isArray(transactions) ? transactions : [transactions];
|
|
788
|
-
return [4 /*yield*/, this.prepareContractCalls(normalizedTransactions)];
|
|
789
|
-
case 3:
|
|
790
|
-
contractCalls = _a.sent();
|
|
791
|
-
operations = contractCalls.map(function (contractCall) { var _a; return _this.prepareTezosOperation(contractCall.toJSON(), fee, (_a = contractCall.amount) === null || _a === void 0 ? void 0 : _a.toString()); });
|
|
792
|
-
_a.label = 4;
|
|
793
|
-
case 4:
|
|
794
|
-
_a.trys.push([4, 7, , 8]);
|
|
795
|
-
return [4 /*yield*/, this.tezos.prepareOperations(publicKey, operations, overrideFees)];
|
|
796
|
-
case 5:
|
|
797
|
-
tezosWrappedOperation = _a.sent();
|
|
798
|
-
return [4 /*yield*/, this.tezos.forgeOperation(tezosWrappedOperation)];
|
|
799
|
-
case 6:
|
|
800
|
-
binaryTx = _a.sent();
|
|
801
|
-
return [2 /*return*/, (0, module_kit_1.newUnsignedTransaction)({ binary: binaryTx })];
|
|
802
|
-
case 7:
|
|
803
|
-
error_2 = _a.sent();
|
|
804
|
-
console.error(error_2);
|
|
805
|
-
if (error_2.code !== undefined && error_2.code === errors_1.ProtocolErrorType.TRANSACTION_FAILED) {
|
|
806
|
-
rpcErrors = error_2.data;
|
|
807
|
-
cannotPayStorageFee = rpcErrors.find(function (error) { return error.id.endsWith('.contract.cannot_pay_storage_fee'); });
|
|
808
|
-
if (cannotPayStorageFee) {
|
|
809
|
-
throw new errors_1.BalanceError(coinlib_core_1.Domain.TEZOS, 'Balance too low, cannot pay for storage fee');
|
|
810
|
-
}
|
|
811
|
-
balanceTooLowError = rpcErrors.find(function (error) { return error.id.endsWith('.contract.balance_too_low'); });
|
|
812
|
-
if (balanceTooLowError) {
|
|
813
|
-
throw new errors_1.BalanceError(coinlib_core_1.Domain.TEZOS, 'Balance too low');
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
throw error_2;
|
|
817
|
-
case 8: return [2 /*return*/];
|
|
818
|
-
}
|
|
819
|
-
});
|
|
820
|
-
});
|
|
821
|
-
};
|
|
822
|
-
TezosSaplingProtocolImpl.prototype.mint = function (recipient, value) {
|
|
823
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
824
|
-
var _a, saplingStateDiff, chainId, output, stateTree, forgedTransaction;
|
|
825
|
-
var _b;
|
|
826
|
-
return __generator(this, function (_c) {
|
|
827
|
-
switch (_c.label) {
|
|
828
|
-
case 0:
|
|
829
|
-
if (this.nodeClient === undefined || this.network.contractAddress === undefined) {
|
|
830
|
-
throw new errors_1.PropertyUndefinedError(coinlib_core_1.Domain.TEZOS, 'Contract address not set.');
|
|
831
|
-
}
|
|
832
|
-
if (!TezosSaplingAddress_1.TezosSaplingAddress.isZetAddress(recipient)) {
|
|
833
|
-
return [2 /*return*/, Promise.reject("Invalid recipient, expected a 'zet' address, got ".concat(recipient))];
|
|
834
|
-
}
|
|
835
|
-
return [4 /*yield*/, Promise.all([
|
|
836
|
-
this.nodeClient.getSaplingStateDiff(),
|
|
837
|
-
this.nodeClient.getChainId()
|
|
838
|
-
])];
|
|
839
|
-
case 1:
|
|
840
|
-
_a = _c.sent(), saplingStateDiff = _a[0], chainId = _a[1];
|
|
841
|
-
_b = {};
|
|
842
|
-
return [4 /*yield*/, TezosSaplingAddress_1.TezosSaplingAddress.fromValue(recipient)];
|
|
843
|
-
case 2:
|
|
844
|
-
output = (_b.address = (_c.sent()).asString(),
|
|
845
|
-
_b.value = value,
|
|
846
|
-
_b.memo = Buffer.alloc(this.memoSize).toString('hex'),
|
|
847
|
-
_b.browsable = true,
|
|
848
|
-
_b);
|
|
849
|
-
return [4 /*yield*/, this.state.getStateTreeFromStateDiff(saplingStateDiff, true)];
|
|
850
|
-
case 3:
|
|
851
|
-
stateTree = _c.sent();
|
|
852
|
-
return [4 /*yield*/, this.forger.forgeSaplingTransaction([], [output], stateTree, this.getAntiReplay(chainId, this.network.contractAddress))];
|
|
853
|
-
case 4:
|
|
854
|
-
forgedTransaction = _c.sent();
|
|
855
|
-
return [2 /*return*/, this.encoder.encodeTransaction(forgedTransaction).toString('hex')];
|
|
270
|
+
async getNetwork() {
|
|
271
|
+
return this.network;
|
|
272
|
+
}
|
|
273
|
+
async getTransactionsForPublicKey(publicKey, limit, cursor) {
|
|
274
|
+
if (this.nodeClient === undefined) {
|
|
275
|
+
return {
|
|
276
|
+
transactions: [],
|
|
277
|
+
cursor: {
|
|
278
|
+
hasNext: false
|
|
856
279
|
}
|
|
857
|
-
}
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
const hexPublicKey = (0, key_1.convertPublicKey)(publicKey, 'hex', 'saplingViewingKey');
|
|
283
|
+
const saplingStateDiff = await this.nodeClient.getSaplingStateDiff();
|
|
284
|
+
const incoming = [];
|
|
285
|
+
const outgoing = [];
|
|
286
|
+
let page = cursor?.page ?? 0;
|
|
287
|
+
let pageStart = page * limit;
|
|
288
|
+
let pageEnd = pageStart + limit;
|
|
289
|
+
let hasNext = pageStart < saplingStateDiff.commitments_and_ciphertexts.length;
|
|
290
|
+
while (incoming.length + outgoing.length < limit && hasNext) {
|
|
291
|
+
const commitmentsAndCiphertexts = saplingStateDiff.commitments_and_ciphertexts
|
|
292
|
+
.map(([commitment, ciphertext], index) => [commitment, ciphertext, new bignumber_1.default(index)])
|
|
293
|
+
.reverse()
|
|
294
|
+
.slice(pageStart, pageEnd);
|
|
295
|
+
const inputs = await Promise.all([
|
|
296
|
+
this.accountant.getIncomingInputs(hexPublicKey.value, commitmentsAndCiphertexts),
|
|
297
|
+
this.accountant.getOutgoingInputs(hexPublicKey.value, commitmentsAndCiphertexts)
|
|
298
|
+
]);
|
|
299
|
+
incoming.push(...inputs[0]);
|
|
300
|
+
outgoing.push(...inputs[1]);
|
|
301
|
+
page += 1;
|
|
302
|
+
pageStart += limit;
|
|
303
|
+
pageEnd += limit;
|
|
304
|
+
hasNext = pageStart < saplingStateDiff.commitments_and_ciphertexts.length;
|
|
305
|
+
}
|
|
306
|
+
const airGapIncoming = await Promise.all(incoming.map(async (input) => ({
|
|
307
|
+
from: ['Shielded Pool'],
|
|
308
|
+
to: [input.address],
|
|
309
|
+
isInbound: true,
|
|
310
|
+
amount: (0, module_kit_1.newAmount)(input.value, 'blockchain'),
|
|
311
|
+
fee: (0, module_kit_1.newAmount)(0, 'blockchain'),
|
|
312
|
+
network: this.network
|
|
313
|
+
})));
|
|
314
|
+
const airGapOutgoing = await Promise.all(outgoing.map(async (input) => ({
|
|
315
|
+
from: [(await this.getAddressFromPublicKey(publicKey)).address],
|
|
316
|
+
to: [input.address],
|
|
317
|
+
isInbound: false,
|
|
318
|
+
amount: (0, module_kit_1.newAmount)(input.value, 'blockchain'),
|
|
319
|
+
fee: (0, module_kit_1.newAmount)(0, 'blockchain'),
|
|
320
|
+
network: this.network
|
|
321
|
+
})));
|
|
322
|
+
return {
|
|
323
|
+
transactions: airGapIncoming.concat(airGapOutgoing),
|
|
324
|
+
cursor: {
|
|
325
|
+
hasNext,
|
|
326
|
+
page: hasNext ? page + 1 : undefined
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
async getBalanceOfPublicKey(publicKey) {
|
|
331
|
+
if (this.nodeClient === undefined) {
|
|
332
|
+
return { total: (0, module_kit_1.newAmount)(0, 'blockchain') };
|
|
333
|
+
}
|
|
334
|
+
const hexPublicKey = (0, key_1.convertPublicKey)(publicKey, 'hex', 'saplingViewingKey');
|
|
335
|
+
const saplingStateDiff = await this.nodeClient.getSaplingStateDiff();
|
|
336
|
+
const unspends = await this.accountant.getUnspends(hexPublicKey.value, saplingStateDiff.commitments_and_ciphertexts, saplingStateDiff.nullifiers);
|
|
337
|
+
const balance = unspends.reduce((sum, next) => sum.plus(next.value), new bignumber_1.default(0));
|
|
338
|
+
return { total: (0, module_kit_1.newAmount)(balance, 'blockchain') };
|
|
339
|
+
}
|
|
340
|
+
async getTransactionMaxAmountWithPublicKey(publicKey, _to, _configuration) {
|
|
341
|
+
const balance = await this.getBalanceOfPublicKey(publicKey);
|
|
342
|
+
return balance.total;
|
|
343
|
+
}
|
|
344
|
+
async getTransactionFeeWithPublicKey(_publicKey, _details, _configuration) {
|
|
345
|
+
return undefined;
|
|
346
|
+
}
|
|
347
|
+
async prepareTransactionWithPublicKey(publicKey, details, configuration) {
|
|
348
|
+
if (details.length > 1) {
|
|
349
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.TEZOS, 'Multiple sapling transactions are not supported yet');
|
|
350
|
+
}
|
|
351
|
+
const recipient = details[0].to;
|
|
352
|
+
if (TezosAddress_1.TezosAddress.isTzAddress(recipient)) {
|
|
353
|
+
return this.prepareUnshieldTransaction(publicKey, details, configuration);
|
|
354
|
+
}
|
|
355
|
+
else if (TezosSaplingAddress_1.TezosSaplingAddress.isZetAddress(recipient)) {
|
|
356
|
+
return this.prepareSaplingTransaction(publicKey, details, configuration);
|
|
357
|
+
}
|
|
358
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.TEZOS, `Invalid recpient, expected a 'tz' or 'zet' address, got ${recipient}`);
|
|
359
|
+
}
|
|
360
|
+
async broadcastTransaction(transaction) {
|
|
361
|
+
if (!this.injectorClient) {
|
|
362
|
+
throw new errors_1.PropertyUndefinedError(coinlib_core_1.Domain.TEZOS, "Can't broadcast a sapling transaction, an injector service URL or contract address has not be set.");
|
|
363
|
+
}
|
|
364
|
+
try {
|
|
365
|
+
const hash = await this.injectorClient.injectTransaction(transaction.binary);
|
|
366
|
+
return hash;
|
|
367
|
+
}
|
|
368
|
+
catch (error) {
|
|
369
|
+
throw new errors_1.NetworkError(coinlib_core_1.Domain.TEZOS, error);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
async getInjectorUrl() {
|
|
373
|
+
return this.network.injectorUrl;
|
|
374
|
+
}
|
|
375
|
+
async setInjectorUrl(url) {
|
|
376
|
+
this.network.injectorUrl = url;
|
|
377
|
+
if (this.network.contractAddress !== undefined) {
|
|
378
|
+
this.injectorClient = new TezosSaplingInjectorClient_1.TezosSaplingInjectorClient(url, this.network.contractAddress);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
async initParameters(spendParams, outputParams) {
|
|
382
|
+
const externalInitParameters = this.externalProvider ? this.externalProvider.initParameters?.bind(this.externalProvider) : undefined;
|
|
383
|
+
if (externalInitParameters !== undefined) {
|
|
384
|
+
await externalInitParameters(spendParams, outputParams);
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
await sapling.initParameters(spendParams, outputParams);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
async getAddressFromViewingKey(viewingKey, index) {
|
|
391
|
+
const address = await TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(viewingKey, index);
|
|
392
|
+
return {
|
|
393
|
+
address: address.asString(),
|
|
394
|
+
cursor: {
|
|
395
|
+
hasNext: address.diversifierIndex !== undefined,
|
|
396
|
+
diversifierIndex: address.diversifierIndex
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
async prepareShieldTransaction(publicKey, details, configuration) {
|
|
401
|
+
if (details.length > 1) {
|
|
402
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.TEZOS, 'Multiple sapling transactions are not supported yet');
|
|
403
|
+
}
|
|
404
|
+
const recipient = details[0].to;
|
|
405
|
+
const value = (0, module_kit_1.newAmount)(details[0].amount).blockchain(this.metadata.units).value;
|
|
406
|
+
const encodedTransaction = await this.mint(recipient, value);
|
|
407
|
+
return this.wrapSaplingTransactions(publicKey, [encodedTransaction], configuration);
|
|
408
|
+
}
|
|
409
|
+
async prepareSaplingTransaction(viewingKey, details, configuration) {
|
|
410
|
+
if (details.length > 1) {
|
|
411
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.TEZOS, 'Multiple sapling transactions are not supported yet');
|
|
412
|
+
}
|
|
413
|
+
if (this.nodeClient === undefined || this.network.contractAddress === undefined) {
|
|
414
|
+
throw new errors_1.PropertyUndefinedError(coinlib_core_1.Domain.TEZOS, 'Contract address not set.');
|
|
415
|
+
}
|
|
416
|
+
const recipient = details[0].to;
|
|
417
|
+
const value = (0, module_kit_1.newAmount)(details[0].amount).blockchain(this.metadata.units).value;
|
|
418
|
+
if (!TezosSaplingAddress_1.TezosSaplingAddress.isZetAddress(recipient)) {
|
|
419
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.TEZOS, `Invalid recpient, expected a 'zet' address, got ${recipient}`);
|
|
420
|
+
}
|
|
421
|
+
const dummyInputsAmount = Math.max(new bignumber_1.default(configuration?.dummyInputs ?? 0).toNumber(), 0);
|
|
422
|
+
const dummyOutputsAmount = Math.max(new bignumber_1.default(configuration?.dummyOutputs ?? 0).toNumber(), 0);
|
|
423
|
+
const [stateDiff, chainId] = await Promise.all([
|
|
424
|
+
this.nodeClient.getSaplingStateDiff(),
|
|
425
|
+
this.nodeClient.getChainId()
|
|
426
|
+
]);
|
|
427
|
+
const hexViewingKey = (0, key_1.convertPublicKey)(viewingKey, 'hex', 'saplingViewingKey');
|
|
428
|
+
const [inputs, toSpend] = await this.chooseInputs(hexViewingKey.value, stateDiff.commitments_and_ciphertexts, stateDiff.nullifiers, value);
|
|
429
|
+
const address = await this.getAddressFromPublicKey(viewingKey).then((address) => TezosSaplingAddress_1.TezosSaplingAddress.fromValue(address.address, address.cursor.diversifierIndex));
|
|
430
|
+
const paymentOutput = this.createPaymentOutput(await TezosSaplingAddress_1.TezosSaplingAddress.fromValue(recipient), value);
|
|
431
|
+
const paybackOutput = this.createPaybackOutput(address, toSpend, value);
|
|
432
|
+
const [dummyInputs, dummyOutputs] = await Promise.all([
|
|
433
|
+
Promise.all(Array.from({ length: dummyInputsAmount }, (_v, _k) => this.createDummyInput(address))),
|
|
434
|
+
Promise.all(Array.from({ length: dummyOutputsAmount }, (_v, _k) => this.createDummyOutput()))
|
|
435
|
+
]);
|
|
436
|
+
return (0, module_kit_1.newUnsignedTransaction)({
|
|
437
|
+
ins: inputs.concat(dummyInputs),
|
|
438
|
+
outs: [paymentOutput, paybackOutput, ...dummyOutputs].filter((output) => output !== undefined),
|
|
439
|
+
contractAddress: this.network.contractAddress,
|
|
440
|
+
chainId,
|
|
441
|
+
stateDiff,
|
|
442
|
+
unshieldTarget: ''
|
|
858
443
|
});
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
444
|
+
}
|
|
445
|
+
async prepareUnshieldTransaction(viewingKey, details, _configuration) {
|
|
446
|
+
if (details.length > 1) {
|
|
447
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.TEZOS, 'Multiple sapling transactions are not supported yet');
|
|
448
|
+
}
|
|
449
|
+
const recipient = details[0].to;
|
|
450
|
+
const value = (0, module_kit_1.newAmount)(details[0].amount).blockchain(this.metadata.units).value;
|
|
451
|
+
const burnTransaction = await this.burn(viewingKey, value);
|
|
452
|
+
return {
|
|
453
|
+
...burnTransaction,
|
|
454
|
+
unshieldTarget: recipient
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
async wrapSaplingTransactions(publicKey, transactions, configuration) {
|
|
458
|
+
if (this.contract === undefined) {
|
|
459
|
+
throw new errors_1.PropertyUndefinedError(coinlib_core_1.Domain.TEZOS, 'Contract address not set.');
|
|
460
|
+
}
|
|
461
|
+
const tezosMetadata = await this.tezos.getMetadata();
|
|
462
|
+
const fee = configuration?.fee ? (0, module_kit_1.newAmount)(configuration.fee).blockchain(tezosMetadata.units).value : '0';
|
|
463
|
+
const overrideFees = configuration?.fee === undefined;
|
|
464
|
+
let operations = [];
|
|
465
|
+
if (typeof transactions === 'string' && this.contract.areValidParameters(transactions)) {
|
|
466
|
+
const parameters = this.contract.parseParameters(transactions);
|
|
467
|
+
operations = [this.prepareTezosOperation(parameters, fee)];
|
|
468
|
+
}
|
|
469
|
+
else {
|
|
470
|
+
const normalizedTransactions = Array.isArray(transactions) ? transactions : [transactions];
|
|
471
|
+
const contractCalls = await this.prepareContractCalls(normalizedTransactions);
|
|
472
|
+
operations = contractCalls.map((contractCall) => this.prepareTezosOperation(contractCall.toJSON(), fee, contractCall.amount?.toString()));
|
|
473
|
+
}
|
|
474
|
+
try {
|
|
475
|
+
const tezosWrappedOperation = await this.tezos.prepareOperations(publicKey, operations, overrideFees);
|
|
476
|
+
const binaryTx = await this.tezos.forgeOperation(tezosWrappedOperation);
|
|
477
|
+
return (0, module_kit_1.newUnsignedTransaction)({ binary: binaryTx });
|
|
478
|
+
}
|
|
479
|
+
catch (error) {
|
|
480
|
+
console.error(error);
|
|
481
|
+
if (error.code !== undefined && error.code === errors_1.ProtocolErrorType.TRANSACTION_FAILED) {
|
|
482
|
+
const rpcErrors = error.data;
|
|
483
|
+
const cannotPayStorageFee = rpcErrors.find((error) => error.id.endsWith('.contract.cannot_pay_storage_fee'));
|
|
484
|
+
if (cannotPayStorageFee) {
|
|
485
|
+
throw new errors_1.BalanceError(coinlib_core_1.Domain.TEZOS, 'Balance too low, cannot pay for storage fee');
|
|
896
486
|
}
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
TezosSaplingProtocolImpl.prototype.chooseInputs = function (viewingKey, commitmentsWithCiphertext, nullifiers, value) {
|
|
901
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
902
|
-
var unspends, balance, chosenUnspends, toSpend, _i, unspends_1, unspend;
|
|
903
|
-
return __generator(this, function (_a) {
|
|
904
|
-
switch (_a.label) {
|
|
905
|
-
case 0: return [4 /*yield*/, this.accountant.getUnspends(viewingKey, commitmentsWithCiphertext, nullifiers)];
|
|
906
|
-
case 1:
|
|
907
|
-
unspends = _a.sent();
|
|
908
|
-
balance = this.accountant.sumNotes(unspends);
|
|
909
|
-
if (balance.lt(value)) {
|
|
910
|
-
return [2 /*return*/, Promise.reject('Not enough balance')];
|
|
911
|
-
}
|
|
912
|
-
chosenUnspends = [];
|
|
913
|
-
toSpend = new bignumber_1.default(0);
|
|
914
|
-
for (_i = 0, unspends_1 = unspends; _i < unspends_1.length; _i++) {
|
|
915
|
-
unspend = unspends_1[_i];
|
|
916
|
-
if (toSpend.gte(value)) {
|
|
917
|
-
break;
|
|
918
|
-
}
|
|
919
|
-
toSpend = toSpend.plus(unspend.value);
|
|
920
|
-
chosenUnspends.push(unspend);
|
|
921
|
-
}
|
|
922
|
-
return [2 /*return*/, [chosenUnspends, toSpend]];
|
|
487
|
+
const balanceTooLowError = rpcErrors.find((error) => error.id.endsWith('.contract.balance_too_low'));
|
|
488
|
+
if (balanceTooLowError) {
|
|
489
|
+
throw new errors_1.BalanceError(coinlib_core_1.Domain.TEZOS, 'Balance too low');
|
|
923
490
|
}
|
|
924
|
-
}
|
|
491
|
+
}
|
|
492
|
+
throw error;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
async mint(recipient, value) {
|
|
496
|
+
if (this.nodeClient === undefined || this.network.contractAddress === undefined) {
|
|
497
|
+
throw new errors_1.PropertyUndefinedError(coinlib_core_1.Domain.TEZOS, 'Contract address not set.');
|
|
498
|
+
}
|
|
499
|
+
if (!TezosSaplingAddress_1.TezosSaplingAddress.isZetAddress(recipient)) {
|
|
500
|
+
return Promise.reject(`Invalid recipient, expected a 'zet' address, got ${recipient}`);
|
|
501
|
+
}
|
|
502
|
+
const [saplingStateDiff, chainId] = await Promise.all([
|
|
503
|
+
this.nodeClient.getSaplingStateDiff(),
|
|
504
|
+
this.nodeClient.getChainId()
|
|
505
|
+
]);
|
|
506
|
+
const output = {
|
|
507
|
+
address: (await TezosSaplingAddress_1.TezosSaplingAddress.fromValue(recipient)).asString(),
|
|
508
|
+
value,
|
|
509
|
+
memo: Buffer.alloc(this.memoSize).toString('hex'),
|
|
510
|
+
browsable: true
|
|
511
|
+
};
|
|
512
|
+
const stateTree = await this.state.getStateTreeFromStateDiff(saplingStateDiff, true);
|
|
513
|
+
const forgedTransaction = await this.forger.forgeSaplingTransaction([], [output], stateTree, this.getAntiReplay(chainId, this.network.contractAddress));
|
|
514
|
+
return this.encoder.encodeTransaction(forgedTransaction).toString('hex');
|
|
515
|
+
}
|
|
516
|
+
async burn(viewingKey, value) {
|
|
517
|
+
if (this.nodeClient === undefined || this.network.contractAddress === undefined) {
|
|
518
|
+
throw new errors_1.PropertyUndefinedError(coinlib_core_1.Domain.TEZOS, 'Contract address not set.');
|
|
519
|
+
}
|
|
520
|
+
const [stateDiff, chainId] = await Promise.all([
|
|
521
|
+
this.nodeClient.getSaplingStateDiff(),
|
|
522
|
+
this.nodeClient.getChainId()
|
|
523
|
+
]);
|
|
524
|
+
const hexViewingKey = (0, key_1.convertPublicKey)(viewingKey, 'hex', 'saplingViewingKey');
|
|
525
|
+
const [inputs, toSpend] = await this.chooseInputs(hexViewingKey.value, stateDiff.commitments_and_ciphertexts, stateDiff.nullifiers, value);
|
|
526
|
+
const paybackOutput = {
|
|
527
|
+
address: (await this.getAddressFromPublicKey(viewingKey)).address,
|
|
528
|
+
value: toSpend.minus(value).toString(),
|
|
529
|
+
memo: Buffer.alloc(this.memoSize).toString('hex'),
|
|
530
|
+
browsable: true
|
|
531
|
+
};
|
|
532
|
+
return (0, module_kit_1.newUnsignedTransaction)({
|
|
533
|
+
ins: inputs,
|
|
534
|
+
outs: [paybackOutput],
|
|
535
|
+
contractAddress: this.network.contractAddress,
|
|
536
|
+
chainId,
|
|
537
|
+
stateDiff,
|
|
538
|
+
unshieldTarget: ''
|
|
925
539
|
});
|
|
926
|
-
}
|
|
927
|
-
|
|
928
|
-
|
|
540
|
+
}
|
|
541
|
+
async chooseInputs(viewingKey, commitmentsWithCiphertext, nullifiers, value) {
|
|
542
|
+
const unspends = await this.accountant.getUnspends(viewingKey, commitmentsWithCiphertext, nullifiers);
|
|
543
|
+
const balance = this.accountant.sumNotes(unspends);
|
|
544
|
+
if (balance.lt(value)) {
|
|
545
|
+
return Promise.reject('Not enough balance');
|
|
546
|
+
}
|
|
547
|
+
const chosenUnspends = [];
|
|
548
|
+
let toSpend = new bignumber_1.default(0);
|
|
549
|
+
for (const unspend of unspends) {
|
|
550
|
+
if (toSpend.gte(value)) {
|
|
551
|
+
break;
|
|
552
|
+
}
|
|
553
|
+
toSpend = toSpend.plus(unspend.value);
|
|
554
|
+
chosenUnspends.push(unspend);
|
|
555
|
+
}
|
|
556
|
+
return [chosenUnspends, toSpend];
|
|
557
|
+
}
|
|
558
|
+
createPaymentOutput(address, value, memo = Buffer.alloc(this.memoSize)) {
|
|
929
559
|
return {
|
|
930
560
|
address: address.asString(),
|
|
931
561
|
value: new bignumber_1.default(value).toString(),
|
|
932
562
|
memo: memo.toString('hex'),
|
|
933
563
|
browsable: true
|
|
934
564
|
};
|
|
935
|
-
}
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
var paybackValue = toSpend.minus(value);
|
|
565
|
+
}
|
|
566
|
+
createPaybackOutput(address, toSpend, value, memo = Buffer.alloc(this.memoSize)) {
|
|
567
|
+
const paybackValue = toSpend.minus(value);
|
|
939
568
|
return paybackValue.gt(0)
|
|
940
569
|
? {
|
|
941
570
|
address: address.asString(),
|
|
@@ -944,78 +573,48 @@ var TezosSaplingProtocolImpl = /** @class */ (function () {
|
|
|
944
573
|
browsable: true
|
|
945
574
|
}
|
|
946
575
|
: undefined;
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
return [2 /*return*/, {
|
|
976
|
-
address: address.address,
|
|
977
|
-
value: '0',
|
|
978
|
-
memo: Buffer.from(memo).toString('hex'),
|
|
979
|
-
browsable: false
|
|
980
|
-
}];
|
|
981
|
-
}
|
|
982
|
-
});
|
|
983
|
-
});
|
|
984
|
-
};
|
|
985
|
-
TezosSaplingProtocolImpl.prototype.getDummyAddress = function () {
|
|
986
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
987
|
-
var seed, xfvk, publicKey;
|
|
988
|
-
return __generator(this, function (_a) {
|
|
989
|
-
switch (_a.label) {
|
|
990
|
-
case 0:
|
|
991
|
-
seed = (0, random_1.randomBytes)(32);
|
|
992
|
-
return [4 /*yield*/, sapling.getExtendedFullViewingKey(seed, this.metadata.account.standardDerivationPath)];
|
|
993
|
-
case 1:
|
|
994
|
-
xfvk = _a.sent();
|
|
995
|
-
publicKey = (0, module_kit_1.newPublicKey)(xfvk.toString('hex'), 'hex');
|
|
996
|
-
return [2 /*return*/, this.getAddressFromPublicKey(publicKey)];
|
|
997
|
-
}
|
|
998
|
-
});
|
|
999
|
-
});
|
|
1000
|
-
};
|
|
1001
|
-
TezosSaplingProtocolImpl.prototype.createAddressBoundData = function (address) {
|
|
1002
|
-
var michelson = MichelsonAddress_1.MichelsonAddress.from((0, pack_1.encodeTzAddress)(address));
|
|
576
|
+
}
|
|
577
|
+
async createDummyInput(address) {
|
|
578
|
+
const rcm = await sapling.randR();
|
|
579
|
+
return {
|
|
580
|
+
rcm: rcm.toString('hex'),
|
|
581
|
+
pos: '0',
|
|
582
|
+
value: '0',
|
|
583
|
+
address: address.asString()
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
async createDummyOutput() {
|
|
587
|
+
const address = await this.getDummyAddress();
|
|
588
|
+
const memo = (0, random_1.randomBytes)(this.memoSize);
|
|
589
|
+
return {
|
|
590
|
+
address: address.address,
|
|
591
|
+
value: '0',
|
|
592
|
+
memo: Buffer.from(memo).toString('hex'),
|
|
593
|
+
browsable: false
|
|
594
|
+
};
|
|
595
|
+
}
|
|
596
|
+
async getDummyAddress() {
|
|
597
|
+
const seed = (0, random_1.randomBytes)(32);
|
|
598
|
+
const xfvk = await sapling.getExtendedFullViewingKey(seed, this.metadata.account.standardDerivationPath);
|
|
599
|
+
const publicKey = (0, module_kit_1.newPublicKey)(xfvk.toString('hex'), 'hex');
|
|
600
|
+
return this.getAddressFromPublicKey(publicKey);
|
|
601
|
+
}
|
|
602
|
+
createAddressBoundData(address) {
|
|
603
|
+
const michelson = MichelsonAddress_1.MichelsonAddress.from((0, pack_1.encodeTzAddress)(address));
|
|
1003
604
|
return (0, pack_1.packMichelsonType)(michelson);
|
|
1004
|
-
}
|
|
1005
|
-
|
|
605
|
+
}
|
|
606
|
+
getAntiReplay(chainId, contractAddress) {
|
|
1006
607
|
return contractAddress + chainId;
|
|
1007
|
-
}
|
|
1008
|
-
|
|
1009
|
-
if (amount === void 0) { amount = '0'; }
|
|
608
|
+
}
|
|
609
|
+
prepareTezosOperation(parameters, fee, amount = '0') {
|
|
1010
610
|
return {
|
|
1011
611
|
kind: TezosOperationType_1.TezosOperationType.TRANSACTION,
|
|
1012
|
-
fee
|
|
1013
|
-
amount
|
|
612
|
+
fee,
|
|
613
|
+
amount,
|
|
1014
614
|
destination: this.network.contractAddress,
|
|
1015
|
-
parameters
|
|
615
|
+
parameters
|
|
1016
616
|
};
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
}());
|
|
617
|
+
}
|
|
618
|
+
}
|
|
1020
619
|
exports.TezosSaplingProtocolImpl = TezosSaplingProtocolImpl;
|
|
1021
620
|
//# sourceMappingURL=TezosSaplingProtocol.js.map
|