Skip to content

Commit

Permalink
Merge pull request #68 from cryptape/rc/0.24.0
Browse files Browse the repository at this point in the history
Rc/v0.24.0
  • Loading branch information
ashchan authored May 30, 2019
2 parents edc5950 + 8cb7fd6 commit d40199e
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 3 additions & 3 deletions CITA.podspec
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,9 +12,9 @@ Pod::Spec.new do |s|
s.author = { "Cryptape" => "[email protected]" }
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' }
Expand Down
2 changes: 1 addition & 1 deletion Source/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.23.0</string>
<string>0.24.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
9 changes: 5 additions & 4 deletions Source/Signer/Signer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions Source/Signer/Transaction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand All @@ -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")
Expand Down

0 comments on commit d40199e

Please sign in to comment.