Skip to content

Commit

Permalink
Bump version to 0.10.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rkalis committed Dec 3, 2024
1 parent f117a36 commit d899365
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 12 deletions.
49 changes: 49 additions & 0 deletions examples/bug.cash
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
pragma cashscript ^0.10.0;

contract PriceContract(
bytes tokenIdOracleContract
) {
// function updatePrice
// Trigger oracle sequence update to avoid letting borrowers spawn coins using old price data
//
// Inputs: 00-pricecontract, 01-oraclecontract, ?02-feeBCH
// Outputs: 00-pricecontract, ?01-changeBCH

function updatePrice() {
require(this.activeInputIndex == 0, "Parity contract must always be at input index 0");

require(tx.outputs[0].lockingBytecode == tx.inputs[0].lockingBytecode, "Recreate contract at output0 - invalid lockingBytecode");
require(tx.outputs[0].tokenCategory == tx.inputs[0].tokenCategory, "Recreate contract at output0 - invalid tokenCategory");
require(tx.outputs[0].value == 1000, "Recreate contract at output0 - needs to hold exactly 1000 sats");
require(tx.outputs[0].tokenAmount == tx.inputs[0].tokenAmount, "Invalid tokenAmount, needs to maintain atleast current tokenAmount");

bytes contractSeq = tx.inputs[0].nftCommitment.split(1)[1].split(6)[0];

require(tokenIdOracleContract == tx.inputs[1].tokenCategory);

// Parse oracle data (Oracle price is denominated in USD cents/BCH)
bytes oracleSeqBytes = tx.inputs[1].nftCommitment.split(6)[0];
int oracleSeq = int(oracleSeqBytes);

// Verify oracle sequence
require(oracleSeq > int(contractSeq), "Invalid oracle sequence, should be more recent than current contract sequence");

require(tx.outputs[0].nftCommitment == 0x00 + tx.inputs[1].nftCommitment, "Invalid nftCommitment, commitment should be the oracle sequence");
}

// function sharePrice
// Provides latest oracle price to various other contracts
//
// Inputs: 00-parity, ...
// Outputs: 00-parity, ...

function sharePrice() {
require(tx.outputs[this.activeInputIndex].lockingBytecode == tx.inputs[this.activeInputIndex].lockingBytecode, "Recreate contract at output0 - invalid lockingBytecode");
require(tx.outputs[this.activeInputIndex].tokenCategory == tx.inputs[this.activeInputIndex].tokenCategory, "Recreate contract at output0 - invalid tokenCategory");
require(tx.outputs[this.activeInputIndex].value == 1000, "Recreate contract at output0 - needs to hold exactly 1000 sats");
// Allow giving the contract more tokens
require(tx.outputs[this.activeInputIndex].tokenAmount >= tx.inputs[this.activeInputIndex].tokenAmount, "Invalid tokenAmount, needs to maintain atleast current tokenAmount");
// keep same contract state
require(tx.outputs[this.activeInputIndex].nftCommitment == tx.inputs[this.activeInputIndex].nftCommitment, "Invalid nftCommitment, commitment should be replicated");
}
}
6 changes: 3 additions & 3 deletions examples/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cashscript-examples",
"private": true,
"version": "0.10.3",
"version": "0.10.4",
"description": "Usage examples of the CashScript SDK",
"main": "p2pkh.js",
"type": "module",
Expand All @@ -13,8 +13,8 @@
"dependencies": {
"@bitauth/libauth": "^3.0.0",
"@types/node": "^12.7.8",
"cashc": "^0.10.3",
"cashscript": "^0.10.3",
"cashc": "^0.10.4",
"cashscript": "^0.10.4",
"eslint": "^8.56.0",
"typescript": "^4.9.5"
}
Expand Down
6 changes: 3 additions & 3 deletions examples/testing-suite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "testing-suite",
"version": "0.10.3",
"version": "0.10.4",
"description": "Example project to develop and test CashScript contracts",
"main": "index.js",
"type": "module",
Expand All @@ -25,8 +25,8 @@
"test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest"
},
"dependencies": {
"cashc": "^0.10.3",
"cashscript": "^0.10.3",
"cashc": "^0.10.4",
"cashscript": "^0.10.4",
"url-join": "^5.0.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions packages/cashc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cashc",
"version": "0.10.3",
"version": "0.10.4",
"description": "Compile Bitcoin Cash contracts to Bitcoin Cash Script or artifacts",
"keywords": [
"bitcoin",
Expand Down Expand Up @@ -50,7 +50,7 @@
},
"dependencies": {
"@bitauth/libauth": "^3.0.0",
"@cashscript/utils": "^0.10.3",
"@cashscript/utils": "^0.10.4",
"antlr4": "^4.13.1-patch-1",
"commander": "^7.1.0",
"semver": "^7.5.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/cashc/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export * from './Errors.js';
export * as utils from '@cashscript/utils';
export { compileFile, compileString } from './compiler.js';

export const version = '0.10.3';
export const version = '0.10.4';
4 changes: 2 additions & 2 deletions packages/cashscript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cashscript",
"version": "0.10.3",
"version": "0.10.4",
"description": "Easily write and interact with Bitcoin Cash contracts",
"keywords": [
"bitcoin cash",
Expand Down Expand Up @@ -44,7 +44,7 @@
},
"dependencies": {
"@bitauth/libauth": "^3.0.0",
"@cashscript/utils": "^0.10.3",
"@cashscript/utils": "^0.10.4",
"@mr-zwets/bchn-api-wrapper": "^1.0.1",
"delay": "^5.0.0",
"electrum-cash": "^2.0.10",
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cashscript/utils",
"version": "0.10.3",
"version": "0.10.4",
"description": "CashScript utilities and types",
"keywords": [
"bitcoin cash",
Expand Down
5 changes: 5 additions & 0 deletions website/docs/releases/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
title: Release Notes
---

## v0.10.4

#### cashc compiler
- :bug: Fix bug in new `--format ts` option.

## v0.10.3

#### cashc compiler
Expand Down

0 comments on commit d899365

Please sign in to comment.