monero-ts
monero-ts copied to clipboard
Invalid type for `getFullHex`
MoneroTx.getFullHex
is typed as string
, but it sometimes also returns undefined
, it should be typed as string | undefined
.
The code below is an example of undefined
return:
import monerojs, { MoneroWalletListener } from 'monero-ts';
const wallet = await monerojs.createWalletFull({
password: 'ssp',
networkType: 'testnet',
privateSpendKey: 'b035cf0e92334bcb4cc35cbe06102582341bc9cc9392bf626b1af4285a53f97d',
server: 'http://node.monerodevs.org:28089',
proxyToWorker: false,
});
function syncListener(wallet: any, to: number) {
return new class extends MoneroWalletListener {
async onSyncProgress(height: number) {
if (height >= to) wallet.stopSyncing();
}
}
}
const fromHeight = 2510731;
const toHeight = 2510731;
await wallet.sync(syncListener(wallet, toHeight), fromHeight);
const txs = await wallet.getTxs({ minHeight: fromHeight, maxHeight: toHeight, isIncoming: true });
console.log(txs[0].getFullHex());