Skip to content

Commit

Permalink
Initial commit using code from relay-sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
szmizorsz committed Mar 11, 2024
0 parents commit 398d2e0
Show file tree
Hide file tree
Showing 57 changed files with 5,318 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cache
dist
node_modules
test
74 changes: 74 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "12",
"sourceType": "module",
"project": "./tsconfig.json"
},
"env": {
"node": true
},
"plugins": ["@typescript-eslint", "prettier", "import"],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:import/recommended",
"plugin:import/typescript",
"prettier"
],
"rules": {
"prettier/prettier": "error",
"no-console": "warn",
"import/order": ["error", { "newlines-between": "always" }],
"@typescript-eslint/no-unused-vars": "error",
"@typescript-eslint/no-explicit-any": "error",
"@typescript-eslint/no-var-requires": "error",
"@typescript-eslint/naming-convention": [
"error",
{
"selector": "variable",
"format": ["camelCase", "UPPER_CASE"],
"leadingUnderscore": "allow",
"trailingUnderscore": "allow"
},
{
"selector": "parameter",
"format": ["camelCase"],
"leadingUnderscore": "allow"
},
{
"selector": ["classProperty"],
"modifiers": ["private", "static"],
"format": ["PascalCase", "UPPER_CASE"]
},
{
"selector": ["classProperty"],
"modifiers": ["public", "static"],
"format": ["PascalCase", "UPPER_CASE"]
},
{
"selector": ["classProperty", "classMethod"],
"modifiers": ["private"],
"format": ["camelCase"],
"leadingUnderscore": "require"
},
{
"selector": ["classProperty", "classMethod"],
"modifiers": ["protected"],
"format": ["camelCase"],
"leadingUnderscore": "require"
}
]
},
"settings": {
"import/parsers": {
"@typescript-eslint/parser": [".ts"]
},
"import/resolver": {
"typescript": {
"alwaysTryTypes": true
}
}
}
}
44 changes: 44 additions & 0 deletions .github/workflows/scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Scan

on:
push:
branches:
- master
- feature/sonarcloud
pull_request:
types: [opened, synchronize, reopened]

jobs:
sonarcloud:
name: SonarCloud
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

# - name: yarn install and build
# run: |
# echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > .npmrc
# yarn install
# yarn build
# rm .npmrc

# - name: Run unit and integration test
# run: yarn test:unit --coverage

# - name: Upload coverage report
# uses: actions/upload-artifact@v3
# with:
# name: test-coverage
# path: ${{ github.workspace }}/coverage
# retention-days: 2

- name: Cleanup for SonarCloud
run: rm -rf ./node_modules .ops .github docs

- name: SonarCloud Scan
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
43 changes: 43 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Dependency directory
node_modules

# local env variables
.env
.env.testing

# npm
.npmrc

# hardhat
artifacts
cache
deployments/localhost

# cache
.eslintcache

# VS Code
.vscode

# macOS
.DS_Store
*.icloud

dist
.idea

# redis
dump.rdb

# coverage
coverage
.nyc_output

# typechain
typechain

test/contracts/types
src/logs/

# yarn
yarn-error.log
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint-staged
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cache
dist
node_modules
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Gelato Relay SDK <!-- omit in toc -->

- [Documentation](https://docs.gelato.network/developer-products/gelato-relay-sdk)
50 changes: 50 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "@gelatonetwork/relay-sdk",
"version": "5.5.5",
"description": "SDK to integrate with Gelato Relay",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"dist/**/*"
],
"scripts": {
"build": "rm -rf dist && npx tsc",
"format:check": "prettier --check \"*/**/*.{js,json,md,ts}\"",
"format": "prettier --write */**/*.{js,json,md,ts}",
"lint": "eslint --cache .",
"prepare": "husky install"
},
"engines": {
"node": ">=14.0.0"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@tsconfig/recommended": "1.0.2",
"@types/node": "16.18.25",
"@typescript-eslint/eslint-plugin": "^5.59.1",
"@typescript-eslint/parser": "^5.59.1",
"dotenv": "^16.0.3",
"eslint": "^8.39.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-prettier": "^4.2.1",
"husky": "^8.0.3",
"lint-staged": "^13.2.2",
"minimize-js": "^1.3.1",
"prettier": "^2.8.8",
"typescript": "5.0.4"
},
"dependencies": {
"axios": "0.27.2",
"ethers": "6.7.0",
"isomorphic-ws": "^5.0.0",
"ws": "^8.5.0"
},
"lint-staged": {
"*.{js,json,md,ts}": "yarn format",
"*.{ts,js}": "yarn lint"
}
}
14 changes: 14 additions & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sonar.projectKey=relay-sdk
sonar.organization=gelato-network

sonar.javascript.lcov.reportPaths=./coverage/lcov.info

# This is the name and version displayed in the SonarCloud UI.
#sonar.projectName=
#sonar.projectVersion=1.0

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
#sonar.sources=.

# Encoding of the source code. Default is default system encoding
#sonar.sourceEncoding=UTF-8
30 changes: 30 additions & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export const GELATO_RELAY_URL = "https://api.gelato.digital"; //Relay GW

export const SIGN_TYPED_DATA_V4 = "eth_signTypedData_v4";

export const DEFAULT_INTERNAL_ERROR_MESSAGE = "Internal Error";

export const DEFAULT_DEADLINE_GAP = 86_400; //24H
export const USER_NONCE_ABI = [
"function userNonce(address account) external view returns (uint256)",
];

export const GELATO_RELAY_ERC2771_ADDRESS =
"0xb539068872230f20456CF38EC52EF2f91AF4AE49";
export const GELATO_RELAY_1BALANCE_ERC2771_ADDRESS =
"0xd8253782c45a12053594b9deB72d8e8aB2Fca54c";

export const GELATO_RELAY_ERC2771_ZKSYNC_ADDRESS =
"0x22DCC39b2AC376862183dd35A1664798dafC7Da6";
export const GELATO_RELAY_1BALANCE_ERC2771_ZKSYNC_ADDRESS =
"0x97015cD4C3d456997DD1C40e2a18c79108FCc412";

export const GELATO_RELAY_CONCURRENT_ERC2771_ADDRESS =
"0x8598806401A63Ddf52473F1B3C55bC9E33e2d73b";
export const GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ADDRESS =
"0xc65d82ECE367EF06bf2AB791B3f3CF037Dc0e816";

export const GELATO_RELAY_CONCURRENT_ERC2771_ZKSYNC_ADDRESS =
"0xBa4082F4961c8Fb76231995C967CD9aa40f321b5";
export const GELATO_RELAY_1BALANCE_CONCURRENT_ERC2771_ZKSYNC_ADDRESS =
"0xB8828e4c662D1a7e4f3d1f622EfAE6B63D852ED8";
Loading

0 comments on commit 398d2e0

Please sign in to comment.