Skip to content

Commit 6cfdf24

Browse files
authored
Update to n-api (#160)
* Update version of bignum dependency * Require node>=10.0.0 * Remove appveyor and travis * Apply clang-format * Remove editorconfig * Use Makefile instead scripts * Rename utils to util * Update standard in dev dependencies * Update api (temporary version) * n-api: init * Update secp256k1 from b19c000 to d644dda * Rewrite to n-api usage (draft) * Rewrite api interface (draft) * Remove second pure js implementation * Remove unused scripts from util * Adjust pure js based on elliptic * Add tests for contextRandomize * Add options to ecdsaSign * Add options to ecdh * Fix linting issues * Remove karma * Update benchmark * Add GitHub Actions pipelines * Add publicKeyVerify * Fix ecdh example in README * Adjust CI pipelines * Use Uint8Array instead Buffer for elliptic * Remove karma from makefile * Update nyc * More tests * Adjust CI workflows
1 parent 47551dc commit 6cfdf24

68 files changed

Lines changed: 3065 additions & 7125 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.clang-format

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: Google
4+
AccessModifierOffset: -1
5+
AlignAfterOpenBracket: Align
6+
AlignConsecutiveAssignments: false
7+
AlignConsecutiveDeclarations: false
8+
AlignEscapedNewlines: Right
9+
AlignOperands: true
10+
AlignTrailingComments: true
11+
AllowAllParametersOfDeclarationOnNextLine: true
12+
AllowShortBlocksOnASingleLine: false
13+
AllowShortCaseLabelsOnASingleLine: false
14+
AllowShortFunctionsOnASingleLine: Inline
15+
AllowShortIfStatementsOnASingleLine: true
16+
AllowShortLoopsOnASingleLine: true
17+
AlwaysBreakAfterDefinitionReturnType: None
18+
AlwaysBreakAfterReturnType: None
19+
AlwaysBreakBeforeMultilineStrings: false
20+
AlwaysBreakTemplateDeclarations: true
21+
BinPackArguments: false
22+
BinPackParameters: false
23+
BraceWrapping:
24+
AfterClass: false
25+
AfterControlStatement: false
26+
AfterEnum: false
27+
AfterFunction: false
28+
AfterNamespace: false
29+
AfterObjCDeclaration: false
30+
AfterStruct: false
31+
AfterUnion: false
32+
AfterExternBlock: false
33+
BeforeCatch: false
34+
BeforeElse: false
35+
IndentBraces: false
36+
SplitEmptyFunction: true
37+
SplitEmptyRecord: true
38+
SplitEmptyNamespace: true
39+
BreakBeforeBinaryOperators: None
40+
BreakBeforeBraces: Attach
41+
BreakBeforeInheritanceComma: false
42+
BreakBeforeTernaryOperators: true
43+
BreakConstructorInitializersBeforeComma: false
44+
BreakConstructorInitializers: BeforeColon
45+
BreakAfterJavaFieldAnnotations: false
46+
BreakStringLiterals: true
47+
ColumnLimit: 80
48+
CommentPragmas: '^ IWYU pragma:'
49+
CompactNamespaces: false
50+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
51+
ConstructorInitializerIndentWidth: 4
52+
ContinuationIndentWidth: 4
53+
Cpp11BracedListStyle: true
54+
DerivePointerAlignment: false
55+
DisableFormat: false
56+
ExperimentalAutoDetectBinPacking: false
57+
FixNamespaceComments: true
58+
ForEachMacros:
59+
- foreach
60+
- Q_FOREACH
61+
- BOOST_FOREACH
62+
IncludeBlocks: Preserve
63+
IncludeCategories:
64+
- Regex: '^<ext/.*\.h>'
65+
Priority: 2
66+
- Regex: '^<.*\.h>'
67+
Priority: 1
68+
- Regex: '^<.*'
69+
Priority: 2
70+
- Regex: '.*'
71+
Priority: 3
72+
IncludeIsMainRegex: '([-_](test|unittest))?$'
73+
IndentCaseLabels: true
74+
IndentPPDirectives: None
75+
IndentWidth: 2
76+
IndentWrappedFunctionNames: false
77+
JavaScriptQuotes: Leave
78+
JavaScriptWrapImports: true
79+
KeepEmptyLinesAtTheStartOfBlocks: false
80+
MacroBlockBegin: ''
81+
MacroBlockEnd: ''
82+
MaxEmptyLinesToKeep: 1
83+
NamespaceIndentation: None
84+
ObjCBlockIndentWidth: 2
85+
ObjCSpaceAfterProperty: false
86+
ObjCSpaceBeforeProtocolList: false
87+
PenaltyBreakAssignment: 2
88+
PenaltyBreakBeforeFirstCallParameter: 1
89+
PenaltyBreakComment: 300
90+
PenaltyBreakFirstLessLess: 120
91+
PenaltyBreakString: 1000
92+
PenaltyExcessCharacter: 1000000
93+
PenaltyReturnTypeOnItsOwnLine: 200
94+
PointerAlignment: Left
95+
ReflowComments: true
96+
SortIncludes: true
97+
SortUsingDeclarations: true
98+
SpaceAfterCStyleCast: false
99+
SpaceAfterTemplateKeyword: true
100+
SpaceBeforeAssignmentOperators: true
101+
SpaceBeforeParens: ControlStatements
102+
SpaceInEmptyParentheses: false
103+
SpacesBeforeTrailingComments: 2
104+
SpacesInAngles: false
105+
SpacesInContainerLiterals: true
106+
SpacesInCStyleCastParentheses: false
107+
SpacesInParentheses: false
108+
SpacesInSquareBrackets: false
109+
Standard: Auto
110+
TabWidth: 8
111+
UseTab: Never

.editorconfig

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

.github/workflows/ci.yaml

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
name: CI
2+
3+
on: [push, pull_request]
4+
5+
env:
6+
CI: true
7+
8+
jobs:
9+
build-and-test:
10+
name: Build addon and run tests
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os:
15+
- macos-latest
16+
- ubuntu-latest
17+
- windows-latest
18+
steps:
19+
- name: Fetch code
20+
uses: actions/checkout@v1
21+
with:
22+
submodules: true
23+
24+
- name: Install dependencies
25+
run: yarn install --ignore-scripts
26+
27+
- name: Build addon
28+
run: make build-addon
29+
30+
- name: Get minimal Node.js version from package.json (Linux & macOS)
31+
id: node-version-nix
32+
if: runner.os != 'Windows'
33+
run: echo "::set-output name=version::$(node -p 'require("./package.json").engines.node.match(/(\d.*)$/)[0]')"
34+
35+
- name: Use Node.js ${{ steps.node-version-nix.outputs.version }} (Linux & macOS)
36+
if: runner.os != 'Windows'
37+
uses: actions/setup-node@v1
38+
with:
39+
node-version: ${{ steps.node-version-nix.outputs.version }}
40+
41+
- name: Get minimal Node.js version from package.json (Windows)
42+
id: node-version-win
43+
if: runner.os == 'Windows'
44+
run: echo "::set-output name=version::$(node -p 'require(\"./package.json\").engines.node.match(/(\d.*)$/)[0]')"
45+
46+
- name: Use Node.js ${{ steps.node-version-win.outputs.version }} (Windows)
47+
if: runner.os == 'Windows'
48+
uses: actions/setup-node@v1
49+
with:
50+
node-version: ${{ steps.node-version-win.outputs.version }}
51+
52+
- name: Run tests for addon
53+
run: make test-tap
54+
55+
- name: Upload prebuilds
56+
uses: actions/upload-artifact@v1
57+
with:
58+
name: addon-${{ runner.os }}
59+
path: prebuilds
60+
61+
package:
62+
name: Build package
63+
needs: build-and-test
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Fetch code
67+
uses: actions/checkout@v1
68+
with:
69+
fetch-depth: 1
70+
71+
- name: Install dependencies
72+
run: yarn install --ignore-scripts
73+
74+
- name: Download macOS addon
75+
uses: actions/download-artifact@v1
76+
with:
77+
name: addon-macOS
78+
79+
- name: Download Linux addon
80+
uses: actions/download-artifact@v1
81+
with:
82+
name: addon-Linux
83+
84+
- name: Download Windows addon
85+
uses: actions/download-artifact@v1
86+
with:
87+
name: addon-Windows
88+
89+
- name: Move addons to one folder
90+
run: mkdir prebuilds && mv ./addon-*/* ./prebuilds/
91+
92+
- name: Build package
93+
run: make package
94+
95+
- name: Get package version from package.json
96+
id: pkg-version
97+
run: echo "::set-output name=version::$(node -p 'require("./package.json").version')"
98+
99+
- name: Upload package
100+
uses: actions/upload-artifact@v1
101+
with:
102+
name: package
103+
path: secp256k1-${{ steps.pkg-version.outputs.version }}.tgz
104+
105+
lint-cpp:
106+
name: Lint C/C++ code
107+
runs-on: ubuntu-latest
108+
steps:
109+
- name: Fetch code
110+
uses: actions/checkout@v1
111+
with:
112+
fetch-depth: 1
113+
114+
- uses: actions/cache@v1
115+
id: cache
116+
with:
117+
path: clang
118+
key: clang-llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04
119+
120+
- name: Download clang-format
121+
if: steps.cache.outputs.cache-hit != 'true'
122+
run: wget -O- -q http://releases.llvm.org/9.0.0/$VER.tar.xz | tar xfJ - $VER/bin/clang-format && mv $VER clang
123+
env:
124+
VER: clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-18.04
125+
126+
- name: Run lint command
127+
run: PATH=$PATH:./clang/bin/ make lint-cpp-ci
128+
129+
lint-js:
130+
name: Lint JS code
131+
runs-on: ubuntu-latest
132+
steps:
133+
- name: Fetch code
134+
uses: actions/checkout@v1
135+
with:
136+
fetch-depth: 1
137+
138+
- name: Install dependencies
139+
run: yarn install --ignore-scripts
140+
141+
- name: Run lint command
142+
run: make lint-js

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
coverage
33
build
44
node_modules
5+
prebuilds
56

67
npm-debug.log
78
package-lock.json
9+
yarn-error.log
810
yarn.lock

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "secp256k1-src"]
2-
path = src/secp256k1-src
1+
[submodule "src/secp256k1"]
2+
path = src/secp256k1
33
url = https://github.com/bitcoin-core/secp256k1

.travis.yml

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

0 commit comments

Comments
 (0)