cashc 0.10.2 → 0.10.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -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")
36
+ -?, --help Display help
36
37
  ```
package/dist/cashc-cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #! /usr/bin/env node
2
2
  import { binToHex } from '@bitauth/libauth';
3
- import { asmToScript, calculateBytesize, countOpcodes, exportArtifact, scriptToAsm, scriptToBytecode, } from '@cashscript/utils';
4
- import { program } from 'commander';
3
+ import { asmToScript, calculateBytesize, countOpcodes, exportArtifact, formatArtifact, scriptToAsm, scriptToBytecode, } from '@cashscript/utils';
4
+ import { program, Option } from 'commander';
5
5
  import fs from 'fs';
6
6
  import path from 'path';
7
7
  import { compileFile, version } from './index.js';
@@ -15,6 +15,9 @@ program
15
15
  .option('-A, --asm', 'Compile the contract to ASM format rather than a full artifact.')
16
16
  .option('-c, --opcount', 'Display the number of opcodes in the compiled bytecode.')
17
17
  .option('-s, --size', 'Display the size in bytes of the compiled bytecode.')
18
+ .addOption(new Option('-f, --format <format>', 'Specify the format of the output.')
19
+ .choices(['json', 'ts'])
20
+ .default('json'))
18
21
  .helpOption('-?, --help', 'Display help')
19
22
  .parse();
20
23
  const opts = program.opts();
@@ -62,11 +65,11 @@ function run() {
62
65
  if (!fs.existsSync(outputDir)) {
63
66
  fs.mkdirSync(outputDir, { recursive: true });
64
67
  }
65
- exportArtifact(artifact, outputFile);
68
+ exportArtifact(artifact, outputFile, opts.format);
66
69
  }
67
70
  else {
68
71
  // Output artifact to STDOUT
69
- console.log(JSON.stringify(artifact, null, 2));
72
+ console.log(formatArtifact(artifact, opts.format));
70
73
  }
71
74
  }
72
75
  catch (e) {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export * from './Errors.js';
2
2
  export * as utils from '@cashscript/utils';
3
3
  export { compileFile, compileString } from './compiler.js';
4
- export declare const version = "0.10.2";
4
+ export declare const version = "0.10.4";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from './Errors.js';
2
2
  export * as utils from '@cashscript/utils';
3
3
  export { compileFile, compileString } from './compiler.js';
4
- export const version = '0.10.2';
4
+ export const version = '0.10.4';
5
5
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cashc",
3
- "version": "0.10.2",
3
+ "version": "0.10.4",
4
4
  "description": "Compile Bitcoin Cash contracts to Bitcoin Cash Script or artifacts",
5
5
  "keywords": [
6
6
  "bitcoin",
@@ -50,7 +50,7 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "@bitauth/libauth": "^3.0.0",
53
- "@cashscript/utils": "^0.10.2",
53
+ "@cashscript/utils": "^0.10.4",
54
54
  "antlr4": "^4.13.1-patch-1",
55
55
  "commander": "^7.1.0",
56
56
  "semver": "^7.5.4"
@@ -65,5 +65,5 @@
65
65
  "typescript": "^5.5.4",
66
66
  "url-join": "^5.0.0"
67
67
  },
68
- "gitHead": "a7c4f652462ddfccd54fc929f06cb16022769df9"
68
+ "gitHead": "d8993655ca9b0074d6d22c1680fcd01b23a62054"
69
69
  }