@@ -5,6 +5,7 @@ import { PublicKeyStatus } from '../interfaces'
5
5
import { AddressUtils } from '../utils/AddressUtils'
6
6
7
7
/**
8
+ * THIS METHOD WILL BE DEPREATED
8
9
* function addKey(string memory publicKey, address subject) public
9
10
* @param web3
10
11
* @param publicKey
@@ -22,7 +23,23 @@ export function addKey(web3, publicKey) {
22
23
}
23
24
24
25
/**
25
- * function revokePublicKey(string memory publicKey) public
26
+ * @param web3
27
+ * @param publicKeyHash
28
+ */
29
+ export function addPublicKey ( web3 , publicKeyHash ) {
30
+ const transaction = Object . assign ( { } , config . basicTransaction )
31
+ const delegatedData = web3 . eth . abi . encodeFunctionCall (
32
+ config . contractsAbi . AlastriaPublicKeyRegistry . addPublicKey ,
33
+ [ publicKeyHash ]
34
+ )
35
+ transaction . data = delegated ( web3 , delegatedData )
36
+ transaction . to = config . alastriaIdentityManager
37
+ transaction . gasLimit = 600000
38
+ return transaction
39
+ }
40
+
41
+ /**
42
+ * THIS METHOD WILL BE DEPREATED
26
43
* @param web3
27
44
* @param publicKey
28
45
*/
@@ -39,7 +56,23 @@ export function revokePublicKey(web3, publicKey) {
39
56
}
40
57
41
58
/**
42
- * function deletePublicKey(string memory publicKey) public
59
+ * @param web3
60
+ * @param publicKeyHash
61
+ */
62
+ export function revokePublicKeyHash ( web3 , publicKeyHash ) {
63
+ const transaction = Object . assign ( { } , config . basicTransaction )
64
+ const delegatedData = web3 . eth . abi . encodeFunctionCall (
65
+ config . contractsAbi . AlastriaPublicKeyRegistry . revokePublicKey ,
66
+ [ publicKeyHash ]
67
+ )
68
+ transaction . data = delegated ( web3 , delegatedData )
69
+ transaction . to = config . alastriaIdentityManager
70
+ transaction . gasLimit = 600000
71
+ return transaction
72
+ }
73
+
74
+ /**
75
+ * THIS METHOD WILL BE DEPREATED
43
76
* @param web3
44
77
* @param publicKey
45
78
*/
@@ -55,6 +88,22 @@ export function deletePublicKey(web3, publicKey) {
55
88
return transaction
56
89
}
57
90
91
+ /**
92
+ * @param web3
93
+ * @param publicKeyHash
94
+ */
95
+ export function deletePublicKeyHash ( web3 , publicKeyHash ) {
96
+ const transaction = Object . assign ( { } , config . basicTransaction )
97
+ const delegatedData = web3 . eth . abi . encodeFunctionCall (
98
+ config . contractsAbi . AlastriaPublicKeyRegistry . deletePublicKey ,
99
+ [ publicKeyHash ]
100
+ )
101
+ transaction . data = delegated ( web3 , delegatedData )
102
+ transaction . to = config . alastriaIdentityManager
103
+ transaction . gasLimit = 600000
104
+ return transaction
105
+ }
106
+
58
107
/**
59
108
* function getCurrentPublicKey(address subject) view public validAddress(subject) returns (string)
60
109
* @param web3
@@ -73,6 +122,7 @@ export function getCurrentPublicKey(web3, did) {
73
122
}
74
123
75
124
/**
125
+ * THIS METHOD WILL BE DEPREATED
76
126
* @param web3
77
127
* @param did
78
128
* @param publicKey
@@ -90,6 +140,24 @@ export function getPublicKeyStatus(web3, did, publicKey) {
90
140
}
91
141
92
142
/**
143
+ * @param web3
144
+ * @param did
145
+ * @param publicKeyHash
146
+ */
147
+ export function getPublicKeyStatusHash ( web3 , did , publicKeyHash ) {
148
+ const subjectAddr = AIdUtils . getProxyAddress ( did )
149
+ const transaction = Object . assign ( { } , config . basicTransaction )
150
+ transaction . data = web3 . eth . abi . encodeFunctionCall (
151
+ config . contractsAbi . AlastriaPublicKeyRegistry . getPublicKeyStatus ,
152
+ [ subjectAddr , publicKeyHash ]
153
+ )
154
+ transaction . to = config . alastriaPublicKeyRegistry
155
+ transaction . gasLimit = 600000
156
+ return transaction
157
+ }
158
+
159
+ /**
160
+ * THIS METHOD WILL BE DEPREATED
93
161
* @param web3
94
162
* @param did
95
163
* @param publicKey
@@ -119,6 +187,36 @@ export function getPublicKeyStatusDecodedAsJSON(
119
187
}
120
188
121
189
/**
190
+ * @param web3
191
+ * @param did
192
+ * @param publicKeyHash
193
+ */
194
+ export function getPublicKeyStatusDecodedAsJSONHash (
195
+ web3 ,
196
+ did ,
197
+ publicKeyHash
198
+ ) : Promise < PublicKeyStatus > {
199
+ const publicKeyStatusTx = getPublicKeyStatus ( web3 , did , publicKeyHash )
200
+
201
+ return new Promise ( ( resolve ) => {
202
+ web3 . eth . call ( publicKeyStatusTx ) . then ( ( data ) => {
203
+ const publicKeyStatusDecoded = web3 . eth . abi . decodeParameters (
204
+ [ 'bool' , 'uint8' , 'uint' , 'uint' ] ,
205
+ data
206
+ )
207
+ const publicKeyStatusDecodedAsJSON = {
208
+ exists : publicKeyStatusDecoded [ '0' ] ,
209
+ status : publicKeyStatusDecoded [ '1' ] ,
210
+ startDate : parseInt ( publicKeyStatusDecoded [ '2' ] ) ,
211
+ endDate : parseInt ( publicKeyStatusDecoded [ '3' ] )
212
+ }
213
+ resolve ( publicKeyStatusDecodedAsJSON )
214
+ } )
215
+ } )
216
+ }
217
+
218
+ /**
219
+ * THIS METHOD WILL BE DEPREATED
122
220
* @param web3
123
221
* @param did
124
222
* @param publicKey
@@ -149,6 +247,37 @@ export function isPublicKeyValidForDate(web3, did, publicKey, date) {
149
247
} )
150
248
}
151
249
250
+ /**
251
+ * @param web3
252
+ * @param did
253
+ * @param publicKeyHash
254
+ * @param date in milliseconds
255
+ */
256
+ export function isPublicKeyValidForDateHash ( web3 , did , publicKeyHash , date ) {
257
+ publicKeyHash = AddressUtils . getAddressWithHexPrefix ( publicKeyHash )
258
+ return new Promise ( ( resolve , reject ) => {
259
+ transactionFactory . publicKeyRegistry
260
+ . getPublicKeyStatusDecodedAsJSON ( web3 , did , publicKeyHash )
261
+ . then ( ( publicKeyStatusAsJSON ) => {
262
+ const existsPublicKey = publicKeyStatusAsJSON . exists
263
+
264
+ if ( existsPublicKey ) {
265
+ const isUserDateBetweenDates = _isUserDateBetweeenDates (
266
+ date ,
267
+ publicKeyStatusAsJSON . startDate ,
268
+ publicKeyStatusAsJSON . endDate
269
+ )
270
+ resolve ( isUserDateBetweenDates )
271
+ } else {
272
+ reject ( new Error ( 'Public key does not exist' ) )
273
+ }
274
+ } )
275
+ . catch ( ( ) => {
276
+ reject ( new Error ( 'Unresolved error' ) )
277
+ } )
278
+ } )
279
+ }
280
+
152
281
/**
153
282
* @param userDate in milliseconds
154
283
* @param publicKeyStartDate in milliseconds
0 commit comments