blockchainethereumblockchain-walleterc20erc721walletxdaidappdecentralizederc1155erc875iosswifttokens
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
901 B
36 lines
901 B
// Copyright SIX DAY LLC. All rights reserved.
|
|
|
|
import Foundation
|
|
|
|
struct ParserResult {
|
|
let protocolName: String
|
|
let address: String
|
|
let params: [String: String]
|
|
}
|
|
|
|
struct QRURLParser {
|
|
|
|
static func from(string: String) -> ParserResult? {
|
|
if string.count == 42 {
|
|
return ParserResult(
|
|
protocolName: "",
|
|
address: string,
|
|
params: [:]
|
|
)
|
|
}
|
|
|
|
guard string.count >= 51 else { return .none }
|
|
|
|
return ParserResult(
|
|
protocolName: string.substring(with: 0..<8),
|
|
address: string.substring(with: 9..<51),
|
|
params: [:]
|
|
)
|
|
}
|
|
}
|
|
|
|
extension ParserResult: Equatable {
|
|
static func == (lhs: ParserResult, rhs: ParserResult) -> Bool {
|
|
return lhs.protocolName == rhs.protocolName && lhs.address == rhs.address && lhs.params == rhs.params
|
|
}
|
|
}
|
|
|