Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
cryptofish7 committed Dec 12, 2023
0 parents commit dc2bf61
Show file tree
Hide file tree
Showing 148 changed files with 23,219 additions and 0 deletions.
64 changes: 64 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true
}
},
"ignorePatterns": ["node_modules/**/*"],
"settings": {
"react": {
"version": "detect"
}
},
"extends": [
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended",
"prettier",
"plugin:prettier/recommended"
],
"plugins": [
"simple-import-sort",
"sort-keys-fix",
"typescript-sort-keys",
"sort-destructure-keys"
],
"rules": {
"sort-imports": "off",
"simple-import-sort/exports": "error",
"simple-import-sort/imports": "error",
"sort-keys-fix/sort-keys-fix": "error",
"typescript-sort-keys/interface": [
"error",
"asc",
{
"caseSensitive": false,
"natural": true,
"requiredFirst": true
}
],
"typescript-sort-keys/string-enum": [
"error",
"asc",
{
"caseSensitive": false,
"natural": true
}
],
"sort-destructure-keys/sort-destructure-keys": [
"error",
{
"caseSensitive": false
}
],
"prettier/prettier": "error",
"@typescript-eslint/no-namespace": "off",
"@typescript-eslint/no-non-null-assertion": "off",
"@typescript-eslint/explicit-function-return-type": "off",
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-unused-vars": "warn"
}
}
21 changes: 21 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Setup
runs:
using: composite
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 18
registry-url: https://registry.npmjs.org
cache: yarn

- uses: actions/cache@v3
id: install-cache
with:
path: node_modules/
key: ${{ runner.os }}-install-${{ hashFiles('**/yarn.lock') }}

- if: steps.install-cache.outputs.cache-hit != 'true'
run: YARN_ENABLE_SCRIPTS=false yarn install --frozen-lockfile
shell: bash
31 changes: 31 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Test

on:
push:
branches:
- main
pull_request:
# manual trigger
workflow_dispatch:

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup
- run: yarn lint

deps-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup
- run: yarn dedupe --strategy highest --check

unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/setup
- run: yarn test
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
.pnp.js
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
.tool-versions

cypress/videos
cypress/screenshots
cypress.env.json
7 changes: 7 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"semi": false,
"singleQuote": true,
"printWidth": 80,
"arrowParens": "always",
"trailingComma": "none"
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit"
}
}
893 changes: 893 additions & 0 deletions .yarn/releases/yarn-4.0.2.cjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.0.2.cjs
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
## Potus Interface

### Dev

```
yarn
yarn start
```

### Environment variables

```
REACT_APP_IS_TESTNET="false" # true for Fuji, false for Avalanche
```

### Linter

```
yarn lint:fix
```

### Running unit tests

```
yarn test
```
69 changes: 69 additions & 0 deletions bin/discord.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/bin/bash

# Start: Remove this if you want successful alerts
if [[ $CODEBUILD_BUILD_SUCCEEDING == "1" ]]; then
exit 0
fi
# End: Remove this if you want successful alerts

ACCOUNT_ID=$(echo "$CODEBUILD_BUILD_ARN" | cut -d ':' -f 5)
PROJECT_NAME=$(echo "$CODEBUILD_BUILD_ID" | cut -d ':' -f 1)

ACTION=$(echo "$PROJECT_NAME" | rev | cut -d '-' -f 1 | rev)

RESULT=succeeded
COLOR=3669879
if [[ $CODEBUILD_BUILD_SUCCEEDING == "0" ]]; then
RESULT=failed
COLOR=16712294
fi

CODEBUILD_URL="https://${AWS_REGION}.console.aws.amazon.com/codesuite/codebuild/${ACCOUNT_ID}/projects/${PROJECT_NAME}/build/$CODEBUILD_BUILD_ID/?region=${AWS_REGION}"

CODEBUILD_START_TIME_S=$((CODEBUILD_START_TIME / 1000))
START_TIME=$(date -d "@${CODEBUILD_START_TIME_S}" +"%b %d, %Y %I:%M %p %z")

DATA=$(cat << EOF
{
"username": "[${ENVIRONMENT^^}] ${ACTION^} ${RESULT}",
"embeds": [
{
"title": "Build Logs",
"url": "${CODEBUILD_URL}",
"color": $COLOR,
"fields": [
{
"name": "Project",
"value": "${PROJECT_NAME}"
},
{
"name": "Build Number",
"value": "${CODEBUILD_BUILD_NUMBER}"
},
{
"name": "Triggered By",
"value": "${CODEBUILD_WEBHOOK_TRIGGER}",
"inline": true
},
{
"name": "Start Time",
"value": "${START_TIME}"
},
{
"name": "Repo URL",
"value": "${CODEBUILD_SOURCE_REPO_URL}"
},
{
"name": "Commit Hash",
"value": "${CODEBUILD_RESOLVED_SOURCE_VERSION}"
}
]
}
]
}
EOF
)

curl --location $DISCORD_URL \
--header 'Content-Type: application/json' \
--data "$DATA"
6 changes: 6 additions & 0 deletions bin/validate-git-tag.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

if [[ -z ${GIT_TAG} || ${GIT_TAG} == "" ]]; then
echo "GIT_TAG can not be empty. Please set additional environment variable GIT_TAG to <${ENVIRONMENT}-#> that matches a git tag from https://github.com/traderjoe-xyz/joe-interface-v2"
exit 1
fi
22 changes: 22 additions & 0 deletions buildspec-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# version: 0.2

# env:
# git-credential-helper: yes

# phases:
# install:
# on-failure: ABORT
# runtime-versions:
# nodejs: 18.x
# build:
# on-failure: ABORT
# commands:
# - npm install -g yarn
# - yarn
# - export REACT_APP_SENTRY_RELEASE=$SENTRY_RELEASE
# - npm run build
# - aws s3 cp build s3://$BUILD_BUCKET_ARTIFACTS/$ENVIRONMENT-$CODEBUILD_BUILD_NUMBER --recursive
# - git tag $ENVIRONMENT-$CODEBUILD_BUILD_NUMBER
# - git push --tags
# finally:
# - bin/discord.sh
16 changes: 16 additions & 0 deletions buildspec-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# version: 0.2

# phases:
# build:
# on-failure: ABORT
# commands:
# - GIT_TAG=${GIT_TAG:-$(echo $CODEBUILD_WEBHOOK_TRIGGER | awk -F/ {'print $2'})}
# - bin/validate-git-tag.sh
# - NOW=$(date +%s)
# - aws s3 rm s3://$DEPLOYMENT_BUCKET/ --recursive
# - aws s3 cp s3://$BUILD_BUCKET_ARTIFACTS/$GIT_TAG s3://$DEPLOYMENT_BUCKET --exclude "*.map" --exclude "*.svg" --recursive
# - aws s3 cp s3://$BUILD_BUCKET_ARTIFACTS/$GIT_TAG s3://$DEPLOYMENT_BUCKET --metadata-directive=REPLACE --cache-control "max-age=31536000" --content-type="image/svg+xml" --exclude "*" --include "*.svg" --recursive
# - sed -e "s|%GIT_TAG%|$GIT_TAG|" -e "s|%NOW%|$NOW|" cache-invalidation.json.tpl > cache-invalidation.json
# - aws cloudfront create-invalidation --distribution-id ${CLOUDFRONT_DISTRIBUTION_ID} --invalidation-batch file://cache-invalidation.json
# finally:
# - bin/discord.sh
15 changes: 15 additions & 0 deletions cache-invalidation.json.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"Paths": {
"Quantity": 7,
"Items": [
"/_headers",
"/asset-manifest.json",
"/favicon.png",
"/images/*",
"/index.html",
"/manifest.json",
"/robots.txt"
]
},
"CallerReference": "%GIT_TAG%-%NOW%"
}
26 changes: 26 additions & 0 deletions jest-environment-jsdom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// there is a compatibility issue between jest and noble-hashes (a library used by viem)
// for now, we need to use this workaround:
// https://github.com/paulmillr/noble-hashes/issues/48#issuecomment-1521437489

const { TextDecoder, TextEncoder } = require('util')

const JsdomEnvironment = require('jest-environment-jsdom')

export default class CustomJsdomEnvironment extends JsdomEnvironment {
async setup() {
await super.setup()

if (!this.global.TextDecoder) {
this.global.TextDecoder = TextDecoder
} else {
throw new Error(`Unnecessary polyfill "TextDecoder"`)
}

if (!this.global.TextEncoder) {
this.global.TextEncoder = TextEncoder
this.global.Uint8Array = Uint8Array
} else {
throw new Error(`Unnecessary polyfill "TextEncoder"`)
}
}
}
Loading

0 comments on commit dc2bf61

Please sign in to comment.