From 40d43f9ee7b02bc5de61cec78a6f0f70da26a30a Mon Sep 17 00:00:00 2001 From: hh Date: Fri, 5 Mar 2021 16:06:48 +0800 Subject: [PATCH 1/3] update readme --- README.md | 59 +++++++++++++++++++++++++++++++++++++++++++++++++-- VERSIONLOG.md | 4 ++-- 2 files changed, 59 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b913919d..f774329d 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,44 @@ The compiler outputs results in a JSON file. It’s a representation used to bui ```json { + "version": 2, // version of description file, you can look at VERSIONLOG.md to see what has changed in each version "compilerVersion": "0.1.0+commit.312f643", // version of compiler used to produce this file "contract": "DemoP2PKH", // name of the contract "md5": "01234...", // md5 of the contract source code file + "structs": [ // All structures defined in the contracts, including dependent contracts + { + "name": "Person", + "params": [ + { + "name": "age", + "type": "Age", + "finalType": "int" + }, + { + "name": "name", + "type": "Name", + "finalType": "bytes" + }, + { + "name": "token", + "type": "Token", + "finalType": "int" + } + ] + }, + ... + ], + "alias": [ // All type alias defined in the contracts, including dependent contracts + { + "name": "Male", + "type": "Person" + }, + { + "name": "Female", + "type": "Person" + }, + ... + ], "abi": [ // ABI of the contract: interfaces of its public functions and constructor. { "type": "constructor", @@ -52,9 +87,20 @@ The compiler outputs results in a JSON file. It’s a representation used to bui } ] }, + ... ], - "asm": "$pubKeyHash OP_OVER OP_HASH160 ..." // locking script of the contract in ASM format, including placeholders for constructor parameters + "file": "file:///C:/Users/sCrypt/code/project/mainContract.scrypt", //file uri of the main contract source code file. + "asm": "$pubKeyHash OP_OVER OP_HASH160 ...", // locking script of the contract in ASM format, including placeholders for constructor parameters + "sources": [ // all compiled sources file related to the contract + "std", + "C:\\Users\\sCrypt\\code\\project\\util.scrypt" + "C:\\Users\\sCrypt\\code\\project\\contract.scrypt" + ], + "sourceMap": [ //sourceMap, you need to enable sourceMap setting in sCrypt IDE, default is disable. + "0:76:53:76:58", + ... + ] } ``` @@ -73,6 +119,9 @@ There are two ways to generate this file (named as `xxx_desc.json`): }, { desc: true // set this flag to be `true` to get the description file output + asm: true // set this flag to be `true` to get the asm file output + optimize: false //set this flag to be `true` to get optimized asm opcode + sourceMap: true //set this flag to be `true` to get source Map } ); ``` @@ -111,10 +160,16 @@ Note that `parameters` in both constructor and function call are mapped to sCryp * `boolean`: mapped to sCrypt `bool` * `number`: mapped to sCrypt `int` -* `new Byte(x)` / `new Bytes(x)` / `new Sig(x)` / `new PubKey(x)` / `new Ripemd160(x)` / … : mapped to sCrypt `byte` / `bytes` / `Sig` / `PubKey` / `Ripemd160` / … , where `x` is hex string +* `new Int(x)`/ `new Bool(x)` / `new Bytes(x)` / `new Sig(x)` / `new PubKey(x)` / `new Ripemd160(x)` / … : mapped to sCrypt `int` / `bool` / `bytes` / `Sig` / `PubKey` / `Ripemd160` / … , where `x` is hex string In this way, the type of parameters could be checked and potential bugs can be detected before running. +Other complex types are the structure and type aliases of user positioning. They need to be dynamically generated and you can use `buildTypeClasses` to do that. + +```typescript +const {Person, Male, Female} = buildTypeClasses(JSON.parse(descFileContent)); +``` + ## Local Unit Tests A useful method `verify(txContext)` is provided for each contract function call. It would execute the function call with the given context locally. The `txContext` argument provides some context information of the current transaction, **needed only if signature is checked inside the contract**. diff --git a/VERSIONLOG.md b/VERSIONLOG.md index a903abe7..b78d584e 100644 --- a/VERSIONLOG.md +++ b/VERSIONLOG.md @@ -3,8 +3,8 @@ ## version = 1 -* Add SourceMap +* Add `sourceMap`, `structs`, `file`, `version` ## version = 2 -* Add type alias \ No newline at end of file +* Add `alias` \ No newline at end of file From 4a602061e5ef2110173b191f9074b36ab8101c91 Mon Sep 17 00:00:00 2001 From: hh Date: Fri, 5 Mar 2021 16:11:03 +0800 Subject: [PATCH 2/3] update link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f774329d..92835ae8 100644 --- a/README.md +++ b/README.md @@ -235,5 +235,5 @@ const asmVars = { instance.replaceAsmVars(asmVars); ``` -You could find more examples using `scryptlib` in the [boilerplate](https://github.com/scrypt-sv/boilerplate) repository. +You could find more examples using `scryptlib` in the [boilerplate](https://github.com/sCrypt-Inc/boilerplate) repository. From fe7f157b30a7f58281ee3dbd3c737f58972789fa Mon Sep 17 00:00:00 2001 From: hh Date: Sat, 6 Mar 2021 09:53:18 +0800 Subject: [PATCH 3/3] update readme --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 92835ae8..0a80619d 100644 --- a/README.md +++ b/README.md @@ -97,7 +97,7 @@ The compiler outputs results in a JSON file. It’s a representation used to bui "C:\\Users\\sCrypt\\code\\project\\util.scrypt" "C:\\Users\\sCrypt\\code\\project\\contract.scrypt" ], - "sourceMap": [ //sourceMap, you need to enable sourceMap setting in sCrypt IDE, default is disable. + "sourceMap": [ //sourceMap, you need to enable sourceMap setting in sCrypt IDE, default is disabled. "0:76:53:76:58", ... ] @@ -121,7 +121,7 @@ There are two ways to generate this file (named as `xxx_desc.json`): desc: true // set this flag to be `true` to get the description file output asm: true // set this flag to be `true` to get the asm file output optimize: false //set this flag to be `true` to get optimized asm opcode - sourceMap: true //set this flag to be `true` to get source Map + sourceMap: true //set this flag to be `true` to get source map } ); ``` @@ -164,7 +164,7 @@ Note that `parameters` in both constructor and function call are mapped to sCryp In this way, the type of parameters could be checked and potential bugs can be detected before running. -Other complex types are the structure and type aliases of user positioning. They need to be dynamically generated and you can use `buildTypeClasses` to do that. +Composite types, including structs and type aliases, are dynamically generated by `buildTypeClasses`. ```typescript const {Person, Male, Female} = buildTypeClasses(JSON.parse(descFileContent));