|
1 | 1 | import { config } from '../config'
|
2 |
| -import { transactionFactory } from './transactionFactory' |
3 | 2 | import { AIdUtils } from '../utils/AIdUtils'
|
4 |
| -import { PublicKeyStatus } from '../interfaces' |
5 | 3 | import { AddressUtils } from '../utils/AddressUtils'
|
6 | 4 |
|
7 | 5 | /**
|
@@ -156,80 +154,6 @@ export function getPublicKeyStatusHash(web3, did, publicKeyHash) {
|
156 | 154 | return transaction
|
157 | 155 | }
|
158 | 156 |
|
159 |
| -/** |
160 |
| - * @param web3 |
161 |
| - * @param did |
162 |
| - * @param publicKeyHash |
163 |
| - */ |
164 |
| -export function getPublicKeyStatusDecodedAsJSON( |
165 |
| - web3, |
166 |
| - did, |
167 |
| - publicKeyHash |
168 |
| -): Promise<PublicKeyStatus> { |
169 |
| - const publicKeyStatusTx = getPublicKeyStatus(web3, did, publicKeyHash) |
170 |
| - |
171 |
| - return new Promise((resolve) => { |
172 |
| - web3.eth.call(publicKeyStatusTx).then((data) => { |
173 |
| - const publicKeyStatusDecoded = web3.eth.abi.decodeParameters( |
174 |
| - ['bool', 'uint8', 'uint', 'uint'], |
175 |
| - data |
176 |
| - ) |
177 |
| - const publicKeyStatusDecodedAsJSON = { |
178 |
| - exists: publicKeyStatusDecoded['0'], |
179 |
| - status: publicKeyStatusDecoded['1'], |
180 |
| - startDate: parseInt(publicKeyStatusDecoded['2']), |
181 |
| - endDate: parseInt(publicKeyStatusDecoded['3']) |
182 |
| - } |
183 |
| - resolve(publicKeyStatusDecodedAsJSON) |
184 |
| - }) |
185 |
| - }) |
186 |
| -} |
187 |
| - |
188 |
| -/** |
189 |
| - * @param web3 |
190 |
| - * @param did |
191 |
| - * @param publicKeyHash |
192 |
| - * @param date in milliseconds |
193 |
| - */ |
194 |
| -export function isPublicKeyValidForDate(web3, did, publicKeyHash, date) { |
195 |
| - publicKeyHash = AddressUtils.getAddressWithHexPrefix(publicKeyHash) |
196 |
| - return new Promise((resolve, reject) => { |
197 |
| - transactionFactory.publicKeyRegistry |
198 |
| - .getPublicKeyStatusDecodedAsJSON(web3, did, publicKeyHash) |
199 |
| - .then((publicKeyStatusAsJSON) => { |
200 |
| - const existsPublicKey = publicKeyStatusAsJSON.exists |
201 |
| - |
202 |
| - if (existsPublicKey) { |
203 |
| - const isUserDateBetweenDates = _isUserDateBetweeenDates( |
204 |
| - date, |
205 |
| - publicKeyStatusAsJSON.startDate, |
206 |
| - publicKeyStatusAsJSON.endDate |
207 |
| - ) |
208 |
| - resolve(isUserDateBetweenDates) |
209 |
| - } else { |
210 |
| - reject(new Error('Public key does not exist')) |
211 |
| - } |
212 |
| - }) |
213 |
| - .catch(() => { |
214 |
| - reject(new Error('Unresolved error')) |
215 |
| - }) |
216 |
| - }) |
217 |
| -} |
218 |
| - |
219 |
| -/** |
220 |
| - * @param userDate in milliseconds |
221 |
| - * @param publicKeyStartDate in milliseconds |
222 |
| - * @param publicKeyEndDate in milliseconds. If equals to 0, there is no enddate |
223 |
| - */ |
224 |
| -function _isUserDateBetweeenDates( |
225 |
| - userDate, |
226 |
| - publicKeyStartDate, |
227 |
| - publicKeyEndDate |
228 |
| -) { |
229 |
| - if (publicKeyStartDate && publicKeyEndDate === 0) return true |
230 |
| - else return userDate >= publicKeyStartDate && userDate <= publicKeyEndDate |
231 |
| -} |
232 |
| - |
233 | 157 | function delegated(web3, delegatedData) {
|
234 | 158 | return web3.eth.abi.encodeFunctionCall(
|
235 | 159 | config.contractsAbi.AlastriaIdentityManager.delegateCall,
|
|
0 commit comments