Skip to content

Commit

Permalink
feat: add returnError to transaction options (#704)
Browse files Browse the repository at this point in the history
Co-authored-by: Willem Wyndham <willem@cs.umd.edu>
  • Loading branch information
willemneal and Willem Wyndham authored Oct 13, 2021
1 parent cc57e5d commit fd6d643
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/account.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/account.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export interface SignAndSendTransactionOptions {
* @see {@link RequestSignTransactionsOptions}
*/
walletCallbackUrl?: string;
returnError?: boolean;
}

/**
Expand Down Expand Up @@ -227,7 +228,7 @@ export class Account {
return this.signAndSendTransactionV2({ receiverId, actions });
}

private async signAndSendTransactionV2({ receiverId, actions }: SignAndSendTransactionOptions): Promise<FinalExecutionOutcome> {
private async signAndSendTransactionV2({ receiverId, actions, returnError }: SignAndSendTransactionOptions): Promise<FinalExecutionOutcome> {
let txHash, signedTx;
// TODO: TX_NONCE (different constants for different uses of exponentialBackoff?)
const result = await exponentialBackoff(TX_NONCE_RETRY_WAIT, TX_NONCE_RETRY_NUMBER, TX_NONCE_RETRY_WAIT_BACKOFF, async () => {
Expand Down Expand Up @@ -268,7 +269,7 @@ export class Account {
}, []);
this.printLogsAndFailures(signedTx.transaction.receiverId, flatLogs);

if (typeof result.status === 'object' && typeof result.status.Failure === 'object') {
if (!returnError && typeof result.status === 'object' && typeof result.status.Failure === 'object') {
// if error data has error_message and error_type properties, we consider that node returned an error in the old format
if (result.status.Failure.error_message && result.status.Failure.error_type) {
throw new TypedError(
Expand Down

0 comments on commit fd6d643

Please sign in to comment.