Use Bytes Primitive
This commit is contained in:
@@ -28,15 +28,15 @@ import {
|
||||
* ```
|
||||
*/
|
||||
export class Script {
|
||||
protected readonly bytes: Uint8Array;
|
||||
protected readonly bytes: Bytes;
|
||||
|
||||
/**
|
||||
* Construct a new Script
|
||||
*
|
||||
* @param bytes {Uint8Array} The raw bytes of the Script.
|
||||
*/
|
||||
protected constructor(bytes: Uint8Array) {
|
||||
this.bytes = bytes;
|
||||
protected constructor(bytes: Bytes | Uint8Array) {
|
||||
this.bytes = Bytes.from(bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,7 +48,7 @@ export class Script {
|
||||
*
|
||||
* @returns The created Script Primitive.
|
||||
*/
|
||||
public static from(script: Uint8Array | string) {
|
||||
public static from(script: Bytes | Uint8Array | string) {
|
||||
return script instanceof Uint8Array
|
||||
? this.fromBytes(script)
|
||||
: this.fromHex(script);
|
||||
@@ -63,7 +63,7 @@ export class Script {
|
||||
*
|
||||
* @returns {Script} The created Script Entity.
|
||||
*/
|
||||
public static fromBytes(bytes: Uint8Array): Script {
|
||||
public static fromBytes(bytes: Bytes | Uint8Array): Script {
|
||||
// Disassemble the bytecode.
|
||||
const disassembledBytecode = disassembleBytecodeBCH(bytes);
|
||||
|
||||
@@ -213,7 +213,7 @@ export class Script {
|
||||
*
|
||||
* @returns {Uint8Array} The compiled bytes.
|
||||
*/
|
||||
public toBytes(): Uint8Array {
|
||||
public toBytes(): Bytes {
|
||||
return this.bytes;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user