Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jiajames committed Aug 16, 2023
0 parents commit b551537
Show file tree
Hide file tree
Showing 224 changed files with 249,409 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/js-lint-build-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "[v4-client-js] Lint, Build, & Test"
on: # yamllint disable-line rule:truthy
pull_request:
paths:
- 'v4-client-js/**'
push:
paths:
- 'v4-client-js/**'
branches:
- main
- "release/*"

jobs:
CI:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./v4-client-js
steps:
- name: Check out repository code
uses: actions/checkout@v3

- name: Use Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org
cache: "npm"
cache-dependency-path: '**/package-lock.json'

- name: Install
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_READ }}

- name: Run eslint
run: npm run lint

- name: Build
run: npm run build

- name: Test
run: npm test
44 changes: 44 additions & 0 deletions .github/workflows/js-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: "[v4-client-js] Publish Image to NPM"
on: # yamllint disable-line rule:truthy
push:
paths:
- 'v4-client-js/**'
branches:
- main

# Ensure only a single instance of this workflow is running.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
build-and-publish:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./v4-client-js
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0 # fetch all history for all tags and branches

- name: Npm
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org
cache: "npm"
cache-dependency-path: '**/package-lock.json'

- name: Install
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_READ }}

- name: Publish
run: ./scripts/publish-if-not-exists.sh
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_WRITE }}
53 changes: 53 additions & 0 deletions .github/workflows/py-lint-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: "[v4-client-py] Lint, Test"

on: # yamllint disable-line rule:truthy
pull_request:
paths:
- 'v4-client-py/**'
push:
paths:
- 'v4-client-py/**'
branches:
- main
- "release/*"

jobs:
lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./v4-client-py
steps:
- name: Check out repository code
uses: actions/checkout@v3

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install Dependencies
run: pip install -r requirements-lint.txt

- name: Lint
run: flake8

test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./v4-client-py
steps:
- name: Check out repository code
uses: actions/checkout@v3

- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11

- name: Install Dependencies
run: sudo pip install -r requirements-test.txt

- name: Run pytest
run: pytest
1 change: 1 addition & 0 deletions v4-client-js/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SERVICE_NAME=v4-client
2 changes: 2 additions & 0 deletions v4-client-js/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
__native__/*.js
__native__/__ios__/*.js
17 changes: 17 additions & 0 deletions v4-client-js/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module.exports = {
extends: './node_modules/@dydxprotocol/node-service-base-dev/.eslintrc.js',

// Override the base configuration to set the correct tsconfigRootDir.
parserOptions: {
tsconfigRootDir: __dirname,
},

ignorePatterns: [
'**/examples/**/*.js',
'**/codegen/**/*.ts',
],

rules: {
'no-console': 'off',
},
};
22 changes: 22 additions & 0 deletions v4-client-js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

# dependencies
node_modules/

# testing
coverage/
.env.test

# production
build/
out/

# misc
.DS_Store
.env.local
.nyc_output
npm-debug.log
.env.test

# vim
*.swo
*.swp
24 changes: 24 additions & 0 deletions v4-client-js/.gitleaks.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Title for the gitleaks configuration file.
title = "Gitleaks title"

[extend]
# useDefault will extend the base configuration with the default gitleaks config:
# https://github.com/zricethezav/gitleaks/blob/master/config/gitleaks.toml
useDefault = true

[allowlist]
paths = [
'''gitleaks\.toml''',
]

regexTarget = "line"
regexes = [
'''clientId''',
'''isEd25519Pubkey''',
'''isSecp256k1Pubkey''',
'''Ed25519Keypair;''',
'''Secp256k1Pubkey''',
'''e92a6595c934c991d3b3e987ea9b3125bf61a076deab3a9cb519787b7b3e8d77''',
'''8d805729d752cbeccbbce08531cc38b271031ae250f7b67bd5f1bf3827c46d87''',
'''44de77c4ee23e1008d4ebf23c9b4b6dca0fd29aadb0950a5bf96dc81b4f4bfc3''',
]
1 change: 1 addition & 0 deletions v4-client-js/.gitleaksignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ee48563a588a0d4bef717c4a64288d676b1f2c84:.coveralls.yml:generic-api-key:1
1 change: 1 addition & 0 deletions v4-client-js/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18
17 changes: 17 additions & 0 deletions v4-client-js/.telescope.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"protoDirs": [
"./proto"
],
"outPath": "./src/codegen",
"options": {
"aminoEncoding": {
"enabled": false
},
"lcdClients": {
"enabled": true
},
"rpcClients": {
"enabled": true
}
}
}
11 changes: 11 additions & 0 deletions v4-client-js/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Node.js - Debug Current File",
"type": "node",
"request": "launch",
"program": "${file}"
}
]
}
11 changes: 11 additions & 0 deletions v4-client-js/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Proprietary License © 2023 dYdX Trading Inc.

dYdX Trading Inc. ("dYdX") hereby grants you the right to access, copy and use the code in this repository (the "Licensed Code") solely for purposes of evaluating the Licensed Code and evaluating interoperability of the Licensed Code with your products and services.

You agree not to (a) access, copy or use the Licensed Code for any purpose other than as expressly licensed above, (b) provide, disclose or distribute the Licensed Code to any third party, or (c) modify or creative derivative works of the Licensed Code. Any violation of these terms will automatically terminate your rights under these terms.

All copies of the Licensed Code are subject to these terms. You must conspicuously display these terms on each copy of the Licensed Code.

dYdX intends to make the Licensed Code available under an open source license in the near term. The terms of this license apply unless and until the Licensed Code is made available by dYdX under an open source license.

These terms do not grant you any right in any trademarks, service marks or logos of dYdX or its affiliates. TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED CODE IS PROVIDED "AS IS". DYDX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT AND TITLE.
35 changes: 35 additions & 0 deletions v4-client-js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# V4 Client

The V4-Client is the Typescript client for placing transactions and querying the dYdX chain.

## Development

`v4-client` uses node `v18` for development. You can use `nvm` to manage different versions of node.

```
nvm install
nvm use
nvm alias default $(nvm version) # optional
```

You can run the following commands to ensure that you are running the correct `node` and `npm` versions.
```
node -v # expected: v18.x.x (should match .nvmrc)
npm -v # expected: 8.x.x
```

## Single-JS for mobile apps

Mobile apps needs to load JS as a single JS file. To build, run
```
npm run webpack
```

The file is generated in __native__/__ios__/v4-native-client.js
Pending: Different configurations may be needed to generate JS for Android app

## Release

Using the `npm version` command will update the appropriate version tags within the package locks and also will add a git tag with the version number..
For example `npm version minor` will perform the necessary changes for a minor version release. After the change is merged, a GitHub action will
[publish](https://github.com/dydxprotocol/v4-client/blob/master/.github/workflows/publish.yml) the new release.
Loading

0 comments on commit b551537

Please sign in to comment.