scrypt-ts
Advanced tools
Comparing version 0.1.5-beta.1 to 0.1.5-beta.2
@@ -292,3 +292,3 @@ import { SigHashType } from "scryptlib"; | ||
static buildOutput(outputScript: ByteString, outputSatoshis: bigint): ByteString; | ||
static buildPublicKeyHashScript(pubKeyHash: PubKeyHash): ByteString; | ||
static buildPublicKeyHashScript(pubKeyHash: PubKeyHash | ByteString): ByteString; | ||
static buildOpreturnScript(data: ByteString): ByteString; | ||
@@ -295,0 +295,0 @@ } |
@@ -446,3 +446,3 @@ "use strict"; | ||
return (0, types_1.toByteString)(OpCode.OP_DUP) + (0, types_1.toByteString)(OpCode.OP_HASH160) + pack(Constants.PubKeyHashLen /* "OP_PUSHDATA0" */) | ||
+ (0, types_1.toByteString)(pubKeyHash) + (0, types_1.toByteString)(OpCode.OP_EQUALVERIFY) + (0, types_1.toByteString)(OpCode.OP_CHECKSIG); | ||
+ pubKeyHash + (0, types_1.toByteString)(OpCode.OP_EQUALVERIFY) + (0, types_1.toByteString)(OpCode.OP_CHECKSIG); | ||
} | ||
@@ -449,0 +449,0 @@ // build false OPRETURN script from data payload |
@@ -1,2 +0,3 @@ | ||
import { Bytes, PubKey, Sig, SigHashPreimage, Ripemd160, PubKeyHash, Sha256, Sha1, OpCodeType, SigHashType } from "scryptlib"; | ||
import { Bytes, SigHashPreimage } from "scryptlib"; | ||
import { SubBytes } from "scryptlib/dist/scryptTypes"; | ||
export { PubKey, Sig, SigHashPreimage, PrivKey, Ripemd160, PubKeyHash, Sha256, Sha1, OpCodeType, SigHashType } from "scryptlib"; | ||
@@ -16,3 +17,3 @@ /** | ||
*/ | ||
export declare function toByteString<T extends string>(str: HexType<T> | PubKey | Sig | SigHashPreimage | Ripemd160 | PubKeyHash | Sha256 | Sha1 | OpCodeType | SigHashType): ByteString; | ||
export declare function toByteString<T extends string>(str: HexType<T> | SubBytes | SigHashPreimage): ByteString; | ||
/** | ||
@@ -19,0 +20,0 @@ * Converts a utf8 literal to string. |
import "reflect-metadata"; | ||
import { VerifyResult, bsv, ContractDescription } from "scryptlib"; | ||
import { SigHashPreimage, SigHashType, Sig, PubKey, PrivKey } from "./builtins/types"; | ||
import { SigHashPreimage, SigHashType, Sig, PubKey, PrivKey, ByteString } from "./builtins/types"; | ||
/** | ||
@@ -18,3 +18,27 @@ * The input point where the smart contract is spent by the transaction | ||
}; | ||
export declare type UTXO = { | ||
scriptCode: ByteString; | ||
value: bigint; | ||
outpoint: Outpoint; | ||
}; | ||
export declare type Outpoint = { | ||
txid: ByteString; | ||
outputIndex: bigint; | ||
}; | ||
/** | ||
* ScriptContext contains all the information in the transaction's preimage. | ||
* The preimage is automatically generated during the user's construction of the transaction, | ||
* and the user does not need to calculate it explicitly | ||
*/ | ||
export declare type ScriptContext = { | ||
nVersion: ByteString; | ||
utxo: UTXO; | ||
hashPrevouts: ByteString; | ||
hashSequence: ByteString; | ||
nSequence: bigint; | ||
hashOutputs: ByteString; | ||
nLocktime: bigint; | ||
sigHashType: SigHashType; | ||
}; | ||
/** | ||
* The main contract class. To write a contract, extend this class as such: | ||
@@ -30,4 +54,5 @@ * @example | ||
export declare class SmartContract { | ||
lockTo?: TxOutputRef; | ||
unlockFrom?: TxInputRef; | ||
private _lockTo?; | ||
private _unlockFrom?; | ||
ctx?: ScriptContext; | ||
private static DelegateClazz; | ||
@@ -38,2 +63,4 @@ private delegateInstance; | ||
private static _getScryptFile; | ||
static _getCtxMethods(): string; | ||
getCtxMethods(): string; | ||
private getDelegateClazz; | ||
@@ -51,3 +78,4 @@ constructor(...args: any[]); | ||
updateStateSigHashType(txPreimage: SigHashPreimage, amount: bigint, sigHashType: SigHashType): boolean; | ||
getStateScript(): string; | ||
buildStateOutput(amount: bigint): ByteString; | ||
getStateScript(): ByteString; | ||
/** | ||
@@ -78,2 +106,6 @@ * verifies an ECDSA signature. It takes two inputs from the stack, a public key (on top of the stack) and an ECDSA signature in its DER_CANONISED format concatenated with sighash flags. It outputs true or false on the stack based on whether the signature check passes or fails. | ||
private buildEntryMethodCall; | ||
set unlockFrom(ref: TxInputRef); | ||
get unlockFrom(): TxInputRef | undefined; | ||
get lockTo(): TxOutputRef | undefined; | ||
set lockTo(ref: TxOutputRef); | ||
} |
@@ -18,8 +18,2 @@ "use strict"; | ||
}); | ||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | ||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | ||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | ||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; | ||
return c > 3 && r && Object.defineProperty(target, key, r), r; | ||
}; | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
@@ -32,5 +26,2 @@ if (mod && mod.__esModule) return mod; | ||
}; | ||
var __metadata = (this && this.__metadata) || function (k, v) { | ||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -50,4 +41,4 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
const lodash_clonedeep_1 = __importDefault(require("lodash.clonedeep")); | ||
const decorators_1 = require("./decorators"); | ||
const library_1 = require("./library"); | ||
const typeCheck_1 = require("scryptlib/dist/typeCheck"); | ||
/** | ||
@@ -124,2 +115,8 @@ * The main contract class. To write a contract, extend this class as such: | ||
} | ||
static _getCtxMethods() { | ||
return Reflect.getMetadata("scrypt:ctxMethods", this); | ||
} | ||
getCtxMethods() { | ||
return Object.getPrototypeOf(this).constructor._getCtxMethods(); | ||
} | ||
getDelegateClazz() { | ||
@@ -174,3 +171,8 @@ return Object.getOwnPropertyDescriptor(this.constructor, 'DelegateClazz')?.value; | ||
statePropKeys.forEach(statePropKey => { | ||
this.delegateInstance[statePropKey] = this[statePropKey]; | ||
if (this[statePropKey] instanceof library_1.SmartContractLib) { | ||
this.delegateInstance[statePropKey] = this[statePropKey].getState(); | ||
} | ||
else { | ||
this.delegateInstance[statePropKey] = this[statePropKey]; | ||
} | ||
}); | ||
@@ -202,6 +204,9 @@ } | ||
(0, functions_1.assert)(this.checkPreimageSigHashType(txPreimage, sigHashType)); | ||
let outputScript = this.getStateScript(); | ||
let output = functions_1.Utils.buildOutput(outputScript, amount); | ||
let output = this.buildStateOutput(amount); | ||
return (0, functions_1.hash256)(output) == functions_1.SigHash.hashOutputs(txPreimage); | ||
} | ||
buildStateOutput(amount) { | ||
let outputScript = this.getStateScript(); | ||
return functions_1.Utils.buildOutput(outputScript, amount); | ||
} | ||
getStateScript() { | ||
@@ -211,40 +216,18 @@ let sBuf = functions_1.VarIntWriter.writeBool(false); | ||
.forEach(p => { | ||
if (p.type === 'int') { | ||
sBuf += functions_1.VarIntWriter.writeInt(this[p.name]); | ||
} | ||
else if (p.type === 'bool') { | ||
sBuf += functions_1.VarIntWriter.writeBool(this[p.name]); | ||
} | ||
else if (p.type === 'bytes') { | ||
sBuf += functions_1.VarIntWriter.writeBytes(this[p.name]); | ||
} | ||
else if (p.type === 'PrivKey') { | ||
const [val, _] = (0, scryptlib_1.parseLiteral)(this[p.name]); | ||
sBuf += functions_1.VarIntWriter.writeInt(val); | ||
} | ||
else if (p.type === 'PubKey') { | ||
sBuf += functions_1.VarIntWriter.writeBytes((0, types_1.toByteString)(this[p.name])); | ||
} | ||
else if (p.type === 'Ripemd160') { | ||
sBuf += functions_1.VarIntWriter.writeBytes((0, types_1.toByteString)(this[p.name])); | ||
} | ||
else if (p.type === 'Sig') { | ||
sBuf += functions_1.VarIntWriter.writeBytes((0, types_1.toByteString)(this[p.name])); | ||
} | ||
else if (p.type === 'Sha1') { | ||
sBuf += functions_1.VarIntWriter.writeBytes((0, types_1.toByteString)(this[p.name])); | ||
} | ||
else if (p.type === 'SigHashPreimage') { | ||
sBuf += functions_1.VarIntWriter.writeBytes((0, types_1.toByteString)(this[p.name])); | ||
} | ||
else if (p.type === 'Sha256') { | ||
sBuf += functions_1.VarIntWriter.writeBytes((0, types_1.toByteString)(this[p.name])); | ||
} | ||
else if (p.type === 'SigHashType') { | ||
sBuf += functions_1.VarIntWriter.writeBytes((0, types_1.toByteString)(this[p.name])); | ||
} | ||
else if (p.type === 'OpCodeType') { | ||
sBuf += functions_1.VarIntWriter.writeBytes((0, types_1.toByteString)(this[p.name])); | ||
} | ||
// TODO: struct | ||
(0, typeCheck_1.flatternArg)(Object.assign({}, p, { | ||
value: this[p.name] | ||
}), this.delegateInstance.resolver, { | ||
state: true, | ||
ignoreValue: false | ||
}).forEach(p => { | ||
if (['bytes', 'PubKey', 'Ripemd160', 'Sig', 'Sha1', 'SigHashPreimage', 'Sha256', 'SigHashType', 'OpCodeType'].includes(p.type)) { | ||
sBuf += functions_1.VarIntWriter.writeBytes(p.value); | ||
} | ||
else if (p.type === 'int' || p.type === 'PrivKey') { | ||
sBuf += functions_1.VarIntWriter.writeInt(p.value); | ||
} | ||
else if (p.type === 'bool') { | ||
sBuf += functions_1.VarIntWriter.writeBool(p.value); | ||
} | ||
}); | ||
}); | ||
@@ -264,3 +247,3 @@ return this.codePart + functions_1.VarIntWriter.serializeState(sBuf); | ||
if (!this.unlockFrom) { | ||
throw new Error('unlockingFrom undefined when checkSig executes'); | ||
throw new Error('unlockFrom should be set when checkSig executes'); | ||
} | ||
@@ -347,5 +330,11 @@ try { | ||
callDelegatedMethod(methodName, ...args) { | ||
const entryMethods = this.getDelegateClazz().abi.map(func => func.name); | ||
if (entryMethods.includes(methodName)) { | ||
const abi = this.getDelegateClazz().abi.find(func => func.name === methodName); | ||
if (abi) { | ||
// only entry (public) method calls will be delegated to the target instance. | ||
// If the actual parameter is missing, but the last parameter type is `SigHashPreimage`, automatically add txPreimage | ||
if (abi.params.length === (args.length + 1) | ||
&& abi.params[abi.params.length - 1].type === "SigHashPreimage") { | ||
const txPreimage = (0, types_1.SigHashPreimage)(this._unlockFrom.tx.getPreimage(this._unlockFrom.inputIndex)); | ||
args.push(txPreimage); | ||
} | ||
return this.getDelegateClazz().prototype[methodName].call(this.delegateInstance, ...args); | ||
@@ -379,52 +368,35 @@ } | ||
} | ||
set unlockFrom(ref) { | ||
this._unlockFrom = ref; | ||
const txPreimage = (0, types_1.SigHashPreimage)(ref.tx.getPreimage(ref.inputIndex)); | ||
const outpoint = functions_1.SigHash.outpoint(txPreimage); | ||
this.ctx = { | ||
nVersion: functions_1.SigHash.nVersion(txPreimage), | ||
utxo: { | ||
value: functions_1.SigHash.value(txPreimage), | ||
scriptCode: functions_1.SigHash.scriptCode(txPreimage), | ||
outpoint: { | ||
txid: outpoint.slice(0, 32 * 2), | ||
outputIndex: functions_1.Utils.fromLEUnsigned(outpoint.slice(32 * 2)) | ||
} | ||
}, | ||
hashPrevouts: functions_1.SigHash.hashPrevouts(txPreimage), | ||
hashSequence: functions_1.SigHash.hashSequence(txPreimage), | ||
nSequence: functions_1.SigHash.nSequence(txPreimage), | ||
hashOutputs: functions_1.SigHash.hashOutputs(txPreimage), | ||
nLocktime: functions_1.SigHash.nLocktime(txPreimage), | ||
sigHashType: functions_1.SigHash.sigHashType(txPreimage), | ||
}; | ||
} | ||
get unlockFrom() { | ||
return this._unlockFrom; | ||
} | ||
get lockTo() { | ||
return this._lockTo; | ||
} | ||
set lockTo(ref) { | ||
this._lockTo = ref; | ||
} | ||
} | ||
__decorate([ | ||
decorators_1.method, | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [String, BigInt, String]), | ||
__metadata("design:returntype", Boolean) | ||
], SmartContract.prototype, "updateStateSigHashType", null); | ||
__decorate([ | ||
decorators_1.method, | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", []), | ||
__metadata("design:returntype", String) | ||
], SmartContract.prototype, "getStateScript", null); | ||
__decorate([ | ||
decorators_1.method, | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [String, String]), | ||
__metadata("design:returntype", Boolean) | ||
], SmartContract.prototype, "checkSig", null); | ||
__decorate([ | ||
decorators_1.method, | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [String, BigInt, String, BigInt, BigInt, String, String]), | ||
__metadata("design:returntype", Boolean) | ||
], SmartContract.prototype, "checkPreimageAdvanced", null); | ||
__decorate([ | ||
decorators_1.method, | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [String, String]), | ||
__metadata("design:returntype", Boolean) | ||
], SmartContract.prototype, "checkPreimageSigHashType", null); | ||
__decorate([ | ||
decorators_1.method, | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [String]), | ||
__metadata("design:returntype", Boolean) | ||
], SmartContract.prototype, "checkPreimage", null); | ||
__decorate([ | ||
decorators_1.method, | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [Array, Array]), | ||
__metadata("design:returntype", Boolean) | ||
], SmartContract.prototype, "checkMultiSig", null); | ||
__decorate([ | ||
decorators_1.method, | ||
__metadata("design:type", Function), | ||
__metadata("design:paramtypes", [String, BigInt]), | ||
__metadata("design:returntype", Boolean) | ||
], SmartContract.prototype, "updateState", null); | ||
exports.SmartContract = SmartContract; | ||
//# sourceMappingURL=contract.js.map |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
export declare function method(target: any, methodName: string, descriptor: PropertyDescriptor): PropertyDescriptor; | ||
export declare function method(sigHashType?: import("scryptlib/dist").SigHashType): (target: any, methodName: string, descriptor: PropertyDescriptor) => PropertyDescriptor; | ||
/** | ||
@@ -8,0 +8,0 @@ * Indicates whether the property is an property of a contract, and ordinary class properties cannot be accessed in contract methods |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.prop = exports.method = void 0; | ||
const dist_1 = require("scryptlib/dist"); | ||
const functions_1 = require("./builtins/functions"); | ||
/** | ||
@@ -8,37 +10,49 @@ * Indicates whether the method is a contract method, and ordinary methods do not affect the execution of the contract | ||
*/ | ||
function method(target, methodName, descriptor) { | ||
const originalMethod = descriptor.value; | ||
const newDescriptor = { | ||
configurable: true, | ||
enumerable: false, | ||
get() { | ||
const wrappedMethod = (...args) => { | ||
// static method on subclasses of `SmartContract` | ||
const isSmartContractLibStatic = typeof target === "function" | ||
&& Object.getPrototypeOf(this).name === "SmartContractLib"; | ||
// instance method on subclasses of `SmartContractLib` | ||
const isSmartContractLibMethod = typeof target === "object" | ||
&& Object.getPrototypeOf(this.constructor).name === "SmartContractLib"; | ||
if (isSmartContractLibStatic || isSmartContractLibMethod) { | ||
return originalMethod.apply(this, args); | ||
} | ||
// static method on subclasses of `SmartContract` | ||
const isSmartContractStatic = typeof target === "function" | ||
&& Object.getPrototypeOf(this).name === "SmartContract"; | ||
// instance method on subclasses of `SmartContract` | ||
const isSmartContractMethod = typeof target === "object" | ||
&& Object.getPrototypeOf(this.constructor).name === "SmartContract"; | ||
if (isSmartContractStatic || isSmartContractMethod) { | ||
// update `this.entryMethodCall` iff the update flag is true & its value is undefined. | ||
if (this.enableUpdateEMC && !this.entryMethodCall) { | ||
this.entryMethodCall = this.callDelegatedMethod(methodName, ...args); | ||
function method(sigHashType = functions_1.SigHash.ALL) { | ||
return function (target, methodName, descriptor) { | ||
const originalMethod = descriptor.value; | ||
const newDescriptor = { | ||
configurable: true, | ||
enumerable: false, | ||
get() { | ||
const wrappedMethod = (...args) => { | ||
// static method on subclasses of `SmartContract` | ||
const isSmartContractLibStatic = typeof target === "function" | ||
&& Object.getPrototypeOf(this).name === "SmartContractLib"; | ||
// instance method on subclasses of `SmartContractLib` | ||
const isSmartContractLibMethod = typeof target === "object" | ||
&& Object.getPrototypeOf(this.constructor).name === "SmartContractLib"; | ||
if (isSmartContractLibStatic || isSmartContractLibMethod) { | ||
return originalMethod.apply(this, args); | ||
} | ||
return originalMethod.apply(this, args); | ||
} | ||
throw new Error(`@method decorator used on \`${this.name || this.constructor.name}#${methodName}\`, it should only be used in subclasses of \`SmartContract\``); | ||
}; | ||
return wrappedMethod; | ||
} | ||
// static method on subclasses of `SmartContract` | ||
const isSmartContractStatic = typeof target === "function" | ||
&& Object.getPrototypeOf(this).name === "SmartContract"; | ||
// instance method on subclasses of `SmartContract` | ||
const isSmartContractMethod = typeof target === "object" | ||
&& Object.getPrototypeOf(this.constructor).name === "SmartContract"; | ||
if (isSmartContractStatic || isSmartContractMethod) { | ||
// update `this.entryMethodCall` iff the update flag is true & its value is undefined. | ||
if (this.enableUpdateEMC && !this.entryMethodCall) { | ||
this.entryMethodCall = this.callDelegatedMethod(methodName, ...args); | ||
const ctxMethods = this.getCtxMethods(); | ||
// check preimage before run the method | ||
if (ctxMethods.includes(methodName)) { | ||
if (!this.unlockFrom) { | ||
throw new Error('unlockFrom should be set'); | ||
} | ||
const ref = this.unlockFrom; | ||
const txPreimage = (0, dist_1.SigHashPreimage)(ref.tx.getPreimage(ref.inputIndex)); | ||
(0, functions_1.assert)(this.checkPreimageSigHashType(txPreimage, sigHashType)); | ||
} | ||
} | ||
return originalMethod.apply(this, args); | ||
} | ||
throw new Error(`@method decorator used on \`${this.name || this.constructor.name}#${methodName}\`, it should only be used in subclasses of \`SmartContract\``); | ||
}; | ||
return wrappedMethod; | ||
} | ||
}; | ||
return newDescriptor; | ||
}; | ||
return newDescriptor; | ||
} | ||
@@ -45,0 +59,0 @@ exports.method = method; |
import "reflect-metadata"; | ||
import { SupportedParamType } from "scryptlib"; | ||
import { StructObject, SupportedParamType } from "scryptlib"; | ||
/** | ||
@@ -17,2 +17,3 @@ * The contract library class. To write a contract library, extend this class as such: | ||
getArgs(): SupportedParamType[]; | ||
getState(): StructObject; | ||
} |
@@ -28,4 +28,21 @@ "use strict"; | ||
} | ||
getState() { | ||
return Object.keys(this).reduce((acc, key) => { | ||
if (typeof this[key] === 'bigint' || typeof this[key] === 'boolean' || typeof this[key] === 'string') { | ||
return Object.assign(acc, { | ||
[key]: this[key] | ||
}); | ||
} | ||
else if (this[key] instanceof SmartContractLib) { | ||
return Object.assign(acc, { | ||
[key]: this[key].getState() | ||
}); | ||
} | ||
else { | ||
return acc; | ||
} | ||
}, {}); | ||
} | ||
} | ||
exports.SmartContractLib = SmartContractLib; | ||
//# sourceMappingURL=library.js.map |
@@ -63,6 +63,12 @@ "use strict"; | ||
const compilerHost = maybeHost ?? tsInstance.createCompilerHost(compilerOptions, true); | ||
if (compilerHost.fileCache !== undefined) { | ||
// return the already patched host | ||
return compilerHost; | ||
} | ||
const cacheableVersion = (originalFunc) => { | ||
return function (fileName) { | ||
if (fileCache.has(fileName)) { | ||
return fileCache.get(fileName); | ||
const file = fileCache.get(fileName); | ||
fileCache.delete(fileName); // patch for making `tsc --watch` to work | ||
return file; | ||
} | ||
@@ -81,3 +87,3 @@ const sourceFile = originalFunc.apply(void 0, Array.from(arguments)); | ||
} | ||
function applyInjections(tsInstance, sourceFile, injections) { | ||
function applyInjections(tsInstance, host, sourceFile, injections) { | ||
const { fileName, text: originText, languageVersion } = sourceFile; | ||
@@ -95,3 +101,5 @@ let updatedText = ""; | ||
updatedText += originText.slice(lastInjectedIdx); | ||
return tsInstance.createSourceFile(fileName, updatedText, languageVersion); | ||
const newFile = tsInstance.createSourceFile(fileName, updatedText, languageVersion, true); | ||
newFile.version = host.createHash(updatedText); // patch for making `tsc --watch` work | ||
return newFile; | ||
} | ||
@@ -105,3 +113,2 @@ function transformFile(host, checker, tsRootDir, scryptOutDir, indexer, ctx) { | ||
} | ||
// console.log('scanning...', sourceFile.fileName); | ||
// ts source file to root dir relative path which will be keeped in scrypt output structure. | ||
@@ -124,3 +131,3 @@ const root2srcRelativePath = path.relative(tsRootDir, sourceFile.fileName); | ||
pos: classNode.end + 1, | ||
code: `Reflect.defineMetadata("scrypt:file", "${scryptFile}", ${className});Reflect.defineMetadata("__filename", __filename, ${className});` | ||
code: `Reflect.defineMetadata("scrypt:file", "${scryptFile}", ${className});Reflect.defineMetadata("__filename", __filename, ${className});Reflect.defineMetadata("scrypt:ctxMethods", "${transpiler.ctxMethods.join(',')}", ${className});` | ||
}); | ||
@@ -133,3 +140,3 @@ } | ||
tsInstance.visitEachChild(sourceFile, visitor, ctx); | ||
const updatedSourceFile = applyInjections(tsInstance, sourceFile, injections); | ||
const updatedSourceFile = applyInjections(tsInstance, host, sourceFile, injections); | ||
host.fileCache.set(sourceFile.fileName, updatedSourceFile); | ||
@@ -136,0 +143,0 @@ return updatedSourceFile; |
@@ -24,10 +24,11 @@ import * as ts from 'typescript'; | ||
} | ||
export declare type Location = { | ||
export declare type Range = { | ||
fileName: string; | ||
coordinates: ts.LineAndCharacter; | ||
start: ts.LineAndCharacter; | ||
end: ts.LineAndCharacter; | ||
}; | ||
export declare class TranspileError { | ||
message: string; | ||
from: Location; | ||
constructor(messge: string, from: Location); | ||
srcRange: Range; | ||
constructor(messge: string, srcRange: Range); | ||
} | ||
@@ -43,8 +44,15 @@ export declare class Transpiler { | ||
_indexer: Indexer; | ||
_existsStateProp: boolean; | ||
_ctxMethods: Array<string>; | ||
_localTypeSymbols: Map<string, ts.Symbol>; | ||
_importedTypeSymbols: Map<string, ts.Symbol>; | ||
constructor(sourceFile: ts.SourceFile, checker: ts.TypeChecker, scryptOutDir: string, scryptOutFile: string, indexer: Indexer); | ||
get ctxMethods(): string[]; | ||
transform(): EmittedSection; | ||
isTransformable(): boolean; | ||
private outputScrypt; | ||
private diagose; | ||
private outputDiagnostic; | ||
private checkTransformedScrypt; | ||
private processCompileResult; | ||
private generateSourceMapFile; | ||
@@ -55,3 +63,3 @@ private updateIndex; | ||
private getCoordinates; | ||
private getLocation; | ||
private getRange; | ||
private getResolvedType; | ||
@@ -70,3 +78,4 @@ private findDeclarationFile; | ||
private transformModifiers; | ||
static isCTCProperty(node: ts.HasModifiers): boolean; | ||
isCTCProperty(node: ts.HasModifiers): boolean; | ||
isPublic(node: ts.HasModifiers): boolean; | ||
private transformImports; | ||
@@ -73,0 +82,0 @@ private transformTypeLiteralAndInterfaces; |
{ | ||
"name": "scrypt-ts", | ||
"version": "0.1.5-beta.1", | ||
"version": "0.1.5-beta.2", | ||
"description": "A toolset for building sCrypt smart contract applications on Bitcoin SV network written in typescript.", | ||
@@ -14,5 +14,2 @@ "main": "dist/index.js", | ||
"test": "cd test && mocha 'out/test/local/**/*.test.js' --timeout 1200000", | ||
"ci": "sh ci-setup.sh", | ||
"precitest": "npm run pretest", | ||
"citest": "npm run ci && cd test && mocha 'out/test/local/**/*.test.js' --timeout 1200000", | ||
"pretestnet": "cross-env TS_NODE_PROJECT=test/tsconfig.json tsc test/testnet/hashpuzzle.ts", | ||
@@ -19,0 +16,0 @@ "testnet": "cd test && node out/test/testnet/hashpuzzle.js", |
Sorry, the diff of this file is too big to display
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
184774
3923