Skip to content

Commit

Permalink
Fix metamask like address format
Browse files Browse the repository at this point in the history
Fixes: #22
  • Loading branch information
gemcoder21 committed Jun 4, 2024
1 parent 3d5f97a commit fde683d
Show file tree
Hide file tree
Showing 24 changed files with 60 additions and 130 deletions.
8 changes: 0 additions & 8 deletions Gem.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,6 @@
D89D690B2A9FBFD400EA74EE /* TransactionSceneInput.swift in Sources */ = {isa = PBXBuildFile; fileRef = D89D690A2A9FBFD400EA74EE /* TransactionSceneInput.swift */; };
D8A1F8782B17F21E00B15F54 /* ScreenshotsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8A1F8772B17F21E00B15F54 /* ScreenshotsLaunchTests.swift */; };
D8A1F87F2B17F23500B15F54 /* SnapshotHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8A1F87E2B17F23500B15F54 /* SnapshotHelper.swift */; };
D8A1F8822B17F88100B15F54 /* PaymentURLDecoder.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8A1F8812B17F88100B15F54 /* PaymentURLDecoder.swift */; };
D8A1F8862B17F8FB00B15F54 /* PaymentURLDecoderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8A1F8852B17F8FB00B15F54 /* PaymentURLDecoderTests.swift */; };
D8AF81252C0E615B002E5FCF /* ButtonListItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AF81242C0E615B002E5FCF /* ButtonListItem.swift */; };
D8AF91F22B51BBCE002193E3 /* StakeDetailScene.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AF91F12B51BBCE002193E3 /* StakeDetailScene.swift */; };
D8AF91F42B51BBEE002193E3 /* StakeDetailViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8AF91F32B51BBEE002193E3 /* StakeDetailViewModel.swift */; };
Expand Down Expand Up @@ -454,8 +452,6 @@
D8A1F8732B17F21E00B15F54 /* Screenshots.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Screenshots.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
D8A1F8772B17F21E00B15F54 /* ScreenshotsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScreenshotsLaunchTests.swift; sourceTree = "<group>"; };
D8A1F87E2B17F23500B15F54 /* SnapshotHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SnapshotHelper.swift; sourceTree = "<group>"; };
D8A1F8812B17F88100B15F54 /* PaymentURLDecoder.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentURLDecoder.swift; sourceTree = "<group>"; };
D8A1F8852B17F8FB00B15F54 /* PaymentURLDecoderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PaymentURLDecoderTests.swift; sourceTree = "<group>"; };
D8AF81242C0E615B002E5FCF /* ButtonListItem.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ButtonListItem.swift; sourceTree = "<group>"; };
D8AF91F12B51BBCE002193E3 /* StakeDetailScene.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StakeDetailScene.swift; sourceTree = "<group>"; };
D8AF91F32B51BBEE002193E3 /* StakeDetailViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StakeDetailViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1406,7 +1402,6 @@
D8A1F8802B17F86600B15F54 /* Decoder */ = {
isa = PBXGroup;
children = (
D8A1F8812B17F88100B15F54 /* PaymentURLDecoder.swift */,
);
path = Decoder;
sourceTree = "<group>";
Expand All @@ -1422,7 +1417,6 @@
D8A1F8842B17F8EE00B15F54 /* Decoder */ = {
isa = PBXGroup;
children = (
D8A1F8852B17F8FB00B15F54 /* PaymentURLDecoderTests.swift */,
);
path = Decoder;
sourceTree = "<group>";
Expand Down Expand Up @@ -1713,7 +1707,6 @@
C3FB448C2A7AE38A0056F124 /* NameResolveView.swift in Sources */,
C34C7CF529FC9B1C009EEC21 /* SettingsViewModel.swift in Sources */,
D89D690B2A9FBFD400EA74EE /* TransactionSceneInput.swift in Sources */,
D8A1F8822B17F88100B15F54 /* PaymentURLDecoder.swift in Sources */,
D8BAC9612BDC82F7001608BC /* WordSuggestor.swift in Sources */,
D8BAC9562BD0C0C5001608BC /* NetworkSelectorNavigationStack.swift in Sources */,
C3CF3BCD29B80B1B00E96586 /* SelectAssetViewModel.swift in Sources */,
Expand Down Expand Up @@ -1886,7 +1879,6 @@
C30952C6299C39D80004C0F9 /* walletTests.swift in Sources */,
C3A7CB9929D35EC200431341 /* WalletSceneViewModelTests.swift in Sources */,
C3A7CB9729D3569C00431341 /* PriceViewModelTests.swift in Sources */,
D8A1F8862B17F8FB00B15F54 /* PaymentURLDecoderTests.swift in Sources */,
C3549B3529C4396A00B4BE01 /* AssetViewModelTests.swift in Sources */,
C3549B3129C42E8F00B4BE01 /* AssetListViewModelTests.swift in Sources */,
);
Expand Down
51 changes: 0 additions & 51 deletions Gem/Core/Decoder/PaymentURLDecoder.swift

This file was deleted.

3 changes: 2 additions & 1 deletion Gem/Transfer/ViewsModels/RecipientViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Foundation
import Primitives
import Keystore
import Blockchain
import GemstoneSwift

enum RecipientAddressType {
case wallets
Expand Down Expand Up @@ -88,7 +89,7 @@ struct RecipientViewModel {

//TODO: Add unit tests
func getTransferDataFromScan(string: String) throws -> ScanRecipientResult {
let payment = try PaymentURLDecoder().decode(string)
let payment = try PaymentURLDecoder.decode(string)

if payment.amount == .none {
return .address(address: payment.address, memo: payment.memo)
Expand Down
54 changes: 0 additions & 54 deletions GemTests/Core/Decoder/PaymentURLDecoderTests.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Packages/Blockchain/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "Blockchain",
platforms: [.iOS(.v16), .macOS(.v12)],
platforms: [.iOS(.v17), .macOS(.v12)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
Expand Down
2 changes: 1 addition & 1 deletion Packages/Components/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "Components",
platforms: [.iOS(.v16), .macOS(.v12)],
platforms: [.iOS(.v17), .macOS(.v12)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
Expand Down
2 changes: 1 addition & 1 deletion Packages/GemAPI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PackageDescription

let package = Package(
name: "GemAPI",
platforms: [.iOS(.v16), .macOS(.v12)],
platforms: [.iOS(.v17), .macOS(.v12)],
products: [
.library(
name: "GemAPI",
Expand Down
2 changes: 1 addition & 1 deletion Packages/GemstoneSwift/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PackageDescription

let package = Package(
name: "GemstoneSwift",
platforms: [.iOS(.v16), .macOS(.v12)],
platforms: [.iOS(.v17), .macOS(.v12)],
products: [
.library(
name: "GemstoneSwift",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c). Gem Wallet. All rights reserved.

import Foundation
import Gemstone

public struct PaymentURLDecoder {
public static func decode(_ string: String) throws -> PaymentWrapper {
return try Gemstone.paymentDecodeUrl(string: string)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Gemstone
import XCTest

final class GemstoneSwiftTests: XCTestCase {

func testExplorerService() throws {
XCTAssertNotNil(Gemstone.libVersion())
XCTAssertEqual(ExplorerService.hostName(url: URL(string: "https://www.mintscan.io/")!), "MintScan")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c). Gem Wallet. All rights reserved.

import XCTest
import Gemstone
@testable import GemstoneSwift

final class PaymentURLDecoderTests: XCTestCase {

func testAddress() {
XCTAssertEqual(
try! PaymentURLDecoder.decode("0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326"),
PaymentWrapper(address: "0x1f9090aaE28b8a3dCeaDf281B0F12828e676c326", amount: .none, memo: .none, chain: .none)
)
}

func testSolana() {
XCTAssertEqual(
try! PaymentURLDecoder.decode("HA4hQMs22nCuRN7iLDBsBkboz2SnLM1WkNtzLo6xEDY5"),
PaymentWrapper(address: "HA4hQMs22nCuRN7iLDBsBkboz2SnLM1WkNtzLo6xEDY5", amount: .none, memo: .none, chain: .none)
)
XCTAssertEqual(
try! PaymentURLDecoder.decode("solana:HA4hQMs22nCuRN7iLDBsBkboz2SnLM1WkNtzLo6xEDY5?amount=0.266232"),
PaymentWrapper(address: "HA4hQMs22nCuRN7iLDBsBkboz2SnLM1WkNtzLo6xEDY5", amount: "0.266232", memo: .none, chain: .none)
)
}
}
2 changes: 1 addition & 1 deletion Packages/Keystore/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "Keystore",
platforms: [.iOS(.v16), .macOS(.v12)],
platforms: [.iOS(.v17), .macOS(.v12)],
products: [
.library(
name: "Keystore",
Expand Down
2 changes: 1 addition & 1 deletion Packages/Primitives/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "Primitives",
platforms: [.iOS(.v16), .macOS(.v12)],
platforms: [.iOS(.v17), .macOS(.v12)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
Expand Down
5 changes: 5 additions & 0 deletions Packages/Primitives/Sources/PaymentDecoder.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
Generated by typeshare 1.7.0
*/

import Foundation
2 changes: 1 addition & 1 deletion Packages/QRScanner/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "QRScanner",
platforms: [.iOS(.v16), .macOS(.v12)],
platforms: [.iOS(.v17), .macOS(.v12)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
Expand Down
2 changes: 1 addition & 1 deletion Packages/Settings/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PackageDescription

let package = Package(
name: "Settings",
platforms: [.iOS(.v16), .macOS(.v12)],
platforms: [.iOS(.v17), .macOS(.v12)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
Expand Down
2 changes: 1 addition & 1 deletion Packages/Signer/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "Signer",
platforms: [.iOS(.v16), .macOS(.v12)],
platforms: [.iOS(.v17), .macOS(.v12)],
products: [
.library(
name: "Signer",
Expand Down
2 changes: 1 addition & 1 deletion Packages/Store/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "Store",
platforms: [.iOS(.v16), .macOS(.v12)],
platforms: [.iOS(.v17), .macOS(.v12)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
Expand Down
2 changes: 1 addition & 1 deletion Packages/Style/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "Style",
platforms: [.iOS(.v16), .macOS(.v12)],
platforms: [.iOS(.v17), .macOS(.v12)],
products: [
.library(
name: "Style",
Expand Down
2 changes: 1 addition & 1 deletion Packages/SwiftHTTPClient/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "SwiftHTTPClient",
platforms: [.iOS(.v16), .macOS(.v12)],
platforms: [.iOS(.v17), .macOS(.v12)],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
Expand Down
2 changes: 1 addition & 1 deletion Packages/WalletConnector/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import PackageDescription

let package = Package(
name: "WalletConnector",
platforms: [.iOS(.v16), .macOS(.v12)],
platforms: [.iOS(.v17), .macOS(.v12)],
products: [
.library(
name: "WalletConnector",
Expand Down
2 changes: 1 addition & 1 deletion Packages/WalletCore/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PackageDescription

let package = Package(
name: "WalletCore",
platforms: [.iOS(.v16)],
platforms: [.iOS(.v17)],
products: [
.library(name: "WalletCore", targets: ["WalletCore"]),
.library(name: "SwiftProtobuf", targets: ["SwiftProtobuf"])
Expand Down
2 changes: 1 addition & 1 deletion Packages/WalletCorePrimitives/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import PackageDescription

let package = Package(
name: "WalletCorePrimitives",
platforms: [.iOS(.v16), .macOS(.v12)],
platforms: [.iOS(.v17), .macOS(.v12)],
products: [
.library(
name: "WalletCorePrimitives",
Expand Down

0 comments on commit fde683d

Please sign in to comment.