From 857b14dd30c66e188e29d93e833226cb1029de41 Mon Sep 17 00:00:00 2001 From: woodser Date: Thu, 15 Aug 2024 13:05:15 -0400 Subject: [PATCH] return promise includes undefined when applicable #221 --- src/main/ts/daemon/MoneroDaemon.ts | 2 +- src/main/ts/daemon/MoneroDaemonRpc.ts | 2 +- src/main/ts/daemon/model/MoneroTx.ts | 4 ++-- src/main/ts/wallet/MoneroWallet.ts | 4 ++-- src/main/ts/wallet/MoneroWalletFull.ts | 4 ++-- src/main/ts/wallet/MoneroWalletRpc.ts | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/main/ts/daemon/MoneroDaemon.ts b/src/main/ts/daemon/MoneroDaemon.ts index 822aadd3e..15c8b4b20 100644 --- a/src/main/ts/daemon/MoneroDaemon.ts +++ b/src/main/ts/daemon/MoneroDaemon.ts @@ -267,7 +267,7 @@ export default class MoneroDaemon { * @param {boolean} [prune] - specifies if the returned tx should be pruned (defaults to false) * @return {Promise} transaction with the given hash or undefined if not found */ - async getTx(txHash?: string, prune = false): Promise { + async getTx(txHash?: string, prune = false): Promise { return (await this.getTxs([txHash], prune))[0]; } diff --git a/src/main/ts/daemon/MoneroDaemonRpc.ts b/src/main/ts/daemon/MoneroDaemonRpc.ts index 5ded43d6c..cc42c01a4 100644 --- a/src/main/ts/daemon/MoneroDaemonRpc.ts +++ b/src/main/ts/daemon/MoneroDaemonRpc.ts @@ -758,7 +758,7 @@ class MoneroDaemonRpc extends MoneroDaemon { } // ----------- ADD JSDOC FOR SUPPORTED DEFAULT IMPLEMENTATIONS -------------- - async getTx(txHash?: string, prune = false): Promise { return super.getTx(txHash, prune); }; + async getTx(txHash?: string, prune = false): Promise { return super.getTx(txHash, prune); }; async getTxHex(txHash: string, prune = false): Promise { return super.getTxHex(txHash, prune); }; async getKeyImageSpentStatus(keyImage: string): Promise { return super.getKeyImageSpentStatus(keyImage); } async setPeerBan(ban: MoneroBan): Promise { return super.setPeerBan(ban); } diff --git a/src/main/ts/daemon/model/MoneroTx.ts b/src/main/ts/daemon/model/MoneroTx.ts index bfce2dc26..7fdc11397 100644 --- a/src/main/ts/daemon/model/MoneroTx.ts +++ b/src/main/ts/daemon/model/MoneroTx.ts @@ -357,9 +357,9 @@ export default class MoneroTx { /** * Get full transaction hex. Full hex = pruned hex + prunable hex. * - * @return {string} full tx hex + * @return {string|undefined} full tx hex */ - getFullHex(): string { + getFullHex(): string|undefined { return this.fullHex; } diff --git a/src/main/ts/wallet/MoneroWallet.ts b/src/main/ts/wallet/MoneroWallet.ts index 405534f27..ceee4ae1a 100644 --- a/src/main/ts/wallet/MoneroWallet.ts +++ b/src/main/ts/wallet/MoneroWallet.ts @@ -430,7 +430,7 @@ export default class MoneroWallet { * * @return {Promise} the number of blocks until the next and last funds unlock in elements 0 and 1, respectively, or undefined if no balance */ - async getNumBlocksToUnlock(): Promise { + async getNumBlocksToUnlock(): Promise { // get balances let balance = await this.getBalance(); @@ -566,7 +566,7 @@ export default class MoneroWallet { * @param {string} txHash - hash of a transaction to get * @return {Promise } the identified transaction or undefined if not found */ - async getTx(txHash: string): Promise { + async getTx(txHash: string): Promise { let txs = await this.getTxs([txHash]); return txs.length === 0 ? undefined : txs[0]; } diff --git a/src/main/ts/wallet/MoneroWalletFull.ts b/src/main/ts/wallet/MoneroWalletFull.ts index dc1247900..926cd0e35 100644 --- a/src/main/ts/wallet/MoneroWalletFull.ts +++ b/src/main/ts/wallet/MoneroWalletFull.ts @@ -1586,8 +1586,8 @@ export default class MoneroWalletFull extends MoneroWalletKeys { // ----------- ADD JSDOC FOR SUPPORTED DEFAULT IMPLEMENTATIONS -------------- - async getNumBlocksToUnlock(): Promise { return super.getNumBlocksToUnlock(); } - async getTx(txHash: string): Promise { return super.getTx(txHash); } + async getNumBlocksToUnlock(): Promise { return super.getNumBlocksToUnlock(); } + async getTx(txHash: string): Promise { return super.getTx(txHash); } async getIncomingTransfers(query: Partial): Promise { return super.getIncomingTransfers(query); } async getOutgoingTransfers(query: Partial) { return super.getOutgoingTransfers(query); } async createTx(config: Partial): Promise { return super.createTx(config); } diff --git a/src/main/ts/wallet/MoneroWalletRpc.ts b/src/main/ts/wallet/MoneroWalletRpc.ts index c90b8f728..0147e7428 100644 --- a/src/main/ts/wallet/MoneroWalletRpc.ts +++ b/src/main/ts/wallet/MoneroWalletRpc.ts @@ -1465,8 +1465,8 @@ export default class MoneroWalletRpc extends MoneroWallet { // ----------- ADD JSDOC FOR SUPPORTED DEFAULT IMPLEMENTATIONS -------------- - async getNumBlocksToUnlock(): Promise { return super.getNumBlocksToUnlock(); } - async getTx(txHash: string): Promise { return super.getTx(txHash); } + async getNumBlocksToUnlock(): Promise { return super.getNumBlocksToUnlock(); } + async getTx(txHash: string): Promise { return super.getTx(txHash); } async getIncomingTransfers(query: Partial): Promise { return super.getIncomingTransfers(query); } async getOutgoingTransfers(query: Partial) { return super.getOutgoingTransfers(query); } async createTx(config: Partial): Promise { return super.createTx(config); }