Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typescript check to the CI #4

Merged
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
26 changes: 7 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,25 @@
name: Tests

on: [pull_request]
on: pull_request

jobs:
test:
runs-on: macos-latest
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v3

- name: Specify node version
uses: actions/setup-node@v2-beta
uses: actions/setup-node@v3
with:
node-version: 16

- name: Use npm caches
uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-

- name: Use node_modules caches
id: cache-nm
uses: actions/cache@v2
with:
path: node_modules
key: ${{ runner.os }}-nm-${{ hashFiles('package-lock.json') }}
cache: 'npm'

- name: Install node_modules
if: steps.cache-nm.outputs.cache-hit != 'true'
run: npm install

- name: Run tests
run: npm test

- name: Run type checks
run: npm run type-check
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
11 changes: 8 additions & 3 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type UTXO = {
txid: string;
vout: number;
WIF: string;
is_taproot: bool;
is_taproot: boolean;
};

type Target = {
Expand All @@ -21,6 +21,11 @@ type Target = {
value?: number;
};

type SilentPaymentGroup = {
Bscan: Buffer;
BmValues: Array<[Buffer, number | undefined]>;
};

const G = Buffer.from("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798", "hex");

export class SilentPayment {
Expand All @@ -35,7 +40,7 @@ export class SilentPayment {
createTransaction(utxos: UTXO[], targets: Target[]): Target[] {
const ret: Target[] = [];

let silentPaymentGroups = [];
let silentPaymentGroups: Array<SilentPaymentGroup> = [];
for (const target of targets) {
if (!target.silentPaymentCode) {
ret.push(target); // passthrough
Expand Down Expand Up @@ -96,7 +101,7 @@ export class SilentPayment {

static _outpointsHash(parameters: UTXO[]): Buffer {
let bufferConcat = Buffer.alloc(0);
let outpoints = [];
let outpoints: Array<Buffer> = [];
for (const parameter of parameters) {
outpoints.push(Buffer.concat([Buffer.from(parameter.txid, "hex").reverse(), SilentPayment._ser32(parameter.vout).reverse()]));
}
Expand Down
30 changes: 21 additions & 9 deletions package-lock.json

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

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"description": "",
"main": "index.ts",
"scripts": {
"test": "jest tests/"
"test": "jest tests/",
"type-check": "tsc --noEmit"
},
"author": "overtorment",
"license": "MIT",
Expand All @@ -20,10 +21,12 @@
"ts-node": "^10.9.1"
},
"devDependencies": {
"@tsconfig/recommended": "^1.0.2",
"@types/create-hash": "^1.2.2",
"@types/node": "^20.2.5",
"babel-jest": "^29.5.0",
"jest": "^29.5.0",
"prettier": "2.8.8"
"prettier": "2.8.8",
"typescript": "^5.1.6"
}
}
7 changes: 7 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "@tsconfig/recommended/tsconfig.json",
"include": [
"index.ts",
"noble_ecc.ts"
],
}