@cashscript/utils
Advanced tools
Comparing version 0.6.5 to 0.7.0-next.0
@@ -7,3 +7,3 @@ export interface AbiInput { | ||
name: string; | ||
covenant: boolean; | ||
covenant?: boolean; | ||
inputs: AbiInput[]; | ||
@@ -10,0 +10,0 @@ } |
export declare function encodeBool(bool: boolean): Uint8Array; | ||
export declare function decodeBool(encodedBool: Uint8Array): boolean; | ||
export declare function encodeInt(int: number): Uint8Array; | ||
export declare function encodeInt(int: number | bigint): Uint8Array; | ||
export declare function decodeInt(encodedInt: Uint8Array, maxLength?: number): number; | ||
@@ -5,0 +5,0 @@ export declare function encodeString(str: string): Uint8Array; |
import { OpcodesBCH } from '@bitauth/libauth'; | ||
export declare enum IntrospectionOp { | ||
OP_INPUTINDEX = 192, | ||
OP_ACTIVEBYTECODE = 193, | ||
OP_TXVERSION = 194, | ||
OP_TXINPUTCOUNT = 195, | ||
OP_TXOUTPUTCOUNT = 196, | ||
OP_TXLOCKTIME = 197, | ||
OP_UTXOVALUE = 198, | ||
OP_UTXOBYTECODE = 199, | ||
OP_OUTPOINTTXHASH = 200, | ||
OP_OUTPOINTINDEX = 201, | ||
OP_INPUTBYTECODE = 202, | ||
OP_INPUTSEQUENCENUMBER = 203, | ||
OP_OUTPUTVALUE = 204, | ||
OP_OUTPUTBYTECODE = 205 | ||
} | ||
export declare const Op: typeof OpcodesBCH; | ||
@@ -14,3 +30,3 @@ export declare type Op = number; | ||
export declare function calculateBytesize(script: Script): number; | ||
export declare function encodeNullDataScript(chunks: (number | Uint8Array)[]): Uint8Array; | ||
export declare function encodeNullDataScript(chunks: OpOrData[]): Uint8Array; | ||
/** | ||
@@ -17,0 +33,0 @@ * When cutting out the tx.bytecode preimage variable, the compiler does not know |
@@ -6,6 +6,24 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.optimiseBytecode = exports.generateRedeemScript = exports.replaceBytecodeNop = exports.encodeNullDataScript = exports.calculateBytesize = exports.countOpcodes = exports.bytecodeToAsm = exports.asmToBytecode = exports.bytecodeToScript = exports.scriptToBytecode = exports.asmToScript = exports.scriptToAsm = exports.Op = void 0; | ||
exports.optimiseBytecode = exports.generateRedeemScript = exports.replaceBytecodeNop = exports.encodeNullDataScript = exports.calculateBytesize = exports.countOpcodes = exports.bytecodeToAsm = exports.asmToBytecode = exports.bytecodeToScript = exports.scriptToBytecode = exports.asmToScript = exports.scriptToAsm = exports.Op = exports.IntrospectionOp = void 0; | ||
const libauth_1 = require("@bitauth/libauth"); | ||
const data_1 = require("./data"); | ||
const cashproof_optimisations_1 = __importDefault(require("./cashproof-optimisations")); | ||
// TODO: Replace this when these opcodes are in Libauth | ||
var IntrospectionOp; | ||
(function (IntrospectionOp) { | ||
IntrospectionOp[IntrospectionOp["OP_INPUTINDEX"] = 192] = "OP_INPUTINDEX"; | ||
IntrospectionOp[IntrospectionOp["OP_ACTIVEBYTECODE"] = 193] = "OP_ACTIVEBYTECODE"; | ||
IntrospectionOp[IntrospectionOp["OP_TXVERSION"] = 194] = "OP_TXVERSION"; | ||
IntrospectionOp[IntrospectionOp["OP_TXINPUTCOUNT"] = 195] = "OP_TXINPUTCOUNT"; | ||
IntrospectionOp[IntrospectionOp["OP_TXOUTPUTCOUNT"] = 196] = "OP_TXOUTPUTCOUNT"; | ||
IntrospectionOp[IntrospectionOp["OP_TXLOCKTIME"] = 197] = "OP_TXLOCKTIME"; | ||
IntrospectionOp[IntrospectionOp["OP_UTXOVALUE"] = 198] = "OP_UTXOVALUE"; | ||
IntrospectionOp[IntrospectionOp["OP_UTXOBYTECODE"] = 199] = "OP_UTXOBYTECODE"; | ||
IntrospectionOp[IntrospectionOp["OP_OUTPOINTTXHASH"] = 200] = "OP_OUTPOINTTXHASH"; | ||
IntrospectionOp[IntrospectionOp["OP_OUTPOINTINDEX"] = 201] = "OP_OUTPOINTINDEX"; | ||
IntrospectionOp[IntrospectionOp["OP_INPUTBYTECODE"] = 202] = "OP_INPUTBYTECODE"; | ||
IntrospectionOp[IntrospectionOp["OP_INPUTSEQUENCENUMBER"] = 203] = "OP_INPUTSEQUENCENUMBER"; | ||
IntrospectionOp[IntrospectionOp["OP_OUTPUTVALUE"] = 204] = "OP_OUTPUTVALUE"; | ||
IntrospectionOp[IntrospectionOp["OP_OUTPUTBYTECODE"] = 205] = "OP_OUTPUTBYTECODE"; | ||
})(IntrospectionOp = exports.IntrospectionOp || (exports.IntrospectionOp = {})); | ||
exports.Op = libauth_1.OpcodesBCH; | ||
@@ -12,0 +30,0 @@ function scriptToAsm(script) { |
@@ -56,3 +56,3 @@ "use strict"; | ||
[PrimitiveType.PUBKEY]: [PrimitiveType.PUBKEY], | ||
[PrimitiveType.SIG]: [PrimitiveType.SIG, PrimitiveType.DATASIG], | ||
[PrimitiveType.SIG]: [PrimitiveType.SIG], | ||
[PrimitiveType.DATASIG]: [PrimitiveType.DATASIG], | ||
@@ -97,3 +97,3 @@ [PrimitiveType.ANY]: [], | ||
if (to === PrimitiveType.INT) | ||
return !from.bound || from.bound <= 4; | ||
return !from.bound || from.bound <= 8; | ||
// Can't cast bytes to bool or string | ||
@@ -100,0 +100,0 @@ if (to === PrimitiveType.BOOL) |
@@ -7,3 +7,3 @@ export interface AbiInput { | ||
name: string; | ||
covenant: boolean; | ||
covenant?: boolean; | ||
inputs: AbiInput[]; | ||
@@ -10,0 +10,0 @@ } |
export declare function encodeBool(bool: boolean): Uint8Array; | ||
export declare function decodeBool(encodedBool: Uint8Array): boolean; | ||
export declare function encodeInt(int: number): Uint8Array; | ||
export declare function encodeInt(int: number | bigint): Uint8Array; | ||
export declare function decodeInt(encodedInt: Uint8Array, maxLength?: number): number; | ||
@@ -5,0 +5,0 @@ export declare function encodeString(str: string): Uint8Array; |
import { OpcodesBCH } from '@bitauth/libauth'; | ||
export declare enum IntrospectionOp { | ||
OP_INPUTINDEX = 192, | ||
OP_ACTIVEBYTECODE = 193, | ||
OP_TXVERSION = 194, | ||
OP_TXINPUTCOUNT = 195, | ||
OP_TXOUTPUTCOUNT = 196, | ||
OP_TXLOCKTIME = 197, | ||
OP_UTXOVALUE = 198, | ||
OP_UTXOBYTECODE = 199, | ||
OP_OUTPOINTTXHASH = 200, | ||
OP_OUTPOINTINDEX = 201, | ||
OP_INPUTBYTECODE = 202, | ||
OP_INPUTSEQUENCENUMBER = 203, | ||
OP_OUTPUTVALUE = 204, | ||
OP_OUTPUTBYTECODE = 205 | ||
} | ||
export declare const Op: typeof OpcodesBCH; | ||
@@ -14,3 +30,3 @@ export declare type Op = number; | ||
export declare function calculateBytesize(script: Script): number; | ||
export declare function encodeNullDataScript(chunks: (number | Uint8Array)[]): Uint8Array; | ||
export declare function encodeNullDataScript(chunks: OpOrData[]): Uint8Array; | ||
/** | ||
@@ -17,0 +33,0 @@ * When cutting out the tx.bytecode preimage variable, the compiler does not know |
import { OpcodesBCH, encodeDataPush, parseBytecode, serializeAuthenticationInstructions, hexToBin, disassembleBytecodeBCH, flattenBinArray, } from '@bitauth/libauth'; | ||
import { decodeInt, encodeInt } from './data'; | ||
import OptimisationsEquivFile from './cashproof-optimisations'; | ||
// TODO: Replace this when these opcodes are in Libauth | ||
export var IntrospectionOp; | ||
(function (IntrospectionOp) { | ||
IntrospectionOp[IntrospectionOp["OP_INPUTINDEX"] = 192] = "OP_INPUTINDEX"; | ||
IntrospectionOp[IntrospectionOp["OP_ACTIVEBYTECODE"] = 193] = "OP_ACTIVEBYTECODE"; | ||
IntrospectionOp[IntrospectionOp["OP_TXVERSION"] = 194] = "OP_TXVERSION"; | ||
IntrospectionOp[IntrospectionOp["OP_TXINPUTCOUNT"] = 195] = "OP_TXINPUTCOUNT"; | ||
IntrospectionOp[IntrospectionOp["OP_TXOUTPUTCOUNT"] = 196] = "OP_TXOUTPUTCOUNT"; | ||
IntrospectionOp[IntrospectionOp["OP_TXLOCKTIME"] = 197] = "OP_TXLOCKTIME"; | ||
IntrospectionOp[IntrospectionOp["OP_UTXOVALUE"] = 198] = "OP_UTXOVALUE"; | ||
IntrospectionOp[IntrospectionOp["OP_UTXOBYTECODE"] = 199] = "OP_UTXOBYTECODE"; | ||
IntrospectionOp[IntrospectionOp["OP_OUTPOINTTXHASH"] = 200] = "OP_OUTPOINTTXHASH"; | ||
IntrospectionOp[IntrospectionOp["OP_OUTPOINTINDEX"] = 201] = "OP_OUTPOINTINDEX"; | ||
IntrospectionOp[IntrospectionOp["OP_INPUTBYTECODE"] = 202] = "OP_INPUTBYTECODE"; | ||
IntrospectionOp[IntrospectionOp["OP_INPUTSEQUENCENUMBER"] = 203] = "OP_INPUTSEQUENCENUMBER"; | ||
IntrospectionOp[IntrospectionOp["OP_OUTPUTVALUE"] = 204] = "OP_OUTPUTVALUE"; | ||
IntrospectionOp[IntrospectionOp["OP_OUTPUTBYTECODE"] = 205] = "OP_OUTPUTBYTECODE"; | ||
})(IntrospectionOp || (IntrospectionOp = {})); | ||
export const Op = OpcodesBCH; | ||
@@ -5,0 +23,0 @@ export function scriptToAsm(script) { |
@@ -50,3 +50,3 @@ export class ArrayType { | ||
[PrimitiveType.PUBKEY]: [PrimitiveType.PUBKEY], | ||
[PrimitiveType.SIG]: [PrimitiveType.SIG, PrimitiveType.DATASIG], | ||
[PrimitiveType.SIG]: [PrimitiveType.SIG], | ||
[PrimitiveType.DATASIG]: [PrimitiveType.DATASIG], | ||
@@ -91,3 +91,3 @@ [PrimitiveType.ANY]: [], | ||
if (to === PrimitiveType.INT) | ||
return !from.bound || from.bound <= 4; | ||
return !from.bound || from.bound <= 8; | ||
// Can't cast bytes to bool or string | ||
@@ -94,0 +94,0 @@ if (to === PrimitiveType.BOOL) |
{ | ||
"name": "@cashscript/utils", | ||
"version": "0.6.5", | ||
"version": "0.7.0-next.0", | ||
"description": "CashScript utilities and types", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
73514
1417