Skip to content

Commit

Permalink
Remove unnecessary functions
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniRumpi committed May 21, 2024
1 parent 8e9fc2e commit 5a54655
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 68 deletions.
66 changes: 2 additions & 64 deletions src/txFactory/publicKeyRegistryTransactionFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,42 +156,12 @@ export function getPublicKeyStatusHash(web3, did, publicKeyHash) {
return transaction
}

/**
* THIS METHOD WILL BE DEPREATED
* @param web3
* @param did
* @param publicKey
*/
export function getPublicKeyStatusDecodedAsJSON(
web3,
did,
publicKey
): Promise<PublicKeyStatus> {
const publicKeyStatusTx = getPublicKeyStatus(web3, did, publicKey)

return new Promise((resolve) => {
web3.eth.call(publicKeyStatusTx).then((data) => {
const publicKeyStatusDecoded = web3.eth.abi.decodeParameters(
['bool', 'uint8', 'uint', 'uint'],
data
)
const publicKeyStatusDecodedAsJSON = {
exists: publicKeyStatusDecoded['0'],
status: publicKeyStatusDecoded['1'],
startDate: parseInt(publicKeyStatusDecoded['2']),
endDate: parseInt(publicKeyStatusDecoded['3'])
}
resolve(publicKeyStatusDecodedAsJSON)
})
})
}

/**
* @param web3
* @param did
* @param publicKeyHash
*/
export function getPublicKeyStatusDecodedAsJSONHash(
export function getPublicKeyStatusDecodedAsJSON(
web3,
did,
publicKeyHash
Expand All @@ -215,45 +185,13 @@ export function getPublicKeyStatusDecodedAsJSONHash(
})
}

/**
* THIS METHOD WILL BE DEPREATED
* @param web3
* @param did
* @param publicKey
* @param date in milliseconds
*/
export function isPublicKeyValidForDate(web3, did, publicKey, date) {
publicKey = AddressUtils.getAddressWithHexPrefix(publicKey)
return new Promise((resolve, reject) => {
transactionFactory.publicKeyRegistry
.getPublicKeyStatusDecodedAsJSON(web3, did, publicKey)
.then((publicKeyStatusAsJSON) => {
const existsPublicKey = publicKeyStatusAsJSON.exists

if (existsPublicKey) {
const isUserDateBetweenDates = _isUserDateBetweeenDates(
date,
publicKeyStatusAsJSON.startDate,
publicKeyStatusAsJSON.endDate
)
resolve(isUserDateBetweenDates)
} else {
reject(new Error('Public key does not exist'))
}
})
.catch(() => {
reject(new Error('Unresolved error'))
})
})
}

/**
* @param web3
* @param did
* @param publicKeyHash
* @param date in milliseconds
*/
export function isPublicKeyValidForDateHash(web3, did, publicKeyHash, date) {
export function isPublicKeyValidForDate(web3, did, publicKeyHash, date) {
publicKeyHash = AddressUtils.getAddressWithHexPrefix(publicKeyHash)
return new Promise((resolve, reject) => {
transactionFactory.publicKeyRegistry
Expand Down
4 changes: 0 additions & 4 deletions src/txFactory/transactionFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ import {
getPublicKeyStatus,
getPublicKeyStatusHash,
getPublicKeyStatusDecodedAsJSON,
getPublicKeyStatusDecodedAsJSONHash,
isPublicKeyValidForDate,
isPublicKeyValidForDateHash,
} from './publicKeyRegistryTransactionFactory'

export const transactionFactory = {
Expand Down Expand Up @@ -112,8 +110,6 @@ export const transactionFactory = {
getPublicKeyStatus: getPublicKeyStatus,
getPublicKeyStatusHash: getPublicKeyStatusHash,
getPublicKeyStatusDecodedAsJSON: getPublicKeyStatusDecodedAsJSON,
getPublicKeyStatusDecodedAsJSONHash: getPublicKeyStatusDecodedAsJSONHash,
isPublicKeyValidForDate: isPublicKeyValidForDate,
isPublicKeyValidForDateHash: isPublicKeyValidForDateHash
}
}

0 comments on commit 5a54655

Please sign in to comment.