Skip to content

v0.14.0

Latest

Choose a tag to compare

@rkalis rkalis released this 06 Oct 12:21
5f0eaff

This release contains several breaking changes, please refer to the migration notes for more information.

cashc compiler

  • ✨ Add support for user-defined reusable functions, including multiple return values.
  • ✨ Add support for top-level global constants, including simple arithmetic / concatenation operations.
  • ✨ Add support for import directives to share user-defined functions across files, including imports from node_modules.
  • ✨ Add support for reassigning existing variables in tuple destructuring (e.g. (a, b) = swap(a, b)), optionally mixed with fresh declarations.
  • ✨ Add unused modifier for parameters or variables that are intentionally unused.
  • 🛠️ Update compileString to take an optional files object for filesystem-free import resolution.
  • 🛠️ Unused variables that are not marked unused now produce a compiler warning instead of a compilation error.
  • 🛠️ Add a compiler warning for values assigned to a variable that are never read afterwards.
  • 🐛 Fix bug where date literals were parsed in the local time zone instead of UTC.
  • 🐛 BREAKING: Fix bug where LockingBytecodeNullData used incorrect push opcodes for empty chunks and chunks of 128-255 bytes, so it did not match the SDK's addOpReturnOutput().
  • 🐛 BREAKING: Fix bug where hex literals with an odd number of digits (e.g. 0x123) compiled to a different value (0x1203). They now cause a compile error.
  • 🐛 Fix bug where using the same variable in both arguments of .slice() could fail to compile.
  • 🐛 Fix bug where a variable reassigned in a for loop's init (e.g. for (i = 0; ...)) had an incorrect value after the loop.
  • 🐛 Fix bug where console.log showed an outdated value for a reassigned variable after its final use.
  • 🐎 Add new optimisations for loop counter updates, reassignments, scope cleanup, stack shuffles, and order-independent operations.
  • 🐎 Greatly improve compiler speed for very large contracts.

CashScript SDK

  • ✨ Add support for debugging user-defined functions, including stack traces for nested functions.
  • ✨ Add a validateTransactions option (default: true) to the MockNetworkProvider to validate sent transactions against the BCH VM.
  • 💥 BREAKING: Remove generateLockingBytecode() from the Unlocker interface.
  • 🛠️ BREAKING: The TransactionBuilder now requires UTXOs to include their lockingBytecode, and validates it against the provided unlocker.
  • 🛠️ BREAKING: Replace the SignatureTemplate's getHashType(), getPublicKey() and getSignatureAlgorithm() methods with the sighashType, publicKey and signatureAlgorithm properties.
  • 🛠️ BREAKING: Remove the bchForkId parameter from SignatureTemplate's generateSignature() method, since BCH consensus rules always require the fork ID flag.
  • 🛠️ BREAKING: Rename the HashType enum to SighashType.
  • 🛠️ Add lockingBytecode field to the Utxo interface, set automatically on all UTXOs returned by network providers.
  • 🛠️ MockNetworkProvider now logs a warning instead of throwing when the same transaction is sent twice.
  • 🛠️ ElectrumNetworkProvider now uses Electrum protocol 1.5.0 (was 1.4.1), and getBlockHeight() no longer subscribes to new headers. Custom electrum clients should negotiate 1.5.0 or later.
  • 🛠️ Update @electrum-cash/network to 4.4.0. In a browser, the ElectrumNetworkProvider now disconnects while the page is hidden and reconnects afterwards, restoring any subscriptions (see Browser visibility and connectivity).
  • 🛠️ Make cashscript/vitest types compatible with Vitest 5.
  • 🐛 Fix bug where invalid hex string arguments were silently encoded to different bytes.
  • 🐛 Fix bug where pubkey arguments were not checked to be 33 or 65 bytes.
  • 🐛 Fix bug in ElectrumNetworkProvider automatic connection management.
  • 🐛 Fix bug where send() threw a FailedTransactionError when the transaction was broadcast but could not be retrieved afterwards.
  • 🐛 Fix bug where debugging reported a VM resource limit as a failed require statement.
  • 🐛 Fix minimum fee check rounding bug.
  • 🐛 Fix bug where setLocktime() accepted invalid values.
  • 🐛 Fix edge case bug where a failing final require(variable) statement was reported incorrectly in debugging.