diff --git a/src/txFactory/credentialRegistryTransactionFactory.ts b/src/txFactory/credentialRegistryTransactionFactory.ts index 6fde667..8184617 100644 --- a/src/txFactory/credentialRegistryTransactionFactory.ts +++ b/src/txFactory/credentialRegistryTransactionFactory.ts @@ -2,10 +2,12 @@ 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 * @param subjectCredentialHash should have 32 bytes, credential identification + * @param URI url for store the credentials for backup */ export function addSubjectCredential(web3, subjectCredentialHash, URI) { const transaction = Object.assign({}, config.basicTransaction) @@ -20,6 +22,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 @@ -38,6 +60,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 @@ -79,10 +102,11 @@ export function getSubjectCredentialStatus( } /** + * THIS METHOD WILL BE DEPREATED, USE INSTEAD updateIssuerCredential * function updateCredentialStatus(web3, issuerCredentialHash, status) - * @param web3 - * @param issuerCredentialHash - * @param status + * @param web3 ethereum connection + * @param issuerCredentialHash should have 32 bytes + * @param status uint that indicates the status of the credential */ export function updateCredentialStatus(web3, issuerCredentialHash, status) { const transaction = Object.assign({}, config.basicTransaction) @@ -96,12 +120,30 @@ export function updateCredentialStatus(web3, issuerCredentialHash, status) { return transaction } +/** + * function updateIssuerCredential(web3, issuerCredentialHash, status) + * @param web3 ethereum connection + * @param issuerCredentialHash should have 32 bytes + * @param status uint that indicates the status of the credential + */ +export function updateIssuerCredential(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) * @param web3 ethereum connection - * @param didIssuer - * @param issuerCredentialHash + * @param didIssuer alastria Id + * @param issuerCredentialHash should have 32 bytes */ export function getIssuerCredentialStatus( web3, @@ -120,10 +162,11 @@ 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 - * @param issuerStatus + * @param subjectStatus uint that indicates the status of the credential for subject + * @param issuerStatus uint that indicates the status of the credential for issuer */ export function getCredentialStatus(web3, subjectStatus, issuerStatus) { const transaction = Object.assign({}, config.basicTransaction) diff --git a/src/txFactory/presentationRegistryTransactionFactory.ts b/src/txFactory/presentationRegistryTransactionFactory.ts index d482207..8f48bb0 100644 --- a/src/txFactory/presentationRegistryTransactionFactory.ts +++ b/src/txFactory/presentationRegistryTransactionFactory.ts @@ -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 ethereum connection + * @param subjectPresentationHash should have 32 bytes + * @param URI url for store the presentations for backup + */ export function addSubjectPresentation(web3, subjectPresentationHash, URI) { const transaction = Object.assign({}, config.basicTransaction) const delegatedData = web3.eth.abi.encodeFunctionCall( @@ -16,8 +24,8 @@ export function addSubjectPresentation(web3, subjectPresentationHash, URI) { /** * Subject functions * function updateSubjectPresentation(bytes32 subjectPresentationHash, Status status) public validStatus(status) - * @param web3 - * @param subjectPresentationHash + * @param web3 ethereum connection + * @param subjectPresentationHash should have 32 bytes */ export function updateSubjectPresentation( web3, @@ -39,9 +47,9 @@ export function updateSubjectPresentation( * If the Presentation does not exists the return is a void Presentation * If we want a log, should we add an event? * function getSubjectPresentationStatus(address subject, bytes32 subjectPresentationHash) view public validAddress(subject) returns(bool exists, Status status) - * @param web3 - * @param didSubject - * @param subsubjectPresentationHashject + * @param web3 ethereum connection + * @param didSubject alastria Id + * @param subsubjectPresentationHashject should have 32 bytes */ export function getSubjectPresentationStatus( web3, @@ -63,9 +71,9 @@ export function getSubjectPresentationStatus( /** * Receiver functions * function updateReceiverPresentation(bytes32 receiverPresentationHash, Status status) public validStatus(status) - * @param web3 - * @param receiverPresentationHash - * @param status + * @param web3 ethereum connection + * @param receiverPresentationHash should have 32 bytes + * @param status uint that indicates the status of the presentation */ export function updateReceiverPresentation( web3, @@ -87,9 +95,9 @@ export function updateReceiverPresentation( * If the Presentation does not exists the return is a void Presentation * If we want a log, should we add an event? * function getReceiverPresentationStatus(address receiver, bytes32 receiverPresentationHash) view public validAddress(receiver) returns(bool exists, Status status) { - * @param web3 - * @param didReceiver - * @param receiverPresentationHash + * @param web3 ethereum connection + * @param didReceiver alastria Id + * @param receiverPresentationHash should have 32 bytes */ export function getReceiverPresentationStatus( web3, @@ -109,12 +117,13 @@ 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){ - * @param web3 - * @param subjectStatus - * @param receiverStatus + * @param web3 ethereum connection + * @param subjectStatus uint that indicates the status of the presentation for subject + * @param receiverStatus uint that indicates the status of the presentation for receiver */ export function getPresentationStatus(web3, subjectStatus, receiverStatus) { const transaction = Object.assign({}, config.basicTransaction) diff --git a/src/txFactory/publicKeyRegistryTransactionFactory.ts b/src/txFactory/publicKeyRegistryTransactionFactory.ts index 3f4f552..91bd28e 100644 --- a/src/txFactory/publicKeyRegistryTransactionFactory.ts +++ b/src/txFactory/publicKeyRegistryTransactionFactory.ts @@ -3,10 +3,10 @@ import { AIdUtils } from '../utils/AIdUtils' import { AddressUtils } from '../utils/AddressUtils' /** - * THIS METHOD WILL BE DEPREATED - * function addKey(string memory publicKey, address subject) public - * @param web3 - * @param publicKey + * THIS METHOD WILL BE DEPREATED, USE INSTEAD addPublicKey + * function addKey(string memory publicKey) public + * @param web3 ethereum connection + * @param publicKey the public key. */ export function addKey(web3, publicKey) { const transaction = Object.assign({}, config.basicTransaction) @@ -21,8 +21,9 @@ export function addKey(web3, publicKey) { } /** - * @param web3 - * @param publicKeyHash + * function addPublicKey(bytes32 publicKeyHash) public + * @param web3 ethereum connection + * @param publicKeyHash the hash of the publickey. should have 32 bytes */ export function addPublicKey(web3, publicKeyHash) { const transaction = Object.assign({}, config.basicTransaction) @@ -37,9 +38,10 @@ export function addPublicKey(web3, publicKeyHash) { } /** - * THIS METHOD WILL BE DEPREATED - * @param web3 - * @param publicKey + * THIS METHOD WILL BE DEPREATED, USE INSTEAD revokePublicKeyHash + * function revokePublicKey(string memory publicKey) public + * @param web3 ethereum connection + * @param publicKey the public key. */ export function revokePublicKey(web3, publicKey) { const transaction = Object.assign({}, config.basicTransaction) @@ -54,8 +56,9 @@ export function revokePublicKey(web3, publicKey) { } /** - * @param web3 - * @param publicKeyHash + * function revokePublicKey(bytes32 publicKeyHash) public + * @param web3 ethereum connection + * @param publicKeyHash the hash of the publickey. should have 32 bytes */ export function revokePublicKeyHash(web3, publicKeyHash) { const transaction = Object.assign({}, config.basicTransaction) @@ -70,9 +73,10 @@ export function revokePublicKeyHash(web3, publicKeyHash) { } /** - * THIS METHOD WILL BE DEPREATED - * @param web3 - * @param publicKey + * THIS METHOD WILL BE DEPREATED, USE INSTEAD deletePublicKeyHash + * function deletePublicKey(string memory publicKey) public + * @param web3 ethereum connection + * @param publicKey the public key. */ export function deletePublicKey(web3, publicKey) { const transaction = Object.assign({}, config.basicTransaction) @@ -87,8 +91,9 @@ export function deletePublicKey(web3, publicKey) { } /** - * @param web3 - * @param publicKeyHash + * function deletePublicKey(bytes32 publicKeyHash) public + * @param web3 ethereum connection + * @param publicKeyHash the hash of the publickey. should have 32 bytes */ export function deletePublicKeyHash(web3, publicKeyHash) { const transaction = Object.assign({}, config.basicTransaction) @@ -103,9 +108,10 @@ export function deletePublicKeyHash(web3, publicKeyHash) { } /** - * THIS METHOD WILL BE DEPREATED - * @param web3 - * @param did + * THIS METHOD WILL BE DEPREATED, USE INSTEAD getPublicKeyStatusHash + * function getCurrentPublicKey(address subject) view public + * @param web3 ethereum connection + * @param did alastri Id */ export function getCurrentPublicKey(web3, did) { const subjectAddr = AIdUtils.getProxyAddress(did) @@ -120,29 +126,12 @@ export function getCurrentPublicKey(web3, did) { } /** - * THIS METHOD WILL BE DEPREATED - * @param web3 - * @param did - * @param publicKey + * function getPublicKeyStatus(address subject, bytes32 publicKeyHash) view public + * @param web3 ethereum connection + * @param did alastri Id + * @param publicKeyHash the hash of the publickey. should have 32 bytes */ -export function getPublicKeyStatus(web3, did, publicKey) { - const subjectAddr = AIdUtils.getProxyAddress(did) - const transaction = Object.assign({}, config.basicTransaction) - transaction.data = web3.eth.abi.encodeFunctionCall( - config.contractsAbi.AlastriaPublicKeyRegistry.getPublicKeyStatus, - [subjectAddr, AddressUtils.getAddressWithoutHexPrefix(publicKey)] - ) - transaction.to = config.alastriaPublicKeyRegistry - transaction.gasLimit = 600000 - return transaction -} - -/** - * @param web3 - * @param did - * @param publicKeyHash - */ -export function getPublicKeyStatusHash(web3, did, publicKeyHash) { +export function getPublicKeyStatus(web3, did, publicKeyHash) { const subjectAddr = AIdUtils.getProxyAddress(did) const transaction = Object.assign({}, config.basicTransaction) transaction.data = web3.eth.abi.encodeFunctionCall( diff --git a/src/txFactory/transactionFactory.ts b/src/txFactory/transactionFactory.ts index dec04b4..a87c517 100644 --- a/src/txFactory/transactionFactory.ts +++ b/src/txFactory/transactionFactory.ts @@ -1,6 +1,8 @@ import { addSubjectCredential, + updateSubjectCredential, addIssuerCredential, + updateIssuerCredential, deleteSubjectCredential, getSubjectCredentialStatus, updateCredentialStatus, @@ -52,13 +54,14 @@ import { deletePublicKeyHash, getCurrentPublicKey, getPublicKeyStatus, - getPublicKeyStatusHash, } from './publicKeyRegistryTransactionFactory' export const transactionFactory = { credentialRegistry: { addSubjectCredential: addSubjectCredential, + updateSubjectCredential: updateSubjectCredential, addIssuerCredential: addIssuerCredential, + updateIssuerCredential: updateIssuerCredential, deleteSubjectCredential: deleteSubjectCredential, getSubjectCredentialStatus: getSubjectCredentialStatus, updateCredentialStatus: updateCredentialStatus, @@ -105,7 +108,6 @@ export const transactionFactory = { deletePublicKey: deletePublicKey, deletePublicKeyHash: deletePublicKeyHash, getCurrentPublicKey: getCurrentPublicKey, - getPublicKeyStatus: getPublicKeyStatus, - getPublicKeyStatusHash: getPublicKeyStatusHash, + getPublicKeyStatus: getPublicKeyStatus } }