Setup typescript subproject

This commit is contained in:
Matthew Little
2019-05-02 19:40:31 -04:00
parent 6a67e291af
commit 23bfc9c2d8
13 changed files with 3341 additions and 1 deletions

4
.gitignore vendored
View File

@@ -67,3 +67,7 @@ Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
node_modules
smart-contract-sdk/.nyc_output
smart-contract-sdk/coverage
smart-contract-sdk/lib

6
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,6 @@
{
"lldb.adapterType": "native",
"lldb.launch.sourceLanguages": ["rust"],
"rust-client.updateOnStartup": true,
"rust.all_features": true
}

15
sdk.code-workspace Normal file
View File

@@ -0,0 +1,15 @@
{
"folders": [
{
"path": ".",
"name": "rust"
},
{
"path": "./smart-contract-sdk",
"name": "smart-contract-sdk"
}
],
"settings": {
}
}

View File

@@ -0,0 +1,16 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
[*.{js,ts,json}]
charset = utf-8
indent_style = space
indent_size = 2
[{.eslintrc}]
charset = utf-8
indent_style = space
indent_size = 2

View File

@@ -0,0 +1,23 @@
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
"project": "./tsconfig.json"
},
plugins: [
"@typescript-eslint",
"prettier"
],
parserOptions: {
ecmaVersion: 2018, // Allows for the parsing of modern ECMAScript features
sourceType: 'module', // Allows for the use of imports
},
extends: [
"plugin:@typescript-eslint/recommended",
"prettier/@typescript-eslint",
"plugin:prettier/recommended"
],
rules: {
"prettier/prettier": "error",
"@typescript-eslint/explicit-function-return-type": "off"
}
}

View File

@@ -0,0 +1,3 @@
module.exports = {
singleQuote: true
};

37
smart-contract-sdk/.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,37 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "sdk",
"args": [
"${workspaceFolder}/src/index.ts"
],
"runtimeArgs": [
"--nolazy",
"-r",
"ts-node/register/transpile-only"
],
"cwd": "${workspaceFolder}",
"outputCapture": "std"
},
{
"type": "node",
"request": "launch",
"name": "sdk-tests",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"--require",
"ts-node/register/transpile-only",
"--colors",
"--recursive",
"${workspaceFolder}/src/test/**/*.ts"
],
"internalConsoleOptions": "openOnSessionStart"
}
]
}

3136
smart-contract-sdk/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,60 @@
{
"name": "smart-contract-sdk",
"version": "1.0.0",
"description": "",
"main": "lib/index.js",
"scripts": {
"compile": "tsc",
"test": "nyc mocha --require ts-node/register/transpile-only --require source-map-support/register --recursive ./src/test/**/*.ts",
"codecovUpload": "codecov",
"lint": "eslint --ext .ts ./src",
"lint-fix": "eslint --ext .ts ./src --fix",
"prettier-fix": "prettier --write \"./src/**/*.ts\""
},
"engines": {
"node": ">=10"
},
"author": "",
"license": "GPL-3.0",
"devDependencies": {
"@types/chai": "^4.1.7",
"@types/mocha": "^5.2.6",
"@types/node": "^10.14.6",
"@typescript-eslint/eslint-plugin": "^1.7.0",
"@typescript-eslint/parser": "^1.7.0",
"chai": "^4.2.0",
"codecov": "^3.3.0",
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.2.0",
"eslint-plugin-prettier": "^3.0.1",
"mocha": "^6.1.4",
"nyc": "^13.3.0",
"prettier": "1.17.0",
"source-map-support": "^0.5.12",
"ts-node": "^8.1.0",
"typescript": "^3.4.5"
},
"nyc": {
"cache": false,
"all": true,
"extension": [
".ts"
],
"include": [
"src/**/*.ts"
],
"exclude": [
"**/*.d.ts",
"src/test"
],
"require": [
"ts-node/register/transpile-only",
"source-map-support/register"
],
"reporter": [
"text",
"html",
"lcov"
]
}
}

View File

@@ -0,0 +1,9 @@
import util from 'util';
function doLog() {
console.log(util.inspect({ asdF: 4545, ggg: { '5656': true } }));
}
doLog();
export { doLog };

View File

@@ -0,0 +1,10 @@
import { assert, expect } from 'chai';
import * as main from '../index';
describe('main', () => {
it('example', () => {
main.doLog();
const thing = true;
assert.isTrue(thing, 'works');
});
});

View File

@@ -0,0 +1,21 @@
{
"compilerOptions": {
"moduleResolution": "node",
"target": "es2018",
"module": "commonjs",
"lib": ["es2018"],
"noImplicitAny": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"sourceMap": true,
"declaration": true,
"esModuleInterop": true,
"outDir": "lib"
},
"include": [
"src"
],
"exclude": [
"src/test"
]
}

View File

@@ -499,7 +499,7 @@ mod tests {
let secret_key: ed25519_PrivateKey = ed25519_PrivateKey::generate(&mut csprng);
let public_key = ed25519_PublicKey::from(&secret_key);
let mut msg = [0u8, 1024];
let mut msg = [0u8; 1024];
csprng.fill_bytes(&mut msg);
let proof = ECVRF_prove(&secret_key, &msg.to_vec());