Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrypt-ts: remove scryptType class, use type #211

Merged
merged 67 commits into from
Jan 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
4f6227c
add error log
Nov 17, 2022
be8178d
don't clean if output sourceMap
Nov 17, 2022
458214d
add bsv type
Nov 17, 2022
266f872
fix compileAsync
Nov 17, 2022
cadd53a
rename to isGenesis
Nov 18, 2022
720f0dc
pump version to 1.1.0-beta2
Nov 18, 2022
aa68904
add dependencies
Nov 23, 2022
e55a716
remove types/bsv
Dec 3, 2022
dc72584
update setInputScript
Dec 3, 2022
45ccc74
remove log
Dec 3, 2022
50bfd74
1.1.0-beta.4
Dec 3, 2022
21e6b96
update bsv
Dec 3, 2022
ae732c9
1.1.0-beta.5
Dec 3, 2022
3c05705
update bsv.d.ts
Dec 3, 2022
c42455b
1.1.0-beta.6
Dec 3, 2022
d635412
update bsv
Dec 4, 2022
3624991
update package-lock.json
Dec 4, 2022
40bd338
1.1.0-beta.7
Dec 4, 2022
d5c9f08
optimize cli
Dec 5, 2022
89af021
update bsv
Dec 5, 2022
10adf97
1.1.0-beta.8
Dec 5, 2022
ffc81e6
delete no use file
Dec 5, 2022
67663e7
don't exit when no compiler foud
Dec 5, 2022
42458be
1.1.0-beta.9
Dec 5, 2022
5e2b25e
Fix findcompile
Dec 5, 2022
6fab7d5
1.1.0-beta.10
Dec 5, 2022
f8f4244
bind scrypt compile version
Dec 5, 2022
fc3fab7
1.1.0-beta.11
Dec 5, 2022
9bac5f6
update bsv
Dec 5, 2022
dbceec1
rename
Dec 5, 2022
ac1696b
1.1.0-beta.12
Dec 5, 2022
95cb3cc
compile before publish
Dec 5, 2022
9817423
Fix buildtype error
Dec 6, 2022
84a9f3e
update bsv
Dec 6, 2022
502b439
add test
Dec 6, 2022
16b222d
1.1.0-beta.13
Dec 6, 2022
06e23b9
update bsv
Dec 7, 2022
a0c1437
remove FORKID from sighash flag
Dec 7, 2022
a3e87c0
add md5 function
Dec 8, 2022
3a3ad85
1.1.0-beta.14
Dec 8, 2022
60553e5
Fix ci
Dec 8, 2022
f297345
1.1.0-beta.14
Dec 8, 2022
4e6062a
Fix ci
Dec 8, 2022
00c64db
remove ScryptType class, use type
Dec 18, 2022
abbd3e9
2.0.0-beta.1
Dec 18, 2022
2fb2154
exclude findCompiler
Dec 18, 2022
bd89240
don't run boilerplate now
Dec 18, 2022
090de0d
refactor: add deserializer
Dec 19, 2022
16d6723
Fix export
Dec 19, 2022
5ee3cb7
2.0.0-beta.2
Dec 19, 2022
9878177
use param type, not argument type
Dec 20, 2022
58ac86b
2.0.0-beta.3
Dec 20, 2022
ee5d056
desc files are only contractname.json now
msinkec Dec 29, 2022
6d271a4
Renamed all occurences of desc to artifacts.
msinkec Dec 30, 2022
b6da9f8
update findKeyIndex
Jan 4, 2023
e35091a
2.0.0-beta.4
Jan 4, 2023
1be3cc1
Organized imports and some other fixes to make linting pass.
msinkec Jan 5, 2023
636c32b
Merge pull request #215 from msinkec/scrypt-ts
zhfnjust Jan 5, 2023
bb1c9fe
2.0.0-beta.5
Jan 6, 2023
736c9db
auto calc keyIndex
Jan 7, 2023
0a168e5
2.0.0-beta.6
Jan 7, 2023
b7e1d56
rename to getSortedItem
Jan 7, 2023
b64e19c
Fix genLaunchConfigFile
Jan 7, 2023
f2bcaa0
mirror fix
Jan 7, 2023
f83ad19
run bp test
Jan 8, 2023
5e87c0d
update readme
Jan 8, 2023
820ae9d
update change log
Jan 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Organized imports and some other fixes to make linting pass.
  • Loading branch information
msinkec committed Jan 5, 2023
commit 1be3cc1c16d4dac3906fc49ea8b4cf74b550a2fc
2 changes: 1 addition & 1 deletion docs/preimage_under_codeseparator_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ The following is an example of how to deploy and call the `CheckLockTimeVerifyOC
const amount = 2000

// get locking script
const CLTVOCS = buildContractClass(loadDesc('cltvOCS_debug_desc.json'));
const CLTVOCS = buildContractClass(loadArtifact('cltvOCS_debug.json'));
cltv = new CLTVOCS(1422674);

// lock fund to the script
Expand Down
2 changes: 1 addition & 1 deletion docs/preimage_under_codeseparator_zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ contract CheckLockTimeVerifyOCS {
const amount = 2000

// get locking script
const CLTVOCS = buildContractClass(loadDesc('cltvOCS_debug_desc.json'));
const CLTVOCS = buildContractClass(loadArtifact('cltvOCS_debug.json'));
cltv = new CLTVOCS(1422674);

// lock fund to the script
Expand Down
2 changes: 1 addition & 1 deletion docs/rawstate.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ contract Counter {


```typescript
const Counter = buildContractClass(loadDescription('counter_desc.json'));
const Counter = buildContractClass(loadArtifact('counter.json'));
counter = new Counter();
const dataPart = counter.dataPart;
const dataPartASM = counter.dataPart.toASM();
Expand Down
12 changes: 6 additions & 6 deletions src/abi.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { int2Asm, bsv, genLaunchConfigFile, buildContractCode } from './utils';
import { AbstractContract, TxContext, VerifyResult, AsmVarValues } from './contract';
import { bin2num } from './builtins';
import { ABIEntity, ABIEntityType } from './compilerWrapper';
import { AbstractContract, AsmVarValues, TxContext, VerifyResult } from './contract';
import { deserializeArgfromHex } from './deserializer';
import { SupportedParamType, TypeResolver } from './scryptTypes';
import { ABIEntityType, ABIEntity } from './compilerWrapper';
import { flatternArg } from './typeCheck';
import { toScriptHex } from './serializer';
import { bin2num } from './builtins';
import Stateful from './stateful';
import { deserializeArgfromHex } from './deserializer';
import { flatternArg } from './typeCheck';
import { bsv, buildContractCode, genLaunchConfigFile, int2Asm } from './utils';

export type Script = bsv.Script;

Expand Down
4 changes: 1 addition & 3 deletions src/builtins.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Int, bsv, Ripemd160, Bytes } from '.';
import { ScryptType } from './scryptTypes';
import { toScriptASM } from './serializer';
import { bsv, Bytes, Int, Ripemd160 } from '.';

/**
* bigint can be converted to string with pack
Expand Down
13 changes: 6 additions & 7 deletions src/compilerWrapper.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { ChildProcess, exec, execSync } from 'child_process';
import { existsSync, mkdirSync, readFileSync, renameSync, unlinkSync, writeFileSync } from 'fs';
import { basename, dirname, join } from 'path';
import { execSync, exec, ChildProcess } from 'child_process';
import { readFileSync, writeFileSync, unlinkSync, existsSync, renameSync, mkdirSync } from 'fs';
import rimraf = require('rimraf');
import JSONbig = require('json-bigint');
import {
path2uri, ContractArtifact, findCompiler, CURRENT_CONTRACT_ARTIFACT_VERSION,
buildTypeResolver, TypeResolver, resolveConstValue, hash160, md5
buildTypeResolver, ContractArtifact, CURRENT_CONTRACT_ARTIFACT_VERSION, findCompiler, hash160, md5, path2uri, resolveConstValue, TypeResolver
} from './internal';
import rimraf = require('rimraf');
import JSONbig = require('json-bigint');


const SYNTAX_ERR_REG = /(?<filePath>[^\s]+):(?<line>\d+):(?<column>\d+):\n([^\n]+\n){3}(unexpected (?<unexpected>[^\n]+)\nexpecting (?<expecting>[^\n]+)|(?<message>[^\n]+))/g;
Expand Down Expand Up @@ -529,7 +528,7 @@ function getOutputFilePath(baseDir: string, target: 'ast' | 'asm' | 'hex' | 'art
} else if (target === 'dbg') {
return join(baseDir, `stdin.${target}.json`);
} else if (target === 'artifact') {
return join(baseDir, `stdin.json`);
return join(baseDir, 'stdin.json');
}
return join(baseDir, `stdin_${target}.json`);
}
Expand Down
9 changes: 4 additions & 5 deletions src/contract.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { basename, dirname } from 'path';
import { ABIEntityType, Argument, LibraryEntity, ParamEntity, parseGenericType } from '.';
import { ContractEntity, getFullFilePath, loadSourceMapfromArtifact, OpCode, StaticEntity } from './compilerWrapper';
import {
ABICoder, Arguments, FunctionCall, Script, bsv, DEFAULT_FLAGS, resolveType, path2uri, TypeResolver,
StructEntity, ABIEntity, CompileResult, AliasEntity, hash160, buildContractCode, JSONParserSync, uri2path, findSrcInfoV2, findSrcInfoV1
ABICoder, ABIEntity, AliasEntity, Arguments, bsv, buildContractCode, CompileResult, DEFAULT_FLAGS, findSrcInfoV1, findSrcInfoV2, FunctionCall, hash160, JSONParserSync, path2uri, resolveType, Script, StructEntity, TypeResolver, uri2path
} from './internal';
import { SymbolType, TypeInfo, SupportedParamType, HashedMap, HashedSet, Bytes, isScryptType } from './scryptTypes';
import { basename, dirname } from 'path';
import { checkSupportedParamType, flatternArg } from './typeCheck';
import { Bytes, HashedMap, HashedSet, isScryptType, SupportedParamType, SymbolType, TypeInfo } from './scryptTypes';
import Stateful from './stateful';
import { checkSupportedParamType, flatternArg } from './typeCheck';


export interface TxContext {
Expand Down
2 changes: 1 addition & 1 deletion src/deserializer.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Argument, arrayTypeAndSize, bin2num, isArrayType, LibraryEntity, ParamEntity, StructEntity, SymbolType, TypeResolver } from '.';
import { Bool, Bytes, Int, OpCodeType, PrivKey, PubKey, Ripemd160, ScryptType, Sha1, Sha256, Sig, SigHashPreimage, SigHashType, StructObject, SupportedParamType } from './scryptTypes';
import Stateful from './stateful';
import { ScryptType, Bool, Bytes, Int, PrivKey, PubKey, Ripemd160, SigHashPreimage, Sha1, Sha256, Sig, OpCodeType, SigHashType, SupportedParamType, StructObject } from './scryptTypes';
import { bsv } from './utils';

/**
Expand Down
8 changes: 4 additions & 4 deletions src/findCompiler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@

import { join, resolve } from 'path';
import * as minimist from 'minimist';
import { execSync } from 'child_process';
import { existsSync, readdirSync, statSync } from 'fs';
import * as minimist from 'minimist';
import * as os from 'os';
import { join, resolve } from 'path';

import compareVersions = require('compare-versions');
import { execSync } from 'child_process';
import * as os from 'os';
import showNoCompilerFound = require('../util/showerror');


Expand Down
2 changes: 1 addition & 1 deletion src/serializer.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Bool, Bytes, Int, SupportedParamType, isBytes, ScryptType } from './scryptTypes';
import { Bool, Bytes, Int, isBytes, ScryptType, SupportedParamType } from './scryptTypes';
import { bsv } from './utils';


Expand Down
4 changes: 2 additions & 2 deletions src/stateful.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AbstractContract, Arguments, bin2num, bsv, num2bin, readBytes } from '.';
import { deserializeArgfromHex } from './deserializer';
import { flatternArg, parseLiteral } from './internal';
import { Int, Bytes, SupportedParamType, ScryptType, Bool, PrivKey, PubKey, Sig, Ripemd160, Sha1, Sha256, SigHashType, SigHashPreimage, OpCodeType, TypeResolver, isBytes } from './scryptTypes';
import { flatternArg } from './internal';
import { Bool, Bytes, Int, isBytes, OpCodeType, PrivKey, PubKey, Ripemd160, ScryptType, Sha1, Sha256, Sig, SigHashPreimage, SigHashType, SupportedParamType, TypeResolver } from './scryptTypes';

export default class Stateful {

Expand Down
2 changes: 1 addition & 1 deletion src/typeCheck.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Argument, Arguments, isArrayType, isGenericType, LibraryEntity, ParamEntity, parseGenericType, StructEntity } from '.';
import { parseLiteral, subscript, toGenericType } from './internal';
import { subscript, toGenericType } from './internal';
import { isBytes, ScryptType, StructObject, SupportedParamType, SymbolType, TypeResolver } from './scryptTypes';


Expand Down
22 changes: 8 additions & 14 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
import { pathToFileURL, fileURLToPath } from 'url';
import * as fs from 'fs';
import * as crypto from 'crypto';
import { parseChunked, stringifyStream } from '@discoveryjs/json-ext';
import * as bsv from 'bsv';
import { join, sep } from 'path';
import * as crypto from 'crypto';
import * as fs from 'fs';
import { tmpdir } from 'os';
import { stringifyStream, parseChunked } from '@discoveryjs/json-ext';
import { join, sep } from 'path';
import { decode } from 'sourcemap-codec';
import { fileURLToPath, pathToFileURL } from 'url';

export { bsv };

import {
SupportedParamType, StructEntity, compile,
findCompiler, CompileResult, AliasEntity, AbstractContract, AsmVarValues, TxContext, DebugConfiguration, DebugLaunch, FileUri,
Arguments,
Script, getValidatedHexString, ScryptType, toJSON, isScryptType
} from './internal';
import { ABIEntity, LibraryEntity, num2bin, SymbolType, toLiteralArrayType, TypeInfo } from '.';
import { compileAsync, OpCode, StaticEntity } from './compilerWrapper';
import { VerifyError } from './contract';
import { ABIEntity, bin2num, LibraryEntity, num2bin, SymbolType, toLiteralArrayType, TypeInfo } from '.';
import { arrayTypeAndSizeStr, flatternArg } from './typeCheck';
import { deserializeArgfromHex } from './deserializer';
import { AbstractContract, AliasEntity, AsmVarValues, compile, CompileResult, DebugConfiguration, DebugLaunch, FileUri, findCompiler, getValidatedHexString, isScryptType, Script, ScryptType, StructEntity, SupportedParamType, toJSON, TxContext } from './internal';
import { arrayTypeAndSizeStr } from './typeCheck';

const BN = bsv.crypto.BN;
const Interp = bsv.Script.Interpreter;
Expand Down