generated from valora-inc/typescript-app-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
1,318 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
|
@@ -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", | ||
|
@@ -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/" | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
]) |
Oops, something went wrong.