Skip to content

Commit

Permalink
TypeError fix on signing
Browse files Browse the repository at this point in the history
  • Loading branch information
Sluder committed Jul 13, 2023
1 parent e127497 commit 75ec57a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 34 deletions.
30 changes: 0 additions & 30 deletions src/dex/models/dex-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,6 @@ export class DexTransaction {
public payToAddresses(payToAddresses: PayToAddress[]): Promise<DexTransaction> {
return this._walletProvider.paymentsForTransaction(this, payToAddresses)
.then(() => {
return this as DexTransaction;
})
.catch((error) => {
this.status = TransactionStatus.Errored;
this.error = {
step: TransactionStatus.Building,
reason: 'Failed to build transaction.',
reasonRaw: error,
};

return this as DexTransaction;
});
}
Expand All @@ -71,16 +61,6 @@ export class DexTransaction {
.then(() => {
this._isSigned = true;

return this as DexTransaction;
})
.catch((error) => {
this.status = TransactionStatus.Errored;
this.error = {
step: TransactionStatus.Signing,
reason: 'Failed to sign transaction.',
reasonRaw: error,
};

return this as DexTransaction;
});
}
Expand All @@ -97,16 +77,6 @@ export class DexTransaction {
.then((txHash: string) => {
this._hash = txHash;

return this as DexTransaction;
})
.catch((error) => {
this.status = TransactionStatus.Errored;
this.error = {
step: TransactionStatus.Submitting,
reason: 'Failed to submit transaction.',
reasonRaw: error,
};

return this as DexTransaction;
});
}
Expand Down
14 changes: 10 additions & 4 deletions src/requests/fetch-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ export class FetchRequest {
* Fetch latest state for a liquidity pool.
*/
public getLiquidityPoolState(liquidityPool: LiquidityPool): Promise<LiquidityPool> {
if (! liquidityPool) {
return Promise.reject('Invalid liquidity pool provided.');
}

const dexInstance: BaseDex | undefined = this._dexter.dexByName(liquidityPool.dex);

if (! dexInstance) {
Expand Down Expand Up @@ -193,9 +197,7 @@ export class FetchRequest {

return await Promise.all(liquidityPoolPromises)
.then((liquidityPools: (LiquidityPool | undefined)[]) => {
return liquidityPools.filter((pool?: LiquidityPool) => {
return pool !== undefined;
}) as LiquidityPool[];
return liquidityPools.filter((pool?: LiquidityPool) => pool !== undefined) as LiquidityPool[];
});
}

Expand Down Expand Up @@ -266,7 +268,11 @@ export class FetchRequest {

return Promise.all(
filterTokenPromises.concat(filterPairPromises).flat(),
).then((allLiquidityPools: Awaited<LiquidityPool[]>[]) => allLiquidityPools.flat());
).then((allLiquidityPools: Awaited<LiquidityPool[]>[]) => {
return allLiquidityPools
.flat()
.filter((pool?: LiquidityPool) => pool !== undefined) as LiquidityPool[];
});
}

}

0 comments on commit 75ec57a

Please sign in to comment.