@airgap/tezos 0.13.45-beta.2 → 0.13.45-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +848 -1385
- 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,30 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __assign = (this && this.__assign) || function () {
|
|
18
|
-
__assign = Object.assign || function(t) {
|
|
19
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
-
s = arguments[i];
|
|
21
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
-
t[p] = s[p];
|
|
23
|
-
}
|
|
24
|
-
return t;
|
|
25
|
-
};
|
|
26
|
-
return __assign.apply(this, arguments);
|
|
27
|
-
};
|
|
28
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
3
|
if (k2 === undefined) k2 = k;
|
|
30
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -41,964 +15,552 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
41
15
|
}) : function(o, v) {
|
|
42
16
|
o["default"] = v;
|
|
43
17
|
});
|
|
44
|
-
var __importStar = (this && this.__importStar) || function (
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
62
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
63
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
64
|
-
function step(op) {
|
|
65
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
66
|
-
while (_) try {
|
|
67
|
-
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;
|
|
68
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
69
|
-
switch (op[0]) {
|
|
70
|
-
case 0: case 1: t = op; break;
|
|
71
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
72
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
73
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
74
|
-
default:
|
|
75
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
76
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
77
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
78
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
79
|
-
if (t[2]) _.ops.pop();
|
|
80
|
-
_.trys.pop(); continue;
|
|
81
|
-
}
|
|
82
|
-
op = body.call(thisArg, _);
|
|
83
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
84
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
88
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
89
|
-
if (ar || !(i in from)) {
|
|
90
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
91
|
-
ar[i] = from[i];
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
95
|
-
};
|
|
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
|
+
})();
|
|
96
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
97
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
98
37
|
};
|
|
99
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
100
39
|
exports.TezosSaplingProtocol = void 0;
|
|
101
|
-
|
|
40
|
+
const bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
102
41
|
// @ts-ignore
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
_this.cryptoClient = new TezosSaplingCryptoClient_1.TezosSaplingCryptoClient(_this.tezosProtocol.cryptoClient);
|
|
148
|
-
_this.nodeClient = _this.options.config.contractAddress
|
|
149
|
-
? new TezosSaplingNodeClient_1.TezosSaplingNodeClient(_this.options.network.rpcUrl, _this.options.config.contractAddress)
|
|
42
|
+
const bip39_2_5_0_1 = require("@airgap/coinlib-core/dependencies/src/bip39-2.5.0");
|
|
43
|
+
const errors_1 = require("@airgap/coinlib-core/errors");
|
|
44
|
+
const coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
|
|
45
|
+
const NonExtendedProtocol_1 = require("@airgap/coinlib-core/protocols/NonExtendedProtocol");
|
|
46
|
+
const array_1 = require("@airgap/coinlib-core/utils/array");
|
|
47
|
+
const sapling = __importStar(require("@airgap/sapling-wasm"));
|
|
48
|
+
const random_1 = require("@stablelib/random");
|
|
49
|
+
const TezosContract_1 = require("../contract/TezosContract");
|
|
50
|
+
const TezosAddress_1 = require("../TezosAddress");
|
|
51
|
+
const TezosProtocol_1 = require("../TezosProtocol");
|
|
52
|
+
const TezosProtocolOptions_1 = require("../TezosProtocolOptions");
|
|
53
|
+
const TezosUtils_1 = require("../TezosUtils");
|
|
54
|
+
const MichelsonAddress_1 = require("../types/michelson/primitives/MichelsonAddress");
|
|
55
|
+
const TezosOperationType_1 = require("../types/TezosOperationType");
|
|
56
|
+
const TezosSaplingInjectorClient_1 = require("./injector/TezosSaplingInjectorClient");
|
|
57
|
+
const TezosSaplingNodeClient_1 = require("./node/TezosSaplingNodeClient");
|
|
58
|
+
const TezosSaplingAddress_1 = require("./TezosSaplingAddress");
|
|
59
|
+
const TezosSaplingCryptoClient_1 = require("./TezosSaplingCryptoClient");
|
|
60
|
+
const TezosSaplingBookkeeper_1 = require("./utils/TezosSaplingBookkeeper");
|
|
61
|
+
const TezosSaplingEncoder_1 = require("./utils/TezosSaplingEncoder");
|
|
62
|
+
const TezosSaplingForger_1 = require("./utils/TezosSaplingForger");
|
|
63
|
+
const TezosSaplingState_1 = require("./utils/TezosSaplingState");
|
|
64
|
+
class TezosSaplingProtocol extends NonExtendedProtocol_1.NonExtendedProtocol {
|
|
65
|
+
constructor(options) {
|
|
66
|
+
super();
|
|
67
|
+
this.options = options;
|
|
68
|
+
this.supportsHD = false;
|
|
69
|
+
this.addressIsCaseSensitive = true;
|
|
70
|
+
this.addressValidationPattern = '^(zet1[1-9A-Za-z]{65}|tz1[1-9A-Za-z]{33})$';
|
|
71
|
+
this.addressPlaceholder = 'zet1...';
|
|
72
|
+
this.tezosProtocol = new TezosProtocol_1.TezosProtocol(new TezosProtocolOptions_1.TezosProtocolOptions(this.options.network, new TezosProtocolOptions_1.TezosProtocolConfig()));
|
|
73
|
+
this.name = options.config.name;
|
|
74
|
+
this.symbol = options.config.symbol ?? this.tezosProtocol.symbol;
|
|
75
|
+
this.marketSymbol = options.config.marketSymbol ?? this.tezosProtocol.marketSymbol;
|
|
76
|
+
this.feeSymbol = this.tezosProtocol.feeSymbol;
|
|
77
|
+
this.feeDefaults = options.config.feeDefaults ?? this.tezosProtocol.feeDefaults;
|
|
78
|
+
this.decimals = options.config.decimals ?? this.tezosProtocol.decimals;
|
|
79
|
+
this.feeDecimals = this.tezosProtocol.feeDecimals;
|
|
80
|
+
this.identifier = options.config.identifier ?? this.tezosProtocol.identifier;
|
|
81
|
+
this.units = this.options.config.units ?? this.tezosProtocol.units;
|
|
82
|
+
this.standardDerivationPath = this.tezosProtocol.standardDerivationPath;
|
|
83
|
+
this.cryptoClient = new TezosSaplingCryptoClient_1.TezosSaplingCryptoClient(this.tezosProtocol.cryptoClient);
|
|
84
|
+
this.nodeClient = this.options.config.contractAddress
|
|
85
|
+
? new TezosSaplingNodeClient_1.TezosSaplingNodeClient(this.options.network.rpcUrl, this.options.config.contractAddress)
|
|
150
86
|
: undefined;
|
|
151
|
-
|
|
152
|
-
? new TezosContract_1.TezosContract(
|
|
87
|
+
this.contract = this.options.config.contractAddress
|
|
88
|
+
? new TezosContract_1.TezosContract(this.options.config.contractAddress, this.options.network)
|
|
153
89
|
: undefined;
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
? new TezosSaplingInjectorClient_1.TezosSaplingInjectorClient(
|
|
90
|
+
this.injectorClient =
|
|
91
|
+
this.options.config.injectorUrl && this.options.config.contractAddress
|
|
92
|
+
? new TezosSaplingInjectorClient_1.TezosSaplingInjectorClient(this.options.config.injectorUrl, this.options.config.contractAddress)
|
|
157
93
|
: undefined;
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
return
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
return __generator(this, function (_a) {
|
|
244
|
-
return [2 /*return*/, this.standardDerivationPath];
|
|
245
|
-
});
|
|
246
|
-
});
|
|
247
|
-
};
|
|
248
|
-
TezosSaplingProtocol.prototype.getAddressIsCaseSensitive = function () {
|
|
249
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
250
|
-
return __generator(this, function (_a) {
|
|
251
|
-
return [2 /*return*/, this.addressIsCaseSensitive];
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
};
|
|
255
|
-
TezosSaplingProtocol.prototype.getAddressValidationPattern = function () {
|
|
256
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
257
|
-
return __generator(this, function (_a) {
|
|
258
|
-
return [2 /*return*/, this.addressValidationPattern];
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
};
|
|
262
|
-
TezosSaplingProtocol.prototype.getAddressPlaceholder = function () {
|
|
263
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
264
|
-
return __generator(this, function (_a) {
|
|
265
|
-
return [2 /*return*/, this.addressPlaceholder];
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
};
|
|
269
|
-
TezosSaplingProtocol.prototype.getOptions = function () {
|
|
270
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
271
|
-
return __generator(this, function (_a) {
|
|
272
|
-
return [2 /*return*/, this.options];
|
|
273
|
-
});
|
|
274
|
-
});
|
|
275
|
-
};
|
|
276
|
-
TezosSaplingProtocol.prototype.getContractAddress = function () {
|
|
277
|
-
var _a;
|
|
278
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
279
|
-
return __generator(this, function (_b) {
|
|
280
|
-
return [2 /*return*/, (_a = this.contract) === null || _a === void 0 ? void 0 : _a.address];
|
|
281
|
-
});
|
|
282
|
-
});
|
|
283
|
-
};
|
|
284
|
-
TezosSaplingProtocol.prototype.setContractAddress = function (address, configuration) {
|
|
285
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
286
|
-
return __generator(this, function (_a) {
|
|
287
|
-
this.options.config.contractAddress = address;
|
|
288
|
-
this.nodeClient = new TezosSaplingNodeClient_1.TezosSaplingNodeClient(this.options.network.rpcUrl, address);
|
|
289
|
-
this.contract = new TezosContract_1.TezosContract(address, this.options.network);
|
|
290
|
-
this.options.config.injectorUrl = configuration === null || configuration === void 0 ? void 0 : configuration.injectorUrl;
|
|
291
|
-
this.injectorClient = new TezosSaplingInjectorClient_1.TezosSaplingInjectorClient(configuration === null || configuration === void 0 ? void 0 : configuration.injectorUrl, address);
|
|
292
|
-
return [2 /*return*/];
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
};
|
|
296
|
-
TezosSaplingProtocol.prototype.initParameters = function (spendParams, outputParams) {
|
|
297
|
-
var _a;
|
|
298
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
299
|
-
var externalInitParameters;
|
|
300
|
-
return __generator(this, function (_b) {
|
|
301
|
-
switch (_b.label) {
|
|
302
|
-
case 0:
|
|
303
|
-
externalInitParameters = (_a = this.options.config.externalProvider) === null || _a === void 0 ? void 0 : _a.initParameters;
|
|
304
|
-
if (!(externalInitParameters !== undefined)) return [3 /*break*/, 2];
|
|
305
|
-
return [4 /*yield*/, externalInitParameters(spendParams, outputParams)];
|
|
306
|
-
case 1:
|
|
307
|
-
_b.sent();
|
|
308
|
-
return [3 /*break*/, 4];
|
|
309
|
-
case 2: return [4 /*yield*/, sapling.initParameters(spendParams, outputParams)];
|
|
310
|
-
case 3:
|
|
311
|
-
_b.sent();
|
|
312
|
-
_b.label = 4;
|
|
313
|
-
case 4: return [2 /*return*/];
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
};
|
|
318
|
-
TezosSaplingProtocol.prototype.getBlockExplorerLinkForTxId = function (txId) {
|
|
319
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
320
|
-
return __generator(this, function (_a) {
|
|
321
|
-
return [2 /*return*/, this.tezosProtocol.getBlockExplorerLinkForTxId(txId)];
|
|
322
|
-
});
|
|
323
|
-
});
|
|
324
|
-
};
|
|
325
|
-
TezosSaplingProtocol.prototype.getPublicKeyFromMnemonic = function (mnemonic, derivationPath, password) {
|
|
326
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
327
|
-
var seed;
|
|
328
|
-
return __generator(this, function (_a) {
|
|
329
|
-
seed = this.getSeedFromMnemonic(mnemonic, password);
|
|
330
|
-
return [2 /*return*/, this.getPublicKeyFromHexSecret(seed.toString('hex'), derivationPath)];
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
|
-
};
|
|
334
|
-
TezosSaplingProtocol.prototype.getPrivateKeyFromMnemonic = function (mnemonic, derivationPath, password) {
|
|
335
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
336
|
-
var seed;
|
|
337
|
-
return __generator(this, function (_a) {
|
|
338
|
-
seed = this.getSeedFromMnemonic(mnemonic, password);
|
|
339
|
-
return [2 /*return*/, this.getPrivateKeyFromHexSecret(seed.toString('hex'), derivationPath)];
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
};
|
|
343
|
-
TezosSaplingProtocol.prototype.getSeedFromMnemonic = function (mnemonic, password) {
|
|
344
|
-
var seed = (0, bip39_2_5_0_1.mnemonicToSeed)(mnemonic, password);
|
|
94
|
+
this.state = new TezosSaplingState_1.TezosSaplingState(this.options.config.merkleTreeHeight);
|
|
95
|
+
this.encoder = new TezosSaplingEncoder_1.TezosSaplingEncoder();
|
|
96
|
+
this.forger = new TezosSaplingForger_1.TezosSaplingForger(this.cryptoClient, this.state, this.encoder, this.options.config.externalProvider);
|
|
97
|
+
this.bookkeeper = new TezosSaplingBookkeeper_1.TezosSaplingBookkeeper(this.identifier, this.options.network, this.cryptoClient, this.encoder);
|
|
98
|
+
}
|
|
99
|
+
async getSymbol() {
|
|
100
|
+
return this.symbol;
|
|
101
|
+
}
|
|
102
|
+
async getName() {
|
|
103
|
+
return this.name;
|
|
104
|
+
}
|
|
105
|
+
async getMarketSymbol() {
|
|
106
|
+
return this.marketSymbol;
|
|
107
|
+
}
|
|
108
|
+
async getAssetSymbol() {
|
|
109
|
+
return undefined;
|
|
110
|
+
}
|
|
111
|
+
async getFeeSymbol() {
|
|
112
|
+
return this.feeSymbol;
|
|
113
|
+
}
|
|
114
|
+
async getDecimals() {
|
|
115
|
+
return this.decimals;
|
|
116
|
+
}
|
|
117
|
+
async getFeeDecimals() {
|
|
118
|
+
return this.feeDecimals;
|
|
119
|
+
}
|
|
120
|
+
async getIdentifier() {
|
|
121
|
+
return this.identifier;
|
|
122
|
+
}
|
|
123
|
+
async getFeeDefaults() {
|
|
124
|
+
return this.feeDefaults;
|
|
125
|
+
}
|
|
126
|
+
async getUnits() {
|
|
127
|
+
return this.units;
|
|
128
|
+
}
|
|
129
|
+
async getSupportsHD() {
|
|
130
|
+
return this.supportsHD;
|
|
131
|
+
}
|
|
132
|
+
async getStandardDerivationPath() {
|
|
133
|
+
return this.standardDerivationPath;
|
|
134
|
+
}
|
|
135
|
+
async getAddressIsCaseSensitive() {
|
|
136
|
+
return this.addressIsCaseSensitive;
|
|
137
|
+
}
|
|
138
|
+
async getAddressValidationPattern() {
|
|
139
|
+
return this.addressValidationPattern;
|
|
140
|
+
}
|
|
141
|
+
async getAddressPlaceholder() {
|
|
142
|
+
return this.addressPlaceholder;
|
|
143
|
+
}
|
|
144
|
+
async getOptions() {
|
|
145
|
+
return this.options;
|
|
146
|
+
}
|
|
147
|
+
async getContractAddress() {
|
|
148
|
+
return this.contract?.address;
|
|
149
|
+
}
|
|
150
|
+
async setContractAddress(address, configuration) {
|
|
151
|
+
this.options.config.contractAddress = address;
|
|
152
|
+
this.nodeClient = new TezosSaplingNodeClient_1.TezosSaplingNodeClient(this.options.network.rpcUrl, address);
|
|
153
|
+
this.contract = new TezosContract_1.TezosContract(address, this.options.network);
|
|
154
|
+
this.options.config.injectorUrl = configuration?.injectorUrl;
|
|
155
|
+
this.injectorClient = new TezosSaplingInjectorClient_1.TezosSaplingInjectorClient(configuration?.injectorUrl, address);
|
|
156
|
+
}
|
|
157
|
+
async initParameters(spendParams, outputParams) {
|
|
158
|
+
const externalInitParameters = this.options.config.externalProvider?.initParameters;
|
|
159
|
+
if (externalInitParameters !== undefined) {
|
|
160
|
+
await externalInitParameters(spendParams, outputParams);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
await sapling.initParameters(spendParams, outputParams);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
async getBlockExplorerLinkForTxId(txId) {
|
|
167
|
+
return this.tezosProtocol.getBlockExplorerLinkForTxId(txId);
|
|
168
|
+
}
|
|
169
|
+
async getPublicKeyFromMnemonic(mnemonic, derivationPath, password) {
|
|
170
|
+
const seed = this.getSeedFromMnemonic(mnemonic, password);
|
|
171
|
+
return this.getPublicKeyFromHexSecret(seed.toString('hex'), derivationPath);
|
|
172
|
+
}
|
|
173
|
+
async getPrivateKeyFromMnemonic(mnemonic, derivationPath, password) {
|
|
174
|
+
const seed = this.getSeedFromMnemonic(mnemonic, password);
|
|
175
|
+
return this.getPrivateKeyFromHexSecret(seed.toString('hex'), derivationPath);
|
|
176
|
+
}
|
|
177
|
+
getSeedFromMnemonic(mnemonic, password) {
|
|
178
|
+
const seed = (0, bip39_2_5_0_1.mnemonicToSeed)(mnemonic, password);
|
|
345
179
|
// We xor the two halves of the BIP-39 seed, as does `tezos-client`
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
return Buffer.from(first32.map(
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
});
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
};
|
|
530
|
-
TezosSaplingProtocol.prototype.signWithPrivateKey = function (privateKey, transaction) {
|
|
531
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
532
|
-
var stateTree, boundData, forgedTransaction;
|
|
533
|
-
return __generator(this, function (_a) {
|
|
534
|
-
switch (_a.label) {
|
|
535
|
-
case 0: return [4 /*yield*/, this.state.getStateTreeFromStateDiff(transaction.stateDiff)];
|
|
536
|
-
case 1:
|
|
537
|
-
stateTree = _a.sent();
|
|
538
|
-
boundData = transaction.unshieldTarget && transaction.unshieldTarget.length > 0
|
|
539
|
-
? this.createAddressBoundData(transaction.unshieldTarget)
|
|
540
|
-
: undefined;
|
|
541
|
-
return [4 /*yield*/, this.forger.forgeSaplingTransaction(transaction.ins, transaction.outs, stateTree, this.getAntiReplay(transaction.chainId, transaction.contractAddress), boundData, Buffer.from(privateKey, 'hex'))];
|
|
542
|
-
case 2:
|
|
543
|
-
forgedTransaction = _a.sent();
|
|
544
|
-
return [2 /*return*/, this.encoder.encodeTransaction(forgedTransaction).toString('hex')];
|
|
545
|
-
}
|
|
546
|
-
});
|
|
547
|
-
});
|
|
548
|
-
};
|
|
549
|
-
TezosSaplingProtocol.prototype.getTransactionDetails = function (transaction, data) {
|
|
550
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
551
|
-
var tx, airGapTxs, unshieldTarget, from, details, wrappedOperation, _a, _b, _c;
|
|
552
|
-
return __generator(this, function (_d) {
|
|
553
|
-
switch (_d.label) {
|
|
554
|
-
case 0:
|
|
555
|
-
tx = transaction.transaction;
|
|
556
|
-
airGapTxs = [];
|
|
557
|
-
if (!this.isRawTezosSaplingTransaction(tx)) return [3 /*break*/, 2];
|
|
558
|
-
unshieldTarget = tx.unshieldTarget.length > 0 ? tx.unshieldTarget : undefined;
|
|
559
|
-
return [4 /*yield*/, this.getAddressFromPublicKey(transaction.publicKey).then(function (address) { return TezosSaplingAddress_1.TezosSaplingAddress.fromValue(address.address, address.cursor.diversifierIndex); })];
|
|
560
|
-
case 1:
|
|
561
|
-
from = _d.sent();
|
|
562
|
-
details = this.bookkeeper
|
|
563
|
-
.getUnsignedTransactionDetails(from, tx.ins, tx.outs, unshieldTarget)
|
|
564
|
-
.map(function (details) { return (__assign(__assign({}, details), { extra: __assign(__assign({}, details.extra), { destination: tx.contractAddress, chainId: tx.chainId }), transactionDetails: tx })); });
|
|
565
|
-
airGapTxs.push.apply(airGapTxs, details);
|
|
566
|
-
return [3 /*break*/, 5];
|
|
567
|
-
case 2: return [4 /*yield*/, this.tezosProtocol.unforgeUnsignedTezosWrappedOperation(tx.binaryTransaction)];
|
|
568
|
-
case 3:
|
|
569
|
-
wrappedOperation = _d.sent();
|
|
570
|
-
_b = (_a = airGapTxs.push).apply;
|
|
571
|
-
_c = [airGapTxs];
|
|
572
|
-
return [4 /*yield*/, this.getTransactionDetailsFromWrappedOperation(wrappedOperation, data === null || data === void 0 ? void 0 : data.knownViewingKeys)];
|
|
573
|
-
case 4:
|
|
574
|
-
_b.apply(_a, _c.concat([(_d.sent())]));
|
|
575
|
-
_d.label = 5;
|
|
576
|
-
case 5: return [2 /*return*/, this.filterOutPaybacks(airGapTxs)];
|
|
577
|
-
}
|
|
578
|
-
});
|
|
579
|
-
});
|
|
580
|
-
};
|
|
581
|
-
TezosSaplingProtocol.prototype.getTransactionDetailsFromSigned = function (transaction, data) {
|
|
582
|
-
var _a;
|
|
583
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
584
|
-
var airGapTxs, tx, defaultDetails, partialDetails, wrappedOperation, _b, _c, _d, _e, partialDetails;
|
|
585
|
-
return __generator(this, function (_f) {
|
|
586
|
-
switch (_f.label) {
|
|
587
|
-
case 0:
|
|
588
|
-
airGapTxs = [];
|
|
589
|
-
tx = transaction.transaction;
|
|
590
|
-
defaultDetails = {
|
|
591
|
-
from: ['Shielded Pool'],
|
|
592
|
-
to: ['Shielded Pool'],
|
|
593
|
-
isInbound: false,
|
|
594
|
-
amount: '0',
|
|
595
|
-
fee: '0',
|
|
596
|
-
protocolIdentifier: this.identifier,
|
|
597
|
-
network: this.options.network
|
|
598
|
-
};
|
|
599
|
-
if (!((_a = this.contract) === null || _a === void 0 ? void 0 : _a.areValidParameters(tx))) return [3 /*break*/, 2];
|
|
600
|
-
return [4 /*yield*/, this.getPartialDetailsFromContractParameters(tx, data === null || data === void 0 ? void 0 : data.knownViewingKeys)];
|
|
601
|
-
case 1:
|
|
602
|
-
partialDetails = _f.sent();
|
|
603
|
-
airGapTxs.push.apply(airGapTxs, partialDetails.map(function (partial) { return (__assign(__assign({}, defaultDetails), partial)); }));
|
|
604
|
-
return [3 /*break*/, 7];
|
|
605
|
-
case 2:
|
|
606
|
-
_f.trys.push([2, 5, , 7]);
|
|
607
|
-
return [4 /*yield*/, this.tezosProtocol.unforgeSignedTezosWrappedOperation(tx)];
|
|
608
|
-
case 3:
|
|
609
|
-
wrappedOperation = _f.sent();
|
|
610
|
-
_c = (_b = airGapTxs.push).apply;
|
|
611
|
-
_d = [airGapTxs];
|
|
612
|
-
return [4 /*yield*/, this.getTransactionDetailsFromWrappedOperation(wrappedOperation, data === null || data === void 0 ? void 0 : data.knownViewingKeys)];
|
|
613
|
-
case 4:
|
|
614
|
-
_c.apply(_b, _d.concat([(_f.sent())]));
|
|
615
|
-
return [3 /*break*/, 7];
|
|
616
|
-
case 5:
|
|
617
|
-
_e = _f.sent();
|
|
618
|
-
return [4 /*yield*/, this.bookkeeper.getTransactionsPartialDetails([tx], data === null || data === void 0 ? void 0 : data.knownViewingKeys)];
|
|
619
|
-
case 6:
|
|
620
|
-
partialDetails = _f.sent();
|
|
621
|
-
airGapTxs.push.apply(airGapTxs, partialDetails.map(function (partial) { return (__assign(__assign({}, defaultDetails), partial)); }));
|
|
622
|
-
return [3 /*break*/, 7];
|
|
623
|
-
case 7: return [2 /*return*/, this.filterOutPaybacks(airGapTxs)];
|
|
624
|
-
}
|
|
625
|
-
});
|
|
626
|
-
});
|
|
627
|
-
};
|
|
628
|
-
TezosSaplingProtocol.prototype.getTransactionDetailsFromWrappedOperation = function (operation, knownViewingKeys) {
|
|
629
|
-
if (knownViewingKeys === void 0) { knownViewingKeys = []; }
|
|
630
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
631
|
-
var contractOperations, details;
|
|
632
|
-
var _this = this;
|
|
633
|
-
return __generator(this, function (_a) {
|
|
634
|
-
switch (_a.label) {
|
|
635
|
-
case 0:
|
|
636
|
-
contractOperations = operation.contents.filter(function (content) {
|
|
637
|
-
return content.kind === TezosOperationType_1.TezosOperationType.TRANSACTION && content.parameters !== undefined;
|
|
638
|
-
});
|
|
639
|
-
return [4 /*yield*/, Promise.all(contractOperations.map(function (operation) { return __awaiter(_this, void 0, void 0, function () {
|
|
640
|
-
var saplingDetails;
|
|
641
|
-
var _this = this;
|
|
642
|
-
return __generator(this, function (_a) {
|
|
643
|
-
switch (_a.label) {
|
|
644
|
-
case 0: return [4 /*yield*/, this.getPartialDetailsFromContractParameters(operation.parameters, knownViewingKeys)];
|
|
645
|
-
case 1:
|
|
646
|
-
saplingDetails = _a.sent();
|
|
647
|
-
return [2 /*return*/, saplingDetails.map(function (partials) { return (__assign(__assign({ from: [operation.source], to: ['Shielded Pool'], isInbound: false, amount: operation.amount, fee: operation.fee, protocolIdentifier: _this.identifier, network: _this.options.network }, partials), { transactionDetails: operation })); })];
|
|
648
|
-
}
|
|
649
|
-
});
|
|
650
|
-
}); }))];
|
|
651
|
-
case 1:
|
|
652
|
-
details = _a.sent();
|
|
653
|
-
return [2 /*return*/, (0, array_1.flattenArray)(details)];
|
|
654
|
-
}
|
|
655
|
-
});
|
|
656
|
-
});
|
|
657
|
-
};
|
|
658
|
-
TezosSaplingProtocol.prototype.getPartialDetailsFromContractParameters = function (rawOrParsed, knownViewingKeys) {
|
|
659
|
-
if (knownViewingKeys === void 0) { knownViewingKeys = []; }
|
|
660
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
661
|
-
var parameters, txs;
|
|
662
|
-
return __generator(this, function (_a) {
|
|
663
|
-
switch (_a.label) {
|
|
664
|
-
case 0:
|
|
665
|
-
parameters = typeof rawOrParsed === 'string' ? (this.contract ? this.contract.parseParameters(rawOrParsed) : JSON.parse(rawOrParsed)) : rawOrParsed;
|
|
666
|
-
return [4 /*yield*/, this.parseParameters(parameters)];
|
|
667
|
-
case 1:
|
|
668
|
-
txs = _a.sent();
|
|
669
|
-
return [2 /*return*/, this.bookkeeper.getTransactionsPartialDetails(txs, knownViewingKeys)];
|
|
670
|
-
}
|
|
671
|
-
});
|
|
672
|
-
});
|
|
673
|
-
};
|
|
674
|
-
TezosSaplingProtocol.prototype.filterOutPaybacks = function (airGapTxs) {
|
|
675
|
-
var filtered = airGapTxs.filter(function (details) {
|
|
180
|
+
const first32 = seed.slice(0, 32);
|
|
181
|
+
const second32 = seed.slice(32);
|
|
182
|
+
return Buffer.from(first32.map((byte, index) => byte ^ second32[index]));
|
|
183
|
+
}
|
|
184
|
+
async getPublicKeyFromHexSecret(secret, derivationPath) {
|
|
185
|
+
const viewingKey = await sapling.getExtendedFullViewingKey(secret, derivationPath);
|
|
186
|
+
return viewingKey.toString('hex');
|
|
187
|
+
}
|
|
188
|
+
async getPrivateKeyFromHexSecret(secret, derivationPath) {
|
|
189
|
+
const xsk = await sapling.getExtendedSpendingKey(secret, derivationPath);
|
|
190
|
+
return xsk.toString('hex');
|
|
191
|
+
}
|
|
192
|
+
async getAddressFromPublicKey(viewingKey, cursor) {
|
|
193
|
+
const current = cursor?.hasNext && cursor?.diversifierIndex
|
|
194
|
+
? await TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(viewingKey, cursor.diversifierIndex)
|
|
195
|
+
: undefined;
|
|
196
|
+
const address = current
|
|
197
|
+
? await TezosSaplingAddress_1.TezosSaplingAddress.next(viewingKey, current)
|
|
198
|
+
: await TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(viewingKey);
|
|
199
|
+
return {
|
|
200
|
+
address: address.asString(),
|
|
201
|
+
cursor: {
|
|
202
|
+
hasNext: address.diversifierIndex !== undefined,
|
|
203
|
+
diversifierIndex: address.diversifierIndex
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
async getAddressesFromPublicKey(viewingKey, cursor) {
|
|
208
|
+
return [await this.getAddressFromPublicKey(viewingKey, cursor)];
|
|
209
|
+
}
|
|
210
|
+
async getAddressFromViewingKey(viewingKey, index) {
|
|
211
|
+
const address = await TezosSaplingAddress_1.TezosSaplingAddress.fromViewingKey(viewingKey, index);
|
|
212
|
+
return {
|
|
213
|
+
address: address.asString(),
|
|
214
|
+
cursor: {
|
|
215
|
+
hasNext: address.diversifierIndex !== undefined,
|
|
216
|
+
diversifierIndex: address.diversifierIndex
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
async getTransactionsFromPublicKey(publicKey, limit, cursor) {
|
|
221
|
+
if (this.nodeClient === undefined) {
|
|
222
|
+
return {
|
|
223
|
+
transactions: [],
|
|
224
|
+
cursor: { page: 0 }
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
const saplingStateDiff = await this.nodeClient.getSaplingStateDiff();
|
|
228
|
+
const incoming = [];
|
|
229
|
+
const outgoing = [];
|
|
230
|
+
let page = cursor?.page ?? 0;
|
|
231
|
+
let pageStart = page * limit;
|
|
232
|
+
let pageEnd = pageStart + limit;
|
|
233
|
+
while (incoming.length + outgoing.length < limit && pageStart < saplingStateDiff.commitments_and_ciphertexts.length) {
|
|
234
|
+
const commitmentsAndCiphertexts = saplingStateDiff.commitments_and_ciphertexts
|
|
235
|
+
.map(([commitment, ciphertext], index) => [commitment, ciphertext, new bignumber_1.default(index)])
|
|
236
|
+
.reverse()
|
|
237
|
+
.slice(pageStart, pageEnd);
|
|
238
|
+
const inputs = await Promise.all([
|
|
239
|
+
this.bookkeeper.getIncomingInputs(publicKey, commitmentsAndCiphertexts),
|
|
240
|
+
this.bookkeeper.getOutgoingInputs(publicKey, commitmentsAndCiphertexts)
|
|
241
|
+
]);
|
|
242
|
+
incoming.push(...inputs[0]);
|
|
243
|
+
outgoing.push(...inputs[1]);
|
|
244
|
+
page += 1;
|
|
245
|
+
pageStart += limit;
|
|
246
|
+
pageEnd += limit;
|
|
247
|
+
}
|
|
248
|
+
const airGapIncoming = await Promise.all(incoming.map(async (input) => ({
|
|
249
|
+
from: ['Shielded Pool'],
|
|
250
|
+
to: [input.address],
|
|
251
|
+
isInbound: true,
|
|
252
|
+
amount: input.value,
|
|
253
|
+
fee: '0',
|
|
254
|
+
protocolIdentifier: this.identifier,
|
|
255
|
+
network: this.options.network
|
|
256
|
+
})));
|
|
257
|
+
const airGapOutgoing = await Promise.all(outgoing.map(async (input) => ({
|
|
258
|
+
from: [(await this.getAddressFromPublicKey(publicKey)).address],
|
|
259
|
+
to: [input.address],
|
|
260
|
+
isInbound: false,
|
|
261
|
+
amount: input.value,
|
|
262
|
+
fee: '0',
|
|
263
|
+
protocolIdentifier: this.identifier,
|
|
264
|
+
network: this.options.network
|
|
265
|
+
})));
|
|
266
|
+
return {
|
|
267
|
+
transactions: airGapIncoming.concat(airGapOutgoing),
|
|
268
|
+
cursor: { page: page + 1 }
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
async signWithPrivateKey(privateKey, transaction) {
|
|
272
|
+
const stateTree = await this.state.getStateTreeFromStateDiff(transaction.stateDiff);
|
|
273
|
+
const boundData = transaction.unshieldTarget && transaction.unshieldTarget.length > 0
|
|
274
|
+
? this.createAddressBoundData(transaction.unshieldTarget)
|
|
275
|
+
: undefined;
|
|
276
|
+
const forgedTransaction = await this.forger.forgeSaplingTransaction(transaction.ins, transaction.outs, stateTree, this.getAntiReplay(transaction.chainId, transaction.contractAddress), boundData, Buffer.from(privateKey, 'hex'));
|
|
277
|
+
return this.encoder.encodeTransaction(forgedTransaction).toString('hex');
|
|
278
|
+
}
|
|
279
|
+
async getTransactionDetails(transaction, data) {
|
|
280
|
+
const tx = transaction.transaction;
|
|
281
|
+
const airGapTxs = [];
|
|
282
|
+
if (this.isRawTezosSaplingTransaction(tx)) {
|
|
283
|
+
const unshieldTarget = tx.unshieldTarget.length > 0 ? tx.unshieldTarget : undefined;
|
|
284
|
+
const from = await this.getAddressFromPublicKey(transaction.publicKey).then((address) => TezosSaplingAddress_1.TezosSaplingAddress.fromValue(address.address, address.cursor.diversifierIndex));
|
|
285
|
+
const details = this.bookkeeper
|
|
286
|
+
.getUnsignedTransactionDetails(from, tx.ins, tx.outs, unshieldTarget)
|
|
287
|
+
.map((details) => ({
|
|
288
|
+
...details,
|
|
289
|
+
extra: {
|
|
290
|
+
...details.extra,
|
|
291
|
+
destination: tx.contractAddress,
|
|
292
|
+
chainId: tx.chainId
|
|
293
|
+
},
|
|
294
|
+
transactionDetails: tx
|
|
295
|
+
}));
|
|
296
|
+
airGapTxs.push(...details);
|
|
297
|
+
}
|
|
298
|
+
else {
|
|
299
|
+
const wrappedOperation = await this.tezosProtocol.unforgeUnsignedTezosWrappedOperation(tx.binaryTransaction);
|
|
300
|
+
airGapTxs.push(...(await this.getTransactionDetailsFromWrappedOperation(wrappedOperation, data?.knownViewingKeys)));
|
|
301
|
+
}
|
|
302
|
+
return this.filterOutPaybacks(airGapTxs);
|
|
303
|
+
}
|
|
304
|
+
async getTransactionDetailsFromSigned(transaction, data) {
|
|
305
|
+
const airGapTxs = [];
|
|
306
|
+
const tx = transaction.transaction;
|
|
307
|
+
const defaultDetails = {
|
|
308
|
+
from: ['Shielded Pool'],
|
|
309
|
+
to: ['Shielded Pool'],
|
|
310
|
+
isInbound: false,
|
|
311
|
+
amount: '0',
|
|
312
|
+
fee: '0',
|
|
313
|
+
protocolIdentifier: this.identifier,
|
|
314
|
+
network: this.options.network
|
|
315
|
+
};
|
|
316
|
+
if (this.contract?.areValidParameters(tx)) {
|
|
317
|
+
const partialDetails = await this.getPartialDetailsFromContractParameters(tx, data?.knownViewingKeys);
|
|
318
|
+
airGapTxs.push(...partialDetails.map((partial) => ({
|
|
319
|
+
...defaultDetails,
|
|
320
|
+
...partial
|
|
321
|
+
})));
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
try {
|
|
325
|
+
const wrappedOperation = await this.tezosProtocol.unforgeSignedTezosWrappedOperation(tx);
|
|
326
|
+
airGapTxs.push(...(await this.getTransactionDetailsFromWrappedOperation(wrappedOperation, data?.knownViewingKeys)));
|
|
327
|
+
}
|
|
328
|
+
catch {
|
|
329
|
+
const partialDetails = await this.bookkeeper.getTransactionsPartialDetails([tx], data?.knownViewingKeys);
|
|
330
|
+
airGapTxs.push(...partialDetails.map((partial) => ({
|
|
331
|
+
...defaultDetails,
|
|
332
|
+
...partial
|
|
333
|
+
})));
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return this.filterOutPaybacks(airGapTxs);
|
|
337
|
+
}
|
|
338
|
+
async getTransactionDetailsFromWrappedOperation(operation, knownViewingKeys = []) {
|
|
339
|
+
const contractOperations = operation.contents.filter((content) => content.kind === TezosOperationType_1.TezosOperationType.TRANSACTION && content.parameters !== undefined);
|
|
340
|
+
const details = await Promise.all(contractOperations.map(async (operation) => {
|
|
341
|
+
const saplingDetails = await this.getPartialDetailsFromContractParameters(operation.parameters, knownViewingKeys);
|
|
342
|
+
return saplingDetails.map((partials) => ({
|
|
343
|
+
from: [operation.source],
|
|
344
|
+
to: ['Shielded Pool'],
|
|
345
|
+
isInbound: false,
|
|
346
|
+
amount: operation.amount,
|
|
347
|
+
fee: operation.fee,
|
|
348
|
+
protocolIdentifier: this.identifier,
|
|
349
|
+
network: this.options.network,
|
|
350
|
+
...partials,
|
|
351
|
+
transactionDetails: operation
|
|
352
|
+
}));
|
|
353
|
+
}));
|
|
354
|
+
return (0, array_1.flattenArray)(details);
|
|
355
|
+
}
|
|
356
|
+
async getPartialDetailsFromContractParameters(rawOrParsed, knownViewingKeys = []) {
|
|
357
|
+
const parameters = typeof rawOrParsed === 'string' ? (this.contract ? this.contract.parseParameters(rawOrParsed) : JSON.parse(rawOrParsed)) : rawOrParsed;
|
|
358
|
+
const txs = await this.parseParameters(parameters);
|
|
359
|
+
return this.bookkeeper.getTransactionsPartialDetails(txs, knownViewingKeys);
|
|
360
|
+
}
|
|
361
|
+
filterOutPaybacks(airGapTxs) {
|
|
362
|
+
const filtered = airGapTxs.filter((details) => {
|
|
676
363
|
if (details.from.length !== details.to.length) {
|
|
677
364
|
return true;
|
|
678
365
|
}
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
return Array.from(fromSet).some(
|
|
366
|
+
const fromSet = new Set(details.from);
|
|
367
|
+
const toSet = new Set(details.to);
|
|
368
|
+
return Array.from(fromSet).some((address) => !toSet.has(address));
|
|
682
369
|
});
|
|
683
370
|
return filtered.length > 0 ? filtered : airGapTxs;
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
371
|
+
}
|
|
372
|
+
async getBalanceOfPublicKey(publicKey) {
|
|
373
|
+
if (this.nodeClient === undefined) {
|
|
374
|
+
return '0';
|
|
375
|
+
}
|
|
376
|
+
const saplingStateDiff = await this.nodeClient.getSaplingStateDiff();
|
|
377
|
+
const unspends = await this.bookkeeper.getUnspends(publicKey, saplingStateDiff.commitments_and_ciphertexts, saplingStateDiff.nullifiers);
|
|
378
|
+
const balance = unspends.reduce((sum, next) => sum.plus(next.value), new bignumber_1.default(0));
|
|
379
|
+
return balance.toString();
|
|
380
|
+
}
|
|
381
|
+
async getTransactionStatuses(transactionHash) {
|
|
382
|
+
throw new Error('Method not implemented.');
|
|
383
|
+
}
|
|
384
|
+
async estimateMaxTransactionValueFromPublicKey(publicKey, recipients, fee) {
|
|
385
|
+
return this.getBalanceOfPublicKey(publicKey);
|
|
386
|
+
}
|
|
387
|
+
async prepareTransactionFromPublicKey(publicKey, recipients, values, fee, data) {
|
|
388
|
+
if (recipients.length > 1 && values.length > 1) {
|
|
389
|
+
return Promise.reject('Multiple sapling transactions are not supported');
|
|
390
|
+
}
|
|
391
|
+
if (recipients.length === 0 && values.length === 0) {
|
|
392
|
+
return Promise.reject('No recpients and values have been provided');
|
|
393
|
+
}
|
|
394
|
+
const recipient = recipients[0];
|
|
395
|
+
const value = values[0];
|
|
396
|
+
if (TezosAddress_1.TezosAddress.isTzAddress(recipient)) {
|
|
397
|
+
return this.prepareUnshieldTransaction(publicKey, recipient, value, data);
|
|
398
|
+
}
|
|
399
|
+
else if (TezosSaplingAddress_1.TezosSaplingAddress.isZetAddress(recipient)) {
|
|
400
|
+
return this.prepareSaplingTransaction(publicKey, recipient, value, data);
|
|
401
|
+
}
|
|
402
|
+
return Promise.reject(`Invalid recpient, expected a 'tz' or 'zet' address, got ${recipient}`);
|
|
403
|
+
}
|
|
404
|
+
async wrapSaplingTransactions(publicKey, transactionsOrString, fee, overrideFees = false) {
|
|
405
|
+
if (this.contract === undefined) {
|
|
406
|
+
throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
|
|
407
|
+
}
|
|
408
|
+
let operations;
|
|
409
|
+
if (typeof transactionsOrString === 'string' && this.contract.areValidParameters(transactionsOrString)) {
|
|
410
|
+
const parameters = this.contract.parseParameters(transactionsOrString);
|
|
411
|
+
operations = [this.prepareTezosOperation(parameters, fee)];
|
|
412
|
+
}
|
|
413
|
+
else {
|
|
414
|
+
const transactions = Array.isArray(transactionsOrString) ? transactionsOrString : [transactionsOrString];
|
|
415
|
+
const contractCalls = await this.prepareContractCalls(transactions);
|
|
416
|
+
operations = contractCalls.map((contractCall) => this.prepareTezosOperation(contractCall.toJSON(), fee, contractCall.amount?.toString()));
|
|
417
|
+
}
|
|
418
|
+
try {
|
|
419
|
+
const tezosWrappedOperation = await this.tezosProtocol.prepareOperations(publicKey, operations, overrideFees);
|
|
420
|
+
const binaryTx = await this.tezosProtocol.forgeTezosOperation(tezosWrappedOperation);
|
|
421
|
+
return { binaryTransaction: binaryTx };
|
|
422
|
+
}
|
|
423
|
+
catch (error) {
|
|
424
|
+
console.error(error);
|
|
425
|
+
if (error.code !== undefined && error.code === errors_1.ProtocolErrorType.TRANSACTION_FAILED) {
|
|
426
|
+
const rpcErrors = error.data;
|
|
427
|
+
const cannotPayStorageFee = rpcErrors.find((error) => error.id.endsWith('.contract.cannot_pay_storage_fee'));
|
|
428
|
+
if (cannotPayStorageFee) {
|
|
429
|
+
throw new errors_1.BalanceError(coinlib_error_1.Domain.TEZOS, 'Balance too low, cannot pay for storage fee');
|
|
737
430
|
}
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
};
|
|
742
|
-
TezosSaplingProtocol.prototype.wrapSaplingTransactions = function (publicKey, transactionsOrString, fee, overrideFees) {
|
|
743
|
-
if (overrideFees === void 0) { overrideFees = false; }
|
|
744
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
745
|
-
var operations, parameters, transactions, contractCalls, tezosWrappedOperation, binaryTx, error_1, rpcErrors, cannotPayStorageFee, balanceTooLowError;
|
|
746
|
-
var _this = this;
|
|
747
|
-
return __generator(this, function (_a) {
|
|
748
|
-
switch (_a.label) {
|
|
749
|
-
case 0:
|
|
750
|
-
if (this.contract === undefined) {
|
|
751
|
-
throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
|
|
752
|
-
}
|
|
753
|
-
if (!(typeof transactionsOrString === 'string' && this.contract.areValidParameters(transactionsOrString))) return [3 /*break*/, 1];
|
|
754
|
-
parameters = this.contract.parseParameters(transactionsOrString);
|
|
755
|
-
operations = [this.prepareTezosOperation(parameters, fee)];
|
|
756
|
-
return [3 /*break*/, 3];
|
|
757
|
-
case 1:
|
|
758
|
-
transactions = Array.isArray(transactionsOrString) ? transactionsOrString : [transactionsOrString];
|
|
759
|
-
return [4 /*yield*/, this.prepareContractCalls(transactions)];
|
|
760
|
-
case 2:
|
|
761
|
-
contractCalls = _a.sent();
|
|
762
|
-
operations = contractCalls.map(function (contractCall) { var _a; return _this.prepareTezosOperation(contractCall.toJSON(), fee, (_a = contractCall.amount) === null || _a === void 0 ? void 0 : _a.toString()); });
|
|
763
|
-
_a.label = 3;
|
|
764
|
-
case 3:
|
|
765
|
-
_a.trys.push([3, 6, , 7]);
|
|
766
|
-
return [4 /*yield*/, this.tezosProtocol.prepareOperations(publicKey, operations, overrideFees)];
|
|
767
|
-
case 4:
|
|
768
|
-
tezosWrappedOperation = _a.sent();
|
|
769
|
-
return [4 /*yield*/, this.tezosProtocol.forgeTezosOperation(tezosWrappedOperation)];
|
|
770
|
-
case 5:
|
|
771
|
-
binaryTx = _a.sent();
|
|
772
|
-
return [2 /*return*/, { binaryTransaction: binaryTx }];
|
|
773
|
-
case 6:
|
|
774
|
-
error_1 = _a.sent();
|
|
775
|
-
console.error(error_1);
|
|
776
|
-
if (error_1.code !== undefined && error_1.code === errors_1.ProtocolErrorType.TRANSACTION_FAILED) {
|
|
777
|
-
rpcErrors = error_1.data;
|
|
778
|
-
cannotPayStorageFee = rpcErrors.find(function (error) { return error.id.endsWith('.contract.cannot_pay_storage_fee'); });
|
|
779
|
-
if (cannotPayStorageFee) {
|
|
780
|
-
throw new errors_1.BalanceError(coinlib_error_1.Domain.TEZOS, 'Balance too low, cannot pay for storage fee');
|
|
781
|
-
}
|
|
782
|
-
balanceTooLowError = rpcErrors.find(function (error) { return error.id.endsWith('.contract.balance_too_low'); });
|
|
783
|
-
if (balanceTooLowError) {
|
|
784
|
-
throw new errors_1.BalanceError(coinlib_error_1.Domain.TEZOS, 'Balance too low');
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
throw error_1;
|
|
788
|
-
case 7: return [2 /*return*/];
|
|
431
|
+
const balanceTooLowError = rpcErrors.find((error) => error.id.endsWith('.contract.balance_too_low'));
|
|
432
|
+
if (balanceTooLowError) {
|
|
433
|
+
throw new errors_1.BalanceError(coinlib_error_1.Domain.TEZOS, 'Balance too low');
|
|
789
434
|
}
|
|
790
|
-
}
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
435
|
+
}
|
|
436
|
+
throw error;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
prepareTezosOperation(parameters, fee, amount = '0') {
|
|
795
440
|
return {
|
|
796
441
|
kind: TezosOperationType_1.TezosOperationType.TRANSACTION,
|
|
797
|
-
fee
|
|
798
|
-
amount
|
|
442
|
+
fee,
|
|
443
|
+
amount,
|
|
799
444
|
destination: this.options.config.contractAddress,
|
|
800
|
-
parameters
|
|
445
|
+
parameters
|
|
801
446
|
};
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
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
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
_b.memo = Buffer.alloc(this.options.config.memoSize).toString('hex'),
|
|
911
|
-
_b.browsable = true,
|
|
912
|
-
_b);
|
|
913
|
-
return [4 /*yield*/, this.state.getStateTreeFromStateDiff(saplingStateDiff, true)];
|
|
914
|
-
case 3:
|
|
915
|
-
stateTree = _c.sent();
|
|
916
|
-
return [4 /*yield*/, this.forger.forgeSaplingTransaction([], [output], stateTree, this.getAntiReplay(chainId, this.options.config.contractAddress))];
|
|
917
|
-
case 4:
|
|
918
|
-
forgedTransaction = _c.sent();
|
|
919
|
-
return [2 /*return*/, this.encoder.encodeTransaction(forgedTransaction).toString('hex')];
|
|
920
|
-
}
|
|
921
|
-
});
|
|
922
|
-
});
|
|
923
|
-
};
|
|
924
|
-
TezosSaplingProtocol.prototype.burn = function (viewingKey, value) {
|
|
925
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
926
|
-
var _a, stateDiff, chainId, _b, inputs, toSpend, paybackOutput;
|
|
927
|
-
var _c;
|
|
928
|
-
return __generator(this, function (_d) {
|
|
929
|
-
switch (_d.label) {
|
|
930
|
-
case 0:
|
|
931
|
-
if (this.nodeClient === undefined || this.options.config.contractAddress === undefined) {
|
|
932
|
-
throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
|
|
933
|
-
}
|
|
934
|
-
return [4 /*yield*/, Promise.all([
|
|
935
|
-
this.nodeClient.getSaplingStateDiff(),
|
|
936
|
-
this.nodeClient.getChainId()
|
|
937
|
-
])];
|
|
938
|
-
case 1:
|
|
939
|
-
_a = _d.sent(), stateDiff = _a[0], chainId = _a[1];
|
|
940
|
-
return [4 /*yield*/, this.chooseInputs(viewingKey, stateDiff.commitments_and_ciphertexts, stateDiff.nullifiers, value)];
|
|
941
|
-
case 2:
|
|
942
|
-
_b = _d.sent(), inputs = _b[0], toSpend = _b[1];
|
|
943
|
-
_c = {};
|
|
944
|
-
return [4 /*yield*/, this.getAddressFromPublicKey(viewingKey)];
|
|
945
|
-
case 3:
|
|
946
|
-
paybackOutput = (_c.address = (_d.sent()).address,
|
|
947
|
-
_c.value = toSpend.minus(value).toString(),
|
|
948
|
-
_c.memo = Buffer.alloc(this.options.config.memoSize).toString('hex'),
|
|
949
|
-
_c.browsable = true,
|
|
950
|
-
_c);
|
|
951
|
-
return [2 /*return*/, {
|
|
952
|
-
ins: inputs,
|
|
953
|
-
outs: [paybackOutput],
|
|
954
|
-
contractAddress: this.options.config.contractAddress,
|
|
955
|
-
chainId: chainId,
|
|
956
|
-
stateDiff: stateDiff,
|
|
957
|
-
unshieldTarget: ''
|
|
958
|
-
}];
|
|
959
|
-
}
|
|
960
|
-
});
|
|
961
|
-
});
|
|
962
|
-
};
|
|
963
|
-
TezosSaplingProtocol.prototype.chooseInputs = function (viewingKey, commitmentsWithCiphertext, nullifiers, value) {
|
|
964
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
965
|
-
var unspends, balance, chosenUnspends, toSpend, _i, unspends_1, unspend;
|
|
966
|
-
return __generator(this, function (_a) {
|
|
967
|
-
switch (_a.label) {
|
|
968
|
-
case 0: return [4 /*yield*/, this.bookkeeper.getUnspends(viewingKey, commitmentsWithCiphertext, nullifiers)];
|
|
969
|
-
case 1:
|
|
970
|
-
unspends = _a.sent();
|
|
971
|
-
balance = this.bookkeeper.sumNotes(unspends);
|
|
972
|
-
if (balance.lt(value)) {
|
|
973
|
-
return [2 /*return*/, Promise.reject('Not enough balance')];
|
|
974
|
-
}
|
|
975
|
-
chosenUnspends = [];
|
|
976
|
-
toSpend = new bignumber_1.default(0);
|
|
977
|
-
for (_i = 0, unspends_1 = unspends; _i < unspends_1.length; _i++) {
|
|
978
|
-
unspend = unspends_1[_i];
|
|
979
|
-
if (toSpend.gte(value)) {
|
|
980
|
-
break;
|
|
981
|
-
}
|
|
982
|
-
toSpend = toSpend.plus(unspend.value);
|
|
983
|
-
chosenUnspends.push(unspend);
|
|
984
|
-
}
|
|
985
|
-
return [2 /*return*/, [chosenUnspends, toSpend]];
|
|
986
|
-
}
|
|
987
|
-
});
|
|
988
|
-
});
|
|
989
|
-
};
|
|
990
|
-
TezosSaplingProtocol.prototype.createPaymentOutput = function (address, value, memo) {
|
|
991
|
-
if (memo === void 0) { memo = Buffer.alloc(this.options.config.memoSize); }
|
|
447
|
+
}
|
|
448
|
+
async prepareShieldTransaction(publicKey, recipient, value, fee, data) {
|
|
449
|
+
const encodedTransaction = await this.mint(recipient, value);
|
|
450
|
+
return this.wrapSaplingTransactions(publicKey, [encodedTransaction], fee, data?.overrideFees);
|
|
451
|
+
}
|
|
452
|
+
async prepareUnshieldTransaction(viewingKey, recipient, value, data) {
|
|
453
|
+
if (!TezosAddress_1.TezosAddress.isTzAddress(recipient)) {
|
|
454
|
+
return Promise.reject(`Invalid recpient, expected a 'tz' address, got ${recipient}`);
|
|
455
|
+
}
|
|
456
|
+
const burnTransaction = await this.burn(viewingKey, value);
|
|
457
|
+
return {
|
|
458
|
+
...burnTransaction,
|
|
459
|
+
unshieldTarget: recipient
|
|
460
|
+
};
|
|
461
|
+
}
|
|
462
|
+
async prepareSaplingTransaction(viewingKey, recipient, value, data) {
|
|
463
|
+
if (this.nodeClient === undefined || this.options.config.contractAddress === undefined) {
|
|
464
|
+
throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
|
|
465
|
+
}
|
|
466
|
+
if (!TezosSaplingAddress_1.TezosSaplingAddress.isZetAddress(recipient)) {
|
|
467
|
+
return Promise.reject(`Invalid recpient, expected a 'zet' address, got ${recipient}`);
|
|
468
|
+
}
|
|
469
|
+
const dummyInputsAmount = Math.max(new bignumber_1.default(data?.dummyInputs ?? 0).toNumber(), 0);
|
|
470
|
+
const dummyOutputsAmount = Math.max(new bignumber_1.default(data?.dummyOutputs ?? 0).toNumber(), 0);
|
|
471
|
+
const [stateDiff, chainId] = await Promise.all([
|
|
472
|
+
this.nodeClient.getSaplingStateDiff(),
|
|
473
|
+
this.nodeClient.getChainId()
|
|
474
|
+
]);
|
|
475
|
+
const [inputs, toSpend] = await this.chooseInputs(viewingKey, stateDiff.commitments_and_ciphertexts, stateDiff.nullifiers, value);
|
|
476
|
+
const address = await this.getAddressFromPublicKey(viewingKey).then((address) => TezosSaplingAddress_1.TezosSaplingAddress.fromValue(address.address, address.cursor.diversifierIndex));
|
|
477
|
+
const paymentOutput = this.createPaymentOutput(await TezosSaplingAddress_1.TezosSaplingAddress.fromValue(recipient), value);
|
|
478
|
+
const paybackOutput = this.createPaybackOutput(address, toSpend, value);
|
|
479
|
+
const [dummyInputs, dummyOutputs] = await Promise.all([
|
|
480
|
+
Promise.all(Array.from({ length: dummyInputsAmount }, (_v, _k) => this.createDummyInput(address))),
|
|
481
|
+
Promise.all(Array.from({ length: dummyOutputsAmount }, (_v, _k) => this.createDummyOutput()))
|
|
482
|
+
]);
|
|
483
|
+
return {
|
|
484
|
+
ins: inputs.concat(dummyInputs),
|
|
485
|
+
outs: [paymentOutput, paybackOutput, ...dummyOutputs].filter((output) => output !== undefined),
|
|
486
|
+
contractAddress: this.options.config.contractAddress,
|
|
487
|
+
chainId,
|
|
488
|
+
stateDiff,
|
|
489
|
+
unshieldTarget: ''
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
async mint(recipient, value) {
|
|
493
|
+
if (this.nodeClient === undefined || this.options.config.contractAddress === undefined) {
|
|
494
|
+
throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
|
|
495
|
+
}
|
|
496
|
+
if (!TezosSaplingAddress_1.TezosSaplingAddress.isZetAddress(recipient)) {
|
|
497
|
+
return Promise.reject(`Invalid recipient, expected a 'zet' address, got ${recipient}`);
|
|
498
|
+
}
|
|
499
|
+
const [saplingStateDiff, chainId] = await Promise.all([
|
|
500
|
+
this.nodeClient.getSaplingStateDiff(),
|
|
501
|
+
this.nodeClient.getChainId()
|
|
502
|
+
]);
|
|
503
|
+
const output = {
|
|
504
|
+
address: (await TezosSaplingAddress_1.TezosSaplingAddress.fromValue(recipient)).asString(),
|
|
505
|
+
value,
|
|
506
|
+
memo: Buffer.alloc(this.options.config.memoSize).toString('hex'),
|
|
507
|
+
browsable: true
|
|
508
|
+
};
|
|
509
|
+
const stateTree = await this.state.getStateTreeFromStateDiff(saplingStateDiff, true);
|
|
510
|
+
const forgedTransaction = await this.forger.forgeSaplingTransaction([], [output], stateTree, this.getAntiReplay(chainId, this.options.config.contractAddress));
|
|
511
|
+
return this.encoder.encodeTransaction(forgedTransaction).toString('hex');
|
|
512
|
+
}
|
|
513
|
+
async burn(viewingKey, value) {
|
|
514
|
+
if (this.nodeClient === undefined || this.options.config.contractAddress === undefined) {
|
|
515
|
+
throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, 'Contract address not set.');
|
|
516
|
+
}
|
|
517
|
+
const [stateDiff, chainId] = await Promise.all([
|
|
518
|
+
this.nodeClient.getSaplingStateDiff(),
|
|
519
|
+
this.nodeClient.getChainId()
|
|
520
|
+
]);
|
|
521
|
+
const [inputs, toSpend] = await this.chooseInputs(viewingKey, stateDiff.commitments_and_ciphertexts, stateDiff.nullifiers, value);
|
|
522
|
+
const paybackOutput = {
|
|
523
|
+
address: (await this.getAddressFromPublicKey(viewingKey)).address,
|
|
524
|
+
value: toSpend.minus(value).toString(),
|
|
525
|
+
memo: Buffer.alloc(this.options.config.memoSize).toString('hex'),
|
|
526
|
+
browsable: true
|
|
527
|
+
};
|
|
528
|
+
return {
|
|
529
|
+
ins: inputs,
|
|
530
|
+
outs: [paybackOutput],
|
|
531
|
+
contractAddress: this.options.config.contractAddress,
|
|
532
|
+
chainId,
|
|
533
|
+
stateDiff,
|
|
534
|
+
unshieldTarget: ''
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
async chooseInputs(viewingKey, commitmentsWithCiphertext, nullifiers, value) {
|
|
538
|
+
const unspends = await this.bookkeeper.getUnspends(viewingKey, commitmentsWithCiphertext, nullifiers);
|
|
539
|
+
const balance = this.bookkeeper.sumNotes(unspends);
|
|
540
|
+
if (balance.lt(value)) {
|
|
541
|
+
return Promise.reject('Not enough balance');
|
|
542
|
+
}
|
|
543
|
+
const chosenUnspends = [];
|
|
544
|
+
let toSpend = new bignumber_1.default(0);
|
|
545
|
+
for (const unspend of unspends) {
|
|
546
|
+
if (toSpend.gte(value)) {
|
|
547
|
+
break;
|
|
548
|
+
}
|
|
549
|
+
toSpend = toSpend.plus(unspend.value);
|
|
550
|
+
chosenUnspends.push(unspend);
|
|
551
|
+
}
|
|
552
|
+
return [chosenUnspends, toSpend];
|
|
553
|
+
}
|
|
554
|
+
createPaymentOutput(address, value, memo = Buffer.alloc(this.options.config.memoSize)) {
|
|
992
555
|
return {
|
|
993
556
|
address: address.asString(),
|
|
994
557
|
value: new bignumber_1.default(value).toString(),
|
|
995
558
|
memo: memo.toString('hex'),
|
|
996
559
|
browsable: true
|
|
997
560
|
};
|
|
998
|
-
}
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
var paybackValue = toSpend.minus(value);
|
|
561
|
+
}
|
|
562
|
+
createPaybackOutput(address, toSpend, value, memo = Buffer.alloc(this.options.config.memoSize)) {
|
|
563
|
+
const paybackValue = toSpend.minus(value);
|
|
1002
564
|
return paybackValue.gt(0)
|
|
1003
565
|
? {
|
|
1004
566
|
address: address.asString(),
|
|
@@ -1007,183 +569,94 @@ var TezosSaplingProtocol = /** @class */ (function (_super) {
|
|
|
1007
569
|
browsable: true
|
|
1008
570
|
}
|
|
1009
571
|
: undefined;
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
memo = (0, random_1.randomBytes)(this.options.config.memoSize);
|
|
1038
|
-
return [2 /*return*/, {
|
|
1039
|
-
address: address.address,
|
|
1040
|
-
value: '0',
|
|
1041
|
-
memo: Buffer.from(memo).toString('hex'),
|
|
1042
|
-
browsable: false
|
|
1043
|
-
}];
|
|
1044
|
-
}
|
|
1045
|
-
});
|
|
1046
|
-
});
|
|
1047
|
-
};
|
|
1048
|
-
TezosSaplingProtocol.prototype.getDummyAddress = function () {
|
|
1049
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1050
|
-
var seed, viewingKey;
|
|
1051
|
-
return __generator(this, function (_a) {
|
|
1052
|
-
switch (_a.label) {
|
|
1053
|
-
case 0:
|
|
1054
|
-
seed = (0, random_1.randomBytes)(32);
|
|
1055
|
-
return [4 /*yield*/, this.getPublicKeyFromHexSecret(Buffer.from(seed).toString('hex'), this.standardDerivationPath)];
|
|
1056
|
-
case 1:
|
|
1057
|
-
viewingKey = _a.sent();
|
|
1058
|
-
return [2 /*return*/, this.getAddressFromPublicKey(viewingKey)];
|
|
1059
|
-
}
|
|
1060
|
-
});
|
|
1061
|
-
});
|
|
1062
|
-
};
|
|
1063
|
-
TezosSaplingProtocol.prototype.createAddressBoundData = function (address) {
|
|
1064
|
-
var michelson = MichelsonAddress_1.MichelsonAddress.from(TezosUtils_1.TezosUtils.encodeTzAddress(address));
|
|
572
|
+
}
|
|
573
|
+
async createDummyInput(address) {
|
|
574
|
+
const rcm = await sapling.randR();
|
|
575
|
+
return {
|
|
576
|
+
rcm: rcm.toString('hex'),
|
|
577
|
+
pos: '0',
|
|
578
|
+
value: '0',
|
|
579
|
+
address: address.asString()
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
async createDummyOutput() {
|
|
583
|
+
const address = await this.getDummyAddress();
|
|
584
|
+
const memo = (0, random_1.randomBytes)(this.options.config.memoSize);
|
|
585
|
+
return {
|
|
586
|
+
address: address.address,
|
|
587
|
+
value: '0',
|
|
588
|
+
memo: Buffer.from(memo).toString('hex'),
|
|
589
|
+
browsable: false
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
async getDummyAddress() {
|
|
593
|
+
const seed = (0, random_1.randomBytes)(32);
|
|
594
|
+
const viewingKey = await this.getPublicKeyFromHexSecret(Buffer.from(seed).toString('hex'), this.standardDerivationPath);
|
|
595
|
+
return this.getAddressFromPublicKey(viewingKey);
|
|
596
|
+
}
|
|
597
|
+
createAddressBoundData(address) {
|
|
598
|
+
const michelson = MichelsonAddress_1.MichelsonAddress.from(TezosUtils_1.TezosUtils.encodeTzAddress(address));
|
|
1065
599
|
return TezosUtils_1.TezosUtils.packMichelsonType(michelson);
|
|
1066
|
-
}
|
|
1067
|
-
|
|
600
|
+
}
|
|
601
|
+
getAntiReplay(chainId, contractAddress) {
|
|
1068
602
|
return contractAddress + chainId;
|
|
1069
|
-
}
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
}
|
|
1094
|
-
|
|
1095
|
-
return
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
}
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
});
|
|
1120
|
-
});
|
|
1121
|
-
};
|
|
1122
|
-
TezosSaplingProtocol.prototype.encryptAES = function (payload, privateKey) {
|
|
1123
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1124
|
-
return __generator(this, function (_a) {
|
|
1125
|
-
return [2 /*return*/, this.encryptAES(payload, privateKey)];
|
|
1126
|
-
});
|
|
1127
|
-
});
|
|
1128
|
-
};
|
|
1129
|
-
TezosSaplingProtocol.prototype.decryptAES = function (encryptedPayload, privateKey) {
|
|
1130
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1131
|
-
return __generator(this, function (_a) {
|
|
1132
|
-
return [2 /*return*/, this.decryptAES(encryptedPayload, privateKey)];
|
|
1133
|
-
});
|
|
1134
|
-
});
|
|
1135
|
-
};
|
|
1136
|
-
TezosSaplingProtocol.prototype.getBlockExplorerLinkForAddress = function (address) {
|
|
1137
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1138
|
-
return __generator(this, function (_a) {
|
|
1139
|
-
throw new Error('Method `getBlockExplorerLinkForAddress` not supported.');
|
|
1140
|
-
});
|
|
1141
|
-
});
|
|
1142
|
-
};
|
|
1143
|
-
TezosSaplingProtocol.prototype.getTransactionsFromAddresses = function (addresses, limit, cursor) {
|
|
1144
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1145
|
-
return __generator(this, function (_a) {
|
|
1146
|
-
throw new Error('Method `getTransactionsFromAddresses` not supported.');
|
|
1147
|
-
});
|
|
1148
|
-
});
|
|
1149
|
-
};
|
|
1150
|
-
TezosSaplingProtocol.prototype.getBalanceOfAddresses = function (addresses) {
|
|
1151
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1152
|
-
return __generator(this, function (_a) {
|
|
1153
|
-
throw new Error('Method `getBalanceOfAddresses` not supported.');
|
|
1154
|
-
});
|
|
1155
|
-
});
|
|
1156
|
-
};
|
|
1157
|
-
TezosSaplingProtocol.prototype.getAvailableBalanceOfAddresses = function (addresses) {
|
|
1158
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1159
|
-
return __generator(this, function (_a) {
|
|
1160
|
-
throw new Error('Method `getAvailableBalanceOfAddresses` not supported.');
|
|
1161
|
-
});
|
|
1162
|
-
});
|
|
1163
|
-
};
|
|
1164
|
-
TezosSaplingProtocol.prototype.getBalanceOfPublicKeyForSubProtocols = function (publicKey, subProtocols) {
|
|
1165
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1166
|
-
return __generator(this, function (_a) {
|
|
1167
|
-
throw new Error('Method `getBalanceOfPublicKeyForSubProtocols` not supported.');
|
|
1168
|
-
});
|
|
1169
|
-
});
|
|
1170
|
-
};
|
|
1171
|
-
TezosSaplingProtocol.prototype.estimateFeeDefaultsFromPublicKey = function (publicKey, recipients, values, data) {
|
|
1172
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
1173
|
-
return __generator(this, function (_a) {
|
|
1174
|
-
throw new Error('Method `estimateFeeDefaultsFromPublicKey` not supported.');
|
|
1175
|
-
});
|
|
1176
|
-
});
|
|
1177
|
-
};
|
|
1178
|
-
TezosSaplingProtocol.prototype.isRawTezosSaplingTransaction = function (transaction) {
|
|
603
|
+
}
|
|
604
|
+
async broadcastTransaction(rawTransaction) {
|
|
605
|
+
if (!this.injectorClient) {
|
|
606
|
+
throw new errors_1.PropertyUndefinedError(coinlib_error_1.Domain.TEZOS, "Can't broadcast a sapling transaction, an injector service URL or contract address has not be set.");
|
|
607
|
+
}
|
|
608
|
+
try {
|
|
609
|
+
const hash = await this.injectorClient.injectTransaction(rawTransaction);
|
|
610
|
+
return hash;
|
|
611
|
+
}
|
|
612
|
+
catch (error) {
|
|
613
|
+
throw new errors_1.NetworkError(coinlib_error_1.Domain.TEZOS, error);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
async signMessage(message, keypair) {
|
|
617
|
+
return this.tezosProtocol.signMessage(message, keypair);
|
|
618
|
+
}
|
|
619
|
+
async verifyMessage(message, signature, publicKey) {
|
|
620
|
+
return this.tezosProtocol.verifyMessage(message, signature, publicKey);
|
|
621
|
+
}
|
|
622
|
+
async encryptAsymmetric(payload, publicKey) {
|
|
623
|
+
return this.encryptAsymmetric(payload, publicKey);
|
|
624
|
+
}
|
|
625
|
+
async decryptAsymmetric(encryptedPayload, keypair) {
|
|
626
|
+
return this.decryptAsymmetric(encryptedPayload, keypair);
|
|
627
|
+
}
|
|
628
|
+
async encryptAES(payload, privateKey) {
|
|
629
|
+
return this.encryptAES(payload, privateKey);
|
|
630
|
+
}
|
|
631
|
+
async decryptAES(encryptedPayload, privateKey) {
|
|
632
|
+
return this.decryptAES(encryptedPayload, privateKey);
|
|
633
|
+
}
|
|
634
|
+
async getBlockExplorerLinkForAddress(address) {
|
|
635
|
+
throw new Error('Method `getBlockExplorerLinkForAddress` not supported.');
|
|
636
|
+
}
|
|
637
|
+
async getTransactionsFromAddresses(addresses, limit, cursor) {
|
|
638
|
+
throw new Error('Method `getTransactionsFromAddresses` not supported.');
|
|
639
|
+
}
|
|
640
|
+
async getBalanceOfAddresses(addresses) {
|
|
641
|
+
throw new Error('Method `getBalanceOfAddresses` not supported.');
|
|
642
|
+
}
|
|
643
|
+
async getAvailableBalanceOfAddresses(addresses) {
|
|
644
|
+
throw new Error('Method `getAvailableBalanceOfAddresses` not supported.');
|
|
645
|
+
}
|
|
646
|
+
async getBalanceOfPublicKeyForSubProtocols(publicKey, subProtocols) {
|
|
647
|
+
throw new Error('Method `getBalanceOfPublicKeyForSubProtocols` not supported.');
|
|
648
|
+
}
|
|
649
|
+
async estimateFeeDefaultsFromPublicKey(publicKey, recipients, values, data) {
|
|
650
|
+
throw new Error('Method `estimateFeeDefaultsFromPublicKey` not supported.');
|
|
651
|
+
}
|
|
652
|
+
isRawTezosSaplingTransaction(transaction) {
|
|
1179
653
|
return (transaction instanceof Object &&
|
|
1180
654
|
'ins' in transaction &&
|
|
1181
655
|
'outs' in transaction &&
|
|
1182
656
|
'contractAddress' in transaction &&
|
|
1183
657
|
'chainId' in transaction &&
|
|
1184
658
|
'stateDiff' in transaction);
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
}(NonExtendedProtocol_1.NonExtendedProtocol));
|
|
659
|
+
}
|
|
660
|
+
}
|
|
1188
661
|
exports.TezosSaplingProtocol = TezosSaplingProtocol;
|
|
1189
662
|
//# sourceMappingURL=TezosSaplingProtocol.js.map
|