Skip to content

Commit b9a75e1

Browse files
authored
Merge pull request #566 from stephensli/typescript-support
Typescript Base Support
2 parents 2da719d + 70b489b commit b9a75e1

27 files changed

+211
-126
lines changed

.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ module.exports = {
77
extends: [
88
'standard'
99
],
10+
parser: '@typescript-eslint/parser',
11+
plugins: [
12+
'@typescript-eslint'
13+
],
1014
parserOptions: {
1115
ecmaVersion: 12,
1216
sourceType: 'module'

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@ bin
3939
out
4040
*.bin
4141
*.abi
42+
43+
dist/**
44+
45+
.nyc_output

.nycrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"exclude": [
3+
"coverage",
4+
"dist/soljson.js",
5+
"**/test/**"
6+
],
7+
"extensions": [
8+
".js"
9+
],
10+
"report-dir": "./coverage",
11+
"reporter": [
12+
"lcov",
13+
"html",
14+
"text-summary"
15+
],
16+
"temp-directory": "./coverage/.nyc_output"
17+
}

abi.js renamed to abi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const semver = require('semver');
1+
import * as semver from 'semver';
22

33
function update (compilerVersion, abi) {
44
let hasConstructor = false;
@@ -58,6 +58,6 @@ function update (compilerVersion, abi) {
5858
return abi;
5959
}
6060

61-
module.exports = {
62-
update: update
61+
export default {
62+
update
6363
};

build/clean.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
const distFolder = path.join(__dirname, 'dist');
5+
6+
if (fs.existsSync(distFolder)) {
7+
fs.rmdirSync(distFolder);
8+
}

build/postbuild.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const fs = require('fs');
2+
const path = require('path');
3+
4+
fs.chmodSync(path.join(__dirname, '../dist', 'solc.js'), '755');

downloadCurrentVersion.js renamed to downloadCurrentVersion.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
// This is used to download the correct binary version
44
// as part of the prepublish step.
55

6-
const pkg = require('./package.json');
7-
const fs = require('fs');
8-
const https = require('follow-redirects').https;
9-
const MemoryStream = require('memorystream');
10-
const keccak256 = require('js-sha3').keccak256;
6+
import * as pkg from './package.json';
7+
import * as fs from 'fs';
8+
import { https } from 'follow-redirects';
9+
import * as MemoryStream from 'memorystream';
10+
import { keccak256 } from 'js-sha3';
1111

1212
function getVersionList (cb) {
1313
console.log('Retrieving available version list...');

index.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import wrapper from './wrapper';
2+
3+
const soljson = require('./soljson.js');
4+
5+
export default wrapper(soljson);

linker.js renamed to linker.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const assert = require('assert');
2-
const keccak256 = require('js-sha3').keccak256;
1+
import * as assert from 'assert';
2+
import { keccak256 } from 'js-sha3';
33

44
function libraryHashPlaceholder (input) {
55
return '$' + keccak256(input).slice(0, 34) + '$';
@@ -88,7 +88,7 @@ const findLinkReferences = function (bytecode) {
8888
return linkReferences;
8989
};
9090

91-
module.exports = {
92-
linkBytecode: linkBytecode,
93-
findLinkReferences: findLinkReferences
91+
export default {
92+
linkBytecode,
93+
findLinkReferences
9494
};

0 commit comments

Comments
 (0)