You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+10-9
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ CashScript is a high-level language that allows you to write Bitcoin Cash smart
16
16
17
17
## The CashScript Compiler
18
18
19
-
CashScript features a compiler as a standalone command line tool, called `cashc`. It can be installed through npm and used to compile `.cash` files into `.json` artifact files. These artifact files can be imported into the CashScript TypeScript SDK (or other SDKs in the future). The `cashc` NPM package can also be imported inside JavaScript files to compile `.cash` files without using the command line tool.
19
+
CashScript features a compiler as a standalone command line tool, called `cashc`. It can be installed through npm and used to compile `.cash` files into `.json`(or `.ts`) artifact files. These artifact files can be imported into the CashScript TypeScript SDK (or other SDKs in the future). The `cashc` NPM package can also be imported inside JavaScript files to compile `.cash` files without using the command line tool.
20
20
21
21
### Installation
22
22
@@ -30,18 +30,19 @@ npm install -g cashc
30
30
Usage: cashc [options] [source_file]
31
31
32
32
Options:
33
-
-V, --version Output the version number.
34
-
-o, --output <path> Specify a file to output the generated artifact.
35
-
-h, --hex Compile the contract to hex format rather than a full artifact.
36
-
-A, --asm Compile the contract to ASM format rather than a full artifact.
37
-
-c, --opcount Display the number of opcodes in the compiled bytecode.
38
-
-s, --size Display the size in bytes of the compiled bytecode.
39
-
-?, --help Display help
33
+
-V, --version Output the version number.
34
+
-o, --output <path> Specify a file to output the generated artifact.
35
+
-h, --hex Compile the contract to hex format rather than a full artifact.
36
+
-A, --asm Compile the contract to ASM format rather than a full artifact.
37
+
-c, --opcount Display the number of opcodes in the compiled bytecode.
38
+
-s, --size Display the size in bytes of the compiled bytecode.
39
+
-f, --format <format> Specify the format of the output. (choices: "json", "ts", default: "json")
40
+
-?, --help Display help
40
41
```
41
42
42
43
## The CashScript SDK
43
44
44
-
The main way to interact with CashScript contracts and integrate them into applications is using the CashScript SDK. This SDK allows you to import `.json` artifact files that were compiled using the `cashc` compiler and convert them to `Contract` objects. These objects are used to create new contract instances. These instances are used to interact with the contracts using the functions that were implemented in the `.cash` file. For more information on the CashScript SDK, refer to the [SDK documentation](https://cashscript.org/docs/sdk/).
45
+
The main way to interact with CashScript contracts and integrate them into applications is using the CashScript SDK. This SDK allows you to import `.json`(or `.ts`) artifact files that were compiled using the `cashc` compiler and convert them to `Contract` objects. These objects are used to create new contract instances. These instances are used to interact with the contracts using the functions that were implemented in the `.cash` file. For more information on the CashScript SDK, refer to the [SDK documentation](https://cashscript.org/docs/sdk/).
Copy file name to clipboardExpand all lines: packages/cashc/README.md
+9-8
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ See the [GitHub repository](https://github.com/CashScript/cashscript) and the [C
14
14
CashScript is a high-level language that allows you to write Bitcoin Cash smart contracts in a straightforward and familiar way. Its syntax is inspired by Ethereum's Solidity language, but its functionality is different since the underlying systems have very different fundamentals. See the [language documentation](https://cashscript.org/docs/language/) for a full reference of the language.
15
15
16
16
## The CashScript Compiler
17
-
CashScript features a compiler as a standalone command line tool, called `cashc`. It can be installed through npm and used to compile `.cash` files into `.json` artifact files. These artifact files can be imported into the CashScript TypeScript SDK (or other SDKs in the future). The `cashc` NPM package can also be imported inside JavaScript files to compile `.cash` files without using the command line tool.
17
+
CashScript features a compiler as a standalone command line tool, called `cashc`. It can be installed through npm and used to compile `.cash` files into `.json`(or `.ts`)artifact files. These artifact files can be imported into the CashScript TypeScript SDK (or other SDKs in the future). The `cashc` NPM package can also be imported inside JavaScript files to compile `.cash` files without using the command line tool.
18
18
19
19
### Installation
20
20
```bash
@@ -26,11 +26,12 @@ npm install -g cashc
26
26
Usage: cashc [options] [source_file]
27
27
28
28
Options:
29
-
-V, --version Output the version number.
30
-
-o, --output <path> Specify a file to output the generated artifact.
31
-
-h, --hex Compile the contract to hex format rather than a full artifact.
32
-
-A, --asm Compile the contract to ASM format rather than a full artifact.
33
-
-c, --opcount Display the number of opcodes in the compiled bytecode.
34
-
-s, --size Display the size in bytes of the compiled bytecode.
35
-
-?, --help Display help
29
+
-V, --version Output the version number.
30
+
-o, --output <path> Specify a file to output the generated artifact.
31
+
-h, --hex Compile the contract to hex format rather than a full artifact.
32
+
-A, --asm Compile the contract to ASM format rather than a full artifact.
33
+
-c, --opcount Display the number of opcodes in the compiled bytecode.
34
+
-s, --size Display the size in bytes of the compiled bytecode.
35
+
-f, --format <format> Specify the format of the output. (choices: "json", "ts", default: "json")
Copy file name to clipboardExpand all lines: packages/cashscript/README.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ See the [GitHub repository](https://github.com/CashScript/cashscript) and the [C
14
14
CashScript is a high-level language that allows you to write Bitcoin Cash smart contracts in a straightforward and familiar way. Its syntax is inspired by Ethereum's Solidity language, but its functionality is different since the underlying systems have very different fundamentals. See the [language documentation](https://cashscript.org/docs/language/) for a full reference of the language.
15
15
16
16
## The CashScript SDK
17
-
The main way to interact with CashScript contracts and integrate them into applications is using the CashScript SDK. This SDK allows you to import `.json` artifact files that were compiled using the `cashc` compiler and convert them to `Contract` objects. These objects are used to create new contract instances. These instances are used to interact with the contracts using the functions that were implemented in the `.cash` file. For more information on the CashScript SDK, refer to the [SDK documentation](https://cashscript.org/docs/sdk/).
17
+
The main way to interact with CashScript contracts and integrate them into applications is using the CashScript SDK. This SDK allows you to import `.json`(or `.ts`) artifact files that were compiled using the `cashc` compiler and convert them to `Contract` objects. These objects are used to create new contract instances. These instances are used to interact with the contracts using the functions that were implemented in the `.cash` file. For more information on the CashScript SDK, refer to the [SDK documentation](https://cashscript.org/docs/sdk/).
thrownewError(`Incorrect number of arguments passed to ${artifact.contractName} constructor. Expected ${artifact.constructorInputs.length} arguments (${artifact.constructorInputs.map(input=>input.type)}) but got ${constructorArgs.length}`);
71
+
thrownewError(`Incorrect number of arguments passed to ${artifact.contractName} constructor. Expected ${artifact.constructorInputs.length} arguments (${artifact.constructorInputs.map((input)=>input.type)}) but got ${constructorArgs.length}`);
57
72
}
58
73
59
74
// Encode arguments (this also performs type checking)
@@ -66,9 +81,11 @@ export class Contract {
66
81
this.functions={};
67
82
if(artifact.abi.length===1){
68
83
constf=artifact.abi[0];
84
+
// @ts-ignore TODO: see if we can use generics to make TypeScript happy
69
85
this.functions[f.name]=this.createFunction(f);
70
86
}else{
71
87
artifact.abi.forEach((f,i)=>{
88
+
// @ts-ignore TODO: see if we can use generics to make TypeScript happy
72
89
this.functions[f.name]=this.createFunction(f,i);
73
90
});
74
91
}
@@ -78,9 +95,11 @@ export class Contract {
78
95
this.unlock={};
79
96
if(artifact.abi.length===1){
80
97
constf=artifact.abi[0];
98
+
// @ts-ignore TODO: see if we can use generics to make TypeScript happy
81
99
this.unlock[f.name]=this.createUnlocker(f);
82
100
}else{
83
101
artifact.abi.forEach((f,i)=>{
102
+
// @ts-ignore TODO: see if we can use generics to make TypeScript happy
thrownewError(`Incorrect number of arguments passed to function ${abiFunction.name}. Expected ${abiFunction.inputs.length} arguments (${abiFunction.inputs.map(input=>input.type)}) but got ${args.length}`);
127
+
thrownewError(`Incorrect number of arguments passed to function ${abiFunction.name}. Expected ${abiFunction.inputs.length} arguments (${abiFunction.inputs.map((input)=>input.type)}) but got ${args.length}`);
109
128
}
110
129
111
130
// Encode passed args (this also performs type checking)
thrownewError(`Incorrect number of arguments passed to function ${abiFunction.name}. Expected ${abiFunction.inputs.length} arguments (${abiFunction.inputs.map(input=>input.type)}) but got ${args.length}`);
148
+
thrownewError(`Incorrect number of arguments passed to function ${abiFunction.name}. Expected ${abiFunction.inputs.length} arguments (${abiFunction.inputs.map((input)=>input.type)}) but got ${args.length}`);
0 commit comments