diff --git a/Cadence.podspec b/Cadence.podspec index e4ef7f0..64226c3 100644 --- a/Cadence.podspec +++ b/Cadence.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Cadence' - s.version = '0.6.0' + s.version = '0.7.0' s.summary = 'JSON-Cadence Data Interchange Format Wrapper' s.homepage = 'https://github.com/portto/flow-swift-sdk' diff --git a/FlowSDK.podspec b/FlowSDK.podspec index 2c0089f..b0c4b51 100644 --- a/FlowSDK.podspec +++ b/FlowSDK.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'FlowSDK' - s.version = '0.6.0' + s.version = '0.7.0' s.summary = 'Flow blockchain swift SDK' s.homepage = 'https://github.com/portto/flow-swift-sdk' @@ -21,7 +21,7 @@ Pod::Spec.new do |s| ss.source_files = "Sources/FlowSDK/**/*" ss.dependency "BigInt", "~> 5.2.0" ss.dependency "CryptoSwift", "~> 1.5.1" - ss.dependency "Cadence", "~> 0.6.0" + ss.dependency "Cadence", "~> 0.7.0" ss.dependency "gRPC-Swiftp", "~> 1.8.2" ss.dependency "secp256k1Swift", "~> 0.7.4" end diff --git a/README.md b/README.md index 22028c4..ce3a3e0 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ platform :ios, '13.0' use_frameworks! target 'ExampleApp' do - pod 'FlowSDK', '~> 0.6.0' + pod 'FlowSDK', '~> 0.7.0' end ``` @@ -26,7 +26,7 @@ end - File > Swift Packages > Add Package Dependency - Add `https://github.com/portto/flow-swift-sdk.git` -- Select "Up to Next Major" with "0.6.0" +- Select "Up to Next Major" with "0.7.0" # Usage diff --git a/Sources/Cadence/CType/ReferenceType.swift b/Sources/Cadence/CType/ReferenceType.swift index 72c697f..85a0531 100644 --- a/Sources/Cadence/CType/ReferenceType.swift +++ b/Sources/Cadence/CType/ReferenceType.swift @@ -8,11 +8,28 @@ import Foundation public struct ReferenceType: Equatable, Codable { - public let authorized: Bool + public let authorization: Authorization public let type: FType - public init(authorized: Bool, type: FType) { - self.authorized = authorized + public init(authorization: Authorization, type: FType) { + self.authorization = authorization self.type = type } } + +public extension ReferenceType { + struct Authorization: Codable, Equatable { + public let kind: AuthorizationKind + + public init(kind: AuthorizationKind) { + self.kind = kind + } + } + + enum AuthorizationKind: String, Codable { + case unauthorized = "Unauthorized" + case entitlementMapAuthorization = "EntitlementMapAuthorization" + case entitlementConjunctionSet = "EntitlementConjunctionSet" + case entitlementDisjunctionSet = "EntitlementDisjunctionSet" + } +} diff --git a/Sources/Cadence/FType.swift b/Sources/Cadence/FType.swift index cf4fc56..caa4444 100644 --- a/Sources/Cadence/FType.swift +++ b/Sources/Cadence/FType.swift @@ -256,11 +256,7 @@ public enum FType: Equatable { case let .function(functionType): return functionType.typeId case let .reference(referenceType): - var id = "&\(referenceType.type.id)" - if referenceType.authorized { - id = "auth" + id - } - return id + return referenceType.authorization.kind.rawValue + "&\(referenceType.type.id)" case let .restriction(restrictionType): return restrictionType.typeId case let .capability(borrowType): diff --git a/Tests/CadenceTests/StaticTypeTests.swift b/Tests/CadenceTests/StaticTypeTests.swift index a75e5ce..c4980a4 100644 --- a/Tests/CadenceTests/StaticTypeTests.swift +++ b/Tests/CadenceTests/StaticTypeTests.swift @@ -1376,7 +1376,10 @@ final class StaticTypeTests: XCTestCase { let jsonData = """ { "kind": "Reference", - "authorized": true, + "authorization": { + "kind": "Unauthorized", + "entitlements": null + }, "type": { "kind": "String" } @@ -1387,7 +1390,7 @@ final class StaticTypeTests: XCTestCase { let value = try decoder.decode(FType.self, from: jsonData) // Then - XCTAssertEqual(value, .reference(.init(authorized: true, type: .string))) + XCTAssertEqual(value, .reference(.init(authorization: .init(kind: .unauthorized), type: .string))) XCTAssertEqual(value.kind, .reference) } @@ -1450,7 +1453,10 @@ final class StaticTypeTests: XCTestCase { "kind": "Capability", "type": { "kind": "Reference", - "authorized": true, + "authorization": { + "kind": "EntitlementMapAuthorization", + "entitlements": null + }, "type": { "kind": "String" } @@ -1463,7 +1469,7 @@ final class StaticTypeTests: XCTestCase { // Then XCTAssertEqual(value, .capability( - borrowType: .reference(.init(authorized: true, type: .string)) + borrowType: .reference(.init(authorization: .init(kind: .entitlementMapAuthorization), type: .string)) )) XCTAssertEqual(value.kind, .capability) } diff --git a/examples/cocoapods/Podfile.lock b/examples/cocoapods/Podfile.lock index 067aa29..4fb518a 100644 --- a/examples/cocoapods/Podfile.lock +++ b/examples/cocoapods/Podfile.lock @@ -1,7 +1,7 @@ PODS: - _NIODataStructures (2.40.0) - BigInt (5.2.0) - - Cadence (0.6.0): + - Cadence (0.7.0): - BigInt (~> 5.2.0) - CryptoSwift (~> 1.5.1) - CGRPCZlibp (1.8.2) @@ -14,11 +14,11 @@ PODS: - CNIOLinux (2.40.0) - CNIOWindows (2.40.0) - CryptoSwift (1.5.1) - - FlowSDK (0.6.0): - - FlowSDK/FlowSDK (= 0.6.0) - - FlowSDK/FlowSDK (0.6.0): + - FlowSDK (0.7.0): + - FlowSDK/FlowSDK (= 0.7.0) + - FlowSDK/FlowSDK (0.7.0): - BigInt (~> 5.2.0) - - Cadence (~> 0.6.0) + - Cadence (~> 0.7.0) - CryptoSwift (~> 1.5.1) - gRPC-Swiftp (~> 1.8.2) - secp256k1Swift (~> 0.7.4) @@ -212,7 +212,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: _NIODataStructures: 3d45d8e70a1d17a15b1dc59d102c63dbc0525ffd BigInt: f668a80089607f521586bbe29513d708491ef2f7 - Cadence: 6fdb8bf299e512132d7e87d3cb0f569b92471eaf + Cadence: 9da7b2a3a168464a2781cff4cee55622e61c19fc CGRPCZlibp: 2f3e1e7a6d6cb481d4d1a26d3ec09aefacf09cbb CNIOAtomics: 8edf08644e5e6fa0f021c239be9e8beb1cd9ef18 CNIOBoringSSL: 2c9c96c2e95f15e83fb8d26b9738d939cc39ae33 @@ -222,7 +222,7 @@ SPEC CHECKSUMS: CNIOLinux: 62e3505f50de558c393dc2f273dde71dcce518da CNIOWindows: 3047f2d8165848a3936a0a755fee27c6b5ee479b CryptoSwift: c4f2debceb38bf44c80659afe009f71e23e4a082 - FlowSDK: 5710e38a29fbf5a1948020a41fa3ed174cf58a2c + FlowSDK: cb955510a2c9ab1fff56ae5595181b28e26b7970 gRPC-Swiftp: 1f5a05ce5b544bff3dce93223e72829daac26113 Logging: beeb016c9c80cf77042d62e83495816847ef108b secp256k1Swift: ea49d2b06724444a03cf7938a2d3fc7acc4c0f08