From 9609b8f5a130cb9a754e2160b6fa97a0fe327425 Mon Sep 17 00:00:00 2001 From: LuFP Date: Wed, 22 May 2019 11:43:36 +0800 Subject: [PATCH 1/3] chore: update chain's version to 2. --- Source/Signer/Signer.swift | 9 +++++---- Source/Signer/Transaction.swift | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/Source/Signer/Signer.swift b/Source/Signer/Signer.swift index 93299b4..0ed1a2f 100644 --- a/Source/Signer/Signer.swift +++ b/Source/Signer/Signer.swift @@ -28,22 +28,23 @@ public struct Signer { tx.validUntilBlock = transaction.validUntilBlock tx.version = transaction.version - if transaction.version == 0 { + switch transaction.version { + case 0: tx.chainID = UInt32(transaction.chainId)! if let to = transaction.to { tx.to = to.address.stripHexPrefix().lowercased() } - } else if transaction.version == 1 { + case 1, 2: guard let chainId = BigUInt.fromHex(transaction.chainId), let chainIdU256 = chainId.toUInt256Hex(), let chainIDV1 = Data.fromHex(chainIdU256) else { - throw TransactionError.chainIdInvalid + throw TransactionError.chainIdInvalid } tx.chainIDV1 = chainIDV1 if let to = transaction.to { tx.toV1 = Data.fromHex(to.address)! } - } else { + default: throw TransactionError.versionNotSupported } diff --git a/Source/Signer/Transaction.swift b/Source/Signer/Transaction.swift index 7f700e3..779a221 100644 --- a/Source/Signer/Transaction.swift +++ b/Source/Signer/Transaction.swift @@ -37,7 +37,7 @@ public struct Transaction: CustomStringConvertible { data: Data? = nil, value: BigUInt = 0, chainId: String, - version: UInt32 = 1 + version: UInt32 = 2 ) { self.to = to self.nonce = nonce.isEmpty ? UUID().uuidString : nonce @@ -69,7 +69,7 @@ extension CitaTransaction { switch version { case 0: return to - case 1: + case 1, 2: return toV1.toHexString() default: fatalError("Transaction version not supported") @@ -79,7 +79,7 @@ extension CitaTransaction { switch version { case 0: return String(chainID) - case 1: + case 1, 2: return chainIDV1.toHexString() default: fatalError("Transaction version not supported") From a85c8d4a72824a634161479980ec41c69cff6339 Mon Sep 17 00:00:00 2001 From: LuFP Date: Wed, 22 May 2019 13:37:52 +0800 Subject: [PATCH 2/3] fix: update CHANGELOG.md and CITA.podspec --- CHANGELOG.md | 6 ++++++ CITA.podspec | 6 +++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5a70f0..3e10806 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ All notable changes to this project will be documented in this file. +# [v0.24](https://github.com/cryptape/cita-sdk-swift/compare/v0.23...v0.24) (2019-05-30) + +### CHANGES + +* [Optimization] Support new protocol version 2 + # [v0.23](https://github.com/cryptape/cita-sdk-swift/compare/v0.22...v0.23) (2019-04-30) ### CHANGES diff --git a/CITA.podspec b/CITA.podspec index f8fb703..f311d2f 100644 --- a/CITA.podspec +++ b/CITA.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "CITA" - s.version = "0.23.0" + s.version = "0.24.0" s.summary = "CITA SDK implementation in Swift for iOS" s.description = <<-DESC @@ -12,9 +12,9 @@ Pod::Spec.new do |s| s.author = { "Cryptape" => "contact@cryptape.com" } s.source = { git: "https://github.com/cryptape/cita-sdk-swift.git", tag: "v#{s.version.to_s}" } - s.swift_version = '4.2' + s.swift_version = '5.0' s.module_name = 'CITA' - s.ios.deployment_target = "10.0" + s.ios.deployment_target = "10.2" s.source_files = "Source/**/*.{h,swift}" s.public_header_files = "Source/**/*.{h}" s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } From 8cb7fd692293e4d4f4c78879b7e26f54a168800a Mon Sep 17 00:00:00 2001 From: LuFP Date: Thu, 30 May 2019 10:31:19 +0800 Subject: [PATCH 3/3] fix: fix info.plist version error --- Source/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Info.plist b/Source/Info.plist index 4e3d54d..81c5afc 100644 --- a/Source/Info.plist +++ b/Source/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.23.0 + 0.24.0 CFBundleVersion $(CURRENT_PROJECT_VERSION) NSPrincipalClass