Skip to content

Commit

Permalink
add: typescript check
Browse files Browse the repository at this point in the history
  • Loading branch information
limpbrains committed Jul 12, 2023
1 parent 87c6812 commit f495f0e
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 48 deletions.
49 changes: 15 additions & 34 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,18 @@
name: Tests

on: [pull_request]

name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
test:
runs-on: macos-latest
Explore-GitHub-Actions:
runs-on: ubuntu-latest
steps:
- name: Checkout project
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v3

- name: Specify node version
uses: actions/setup-node@v2-beta
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') }}

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

- name: Run tests
run: npm test
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "🍏 This job's status is ${{ job.status }}."
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"
],
}

0 comments on commit f495f0e

Please sign in to comment.