-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #979 from WalletConnect/develop
1.6.14
- Loading branch information
Showing
16 changed files
with
321 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
Sources/WalletConnectModal/Modal/RecentWalletStorage.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import Foundation | ||
|
||
final class RecentWalletsStorage { | ||
private let defaults: UserDefaults | ||
|
||
init(defaults: UserDefaults = .standard) { | ||
self.defaults = defaults | ||
} | ||
|
||
var recentWallets: [Listing] { | ||
get { | ||
guard | ||
let data = defaults.data(forKey: "recentWallets"), | ||
let wallets = try? JSONDecoder().decode([Listing].self, from: data) | ||
else { | ||
return [] | ||
} | ||
|
||
return wallets | ||
} | ||
set { | ||
guard | ||
let walletsData = try? JSONEncoder().encode(newValue) | ||
else { | ||
return | ||
} | ||
|
||
defaults.set(walletsData, forKey: "recentWallets") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.