Skip to content

Commit

Permalink
added updateSubjectCredential and updateIssuerCredential functions. A…
Browse files Browse the repository at this point in the history
…lso marks some deprecated functions
  • Loading branch information
rober12 committed Nov 10, 2024
1 parent 725782c commit 5067675
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/txFactory/credentialRegistryTransactionFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { config } from '../config'
import { AIdUtils } from '../utils/AIdUtils'

/**
* THIS METHOD WILL BE DEPREATED, USE INSTEAD updateSubjectCredential
* function addSubjectCredential(web3, subjectCredentialHash, URI)
* Dev: get delegated invoke addSubjectCredential transaction object
* @param web3 ethereum connection
Expand All @@ -20,6 +21,26 @@ export function addSubjectCredential(web3, subjectCredentialHash, URI) {
}

/**
* function updateSubjectCredential(web3, subjectCredentialHash, status)
* Dev: get delegated invoke updateSubjectCredential transaction object
* @param web3 ethereum connection
* @param subjectCredentialHash should have 32 bytes, credential identification
* @param status uint that indicates the status of the credential
*/
export function updateSubjectCredential(web3, subjectCredentialHash, status) {
const transaction = Object.assign({}, config.basicTransaction)
const delegatedData = web3.eth.abi.encodeFunctionCall(
config.contractsAbi.AlastriaCredentialRegistry.updateSubjectCredential,
[subjectCredentialHash, status]
)
transaction.data = delegated(web3, delegatedData)
transaction.to = config.alastriaIdentityManager // When delegated, target is alastriaIdentityManager
transaction.gasLimit = 600000
return transaction
}

/**
* THIS METHOD WILL BE DEPREATED, USE INSTEAD updateIssuerCredential
* function addIssuerCredential(web3, issuerCredentialHash)
* Dev: get delegated invoke addIssuerCredential transaction object
* @param web3 ethereum connection
Expand All @@ -38,6 +59,7 @@ export function addIssuerCredential(web3, issuerCredentialHash) {
}

/**
* THIS METHOD WILL BE DEPREATED, USE INSTEAD updateSubjectCredential
* function deleteSubjectCredential(web3, subjectCredentialHash)
* Dev: get delegated invoke deleteSubjectCredential transaction object
* @param web3 ethereum connection
Expand Down Expand Up @@ -79,6 +101,7 @@ export function getSubjectCredentialStatus(
}

/**
* THIS METHOD WILL BE DEPREATED, USE INSTEAD updateIssuerCredential
* function updateCredentialStatus(web3, issuerCredentialHash, status)
* @param web3
* @param issuerCredentialHash
Expand All @@ -96,6 +119,24 @@ export function updateCredentialStatus(web3, issuerCredentialHash, status) {
return transaction
}

/**
* function updateIssuerCredentialStatus(web3, issuerCredentialHash, status)
* @param web3
* @param issuerCredentialHash
* @param status
*/
export function updateIssuerCredentialStatus(web3, issuerCredentialHash, status) {
const transaction = Object.assign({}, config.basicTransaction)
const delegatedData = web3.eth.abi.encodeFunctionCall(
config.contractsAbi.AlastriaCredentialRegistry.updateIssuerCredential,
[issuerCredentialHash, status]
)
transaction.data = delegated(web3, delegatedData)
transaction.to = config.alastriaIdentityManager
transaction.gasLimit = 600000
return transaction
}

/**
* Dev: get the invoke updateCredentialStatus transaction object
* function getIssuerCredentialStatus(address issuer, bytes32 issuerCredentialHash) view public validAddress(issuer) returns (bool exists, Status status)
Expand All @@ -120,6 +161,7 @@ export function getIssuerCredentialStatus(
}

/**
* THIS METHOD WILL BE DEPREATED
* Dev: Defining three status functions avoid linking the subject to the issuer or the corresponding hashes
* @param web3 ethereum connection
* @param subjectStatus
Expand Down
9 changes: 9 additions & 0 deletions src/txFactory/presentationRegistryTransactionFactory.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
import { config } from '../config'
import { AIdUtils } from '../utils/AIdUtils'

/**
* THIS METHOD WILL BE DEPREATED, USE INSTEAD updateSubjectPresentation
* Subject functions
* function addSubjectPresentation(web3, subjectPresentationHash, URI)
* @param web3
* @param subjectPresentationHash
* @param URI
*/
export function addSubjectPresentation(web3, subjectPresentationHash, URI) {
const transaction = Object.assign({}, config.basicTransaction)
const delegatedData = web3.eth.abi.encodeFunctionCall(
Expand Down Expand Up @@ -109,6 +117,7 @@ export function getReceiverPresentationStatus(
}

/**
* THIS METHOD WILL BE DEPREATED
* Utility function
* Defining three status functions avoids linking the Subject to the Receiver or the corresponding hashes
* function getPresentationStatus(Status subjectStatus, Status receiverStatus) pure public validStatus(subjectStatus) validStatus(receiverStatus) returns(Status){
Expand Down

0 comments on commit 5067675

Please sign in to comment.