From 55cc320ac18fa6beb6252c2b8242dc3d97a46e55 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Wed, 17 Apr 2024 13:58:49 -0600 Subject: [PATCH] Update to zcash-light-client-ffi version 0.8.0. --- CHANGELOG.md | 5 ++++ .../xcshareddata/swiftpm/Package.resolved | 28 ++++++++--------- Package.resolved | 4 +-- Package.swift | 2 +- .../Rust/ZcashKeyDerivationBackend.swift | 2 +- .../Rust/ZcashRustBackend.swift | 4 +-- .../Rust/ZcashRustBackendWelding.swift | 3 +- .../AutoMockable.generated.swift | 30 +++++++++---------- Tests/TestUtils/Sourcery/generateMocks.sh | 4 +-- Tests/TestUtils/Stubs.swift | 2 +- 10 files changed, 45 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f336439..f70b45ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ and this library adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 # Unreleased +## Changed +- Updated to `zcash-light-client-ffi` version 0.8.0. +- `ZcashRustBackend.getMemo` now takes an additional `outputPool` argument that identifies + the shielded pool for the decrypted output. + # 2.1.4 - 2024-04-17 ## Changed diff --git a/Example/ZcashLightClientSample/ZcashLightClientSample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Example/ZcashLightClientSample/ZcashLightClientSample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index 2cc78dbb..3681b337 100644 --- a/Example/ZcashLightClientSample/ZcashLightClientSample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Example/ZcashLightClientSample/ZcashLightClientSample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/grpc/grpc-swift.git", "state" : { - "revision" : "6ade19f0b57f5fc436dfecfced83f3c84d1095b9", - "version" : "1.21.0" + "revision" : "393b02b1c39cc82fb24e57f24fa446f43e8124c9", + "version" : "1.22.0" } }, { @@ -59,8 +59,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/stephencelis/SQLite.swift.git", "state" : { - "revision" : "7a2e3cd27de56f6d396e84f63beefd0267b55ccb", - "version" : "0.14.1" + "revision" : "e5e833921a8f98870e547e428df017c266cd98f2", + "version" : "0.15.2" } }, { @@ -77,8 +77,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-collections.git", "state" : { - "revision" : "d029d9d39c87bed85b1c50adee7c41795261a192", - "version" : "1.0.6" + "revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb", + "version" : "1.1.0" } }, { @@ -113,8 +113,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio.git", "state" : { - "revision" : "635b2589494c97e48c62514bc8b37ced762e0a62", - "version" : "2.63.0" + "revision" : "fc63f0cf4e55a4597407a9fc95b16a2bc44b4982", + "version" : "2.64.0" } }, { @@ -122,8 +122,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-nio-extras.git", "state" : { - "revision" : "363da63c1966405764f380c627409b2f9d9e710b", - "version" : "1.21.0" + "revision" : "a3b640d7dc567225db7c94386a6e71aded1bfa63", + "version" : "1.22.0" } }, { @@ -158,8 +158,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/apple/swift-protobuf.git", "state" : { - "revision" : "65e8f29b2d63c4e38e736b25c27b83e012159be8", - "version" : "1.25.2" + "revision" : "9f0c76544701845ad98716f3f6a774a892152bcb", + "version" : "1.26.0" } }, { @@ -176,8 +176,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/zcash-hackworks/zcash-light-client-ffi", "state" : { - "revision" : "e2d8763f3a963fb0026b6160af2d211b527453cd", - "version" : "0.7.4" + "revision" : "9314c83d7a09d88e1c0bd3ff3738a50833325059", + "version" : "0.8.0" } } ], diff --git a/Package.resolved b/Package.resolved index 30efaf66..c8615efd 100644 --- a/Package.resolved +++ b/Package.resolved @@ -122,8 +122,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/zcash-hackworks/zcash-light-client-ffi", "state" : { - "revision" : "e2d8763f3a963fb0026b6160af2d211b527453cd", - "version" : "0.7.4" + "revision" : "9314c83d7a09d88e1c0bd3ff3738a50833325059", + "version" : "0.8.0" } } ], diff --git a/Package.swift b/Package.swift index 58644946..7827d080 100644 --- a/Package.swift +++ b/Package.swift @@ -16,7 +16,7 @@ let package = Package( dependencies: [ .package(url: "https://github.com/grpc/grpc-swift.git", from: "1.19.1"), .package(url: "https://github.com/stephencelis/SQLite.swift.git", from: "0.14.1"), - .package(url: "https://github.com/zcash-hackworks/zcash-light-client-ffi", exact: "0.7.4") + .package(url: "https://github.com/zcash-hackworks/zcash-light-client-ffi", from: "0.8.0") ], targets: [ .target( diff --git a/Sources/ZcashLightClientKit/Rust/ZcashKeyDerivationBackend.swift b/Sources/ZcashLightClientKit/Rust/ZcashKeyDerivationBackend.swift index fb7ed96e..2ecaabc9 100644 --- a/Sources/ZcashLightClientKit/Rust/ZcashKeyDerivationBackend.swift +++ b/Sources/ZcashLightClientKit/Rust/ZcashKeyDerivationBackend.swift @@ -68,7 +68,7 @@ struct ZcashKeyDerivationBackend: ZcashKeyDerivationBackendWelding { return false } - return zcashlc_is_valid_shielded_address([CChar](address.utf8CString), networkType.networkId) + return zcashlc_is_valid_sapling_address([CChar](address.utf8CString), networkType.networkId) } func isValidSaplingExtendedFullViewingKey(_ key: String) -> Bool { diff --git a/Sources/ZcashLightClientKit/Rust/ZcashRustBackend.swift b/Sources/ZcashLightClientKit/Rust/ZcashRustBackend.swift index bc69afe7..6377fd4d 100644 --- a/Sources/ZcashLightClientKit/Rust/ZcashRustBackend.swift +++ b/Sources/ZcashLightClientKit/Rust/ZcashRustBackend.swift @@ -255,7 +255,7 @@ struct ZcashRustBackend: ZcashRustBackendWelding { } @DBActor - func getMemo(txId: Data, outputIndex: UInt16) async throws -> Memo? { + func getMemo(txId: Data, outputPool: UInt32, outputIndex: UInt16) async throws -> Memo? { guard txId.count == 32 else { throw ZcashError.rustGetMemoInvalidTxIdLength } @@ -264,7 +264,7 @@ struct ZcashRustBackend: ZcashRustBackendWelding { var success = false contiguousMemoBytes.withUnsafeMutableBufferPointer { memoBytePtr in - success = zcashlc_get_memo(dbData.0, dbData.1, txId.bytes, outputIndex, memoBytePtr.baseAddress, networkType.networkId) + success = zcashlc_get_memo(dbData.0, dbData.1, txId.bytes, outputPool, outputIndex, memoBytePtr.baseAddress, networkType.networkId) } guard success else { return nil } diff --git a/Sources/ZcashLightClientKit/Rust/ZcashRustBackendWelding.swift b/Sources/ZcashLightClientKit/Rust/ZcashRustBackendWelding.swift index 011135e8..35fb701e 100644 --- a/Sources/ZcashLightClientKit/Rust/ZcashRustBackendWelding.swift +++ b/Sources/ZcashLightClientKit/Rust/ZcashRustBackendWelding.swift @@ -85,8 +85,9 @@ protocol ZcashRustBackendWelding { /// Get memo from note. /// - parameter txId: ID of transaction containing the note + /// - parameter outputPool: output pool identifier (2 = Sapling, 3 = Orchard) /// - parameter outputIndex: output index of note - func getMemo(txId: Data, outputIndex: UInt16) async throws -> Memo? + func getMemo(txId: Data, outputPool: UInt32, outputIndex: UInt16) async throws -> Memo? /// Get the verified cached transparent balance for the given address /// - parameter account; the account index to query diff --git a/Tests/TestUtils/Sourcery/GeneratedMocks/AutoMockable.generated.swift b/Tests/TestUtils/Sourcery/GeneratedMocks/AutoMockable.generated.swift index 655c250a..2baa2e47 100644 --- a/Tests/TestUtils/Sourcery/GeneratedMocks/AutoMockable.generated.swift +++ b/Tests/TestUtils/Sourcery/GeneratedMocks/AutoMockable.generated.swift @@ -1,4 +1,4 @@ -// Generated using Sourcery 2.1.7 — https://github.com/krzysztofzablocki/Sourcery +// Generated using Sourcery 2.2.3 — https://github.com/krzysztofzablocki/Sourcery // DO NOT EDIT import Combine @testable import ZcashLightClientKit @@ -2434,25 +2434,25 @@ class ZcashRustBackendWeldingMock: ZcashRustBackendWelding { // MARK: - getMemo - var getMemoTxIdOutputIndexThrowableError: Error? - var getMemoTxIdOutputIndexCallsCount = 0 - var getMemoTxIdOutputIndexCalled: Bool { - return getMemoTxIdOutputIndexCallsCount > 0 + var getMemoTxIdOutputPoolOutputIndexThrowableError: Error? + var getMemoTxIdOutputPoolOutputIndexCallsCount = 0 + var getMemoTxIdOutputPoolOutputIndexCalled: Bool { + return getMemoTxIdOutputPoolOutputIndexCallsCount > 0 } - var getMemoTxIdOutputIndexReceivedArguments: (txId: Data, outputIndex: UInt16)? - var getMemoTxIdOutputIndexReturnValue: Memo? - var getMemoTxIdOutputIndexClosure: ((Data, UInt16) async throws -> Memo?)? + var getMemoTxIdOutputPoolOutputIndexReceivedArguments: (txId: Data, outputPool: UInt32, outputIndex: UInt16)? + var getMemoTxIdOutputPoolOutputIndexReturnValue: Memo? + var getMemoTxIdOutputPoolOutputIndexClosure: ((Data, UInt32, UInt16) async throws -> Memo?)? - func getMemo(txId: Data, outputIndex: UInt16) async throws -> Memo? { - if let error = getMemoTxIdOutputIndexThrowableError { + func getMemo(txId: Data, outputPool: UInt32, outputIndex: UInt16) async throws -> Memo? { + if let error = getMemoTxIdOutputPoolOutputIndexThrowableError { throw error } - getMemoTxIdOutputIndexCallsCount += 1 - getMemoTxIdOutputIndexReceivedArguments = (txId: txId, outputIndex: outputIndex) - if let closure = getMemoTxIdOutputIndexClosure { - return try await closure(txId, outputIndex) + getMemoTxIdOutputPoolOutputIndexCallsCount += 1 + getMemoTxIdOutputPoolOutputIndexReceivedArguments = (txId: txId, outputPool: outputPool, outputIndex: outputIndex) + if let closure = getMemoTxIdOutputPoolOutputIndexClosure { + return try await closure(txId, outputPool, outputIndex) } else { - return getMemoTxIdOutputIndexReturnValue + return getMemoTxIdOutputPoolOutputIndexReturnValue } } diff --git a/Tests/TestUtils/Sourcery/generateMocks.sh b/Tests/TestUtils/Sourcery/generateMocks.sh index b25143e5..4f735d58 100755 --- a/Tests/TestUtils/Sourcery/generateMocks.sh +++ b/Tests/TestUtils/Sourcery/generateMocks.sh @@ -3,11 +3,11 @@ scriptDir=${0:a:h} cd "${scriptDir}" -sourcery_version=2.1.7 +sourcery_version=2.2.3 if which sourcery >/dev/null; then if [[ $(sourcery --version) != $sourcery_version ]]; then - echo "warning: Compatible sourcery version not installed. Install sourcer $sourcery_version. Currently installed version is $(sourcery --version)" + echo "warning: Compatible sourcery version not installed. Install sourcery $sourcery_version. Currently installed version is $(sourcery --version)" exit 1 fi diff --git a/Tests/TestUtils/Stubs.swift b/Tests/TestUtils/Stubs.swift index 93ee7f54..62c70d3e 100644 --- a/Tests/TestUtils/Stubs.swift +++ b/Tests/TestUtils/Stubs.swift @@ -79,7 +79,7 @@ class RustBackendMockHelper { rustBackendMock.getCurrentAddressAccountThrowableError = ZcashError.rustGetCurrentAddress("mocked error") rustBackendMock.getNextAvailableAddressAccountThrowableError = ZcashError.rustGetNextAvailableAddress("mocked error") rustBackendMock.createAccountSeedTreeStateRecoverUntilThrowableError = ZcashError.rustInitAccountsTableViewingKeyCotainsNullBytes - rustBackendMock.getMemoTxIdOutputIndexReturnValue = nil + rustBackendMock.getMemoTxIdOutputPoolOutputIndexReturnValue = nil rustBackendMock.initDataDbSeedReturnValue = .seedRequired rustBackendMock.getNearestRewindHeightHeightReturnValue = -1 rustBackendMock.putUnspentTransparentOutputTxidIndexScriptValueHeightClosure = { _, _, _, _, _ in }