diff --git a/docs/API-Guide.md b/docs/API-Guide.md index 9ab8340..e826910 100644 --- a/docs/API-Guide.md +++ b/docs/API-Guide.md @@ -34,11 +34,11 @@ echo "Did was created: $did" ```sh ## input variables path_to_crt=../certs/DSC/DSC.crt # you should point to the public pem certificate that represents the signing certificate used to sign health related data -did="did:lac1:1iT5mqjxfSLyV24tHNgPwg5KMixYdP2FUHRCkir8Sr1RBepGA2da6peZgyB48tFUAdPy" # replace with the did previously created +did="did:lac1:1iT4ksoK9qcxYYe8vGu2fZEDsYHCkJ7FkpxMeSJUrgLRDMmH3g5hKGry4H9bqGpZJPpB" # replace with the did previously created # process -add_pem_certificate_url="$api_url"/api/v1/did-lac1/attribute/add/jwk-from-x509certificate +add_pem_certificate_url="$api_url"/api/v1/did/lac1/attribute/add/jwk-from-x509certificate relation=asse data='{"did":'"\"$did\""', "relation":'"\"$relation\""'}' curl -X 'POST' ${add_pem_certificate_url} -H 'accept: application/json' -F x509Cert=@$path_to_crt -F data=$data diff --git a/package.json b/package.json index 0ebd036..7f5c647 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lacpass-identity", - "version": "0.0.20", + "version": "0.0.23", "description": "Rest api for laccpass identity manager", "main": "dist/src/index.js", "types": "dist/src/index.d.ts", diff --git a/src/constants/errorMessages.ts b/src/constants/errorMessages.ts index 3324bbd..f27164e 100644 --- a/src/constants/errorMessages.ts +++ b/src/constants/errorMessages.ts @@ -37,7 +37,9 @@ export enum ErrorsMessages { X509_INVALID_ORGANIZATION_SUBJECT = 'Invalid or organization subject', X509_INVALID_COUNTRY = 'Invalid or certificate country', X509_INVALID_COMMON_NAME = 'Invalid x509 CN name', - ATTRIBUTE_VALUE_ERROR = 'Attribute value is not an address' + ATTRIBUTE_VALUE_ERROR = 'Attribute value is not an address', + // eslint-disable-next-line max-len + LACCHAIN_CONTRACT_TRANSACTION_ERROR = 'There was an error, there may be an issue with the params you are sending' } export const Errors = { diff --git a/src/index.ts b/src/index.ts index 6e63288..b421518 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,3 +11,5 @@ export * from './dto/did-lac/addAttributeDTO'; export * from './dto/did-lac/delegateDTO'; export * from './interfaces/did-lacchain/did-lacchain.interface'; export * from './interfaces/did-lacchain/did-lacchain-response.interface'; +export * from './services/did-lac/lacchain/lacchain-ethers'; +export * from './interfaces/ethereum/transaction'; diff --git a/src/services/did-lac/did.service.ts b/src/services/did-lac/did.service.ts index 7bf7b4e..cc17acc 100644 --- a/src/services/did-lac/did.service.ts +++ b/src/services/did-lac/did.service.ts @@ -121,7 +121,7 @@ export abstract class DidService implements DidLacService { const name = type; const value = delegateAddress; - const methodName = 'setDelegate'; + const methodName = 'addDelegate'; const methodSignature = [ `function ${methodName}(address,bytes32,address,uint256) public` ]; diff --git a/src/services/did-lac/lacchain/lacchain-ethers.ts b/src/services/did-lac/lacchain/lacchain-ethers.ts index fde31e8..9d4389d 100644 --- a/src/services/did-lac/lacchain/lacchain-ethers.ts +++ b/src/services/did-lac/lacchain/lacchain-ethers.ts @@ -6,6 +6,8 @@ import { IEthereumTransactionResponse, ITransaction } from 'src/interfaces/ethereum/transaction'; +import { BadRequestError } from 'routing-controllers'; +import { ErrorsMessages } from '../../../constants/errorMessages'; export class LacchainLib { log = log4TSProvider.getLogger('lacchainUtils'); @@ -36,6 +38,14 @@ export class LacchainLib { const txResponse = await this.provider.sendTransaction( signedTx.signedTransaction ); + this.log.info('waiting for transaction response...'); + try { + await txResponse.wait(); + } catch (err: any) { + throw new BadRequestError( + ErrorsMessages.LACCHAIN_CONTRACT_TRANSACTION_ERROR + ); + } this.log.info('Transaction successfully sent, txHash', txResponse.hash); return { txHash: txResponse.hash }; } diff --git a/yarn.lock b/yarn.lock index a557a65..9990a33 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5217,10 +5217,10 @@ koa@^2.8.2: type-is "^1.6.16" vary "^1.1.2" -lacpass-key-manager@^0.0.16: - version "0.0.16" - resolved "https://registry.yarnpkg.com/lacpass-key-manager/-/lacpass-key-manager-0.0.16.tgz#0f6f11f541b121a7df77e5b3424d0b033a24088d" - integrity sha512-QPbLfanEG3tu0en+pDsJzsHAjrnnqvELVXavsSKBcFgaHsNvWcFsqaU0lWDw/FEYQH0bn9gq5j4KRN+VqaCrTg== +lacpass-key-manager@^0.0.17: + version "0.0.17" + resolved "https://registry.yarnpkg.com/lacpass-key-manager/-/lacpass-key-manager-0.0.17.tgz#3e8ddc87e4a2766467c53f6f22d06975c1723030" + integrity sha512-D36Lau2UKK0LwDQSrE6xQM4JMiI5/tS+Z6fmFBFUiYg4/hrtPWL6ii50S6IM/lVcm5UcEhwzMxwoI/QHHUs2Pw== dependencies: "@lacchain/gas-model-provider" "^1.0.1" aws-sdk "^2.1116.0"