From 46604110155f3b5b87ced017e5c397656672f848 Mon Sep 17 00:00:00 2001 From: Renfeng Shi Date: Tue, 28 Nov 2023 18:33:15 +0800 Subject: [PATCH 1/3] fix: tron signature --- Package.resolved | 4 ++-- Package.swift | 4 ++-- Sources/KeystoneSDK/Chain/KeystoneTronSDK.swift | 4 ++-- Sources/KeystoneSDK/Model/TronSignature.swift | 13 +++++++++++++ .../Chain/KeystoneTronSDKTests.swift | 2 +- 5 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 Sources/KeystoneSDK/Model/TronSignature.swift diff --git a/Package.resolved b/Package.resolved index fd5e454..7a40204 100644 --- a/Package.resolved +++ b/Package.resolved @@ -5,8 +5,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/KeystoneHQ/BCSwiftDCBOR.git", "state" : { - "revision" : "1830abea38243eac9ccc5e1f8c03244073791a4d", - "version" : "0.10.0" + "revision" : "71a4b14e77679b7f925df11b0aac01fcb03d647f", + "version" : "0.10.1" } }, { diff --git a/Package.swift b/Package.swift index 8bcacaa..bd56eb5 100644 --- a/Package.swift +++ b/Package.swift @@ -26,8 +26,8 @@ let package = Package( ), .binaryTarget( name: "URRegistryFFI", - url: "https://github.com/KeystoneHQ/keystone-sdk-rust/releases/download/sdk-0.1.6/URRegistryFFI.xcframework.zip", - checksum: "299b4adb24b04c62f1a651c7ac7b8ac4d5040fcf56295cbc0f43d16969bd8e7e" + url: "https://github.com/KeystoneHQ/keystone-sdk-rust/releases/download/sdk-0.1.8/URRegistryFFI.xcframework.zip", + checksum: "5fc2d2f82e99793d1d6650d25ebbab99fb2c77d5622bdb3374d65aa87264b61e" ), .testTarget( name: "KeystoneSDKTests", diff --git a/Sources/KeystoneSDK/Chain/KeystoneTronSDK.swift b/Sources/KeystoneSDK/Chain/KeystoneTronSDK.swift index a400943..78f0c65 100644 --- a/Sources/KeystoneSDK/Chain/KeystoneTronSDK.swift +++ b/Sources/KeystoneSDK/Chain/KeystoneTronSDK.swift @@ -12,11 +12,11 @@ import URKit public class KeystoneTronSDK: KeystoneBaseSDK { - public func parseSignature(ur: UR) throws -> Signature { + public func parseSignature(ur: UR) throws -> TronSignature { let signResult = handle_error( get_result: { parse_tron_signature($0, ur.type, ur.cborData.hexEncodedString()) } ) - return try super.parseSignature(signResult: signResult) + return try super.parseUR(urString: signResult, ofType: TronSignature.self, ofError: KeystoneError.parseSignatureError) } public func generateSignRequest(tronSignRequest: TronSignRequest) throws -> UREncoder { diff --git a/Sources/KeystoneSDK/Model/TronSignature.swift b/Sources/KeystoneSDK/Model/TronSignature.swift new file mode 100644 index 0000000..fc8f3f6 --- /dev/null +++ b/Sources/KeystoneSDK/Model/TronSignature.swift @@ -0,0 +1,13 @@ +// +// File.swift +// +// +// Created by Renfeng Shi on 2023/11/28. +// + +import Foundation + +public struct TronSignature : Equatable, Codable { + public var requestId: String + public var raw: String +} diff --git a/Tests/KeystoneSDKTests/Chain/KeystoneTronSDKTests.swift b/Tests/KeystoneSDKTests/Chain/KeystoneTronSDKTests.swift index e7853e1..08d4f54 100644 --- a/Tests/KeystoneSDKTests/Chain/KeystoneTronSDKTests.swift +++ b/Tests/KeystoneSDKTests/Chain/KeystoneTronSDKTests.swift @@ -29,7 +29,7 @@ final class KeystoneTronSDKTests: XCTestCase { let tronSignature = try! tronSdk.parseSignature(ur: ur) XCTAssertEqual(tronSignature.requestId, "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d") - XCTAssertEqual(tronSignature.signature, "42a9ece5a555a9437de74108d0fb5320f20835e108b961bb8b230228ea07c485412625863391d49692be558067f9e00559641f5ee63d8ab09275a51afe555b7e01") + XCTAssertEqual(tronSignature.raw, "42a9ece5a555a9437de74108d0fb5320f20835e108b961bb8b230228ea07c485412625863391d49692be558067f9e00559641f5ee63d8ab09275a51afe555b7e01") } func testGenerateSignRequest() { From 34d446be102ec40af0778f0c71a60391e2b0733f Mon Sep 17 00:00:00 2001 From: Renfeng Shi Date: Wed, 29 Nov 2023 11:20:16 +0800 Subject: [PATCH 2/3] fix test --- Tests/KeystoneSDKTests/Chain/KeystoneTronSDKTests.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/KeystoneSDKTests/Chain/KeystoneTronSDKTests.swift b/Tests/KeystoneSDKTests/Chain/KeystoneTronSDKTests.swift index 08d4f54..d4dba5c 100644 --- a/Tests/KeystoneSDKTests/Chain/KeystoneTronSDKTests.swift +++ b/Tests/KeystoneSDKTests/Chain/KeystoneTronSDKTests.swift @@ -29,7 +29,7 @@ final class KeystoneTronSDKTests: XCTestCase { let tronSignature = try! tronSdk.parseSignature(ur: ur) XCTAssertEqual(tronSignature.requestId, "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d") - XCTAssertEqual(tronSignature.raw, "42a9ece5a555a9437de74108d0fb5320f20835e108b961bb8b230228ea07c485412625863391d49692be558067f9e00559641f5ee63d8ab09275a51afe555b7e01") + XCTAssertEqual(tronSignature.raw, "0ad4010a0207902208e1b9de559665c6714080c49789bb2c5aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a15418dfec1cde1fe6a9ec38a16c7d67073e3020851c01215410d292c98a5eca06c2085fff993996423cf66c93b2244a9059cbb0000000000000000000000009c0279f1bda9fc40a85f1b53c306602864533e7300000000000000000000000000000000000000000000000000000000000f424070c0b6e087bb2c90018094ebdc03124142a9ece5a555a9437de74108d0fb5320f20835e108b961bb8b230228ea07c485412625863391d49692be558067f9e00559641f5ee63d8ab09275a51afe555b7e01") } func testGenerateSignRequest() { From 8dc1db64ee4d27e15edcf9515575a0935ecb6871 Mon Sep 17 00:00:00 2001 From: Renfeng Shi Date: Wed, 29 Nov 2023 11:37:26 +0800 Subject: [PATCH 3/3] fix: update version for pod --- KeystoneSDK.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/KeystoneSDK.podspec b/KeystoneSDK.podspec index 7bb4f88..1f39281 100644 --- a/KeystoneSDK.podspec +++ b/KeystoneSDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = "KeystoneSDK" - spec.version = "0.6.3" + spec.version = "0.6.4" spec.summary = "A library to simplify the way how software wallets communicate with the Keystone hardware wallet via UR." spec.homepage = "https://github.com/KeystoneHQ/keystone-sdk-ios" spec.license = { :type => 'Copyright', :text => 'Copyright 2023 Keystone' } @@ -12,6 +12,6 @@ Pod::Spec.new do |spec| spec.source_files = "Sources/KeystoneSDK/*.swift", "Sources/KeystoneSDK/**/*.swift" spec.requires_arc = true spec.static_framework = true - spec.dependency "URRegistryFFI", "~> 0.2.4" + spec.dependency "URRegistryFFI", "~> 0.2.5" spec.dependency "URKit", "~> 10.1.0" end