Skip to content

Commit

Permalink
return promise includes undefined when applicable #214, #221
Browse files Browse the repository at this point in the history
  • Loading branch information
woodser committed Aug 16, 2024
1 parent 80d80d0 commit 76ad4f6
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/ts/daemon/MoneroDaemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export default class MoneroDaemon {
* @param {boolean} [prune] - specifies if the returned tx should be pruned (defaults to false)
* @return {Promise<MoneroTx>} transaction with the given hash or undefined if not found
*/
async getTx(txHash?: string, prune = false): Promise<MoneroTx> {
async getTx(txHash?: string, prune = false): Promise<MoneroTx|undefined> {
return (await this.getTxs([txHash], prune))[0];
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/ts/daemon/MoneroDaemonRpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ class MoneroDaemonRpc extends MoneroDaemon {
}

// ----------- ADD JSDOC FOR SUPPORTED DEFAULT IMPLEMENTATIONS --------------
async getTx(txHash?: string, prune = false): Promise<MoneroTx> { return super.getTx(txHash, prune); };
async getTx(txHash?: string, prune = false): Promise<MoneroTx|undefined> { return super.getTx(txHash, prune); };
async getTxHex(txHash: string, prune = false): Promise<string> { return super.getTxHex(txHash, prune); };
async getKeyImageSpentStatus(keyImage: string): Promise<MoneroKeyImageSpentStatus> { return super.getKeyImageSpentStatus(keyImage); }
async setPeerBan(ban: MoneroBan): Promise<void> { return super.setPeerBan(ban); }
Expand Down
4 changes: 2 additions & 2 deletions src/main/ts/daemon/model/MoneroTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/ts/wallet/MoneroWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ export default class MoneroWallet {
*
* @return {Promise<number[]>} 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<number[]> {
async getNumBlocksToUnlock(): Promise<number[]|undefined> {

// get balances
let balance = await this.getBalance();
Expand Down Expand Up @@ -566,7 +566,7 @@ export default class MoneroWallet {
* @param {string} txHash - hash of a transaction to get
* @return {Promise<MoneroTxWallet> } the identified transaction or undefined if not found
*/
async getTx(txHash: string): Promise<MoneroTxWallet> {
async getTx(txHash: string): Promise<MoneroTxWallet|undefined> {
let txs = await this.getTxs([txHash]);
return txs.length === 0 ? undefined : txs[0];
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/ts/wallet/MoneroWalletFull.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1587,8 +1587,8 @@ export default class MoneroWalletFull extends MoneroWalletKeys {

// ----------- ADD JSDOC FOR SUPPORTED DEFAULT IMPLEMENTATIONS --------------

async getNumBlocksToUnlock(): Promise<number[]> { return super.getNumBlocksToUnlock(); }
async getTx(txHash: string): Promise<MoneroTxWallet> { return super.getTx(txHash); }
async getNumBlocksToUnlock(): Promise<number[]|undefined> { return super.getNumBlocksToUnlock(); }
async getTx(txHash: string): Promise<MoneroTxWallet|undefined> { return super.getTx(txHash); }
async getIncomingTransfers(query: Partial<MoneroTransferQuery>): Promise<MoneroIncomingTransfer[]> { return super.getIncomingTransfers(query); }
async getOutgoingTransfers(query: Partial<MoneroTransferQuery>) { return super.getOutgoingTransfers(query); }
async createTx(config: Partial<MoneroTxConfig>): Promise<MoneroTxWallet> { return super.createTx(config); }
Expand Down
4 changes: 2 additions & 2 deletions src/main/ts/wallet/MoneroWalletRpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1465,8 +1465,8 @@ export default class MoneroWalletRpc extends MoneroWallet {

// ----------- ADD JSDOC FOR SUPPORTED DEFAULT IMPLEMENTATIONS --------------

async getNumBlocksToUnlock(): Promise<number[]> { return super.getNumBlocksToUnlock(); }
async getTx(txHash: string): Promise<MoneroTxWallet> { return super.getTx(txHash); }
async getNumBlocksToUnlock(): Promise<number[]|undefined> { return super.getNumBlocksToUnlock(); }
async getTx(txHash: string): Promise<MoneroTxWallet|undefined> { return super.getTx(txHash); }
async getIncomingTransfers(query: Partial<MoneroTransferQuery>): Promise<MoneroIncomingTransfer[]> { return super.getIncomingTransfers(query); }
async getOutgoingTransfers(query: Partial<MoneroTransferQuery>) { return super.getOutgoingTransfers(query); }
async createTx(config: Partial<MoneroTxConfig>): Promise<MoneroTxWallet> { return super.createTx(config); }
Expand Down

0 comments on commit 76ad4f6

Please sign in to comment.