Skip to content

Commit 079a097

Browse files
authored
Merge pull request #194 from alastria/feature/193-createNewGetCurrentPublicKeyFunction
Feature/193 create new get current public key function
2 parents 7d56a55 + dcbe2e3 commit 079a097

File tree

3 files changed

+22
-3
lines changed

3 files changed

+22
-3
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "alastria-identity-lib",
3-
"version": "2.1.1",
3+
"version": "2.2.0",
44
"description": "A library to interact with alastria-identity smart contracts",
55
"main": "src/index.js",
66
"bin": {

src/txFactory/publicKeyRegistryTransactionFactory.ts

+18-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export function deletePublicKeyHash(web3, publicKeyHash) {
105105
}
106106

107107
/**
108-
* function getCurrentPublicKey(address subject) view public validAddress(subject) returns (string)
108+
* THIS METHOD WILL BE DEPREATED
109109
* @param web3
110110
* @param did
111111
*/
@@ -121,6 +121,23 @@ export function getCurrentPublicKey(web3, did) {
121121
return transaction
122122
}
123123

124+
/**
125+
* @param web3
126+
* @param did
127+
* @param publicKeyHash
128+
*/
129+
export function getCurrentPublicKeyHash(web3, did, publicKeyHash) {
130+
const subjectAddr = AIdUtils.getProxyAddress(did)
131+
const transaction = Object.assign({}, config.basicTransaction)
132+
transaction.data = web3.eth.abi.encodeFunctionCall(
133+
config.contractsAbi.AlastriaPublicKeyRegistry.getCurrentPublicKey,
134+
[subjectAddr, publicKeyHash]
135+
)
136+
transaction.to = config.alastriaPublicKeyRegistry
137+
transaction.gasLimit = 600000
138+
return transaction
139+
}
140+
124141
/**
125142
* THIS METHOD WILL BE DEPREATED
126143
* @param web3

src/txFactory/transactionFactory.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ import {
5656
getPublicKeyStatusHash,
5757
deletePublicKeyHash,
5858
revokePublicKeyHash,
59-
addPublicKey
59+
addPublicKey,
60+
getCurrentPublicKeyHash
6061
} from './publicKeyRegistryTransactionFactory'
6162

6263
export const transactionFactory = {
@@ -109,6 +110,7 @@ export const transactionFactory = {
109110
deletePublicKey: deletePublicKey,
110111
deletePublicKeyHash: deletePublicKeyHash,
111112
getCurrentPublicKey: getCurrentPublicKey,
113+
getCurrentPublicKeyHash: getCurrentPublicKeyHash,
112114
getPublicKeyStatus: getPublicKeyStatus,
113115
getPublicKeyStatusHash: getPublicKeyStatusHash,
114116
getPublicKeyStatusDecodedAsJSON: getPublicKeyStatusDecodedAsJSON,

0 commit comments

Comments
 (0)