Skip to content

Commit

Permalink
Merge branch 'main' into remove-election-difficulty
Browse files Browse the repository at this point in the history
  • Loading branch information
milsawicki committed Jul 14, 2023
2 parents 21736fd + 861bb6c commit 514147e
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 20 deletions.
20 changes: 10 additions & 10 deletions ConcordiumWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -8493,7 +8493,7 @@
CODE_SIGN_ENTITLEMENTS = ConcordiumWallet/Resources/Entitlements/Mock.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 43;
CURRENT_PROJECT_VERSION = 47;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
GCC_PREPROCESSOR_DEFINITIONS = (
Expand Down Expand Up @@ -8530,7 +8530,7 @@
CODE_SIGN_ENTITLEMENTS = ConcordiumWallet/Resources/Entitlements/Mock.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 43;
CURRENT_PROJECT_VERSION = 47;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
INFOPLIST_FILE = "ConcordiumWallet/Resources/ConcordiumWallet-mock-Info.plist";
Expand Down Expand Up @@ -8564,7 +8564,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 46;
CURRENT_PROJECT_VERSION = 47;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = K762RM4LQ3;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -8602,7 +8602,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 46;
CURRENT_PROJECT_VERSION = 47;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = K762RM4LQ3;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -8639,7 +8639,7 @@
CODE_SIGN_ENTITLEMENTS = ConcordiumWallet/Resources/Entitlements/ProdMainNet.entitlements;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 46;
CURRENT_PROJECT_VERSION = 47;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = K762RM4LQ3;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -8675,7 +8675,7 @@
CODE_SIGN_ENTITLEMENTS = ConcordiumWallet/Resources/Entitlements/ProdMainNet.entitlements;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 46;
CURRENT_PROJECT_VERSION = 47;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = K762RM4LQ3;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -8830,7 +8830,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 46;
CURRENT_PROJECT_VERSION = 47;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = K762RM4LQ3;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -8868,7 +8868,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 46;
CURRENT_PROJECT_VERSION = 47;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = K762RM4LQ3;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -9014,8 +9014,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/WalletConnect/WalletConnectSwiftV2.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 6.0.0;
kind = exactVersion;
version = 1.6.11;
};
};
8927A66D286AC6820007CAF1 /* XCRemoteSwiftPackageReference "realm-swift" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/WalletConnect/WalletConnectSwiftV2.git",
"state" : {
"revision" : "afdc8cdbaf99ad741a7716f8475339c80a92441d",
"version" : "6.6.6"
"revision" : "84b09a13b48d08f1092a7494e2ad70cbb92545c2",
"version" : "1.6.11"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

struct ContractUpdateParams: Decodable {
let schema: Schema
var schema: Schema
let type: TransferType
let sender: String
let payload: ContractUpdatePayload
Expand Down Expand Up @@ -33,7 +33,10 @@ struct ContractUpdateParams: Decodable {
if let s = try? container.decode(Schema.self, forKey: .schema) {
schema = s
} else {
let schemaValueBase64 = try container.decode(String.self, forKey: .schema)
guard let schemaValueBase64 = try container.decodeIfPresent(String.self, forKey: .schema) else {
schema = .empty
return
}
if let data = Data(base64Encoded: schemaValueBase64) {
schema = .moduleSchema(value: data, version: nil)
} else {
Expand Down
19 changes: 15 additions & 4 deletions ConcordiumWallet/Model/Schema/Schema.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Foundation
enum Schema: Codable {
case moduleSchema(value: Data, version: SchemaVersion?)
case typeSchema(value: Data)

case empty
enum CodingKeys: String, CodingKey {
case type, value, version
}
Expand All @@ -18,6 +18,7 @@ enum Schema: Codable {
case let .typeSchema(value: value):
try container.encode("parameter", forKey: .type)
try container.encode(value, forKey: .value)
case .empty: return
}
}

Expand Down Expand Up @@ -45,12 +46,12 @@ enum Schema: Codable {

static func decodeValue(_ container: KeyedDecodingContainer<Schema.CodingKeys>) throws -> Data {
// First attempt to decode schema as base64-encoded string.
if let valueBase64 = try? container.decode(String.self, forKey: .value) {
if let data = Data(base64Encoded: valueBase64) {
if let rawValueBase64 = try? container.decode(String.self, forKey: .value) {
if let data = Data(base64Encoded: fixedBase64Format(for: rawValueBase64)) {
return data
}
// Invalid Base64 encoding.
throw WalletConnectError.schemaError(.invalidBase64(valueBase64))
throw WalletConnectError.schemaError(.invalidBase64(rawValueBase64))
}
// If it fails, attempt to decode as JavaScript's Buffer.
if let buffer = try? container.decode(SchemaValueBufferBroken.self, forKey: .value) {
Expand All @@ -67,6 +68,16 @@ enum Schema: Codable {
default: return nil
}
}

/// Returns the fixed base64 format of the string.
/// This method is used to ensure that a string representing base64-encoded data has a proper format. In some cases,
/// when working with certain schemas or data sources, the base64 string returned may not adhere to the standard format.
/// This method addresses that issue by adding padding characters ('=') to the end of the string if its length is not a multiple of 4, thus making it a valid base64 format.
private static func fixedBase64Format(for string: String) -> String {
let offset = string.count % 4
guard offset != 0 else { return string }
return string.padding(toLength: string.count + 4 - offset, withPad: "=", startingAt: 0)
}
}

enum SchemaType: String, Decodable {
Expand Down
2 changes: 1 addition & 1 deletion ConcordiumWallet/Views/ScanQR/ScanQRViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class ScanQRViewController: BaseViewController, ShowToast {
image.tintColor = .white
return image
}()

init(presenter: ScanQRPresenter) {
captureSession = AVCaptureSession()
previewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private extension WalletConnectCoordinator {
return
}
if let chains = ccdNamespace.chains, chains != supportedChains {
self.reject(proposal: proposal, reason: .userRejectedChains, msg: "Expected chain \"\(supportedChains)\" bot got \(chains)")
self.reject(proposal: proposal, reason: .userRejectedChains, msg: "Expected chain \"\(supportedChains)\" but got \(chains)")
return
}
if !ccdNamespace.events.isSubset(of: supportedEvents) {
Expand Down

0 comments on commit 514147e

Please sign in to comment.