File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Packages/Sequence-Unity/Sequence/SequenceSDK/EcosystemWallet/Guard Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 1+ using System . Collections . Generic ;
12using Newtonsoft . Json ;
23using Sequence . Utils . SecureStorage ;
3- using UnityEngine ;
44
55namespace Sequence . EcosystemWallet
66{
77 public class GuardStorage
88 {
9+ private static readonly Dictionary < Address , GuardConfig > Configs = new ( ) ;
10+
911 private readonly ISecureStorage _storage = SecureStorageFactory . CreateSecureStorage ( ) ;
1012
1113 public GuardConfig GetConfig ( Address address )
1214 {
15+ if ( Configs . TryGetValue ( address , out var memorizedConfig ) )
16+ return memorizedConfig ;
17+
1318 var json = _storage . RetrieveString ( BuildStorageKey ( address ) ) ;
14- Debug . Log ( $ "{ json } ") ;
15- return string . IsNullOrEmpty ( json ) ? null :
16- JsonConvert . DeserializeObject < GuardConfig > ( json ) ;
19+ var config = string . IsNullOrEmpty ( json ) ? null : JsonConvert . DeserializeObject < GuardConfig > ( json ) ;
20+ if ( config != null )
21+ Configs [ address ] = config ;
22+
23+ return config ;
1724 }
1825
1926 public void SaveConfig ( Address address , GuardConfig config )
2027 {
2128 var json = JsonConvert . SerializeObject ( config ) ;
2229 _storage . StoreString ( BuildStorageKey ( address ) , json ) ;
30+ Configs [ address ] = config ;
2331 }
2432
2533 private string BuildStorageKey ( Address address )
You can’t perform that action at this time.
0 commit comments