Skip to content

Commit

Permalink
feat: retrieve multisig account id (#1084)
Browse files Browse the repository at this point in the history
Signed-off-by: Mario Francia <[email protected]>
  • Loading branch information
M-Francia authored Apr 1, 2024
1 parent 3f2bf75 commit 02edcd0
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 14 deletions.
21 changes: 10 additions & 11 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
#!/bin/bash

# Initialize commit message
message="$(cat $1)"
signedOffPattern="Signed-off-by:"

# Check if the commit message follows the Conventional Commits format
echo $message | npm run commitlint
echo "$message" | npm run --silent commitlint --edit
if [ $? -ne 0 ]; then
echo "❌ Commit message does not follow the Conventional Commits format."
exit 1
fi

# Check if the commit message has a 'Signed-off-by:' line
if ! [[ $message =~ $signedOffPattern ]]; then
if ! echo "$message" | grep -q "$signedOffPattern"; then
echo "❌ Missing 'Signed-off-by:' line! 😕"
echo "Please add a 'Signed-off-by:' line to your commit message."
echo "Message: $message"
exit 1
fi

# # Verify GPG signature for the previous HEAD commit
# if ! git verify-commit HEAD &>/dev/null; then
# echo "❌ Previos (HEAD) Commit does not have a valid GPG signature. Please sign your commits."
# exit 1
# fi

# #! Uncomment for Testing
# exit 1
3 changes: 3 additions & 0 deletions backend/src/transaction/dto/get-transactions-response.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export class GetTransactionsResponseDto {
signed_keys: string[];
signatures: string[];
network: string;
hedera_account_id: string;

constructor(
id: string,
Expand All @@ -39,6 +40,7 @@ export class GetTransactionsResponseDto {
signed_keys: string[],
signatures: string[],
network: string,
hedera_account_id: string
) {
this.id = id;
this.transaction_message = transaction_message;
Expand All @@ -49,5 +51,6 @@ export class GetTransactionsResponseDto {
this.signed_keys = signed_keys;
this.signatures = signatures;
this.network = network;
this.hedera_account_id = hedera_account_id;
}
}
2 changes: 2 additions & 0 deletions backend/src/transaction/transaction.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ export default class TransactionController {
@Query('page', new DefaultValuePipe(1), ParseIntPipe) page?: number,
@Query('limit', new DefaultValuePipe(10), ParseIntPipe) limit?: number,
@Query('network') network?: string,
@Query('hederaAccountId') hederaAccountId?: string,
): Promise<Pagination<GetTransactionsResponseDto>> {
{
if (page < 1) {
Expand All @@ -248,6 +249,7 @@ export default class TransactionController {
publicKey,
status,
network,
hederaAccountId,
{
page,
limit,
Expand Down
12 changes: 9 additions & 3 deletions backend/src/transaction/transaction.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ export default class TransactionService {
publicKey?: string,
status?: string,
network?: string,
hederaAccountId?: string,
options?: IPaginationOptions,
): Promise<Pagination<GetTransactionsResponseDto>> {
let queryBuilder =
Expand All @@ -155,7 +156,6 @@ export default class TransactionService {
`Invalid status: ${status}. Valid values are: ${Object.values(TransactionStatus).join(', ')}`,
);
}
//---
if (publicKey) {
queryBuilder = queryBuilder.where(
':publicKey = ANY(transaction.key_list)',
Expand All @@ -172,7 +172,12 @@ export default class TransactionService {
network: normalizedNetwork,
});
}

if (hederaAccountId) {
queryBuilder = queryBuilder.andWhere(
'transaction.hedera_account_id = :hederaAccountId',
{ hederaAccountId },
);
}
const paginatedResults = await paginate<Transaction>(queryBuilder, options);

const itemsTransformed = paginatedResults.items.map((transaction) =>
Expand Down Expand Up @@ -200,7 +205,7 @@ export default class TransactionService {
}
}

//This function is used to delete all transactions from the database
//*This function is used to delete all transactions from the database
async deleteAllTransactions(): Promise<void> {
await this.transactionRepository.clear();
}
Expand All @@ -216,6 +221,7 @@ export default class TransactionService {
transaction.signed_keys,
transaction.signatures,
transaction.network,
transaction.hedera_account_id,
);
}
}
3 changes: 3 additions & 0 deletions backend/test/transaction/transaction.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ describe('Transaction Controller Test', () => {
DEFAULT.signed_keys,
DEFAULT.signatures,
DEFAULT.network,
DEFAULT.hedera_account_id,
),
),
);
Expand All @@ -345,6 +346,7 @@ describe('Transaction Controller Test', () => {
DEFAULT.signed_keys,
DEFAULT.signatures,
DEFAULT.network,
DEFAULT.hedera_account_id
);
//* 🎬 Act ⬇
const result = await controller.getTransactionById(
Expand Down Expand Up @@ -375,6 +377,7 @@ function createMockGetAllByPublicKeyTxServiceResult(
pendingTransaction.signed_keys,
pendingTransaction.signatures,
pendingTransaction.network,
pendingTransaction.hedera_account_id,
);
return new Pagination<GetTransactionsResponseDto>(
[transactionResponse, transactionResponse],
Expand Down

0 comments on commit 02edcd0

Please sign in to comment.