Skip to content

Commit d899365

Browse files
committed
Bump version to 0.10.4
1 parent f117a36 commit d899365

File tree

8 files changed

+66
-12
lines changed

8 files changed

+66
-12
lines changed

examples/bug.cash

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
pragma cashscript ^0.10.0;
2+
3+
contract PriceContract(
4+
bytes tokenIdOracleContract
5+
) {
6+
// function updatePrice
7+
// Trigger oracle sequence update to avoid letting borrowers spawn coins using old price data
8+
//
9+
// Inputs: 00-pricecontract, 01-oraclecontract, ?02-feeBCH
10+
// Outputs: 00-pricecontract, ?01-changeBCH
11+
12+
function updatePrice() {
13+
require(this.activeInputIndex == 0, "Parity contract must always be at input index 0");
14+
15+
require(tx.outputs[0].lockingBytecode == tx.inputs[0].lockingBytecode, "Recreate contract at output0 - invalid lockingBytecode");
16+
require(tx.outputs[0].tokenCategory == tx.inputs[0].tokenCategory, "Recreate contract at output0 - invalid tokenCategory");
17+
require(tx.outputs[0].value == 1000, "Recreate contract at output0 - needs to hold exactly 1000 sats");
18+
require(tx.outputs[0].tokenAmount == tx.inputs[0].tokenAmount, "Invalid tokenAmount, needs to maintain atleast current tokenAmount");
19+
20+
bytes contractSeq = tx.inputs[0].nftCommitment.split(1)[1].split(6)[0];
21+
22+
require(tokenIdOracleContract == tx.inputs[1].tokenCategory);
23+
24+
// Parse oracle data (Oracle price is denominated in USD cents/BCH)
25+
bytes oracleSeqBytes = tx.inputs[1].nftCommitment.split(6)[0];
26+
int oracleSeq = int(oracleSeqBytes);
27+
28+
// Verify oracle sequence
29+
require(oracleSeq > int(contractSeq), "Invalid oracle sequence, should be more recent than current contract sequence");
30+
31+
require(tx.outputs[0].nftCommitment == 0x00 + tx.inputs[1].nftCommitment, "Invalid nftCommitment, commitment should be the oracle sequence");
32+
}
33+
34+
// function sharePrice
35+
// Provides latest oracle price to various other contracts
36+
//
37+
// Inputs: 00-parity, ...
38+
// Outputs: 00-parity, ...
39+
40+
function sharePrice() {
41+
require(tx.outputs[this.activeInputIndex].lockingBytecode == tx.inputs[this.activeInputIndex].lockingBytecode, "Recreate contract at output0 - invalid lockingBytecode");
42+
require(tx.outputs[this.activeInputIndex].tokenCategory == tx.inputs[this.activeInputIndex].tokenCategory, "Recreate contract at output0 - invalid tokenCategory");
43+
require(tx.outputs[this.activeInputIndex].value == 1000, "Recreate contract at output0 - needs to hold exactly 1000 sats");
44+
// Allow giving the contract more tokens
45+
require(tx.outputs[this.activeInputIndex].tokenAmount >= tx.inputs[this.activeInputIndex].tokenAmount, "Invalid tokenAmount, needs to maintain atleast current tokenAmount");
46+
// keep same contract state
47+
require(tx.outputs[this.activeInputIndex].nftCommitment == tx.inputs[this.activeInputIndex].nftCommitment, "Invalid nftCommitment, commitment should be replicated");
48+
}
49+
}

examples/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "cashscript-examples",
33
"private": true,
4-
"version": "0.10.3",
4+
"version": "0.10.4",
55
"description": "Usage examples of the CashScript SDK",
66
"main": "p2pkh.js",
77
"type": "module",
@@ -13,8 +13,8 @@
1313
"dependencies": {
1414
"@bitauth/libauth": "^3.0.0",
1515
"@types/node": "^12.7.8",
16-
"cashc": "^0.10.3",
17-
"cashscript": "^0.10.3",
16+
"cashc": "^0.10.4",
17+
"cashscript": "^0.10.4",
1818
"eslint": "^8.56.0",
1919
"typescript": "^4.9.5"
2020
}

examples/testing-suite/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "testing-suite",
3-
"version": "0.10.3",
3+
"version": "0.10.4",
44
"description": "Example project to develop and test CashScript contracts",
55
"main": "index.js",
66
"type": "module",
@@ -25,8 +25,8 @@
2525
"test": "NODE_OPTIONS='--experimental-vm-modules --no-warnings' jest"
2626
},
2727
"dependencies": {
28-
"cashc": "^0.10.3",
29-
"cashscript": "^0.10.3",
28+
"cashc": "^0.10.4",
29+
"cashscript": "^0.10.4",
3030
"url-join": "^5.0.0"
3131
},
3232
"devDependencies": {

packages/cashc/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cashc",
3-
"version": "0.10.3",
3+
"version": "0.10.4",
44
"description": "Compile Bitcoin Cash contracts to Bitcoin Cash Script or artifacts",
55
"keywords": [
66
"bitcoin",
@@ -50,7 +50,7 @@
5050
},
5151
"dependencies": {
5252
"@bitauth/libauth": "^3.0.0",
53-
"@cashscript/utils": "^0.10.3",
53+
"@cashscript/utils": "^0.10.4",
5454
"antlr4": "^4.13.1-patch-1",
5555
"commander": "^7.1.0",
5656
"semver": "^7.5.4"

packages/cashc/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ export * from './Errors.js';
22
export * as utils from '@cashscript/utils';
33
export { compileFile, compileString } from './compiler.js';
44

5-
export const version = '0.10.3';
5+
export const version = '0.10.4';

packages/cashscript/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cashscript",
3-
"version": "0.10.3",
3+
"version": "0.10.4",
44
"description": "Easily write and interact with Bitcoin Cash contracts",
55
"keywords": [
66
"bitcoin cash",
@@ -44,7 +44,7 @@
4444
},
4545
"dependencies": {
4646
"@bitauth/libauth": "^3.0.0",
47-
"@cashscript/utils": "^0.10.3",
47+
"@cashscript/utils": "^0.10.4",
4848
"@mr-zwets/bchn-api-wrapper": "^1.0.1",
4949
"delay": "^5.0.0",
5050
"electrum-cash": "^2.0.10",

packages/utils/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cashscript/utils",
3-
"version": "0.10.3",
3+
"version": "0.10.4",
44
"description": "CashScript utilities and types",
55
"keywords": [
66
"bitcoin cash",

website/docs/releases/release-notes.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
title: Release Notes
33
---
44

5+
## v0.10.4
6+
7+
#### cashc compiler
8+
- :bug: Fix bug in new `--format ts` option.
9+
510
## v0.10.3
611

712
#### cashc compiler

0 commit comments

Comments
 (0)