Skip to content

Commit

Permalink
Merge pull request #33 from KeystoneHQ/fix-tron
Browse files Browse the repository at this point in the history
Fix tron
  • Loading branch information
LiYanLance authored Nov 29, 2023
2 parents 8df8a3c + 8dc1db6 commit d1aa8a5
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
4 changes: 2 additions & 2 deletions KeystoneSDK.podspec
Original file line number Diff line number Diff line change
@@ -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' }
Expand All @@ -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
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions Sources/KeystoneSDK/Chain/KeystoneTronSDK.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
13 changes: 13 additions & 0 deletions Sources/KeystoneSDK/Model/TronSignature.swift
Original file line number Diff line number Diff line change
@@ -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
}
2 changes: 1 addition & 1 deletion Tests/KeystoneSDKTests/Chain/KeystoneTronSDKTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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, "0ad4010a0207902208e1b9de559665c6714080c49789bb2c5aae01081f12a9010a31747970652e676f6f676c65617069732e636f6d2f70726f746f636f6c2e54726967676572536d617274436f6e747261637412740a15418dfec1cde1fe6a9ec38a16c7d67073e3020851c01215410d292c98a5eca06c2085fff993996423cf66c93b2244a9059cbb0000000000000000000000009c0279f1bda9fc40a85f1b53c306602864533e7300000000000000000000000000000000000000000000000000000000000f424070c0b6e087bb2c90018094ebdc03124142a9ece5a555a9437de74108d0fb5320f20835e108b961bb8b230228ea07c485412625863391d49692be558067f9e00559641f5ee63d8ab09275a51afe555b7e01")
}

func testGenerateSignRequest() {
Expand Down

0 comments on commit d1aa8a5

Please sign in to comment.