Skip to content

Commit

Permalink
Remove unused function and commented functions
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniRumpi committed May 22, 2024
1 parent c54d8b6 commit 29c564f
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 115 deletions.
18 changes: 0 additions & 18 deletions src/txFactory/credentialRegistryTransactionFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,24 +78,6 @@ export function getSubjectCredentialStatus(
return transaction
}

/**
* function getSubjectCredentialList(web3, subject)
* Dev: get invoke getSubjectCredentialList transaction object
* @param web3 ethereum connection
* @param didSubject subject to recover credential list
*/
// export function getSubjectCredentialList(web3, didSubject) {
// const subjectAddr = AIdUtils.getProxyAddress(didSubject)
// const transaction = Object.assign({}, config.basicTransaction)
// transaction.data = web3.eth.abi.encodeFunctionCall(
// config.contractsAbi.AlastriaCredentialRegistry.getSubjectCredentialList,
// [subjectAddr]
// )
// transaction.to = config.alastriaCredentialRegistry
// transaction.gasLimit = 600000
// return transaction
// }

/**
* function updateCredentialStatus(web3, issuerCredentialHash, status)
* @param web3
Expand Down
17 changes: 0 additions & 17 deletions src/txFactory/presentationRegistryTransactionFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,6 @@ export function getSubjectPresentationStatus(
return transaction
}

/**
* function getSubjectPresentationList(address subject) public view returns(uint, bytes32[])
* @param web3
* @param didSubject
*/
/** export function getSubjectPresentationList(web3, didSubject) {
const subjectAddr = AIdUtils.getProxyAddress(didSubject)
const transaction = Object.assign({}, config.basicTransaction)
transaction.data = web3.eth.abi.encodeFunctionCall(
config.contractsAbi.AlastriaPresentationRegistry.getSubjectPresentationList,
[subjectAddr]
)
transaction.to = config.alastriaPresentationRegistry
transaction.gasLimit = 600000
return transaction
} */

/**
* Receiver functions
* function updateReceiverPresentation(bytes32 receiverPresentationHash, Status status) public validStatus(status)
Expand Down
76 changes: 0 additions & 76 deletions src/txFactory/publicKeyRegistryTransactionFactory.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { config } from '../config'
import { transactionFactory } from './transactionFactory'
import { AIdUtils } from '../utils/AIdUtils'
import { PublicKeyStatus } from '../interfaces'
import { AddressUtils } from '../utils/AddressUtils'

/**
Expand Down Expand Up @@ -156,80 +154,6 @@ export function getPublicKeyStatusHash(web3, did, publicKeyHash) {
return transaction
}

/**
* @param web3
* @param did
* @param publicKeyHash
*/
export function getPublicKeyStatusDecodedAsJSON(
web3,
did,
publicKeyHash
): Promise<PublicKeyStatus> {
const publicKeyStatusTx = getPublicKeyStatus(web3, did, publicKeyHash)

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
* @param date in milliseconds
*/
export function isPublicKeyValidForDate(web3, did, publicKeyHash, date) {
publicKeyHash = AddressUtils.getAddressWithHexPrefix(publicKeyHash)
return new Promise((resolve, reject) => {
transactionFactory.publicKeyRegistry
.getPublicKeyStatusDecodedAsJSON(web3, did, publicKeyHash)
.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 userDate in milliseconds
* @param publicKeyStartDate in milliseconds
* @param publicKeyEndDate in milliseconds. If equals to 0, there is no enddate
*/
function _isUserDateBetweeenDates(
userDate,
publicKeyStartDate,
publicKeyEndDate
) {
if (publicKeyStartDate && publicKeyEndDate === 0) return true
else return userDate >= publicKeyStartDate && userDate <= publicKeyEndDate
}

function delegated(web3, delegatedData) {
return web3.eth.abi.encodeFunctionCall(
config.contractsAbi.AlastriaIdentityManager.delegateCall,
Expand Down
4 changes: 0 additions & 4 deletions src/txFactory/transactionFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ import {
getCurrentPublicKey,
getPublicKeyStatus,
getPublicKeyStatusHash,
getPublicKeyStatusDecodedAsJSON,
isPublicKeyValidForDate,
} from './publicKeyRegistryTransactionFactory'

export const transactionFactory = {
Expand Down Expand Up @@ -109,7 +107,5 @@ export const transactionFactory = {
getCurrentPublicKey: getCurrentPublicKey,
getPublicKeyStatus: getPublicKeyStatus,
getPublicKeyStatusHash: getPublicKeyStatusHash,
getPublicKeyStatusDecodedAsJSON: getPublicKeyStatusDecodedAsJSON,
isPublicKeyValidForDate: isPublicKeyValidForDate,
}
}

0 comments on commit 29c564f

Please sign in to comment.