Skip to content

Commit

Permalink
Initial (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
silasbw authored Nov 11, 2022
1 parent f628b41 commit 4b9f1bb
Show file tree
Hide file tree
Showing 10 changed files with 1,318 additions and 326 deletions.
4 changes: 0 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,5 @@ module.exports = {
parserOptions: {
project: './tsconfig.eslint.json',
},
rules: {
// Maybe move it to @valora/eslint-config-typescript?
'jest/valid-title': ['error', { ignoreTypeOfDescribeName: true }],
},
ignorePatterns: ['tsconfig.json'],
}
36 changes: 0 additions & 36 deletions .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,6 @@ jobs:
steps:
- uses: actions/checkout@v3
- run: "echo '*** Do not write .sh scripts! ***'; ! find . -type f -name '*.sh' | grep ."
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
check-latest: true
- run: yarn
- run: yarn typecheck
- run: yarn format:check
- run: yarn lint
test:
name: Test
runs-on: ubuntu-latest
Expand All @@ -45,26 +32,3 @@ jobs:
check-latest: true
- run: yarn
- run: yarn test:ci
- name: Upload Coverage Report
uses: actions/upload-artifact@v3
with:
path: coverage/lcov-report
- name: 'Upload coverage to Codecov'
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
deploy:
name: Deploy
if: github.ref == 'refs/heads/main'
needs:
- lint
- test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16'
check-latest: true
- run: yarn
- run: yarn deploy
77 changes: 16 additions & 61 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,25 @@
# typescript-app-starter
# ofac-sdn-list

A starter template for Valora TypeScript projects with best practices.
Checksum addresses on the OFAC SDN list.

## What's in the stack?
## Usage

- [TypeScript](https://www.typescriptlang.org/)
- Unit testing with [Jest](https://jestjs.io)
- Linting with [ESLint](https://eslint.org/), configured with [@valora/eslint-config-typescript](https://github.com/valora-inc/eslint-config-typescript)
- Automatic code formating with [Prettier](https://prettier.io/), configured with [@valora/prettier-config](https://github.com/valora-inc/prettier-config)
- Scripts using [ShellJS](https://github.com/shelljs/shelljs)
- Linted and statically checked with [TypeScript](https://www.typescriptlang.org/)
- CI/CD with [GitHub Actions](https://docs.github.com/en/actions)
- Code coverage uploaded to [Codecov](codecov.io)
- Automated dependency updates with [Renovate](https://renovatebot.com/), configured with [valora-inc/renovate-config](https://github.com/valora-inc/renovate-config)

## How to use this?

Above the file list, click the big green button: `Use this template`.

Or using [GitHub CLI](https://cli.github.com/):

```sh
gh repo create --template valora-inc/typescript-app-starter valora-inc/new-repo
```
import { sanctionedAddresses } from '@valora/ofac-sdn-list'
// Or whatever your favorite checksum address helper function is.
import { getAddress } from '@ethersproject/address'
### Set up Codecov

- Get a token for the repo [following these instructions](https://docs.codecov.com/docs#step-2-get-the-repository-upload-token).
- Add `CODECOV_TOKEN` to the repo secrets [following these instructions](https://docs.github.com/en/codespaces/managing-codespaces-for-your-organization/managing-encrypted-secrets-for-your-repository-and-organization-for-codespaces#adding-secrets-for-a-repository).

## Structure

Here's the recommended structure:

- [`src`](src): source code
- [`index.ts`](src/index.ts): example source file
- [`index.test.ts`](src/index.test.ts): unit tests for `index.ts`
- [`scripts`](scripts): more complex scripts in TypeScript
- [`example.ts`](scripts/example.ts): example script using [ShellJS](https://github.com/shelljs/shelljs)

## Type Checking

This project uses [TypeScript](https://www.typescriptlang.org/). It's recommended to get TypeScript set up for your editor to get a really great in-editor experience with type checking and auto-complete. To run type checking across the whole project, run `yarn typecheck`.

## Testing

For lower level tests of utilities and individual modules, we use [Jest](https://jestjs.io).

## Linting

This project uses [ESLint](https://eslint.org/) for linting. That is configured in [`.eslintrc.js`](.eslintrc.js).

## Formatting

We use [Prettier](https://prettier.io) for auto-formatting. It's recommended to install an editor plugin (like the [VSCode Prettier plugin](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)) to get auto-formatting on save. There's also a `yarn format` script you can run to format all files in the project.

## Scripts

We use TypeScript instead of shell scripts. This is it to avoid the many pitfalls of shell scripts.

To run external commands we recommend using [ShellJS](https://github.com/shelljs/shelljs).
if (sanctionedAddresses.has(getAddress(address))) {
console.log('SDN address')
}
```

## GitHub Actions
## Publishing

We use [GitHub Actions](https://docs.github.com/en/actions) for continuous integration and deployment (CI/CD). Anything that gets into the `main` branch will be deployed using `yarn deploy` after running tests/build/etc.
Run:

## Renovate
```
yarn release
```

[Renovate](https://renovatebot.com/) ensures our dependencies are kept up to date. It's configured with our shared config in [`renovate.json5`](renovate.json5).
And follow the directions.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */

module.exports = {
watchman: false,
moduleFileExtensions: ['ts', 'js', 'json'],
// Allow absolute imports from the tsconfig baseUrl
moduleDirectories: ['node_modules', '<rootDir>'],
Expand Down
29 changes: 14 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "typescript-starter",
"name": "@valora/ofac-sdn-list",
"version": "0.0.1",
"main": "dist/index.js",
"repository": "[email protected]:valora-inc/typescript-starter.git",
"repository": "[email protected]:valora-inc/ofac-sdn-list.git",
"author": "Valora Inc",
"license": "Apache-2.0",
"private": true,
Expand All @@ -11,23 +11,19 @@
},
"scripts": {
"build": "tsc",
"build:scripts": "tsc --project scripts/tsconfig.json",
"typecheck": "yarn build && yarn build:scripts",
"lint": "eslint --ext=.tsx,.ts,.json src/ scripts/",
"lint": "eslint --ext=.tsx,.ts,.json src/",
"lint:fix": "yarn lint --fix",
"format": "prettier --loglevel error --write .",
"format:check": "prettier --check .",
"test": "jest",
"test:watch": "yarn test --watch",
"test:ci": "yarn test --ci --coverage",
"supercheck": "yarn format && yarn lint:fix && yarn typecheck && yarn test",
"example": "ts-node ./scripts/example.ts",
"deploy": "echo 'Deployed!'"
"test:ci": "yarn build && yarn lint && yarn format:check && yarn test",
"release": "standard-version",
"prepublishOnly": "yarn build"
},
"devDependencies": {
"@ethersproject/address": "^5.7.0",
"@types/jest": "^28.1.8",
"@types/shelljs": "^0.8.11",
"@typescript-eslint/eslint-plugin": "^5.40.1",
"@typescript-eslint/eslint-plugin": "^5.33.1",
"@valora/eslint-config-typescript": "^1.0.1",
"@valora/prettier-config": "^0.0.1",
"eslint": "^8.25.0",
Expand All @@ -38,10 +34,13 @@
"eslint-plugin-react-native": "^4.0.0",
"jest": "^28.1.3",
"prettier": "^2.7.1",
"shelljs": "^0.8.5",
"standard-version": "^9.5.0",
"ts-jest": "^28.0.8",
"ts-node": "^10.9.1",
"typescript": "^4.8.4"
"typescript": "4.4.4"
},
"prettier": "@valora/prettier-config"
"prettier": "@valora/prettier-config",
"publishConfig": {
"registry": "https://registry.npmjs.org/"
}
}
8 changes: 0 additions & 8 deletions scripts/example.ts

This file was deleted.

12 changes: 0 additions & 12 deletions scripts/tsconfig.json

This file was deleted.

11 changes: 7 additions & 4 deletions src/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { main } from 'src'
import { getAddress } from '@ethersproject/address'
import { sanctionedAddresses } from './index'

describe(main, () => {
it("should return 'Hello, world!'", () => {
expect(main()).toBe('Hello, world!')
describe('sanctionedAddresses', () => {
it('contains all checksummed addresses', () => {
for (const address of sanctionedAddresses) {
expect(getAddress(address)).toEqual(address)
}
})
})
73 changes: 70 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,70 @@
export function main() {
return 'Hello, world!'
}
export const sanctionedAddresses = new Set([
'0x03893a7c7463AE47D46bc7f091665f1893656003',
'0x07687e702b410Fa43f4cB4Af7FA097918ffD2730',
'0x0836222F2B2B24A3F36f98668Ed8F0B38D1a872f',
'0x08723392Ed15743cc38513C4925f5e6be5c17243',
'0x098B716B8Aaf21512996dC57EB0615e2383E2f96',
'0x0D5550d52428E7e3175bfc9550207e4ad3859b17',
'0x12D66f87A04A9E220743712cE6d9bB1B5616B8Fc',
'0x1356c899D8C9467C7f71C195612F8A395aBf2f0a',
'0x169AD27A470D064DEDE56a2D3ff727986b15D52B',
'0x178169B423a011fff22B9e3F3abeA13414dDD0F1',
'0x19Aa5Fe80D33a56D56c78e82eA5E50E5d80b4Dff',
'0x1da5821544e25c636c1417Ba96Ade4Cf6D2f9B5A',
'0x22aaA7720ddd5388A3c0A3333430953C68f1849b',
'0x23773E65ed146A459791799d01336DB287f25334',
'0x2717c5e28cf931547B621a5dddb772Ab6A35B701',
'0x2f389cE8bD8ff92De3402FFCe4691d17fC4f6535',
'0x308eD4B7b49797e1A98D3818bFF6fe5385410370',
'0x35fB6f6DB4fb05e6A4cE86f2C93691425626d4b1',
'0x3CBdeD43EFdAf0FC77b9C55F6fC9988fCC9b757d',
'0x3Cffd56B47B7b41c56258D9C7731ABaDc360E073',
'0x3e37627dEAA754090fBFbb8bd226c1CE66D255e9',
'0x4736dCf1b7A3d580672CcE6E7c65cd5cc9cFBa9D',
'0x47CE0C6eD5B0Ce3d3A51fdb1C52DC66a7c3c2936',
'0x48549A34AE37b12F6a30566245176994e17C6b4A',
'0x527653eA119F3E6a1F5BD18fbF4714081D7B31ce',
'0x53b6936513e738f44FB50d2b9476730C0Ab3Bfc1',
'0x5512d943eD1f7c8a43F3435C85F7aB68b30121b0',
'0x58E8dCC13BE9780fC42E8723D8EaD4CF46943dF2',
'0x610B717796ad172B316836AC95a2ffad065CeaB4',
'0x67d40EE1A85bf4a4Bb7Ffae16De985e8427B6b45',
'0x6aCDFBA02D390b97Ac2b2d42A63E85293BCc160e',
'0x6F1cA141A28907F78Ebaa64fb83A9088b02A8352',
'0x722122dF12D4e14e13Ac3b6895a86e84145b6967',
'0x72a5843cc08275C8171E582972Aa4fDa8C397B2A',
'0x7Db418b5D567A4e0E8c59Ad71BE1FcE48f3E6107',
'0x7F19720A857F834887FC9A7bC0a0fBe7Fc7f8102',
'0x7F367cC41522cE07553e823bf3be79A889DEbe1B',
'0x8576aCC5C05D6Ce88f4e49bf65BdF0C62F91353C',
'0x8589427373D6D84E98730D7795D8f6f8731FDA16',
'0x905b63Fff465B9fFBF41DeA908CEb12478ec7601',
'0x910Cbd523D972eb0a6f4cAe4618aD62622b39DbF',
'0x94A1B5CdB22c43faab4AbEb5c74999895464Ddaf',
'0x9AD122c22B14202B4490eDAf288FDb3C7cb3ff5E',
'0x9F4cda013E354b8fC285BF4b9A60460cEe7f7Ea9',
'0xa0e1c89Ef1a489c9C7dE96311eD5Ce5D32c20E4B',
'0xA160cdAB225685dA1d56aa342Ad8841c3b53f291',
'0xA60C772958a3eD56c1F15dD055bA37AC8e523a0D',
'0xA7e5d5A720f06526557c513402f2e6B5fA20b008',
'0xaEaaC358560e11f52454D997AAFF2c5731B6f8a6',
'0xb1C8094B234DcE6e03f10a5b673c1d8C69739A00',
'0xb541fc07bC7619fD4062A54d96268525cBC6FfEF',
'0xBA214C1c1928a32Bffe790263E38B4Af9bFCD659',
'0xbB93e510BbCD0B7beb5A853875f9eC60275CF498',
'0xC455f7fd3e0e12afd51fba5c106909934D8A0e4a',
'0xCa0840578f57fE71599D29375e16783424023357',
'0xD21be7248e0197Ee08E0c20D4a96DEBdaC3D20Af',
'0xD4B88Df4D29F5CedD6857912842cff3b20C8Cfa3',
'0xD691F27f38B395864Ea86CfC7253969B409c362d',
'0xd882cFc20F52f2599D84b8e8D58C7FB62cfE344b',
'0xd90e2f925DA726b50C4Ed8D0Fb90Ad053324F31b',
'0xd96f2B1c14Db8458374d9Aca76E26c3D18364307',
'0xDD4c48C0B24039969fC16D1cdF626eaB821d3384',
'0xe7aa314c77F4233C18C6CC84384A9247c0cf367B',
'0xF60dD140cFf0706bAE9Cd734Ac3ae76AD9eBC32A',
'0xF67721A2D8F736E75a49FdD7FAd2e31D8676542a',
'0xF7B31119c2682c88d88D455dBb9d5932c65Cf1bE',
'0xFD8610d20aA15b7B2E3Be39B396a1bC3516c7144',
'0x9d095b9c373207cbC8Bec0A03AD789fDc9dEC911',
])
Loading

0 comments on commit 4b9f1bb

Please sign in to comment.