Skip to content

Commit

Permalink
Merge pull request #24 from lacchain/fix/lacchain-transaction-sender
Browse files Browse the repository at this point in the history
Fix/lacchain transaction sender, closes #23
  • Loading branch information
eum602 authored Jun 4, 2023
2 parents dee2b46 + 1a4b0f4 commit b8aaaa4
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 9 deletions.
4 changes: 2 additions & 2 deletions docs/API-Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/constants/errorMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
2 changes: 1 addition & 1 deletion src/services/did-lac/did.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`
];
Expand Down
10 changes: 10 additions & 0 deletions src/services/did-lac/lacchain/lacchain-ethers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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 };
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit b8aaaa4

Please sign in to comment.