Skip to content

Commit bc2160d

Browse files
committed
support multiple guard signer addresses
1 parent 9fdf575 commit bc2160d

File tree

4 files changed

+30
-5
lines changed

4 files changed

+30
-5
lines changed

Packages/Sequence-Unity/Sequence/SequenceSDK/EcosystemWallet/Authentication/Requests/Connect.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public class GuardConfig
3636
public class ModuleAddresses
3737
{
3838
public bool isMap;
39-
public string[][] data;
39+
public Address[][] data;
4040
}
4141

4242
[Preserve]

Packages/Sequence-Unity/Sequence/SequenceSDK/EcosystemWallet/Guard/GuardSigner.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
24
using System.Numerics;
35
using System.Threading.Tasks;
46
using Newtonsoft.Json;
@@ -10,11 +12,12 @@ namespace Sequence.EcosystemWallet
1012
{
1113
public class GuardSigner
1214
{
13-
private readonly Address _guardSigner = ExtensionsFactory.Current.Guard;
15+
private readonly Address _guardSigner;
1416
private readonly GuardService _service;
1517

1618
public GuardSigner(GuardConfig config)
1719
{
20+
_guardSigner = GetGuardSignerAddress(config);
1821
_service = new GuardService(config.url);
1922
}
2023

@@ -116,5 +119,17 @@ private GuardSignatureArgs ToGuardSignature(EnvelopeSignature signature)
116119

117120
throw new System.Exception("Unknown signature type");
118121
}
122+
123+
private Address GetGuardSignerAddress(GuardConfig config)
124+
{
125+
var setOther = new HashSet<Address>(ExtensionsFactory.Current.GuardSigners);
126+
var overlapped = config.moduleAddresses.data
127+
.SelectMany(row => row)
128+
.Where(value => setOther.Contains(value))
129+
.Distinct()
130+
.ToList().First();
131+
132+
return overlapped;
133+
}
119134
}
120135
}

Packages/Sequence-Unity/Sequence/SequenceSDK/EcosystemWallet/Guard/GuardStorage.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Newtonsoft.Json;
22
using Sequence.Utils.SecureStorage;
3+
using UnityEngine;
34

45
namespace Sequence.EcosystemWallet
56
{
@@ -10,6 +11,7 @@ public class GuardStorage
1011
public GuardConfig GetConfig(Address address)
1112
{
1213
var json = _storage.RetrieveString(BuildStorageKey(address));
14+
Debug.Log($"{json}");
1315
return string.IsNullOrEmpty(json) ? null :
1416
JsonConvert.DeserializeObject<GuardConfig>(json);
1517
}

Packages/Sequence-Unity/Sequence/SequenceSDK/EcosystemWallet/Wallet/Extensions.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public struct Extensions
77
public Address Stage2;
88
public string CreationCode;
99
public Address Sessions;
10-
public Address Guard;
10+
public Address[] GuardSigners;
1111
}
1212

1313
public static class ExtensionsFactory
@@ -19,7 +19,11 @@ public static class ExtensionsFactory
1919
Stage2 = new Address("0x7438718F9E4b9B834e305A620EEeCf2B9E6eBE79"),
2020
CreationCode = "0x6041600e3d396021805130553df33d3d36153402601f57363d3d373d363d30545af43d82803e903d91601f57fd5bf3",
2121
Sessions = new Address("0x0000000000CC58810c33F3a0D78aA1Ed80FaDcD8"),
22-
Guard = new Address("0x18002Fc09deF9A47437cc64e270843dE094f5984")
22+
GuardSigners = new []
23+
{
24+
new Address("0x18002Fc09deF9A47437cc64e270843dE094f5984"),
25+
new Address("0xF6Bc87F5F2edAdb66737E32D37b46423901dfEF1")
26+
}
2327
};
2428

2529
public static Extensions Rc4 = new Extensions
@@ -29,7 +33,11 @@ public static class ExtensionsFactory
2933
Stage2 = new Address("0x10bE1Abf3cD0918bb1079ECc6b8220c177F34088"),
3034
CreationCode = "0x6041600e3d396021805130553df33d3d36153402601f57363d3d373d363d30545af43d82803e903d91601f57fd5bf3",
3135
Sessions = new Address("0x00000000000030Bcc832F7d657f50D6Be35C92b3"),
32-
Guard = new Address("0x18002Fc09deF9A47437cc64e270843dE094f5984")
36+
GuardSigners = new []
37+
{
38+
new Address("0x18002Fc09deF9A47437cc64e270843dE094f5984"),
39+
new Address("0xF6Bc87F5F2edAdb66737E32D37b46423901dfEF1")
40+
}
3341
};
3442

3543
public static Extensions Current => Rc4;

0 commit comments

Comments
 (0)