Update TypeScript to use ! instead of casting
This commit is contained in:
parent
bc28949056
commit
1732bafbc1
17 changed files with 99 additions and 97 deletions
ts_src/payments
|
@ -36,15 +36,15 @@ export function p2data (a: Payment, opts?: PaymentOpts): Payment {
|
|||
})
|
||||
lazy.prop(o, 'data', function () {
|
||||
if (!a.output) return
|
||||
return (<Array<Buffer | number>>bscript.decompile(a.output)).slice(1)
|
||||
return bscript.decompile(a.output)!.slice(1)
|
||||
})
|
||||
|
||||
// extended validation
|
||||
if (opts.validate) {
|
||||
if (a.output) {
|
||||
const chunks = bscript.decompile(a.output)
|
||||
if ((<Array<Buffer | number>>chunks)[0] !== OPS.OP_RETURN) throw new TypeError('Output is invalid')
|
||||
if (!(<Array<Buffer | number>>chunks).slice(1).every(typef.Buffer)) throw new TypeError('Output is invalid')
|
||||
if (chunks![0] !== OPS.OP_RETURN) throw new TypeError('Output is invalid')
|
||||
if (!chunks!.slice(1).every(typef.Buffer)) throw new TypeError('Output is invalid')
|
||||
|
||||
if (a.data && !stacksEqual(a.data, <Array<Buffer>>o.data)) throw new TypeError('Data mismatch')
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue