Skip to content

Commit

Permalink
Merge pull request #194 from alastria/feature/193-createNewGetCurrent…
Browse files Browse the repository at this point in the history
…PublicKeyFunction

Feature/193 create new get current public key function
  • Loading branch information
rober12 authored May 20, 2024
2 parents 7d56a55 + dcbe2e3 commit 079a097
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "alastria-identity-lib",
"version": "2.1.1",
"version": "2.2.0",
"description": "A library to interact with alastria-identity smart contracts",
"main": "src/index.js",
"bin": {
Expand Down
19 changes: 18 additions & 1 deletion src/txFactory/publicKeyRegistryTransactionFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export function deletePublicKeyHash(web3, publicKeyHash) {
}

/**
* function getCurrentPublicKey(address subject) view public validAddress(subject) returns (string)
* THIS METHOD WILL BE DEPREATED
* @param web3
* @param did
*/
Expand All @@ -121,6 +121,23 @@ export function getCurrentPublicKey(web3, did) {
return transaction
}

/**
* @param web3
* @param did
* @param publicKeyHash
*/
export function getCurrentPublicKeyHash(web3, did, publicKeyHash) {
const subjectAddr = AIdUtils.getProxyAddress(did)
const transaction = Object.assign({}, config.basicTransaction)
transaction.data = web3.eth.abi.encodeFunctionCall(
config.contractsAbi.AlastriaPublicKeyRegistry.getCurrentPublicKey,
[subjectAddr, publicKeyHash]
)
transaction.to = config.alastriaPublicKeyRegistry
transaction.gasLimit = 600000
return transaction
}

/**
* THIS METHOD WILL BE DEPREATED
* @param web3
Expand Down
4 changes: 3 additions & 1 deletion src/txFactory/transactionFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ import {
getPublicKeyStatusHash,
deletePublicKeyHash,
revokePublicKeyHash,
addPublicKey
addPublicKey,
getCurrentPublicKeyHash
} from './publicKeyRegistryTransactionFactory'

export const transactionFactory = {
Expand Down Expand Up @@ -109,6 +110,7 @@ export const transactionFactory = {
deletePublicKey: deletePublicKey,
deletePublicKeyHash: deletePublicKeyHash,
getCurrentPublicKey: getCurrentPublicKey,
getCurrentPublicKeyHash: getCurrentPublicKeyHash,
getPublicKeyStatus: getPublicKeyStatus,
getPublicKeyStatusHash: getPublicKeyStatusHash,
getPublicKeyStatusDecodedAsJSON: getPublicKeyStatusDecodedAsJSON,
Expand Down

0 comments on commit 079a097

Please sign in to comment.