Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ Would like to implement tests and other sustainability features before bumping v
## 0.1.2
- Added tx to completion provider and syntax highlighting
- added byte alias for bytes1

## 0.2.0
- Compatible with ```cashscript@0.7.0```
- Updated to new Native Introspection functionality
- Added tuple destructuring
- Added new ```constant``` keyword
- Added ```*``` operator

9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ None available yet.

Check the [changelog](/CHANGELOG.md) for past releases. Latest stable version:

### 0.1.2
- Added tx to completion provider and syntax highlighting
- added byte alias for bytes1
## 0.2.0
- Compatible with ```cashscript@0.7.0```
- Updated to new Native Introspection functionality
- Added tuple destructuring
- Added new ```constant``` keyword
- Added ```'*'``` operator
11 changes: 11 additions & 0 deletions examples/next.cash
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pragma cashscript ^0.7.0;

contract P2PKH() {
function spend() {
bytes2 left, bytes2 right = 0x123456.split(2);
int constant c = 5;
require(left == right);
require(c*2 == 2);
require(tx.outputs[0].value == tx.inputs[this.activeInputIndex].value - 10*10);
}
}
139 changes: 74 additions & 65 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"publisher": "NathanielCherian",
"displayName": "cashscript",
"description": "Cashscript language support for Visual Studio Code",
"version": "0.1.2",
"version": "0.2.0",
"icon": "media/icon.png",
"repository": {
"type": "git",
Expand Down Expand Up @@ -96,17 +96,17 @@
},
"dependencies": {
"antlr4ts": "^0.5.0-alpha.4",
"cashc": "0.6.4",
"cashscript": "^0.6.4",
"cashc": "^0.7.0",
"cashscript": "^0.7.0",
"vscode-languageclient": "^7.0.0",
"vscode-languageserver": "^7.0.0",
"vscode-languageserver-textdocument": "^1.0.1"
"vscode-languageserver-textdocument": "^1.0.4"
},
"devDependencies": {
"@types/vscode": "^1.56.0",
"esbuild": "^0.12.8",
"typescript": "^4.3.2",
"@types/vscode": "^1.63.1",
"esbuild": "^0.12.29",
"typescript": "^4.5.5",
"vscode": "^1.1.37",
"vscode-test": "^1.5.2"
"vscode-test": "^1.6.1"
}
}
3 changes: 2 additions & 1 deletion src/CashscriptCompletionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,13 @@ export default class CashscriptCompletionProvider implements vscode.CompletionIt

protected getDotCompletions():CompletionItem[]{

const re = /(\w+).$/ // EX: "tx."
const re = /(\w+)(\[.+\])?.$/ // EX: "tx."
const range:Range = new Range(new vscode.Position(this.pos.line, 0), this.pos)
const text = this.doc.getText(range);
var arr, keyword;
if((arr=text?.match(re))){
keyword = arr[1];
if(arr[2]) keyword+="_indexed"; // ex. inputs[0].
console.log("keyword: ", keyword);

return DOT_COMPLETIONS[keyword];
Expand Down
6 changes: 3 additions & 3 deletions src/CashscriptHoverProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ class CashscriptHoverProvider implements vscode.HoverProvider{
const miscel = this.getMiscellaneousHovers(document, position);
if(miscel) return new vscode.Hover(miscel, range)

const dotHovers = this.getTxDotHovers(document, position);
if(dotHovers) return new vscode.Hover(dotHovers, range)
// const dotHovers = this.getTxDotHovers(document, position);
// if(dotHovers) return new vscode.Hover(dotHovers, range)


return null;
Expand Down Expand Up @@ -83,12 +83,12 @@ class CashscriptHoverProvider implements vscode.HoverProvider{
return matches[1];
}

// NEED TO UPDATE THIS AFTER NEW DOCS COME OUT
getTxDotHovers(document:vscode.TextDocument, position:vscode.Position):vscode.MarkdownString[]{
const reg = /tx.[a-zA-Z0-9]+/;
let range = document.getWordRangeAtPosition(position, reg);
let word = document.getText(range).substring(3);

// /### tx.(\w+)\n+```solidity\n(.+)\n```/
const TX_HOVERS = {
time:{
code:'require(tx.time >= <expression>);'
Expand Down
Loading