Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
fix(lsk): handle 400 response errors
Browse files Browse the repository at this point in the history
  • Loading branch information
faustbrian committed Jul 19, 2021
1 parent 4b31687 commit 41d73be
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 19 deletions.
30 changes: 20 additions & 10 deletions packages/sdk-lsk/source/client-three.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,30 @@ export class ClientService extends Services.AbstractClientService {
};

for (const transaction of transactions) {
const { transactionId, message } = await this.#post("transactions", {
transaction: this.broadcastSerializer.toString(transaction.toBroadcast()),
});
try {
const { transactionId, message } = await this.#post("transactions", {
transaction: this.broadcastSerializer.toString(transaction.toBroadcast()),
});

if (transactionId) {
result.accepted.push(transaction.id());
if (transactionId) {
result.accepted.push(transaction.id());

continue;
}
continue;
}

if (message) {
result.rejected.push(transaction.id());

result.errors[transaction.id()] = message;
}
} catch (error) {
const { message } = error.response.body();

if (message) {
result.rejected.push(transaction.id());
if (message) {
result.rejected.push(transaction.id());

result.errors[transaction.id()] = message;
result.errors[transaction.id()] = message;
}
}
}

Expand Down
20 changes: 12 additions & 8 deletions packages/sdk-lsk/source/multi-signature.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,22 @@ export class MultiSignatureService extends Services.AbstractMultiSignatureServic

/** @inheritdoc */
public override async allWithPendingState(publicKey: string): Promise<Services.MultiSignatureTransaction[]> {
return (await this.#post("list", {
publicKey,
state: "pending",
})).map((transaction) => this.#normalizeTransaction(transaction));
return (
await this.#post("list", {
publicKey,
state: "pending",
})
).map((transaction) => this.#normalizeTransaction(transaction));
}

/** @inheritdoc */
public override async allWithReadyState(publicKey: string): Promise<Services.MultiSignatureTransaction[]> {
return (await this.#post("list", {
publicKey,
state: "ready",
})).map((transaction) => this.#normalizeTransaction(transaction));
return (
await this.#post("list", {
publicKey,
state: "ready",
})
).map((transaction) => this.#normalizeTransaction(transaction));
}

/** @inheritdoc */
Expand Down
1 change: 0 additions & 1 deletion packages/sdk-lsk/source/transaction-three.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,6 @@ export class TransactionService extends Services.AbstractTransactionService {
);
}


return this.dataTransferObjectService.signedTransaction(
convertBuffer(signedTransaction.id),
{
Expand Down

0 comments on commit 41d73be

Please sign in to comment.