Skip to content

Commit

Permalink
refactor: require specific public key to retrieve transactions (#90)
Browse files Browse the repository at this point in the history
  • Loading branch information
faustbrian committed Aug 27, 2020
1 parent ae035f3 commit ccc0527
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions packages/server/src/server/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,17 @@ import { getBaseTransactionId, verifySignatures } from "./utils";

export const getTransactions = (request, h) => {
try {
if (request.query.publicKey) {
const storeTransactions = memory.getTransactionsByPublicKey(request.query.publicKey);
const storeTransactions = memory.getTransactionsByPublicKey(request.query.publicKey);

if (request.query.state === TransactionStatus.Pending) {
return storeTransactions.filter((t) => t.data.signatures.length < t.multisigAsset.min);
}

if (request.query.state === TransactionStatus.Ready) {
return storeTransactions.filter((t) => t.data.signatures.length >= t.multisigAsset.min);
}
if (request.query.state === TransactionStatus.Pending) {
return storeTransactions.filter((t) => t.data.signatures.length < t.multisigAsset.min);
}

return storeTransactions;
if (request.query.state === TransactionStatus.Ready) {
return storeTransactions.filter((t) => t.data.signatures.length >= t.multisigAsset.min);
}

return memory.getAllTransactions(); // keep or throw error ? (why would we need to get all tx ?)
return storeTransactions;
} catch (error) {
return Boom.badImplementation(error.message);
}
Expand Down

0 comments on commit ccc0527

Please sign in to comment.