From f3ea3db1ccafc5cc426e0177c05bfde3ee7869ec Mon Sep 17 00:00:00 2001 From: Dan Krutoholov Date: Tue, 9 Jul 2024 00:02:33 +0200 Subject: [PATCH] fix: linter issues --- src/transaction.ts | 5 ++++- src/utxo.ts | 20 +++++++++++++++++--- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/transaction.ts b/src/transaction.ts index c0cba0d..e9cc54a 100644 --- a/src/transaction.ts +++ b/src/transaction.ts @@ -518,7 +518,10 @@ export class Transaction { ): psbt.TransactionOutput { let { amount, script } = o; if (amount === undefined) amount = cur?.amount; - if (typeof amount !== 'bigint') throw new Error(`Wrong amount type, should be of type bigint in sats, but got ${amount} of type ${typeof amount}`); + if (typeof amount !== 'bigint') + throw new Error( + `Wrong amount type, should be of type bigint in sats, but got ${amount} of type ${typeof amount}` + ); if (typeof script === 'string') script = hex.decode(script); if (script === undefined) script = cur?.script; let res: psbt.PSBTKeyMapKeys = { ...cur, ...o, amount, script }; diff --git a/src/utxo.ts b/src/utxo.ts index 4a5e754..5df85d4 100644 --- a/src/utxo.ts +++ b/src/utxo.ts @@ -284,7 +284,12 @@ function getScript(o: Output, opts: TxOpts = {}, network = NETWORK) { script = OutScript.encode(Address(network).decode(o.address)); } if (!script) throw new Error('Estimator: wrong output script'); - if (typeof o.amount !== 'bigint') throw new Error(`Estimator: wrong output amount=${o.amount}, should be of type bigint but got ${typeof o.amount}.`); + if (typeof o.amount !== 'bigint') + throw new Error( + `Estimator: wrong output amount=${ + o.amount + }, should be of type bigint but got ${typeof o.amount}.` + ); if (script && !opts.allowUnknownOutputs && OutScript.decode(script).type === 'unknown') { throw new Error( 'Estimator: unknown output script type, there is a chance that input is unspendable. Pass allowUnknownOutputs=true, if you sure' @@ -333,9 +338,18 @@ export class _Estimator { private opts: EstimatorOpts ) { if (typeof opts.feePerByte !== 'bigint') - throw new Error(`Estimator: wrong feePerByte=${opts.feePerByte}, should be of type bigint but got ${typeof opts.feePerByte}.`); + throw new Error( + `Estimator: wrong feePerByte=${ + opts.feePerByte + }, should be of type bigint but got ${typeof opts.feePerByte}.` + ); if (opts.dust) { - if (typeof opts.dust !== 'bigint') throw new Error(`Estimator: wrong dust=${opts.dust}, should be of type bigint but got ${typeof opts.dust}.`); + if (typeof opts.dust !== 'bigint') + throw new Error( + `Estimator: wrong dust=${ + opts.dust + }, should be of type bigint but got ${typeof opts.dust}.` + ); this.dust = opts.dust; } if (opts.requiredInputs !== undefined && !Array.isArray(opts.requiredInputs))