Merge pull request #6987 from AlphaWallet/refactoring-move-smart-layer-pass-specific-attestation-code-out-from-attestation-pod

[Refactoring] Move Smart Layer Pass-specific attestation code out from attestation pod
pull/6988/head
Hwee-Boon Yar 1 year ago committed by GitHub
commit af789478ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      AlphaWallet/Attestation/Attestation+Extensions.swift
  2. 4
      AlphaWallet/Attestation/SmartLayerPass.swift
  3. 12
      modules/AlphaWalletAttestation/AlphaWalletAttestation/Attestation.swift

@ -4,6 +4,11 @@ import Foundation
import AlphaWalletAttestation
extension Attestation {
enum AttestationType {
case smartLayerPass
case others
}
var name: String {
switch attestationType {
case .smartLayerPass:
@ -12,4 +17,12 @@ extension Attestation {
return R.string.localizable.attestationsEas()
}
}
var attestationType: AttestationType {
if let eventId = stringProperty(withName: SmartLayerPass.typeFieldName), eventId == "SMARTLAYER" {
return .smartLayerPass
} else {
return .others
}
}
}

@ -7,6 +7,8 @@ import AlphaWalletLogger
import Alamofire
class SmartLayerPass {
static let typeFieldName = "eventId"
private func authHeaderValue(forDomain domain: String) -> String? {
if domain == "www.smartlayer.network" || domain == "smartlayer.network" {
let value = Constants.Credentials.smartLayerPassAuthProd
@ -38,7 +40,7 @@ class SmartLayerPass {
}
func handleAddedAttestation(_ attestation: Attestation, attestationStore: AttestationsStore) {
let optionalEventId = attestation.stringProperty(withName: "eventId")
let optionalEventId = attestation.stringProperty(withName: Self.typeFieldName)
guard let eventId = optionalEventId, eventId == "SMARTLAYER" else {
infoLog("[SmartLayerPass] Not a Smart Layer pass attestation, as eventId: \(String(describing: optionalEventId)) so no-op")
return

@ -170,11 +170,6 @@ public struct Attestation: Codable, Hashable {
case easContractNotFound(server: RPCServer)
}
public enum AttestationType {
case smartLayerPass
case others
}
public let data: [TypeValuePair]
public let source: String
private let easAttestation: EasAttestation
@ -196,13 +191,6 @@ public struct Attestation: Codable, Hashable {
public var server: RPCServer { easAttestation.server }
//Good for debugging, in case converting to `RPCServer` is done wrongly
public var chainId: Int { easAttestation.chainId }
public var attestationType: AttestationType {
if let eventId = stringProperty(withName: "eventId"), eventId == "SMARTLAYER" {
return .smartLayerPass
} else {
return .others
}
}
public var scriptUri: URL? {
let url: URL? = data.compactMap { each in
if each.type.name == "scriptURI" {

Loading…
Cancel
Save