-
Notifications
You must be signed in to change notification settings - Fork 0
Refactor the project #19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
7ed90e3
rewrite project in TS
volovyks 3c2fb93
add test setup
volovyks 140610a
add formatting
volovyks f66b67d
add ling generated for /dist
volovyks 30a6123
JS - TS fin
volovyks 55afb68
format ignore /dist
volovyks 349884a
fix input parameter tets
volovyks b198550
close server after tests
volovyks f166b75
rewrite env setup
volovyks 4d35829
add no check positive tests
volovyks e0556e5
throw only unexpected 500s
volovyks 55e72fc
add solana test with check
volovyks eb86579
add laad test
volovyks de89766
CI
volovyks f2064e4
update lock file
volovyks b214775
ignore lock git diff
volovyks eb2bed1
ignore lock in formatting
volovyks 852059d
add env variables in CI
volovyks 6d73c13
debug ci env
volovyks 6166b49
Update src/utils/initEvm.ts
volovyks e2cf1fc
Update src/handlers/ethereum.ts
volovyks a4fce8c
add environment to CI
volovyks 82eb597
fix formatting
volovyks df2c4d0
fix file extension issue
volovyks da76e3f
added image push workflow, added healthcheck route
auto-mausx bd320b3
test fixes/linting
auto-mausx 5ab9e38
prettier check
auto-mausx b7010a1
set api key
auto-mausx 39c6642
build files
auto-mausx 80cac3c
fix / tests
volovyks e279a28
fix / tests
volovyks 5bbd2ec
fix return status
volovyks c139354
fix eth key rotation
volovyks 5d51173
Update test/ping.integration.test.ts
volovyks e116a7c
add eth balance endpoint
volovyks 04c1479
Merge pull request #23 from sig-net/serhii/acc-balances
volovyks 1df68d4
Merge pull request #22 from sig-net/serhii/proper-rotation
volovyks 3817973
eth test test
volovyks 326d566
eth test test
volovyks 6726f6b
remove test
volovyks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,19 +1,19 @@ | ||
| # Server Configuration | ||
| PORT=3001 | ||
|
|
||
| # Add other environment variables as needed | ||
| NODE_ENV=development | ||
|
|
||
| NEAR_NETWORK_ID=testnet | ||
| NEAR_ACCOUNT= | ||
| NEAR_PRIVATE_KEY= | ||
| # ETHEREUM | ||
| SIG_ETH_RPC_URL_SEPOLIA= | ||
| SIG_ETH_RPC_URL_MAINNET= | ||
| # Ethereum setup requires multiple keys for rotation. We can resue same keys for different networks. | ||
| SIG_EVM_SK_1= | ||
| SIG_EVM_SK_2= | ||
| SIG_EVM_SK_3= | ||
| SIG_EVM_SK_4= | ||
| SIG_EVM_SK_5= | ||
|
|
||
| # Infura URL for Sepolia testnet | ||
| SEPOLIA_INFURA_URL= | ||
| # SOLANA | ||
| SIG_SOL_RPC_URL_DEV= | ||
| SIG_SOL_RPC_URL_MAINNET= | ||
|
|
||
| # EVM private key | ||
| EMV_PRIVATE_KEY_1= | ||
| EMV_PRIVATE_KEY_2= | ||
| EMV_PRIVATE_KEY_3= | ||
| EMV_PRIVATE_KEY_4= | ||
| EMV_PRIVATE_KEY_5= | ||
| SIG_SOL_SK= |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| /dist/* linguist-generated=true |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: Docker Image | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [closed] | ||
| branches: | ||
| - main | ||
|
|
||
| env: | ||
| IMAGE: 'europe-west1-docker.pkg.dev/near-cs-dev/tools/contract-pinger' | ||
| TAG: ${{ github.sha }} | ||
|
|
||
| jobs: | ||
| build: | ||
| if: github.event.pull_request.merged == true | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| name: 'Checkout mpc' | ||
|
|
||
| - name: Login to GCP Artifact Registry | ||
| run: echo "$GOOGLE_CREDENTIALS" | docker login -u _json_key --password-stdin https://europe-west1-docker.pkg.dev | ||
| env: | ||
| GOOGLE_CREDENTIALS: ${{ secrets.SIG_CREDENTIALS_DEV }} | ||
|
|
||
| - name: Build Docker image and push to Google Artifact Registry | ||
| if: github.event.pull_request.merged == true | ||
| id: docker-push-tagged | ||
| uses: docker/build-push-action@v4 | ||
| with: | ||
| push: true | ||
| file: ./Dockerfile | ||
| tags: '${{ env.IMAGE }}:${{ env.TAG }},${{ env.IMAGE }}:latest' |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| name: CI | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| check-generated-build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: pnpm/action-setup@v3 | ||
| with: | ||
| version: 8 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: 'pnpm' | ||
| - name: Install dependencies | ||
| run: pnpm install | ||
| - name: Run build | ||
| run: pnpm build | ||
| - name: Check for uncommitted changes after build | ||
| run: | | ||
| git update-index --assume-unchanged pnpm-lock.yaml | ||
| if ! git diff --exit-code; then | ||
| echo 'Build produced uncommitted changes (excluding lock file). Please run pnpm build and commit the results.' | ||
| git diff | ||
| exit 1 | ||
| fi | ||
| git update-index --no-assume-unchanged pnpm-lock.yaml | ||
|
|
||
| prettier-check: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: pnpm/action-setup@v3 | ||
| with: | ||
| version: 8 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: 'pnpm' | ||
| - name: Install dependencies | ||
| run: pnpm install | ||
| - name: Run Prettier check | ||
| run: pnpm prettier --check . | ||
|
|
||
| test: | ||
| runs-on: ubuntu-latest | ||
| environment: Pinger Test ENV | ||
| env: | ||
| PORT: 3001 | ||
| NODE_ENV: development | ||
| SIG_ETH_RPC_URL_SEPOLIA: ${{ secrets.SIG_ETH_RPC_URL_SEPOLIA }} | ||
| SIG_ETH_RPC_URL_MAINNET: ${{ secrets.SIG_ETH_RPC_URL_MAINNET }} | ||
| SIG_EVM_SK_1: ${{ secrets.SIG_EVM_SK_1 }} | ||
| SIG_EVM_SK_2: ${{ secrets.SIG_EVM_SK_2 }} | ||
| SIG_EVM_SK_3: ${{ secrets.SIG_EVM_SK_3 }} | ||
| SIG_EVM_SK_4: ${{ secrets.SIG_EVM_SK_4 }} | ||
| SIG_EVM_SK_5: ${{ secrets.SIG_EVM_SK_5 }} | ||
| SIG_SOL_RPC_URL_DEV: ${{ secrets.SIG_SOL_RPC_URL_DEV }} | ||
| SIG_SOL_RPC_URL_MAINNET: ${{ secrets.SIG_SOL_RPC_URL_MAINNET }} | ||
| SIG_SOL_SK: ${{ secrets.SIG_SOL_SK }} | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - uses: pnpm/action-setup@v3 | ||
| with: | ||
| version: 8 | ||
| - uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: 'pnpm' | ||
| - name: Install dependencies | ||
| run: pnpm install | ||
| - name: Run tests | ||
| run: pnpm test |
This file contains hidden or 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,2 @@ | ||
| /node_modules | ||
| .env | ||
| /dist | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| dist/ | ||
| pnpm-lock.yaml |
This file contains hidden or 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,21 +1,21 @@ | ||
| { | ||
| "editor.defaultFormatter": "esbenp.prettier-vscode", | ||
| "editor.formatOnSave": true, | ||
| "editor.codeActionsOnSave": { | ||
| "source.fixAll.eslint": "explicit", | ||
| "source.fixAll": "explicit" | ||
| }, | ||
| "[javascript]": { | ||
| "editor.defaultFormatter": "esbenp.prettier-vscode" | ||
| }, | ||
| "[javascriptreact]": { | ||
| "editor.defaultFormatter": "esbenp.prettier-vscode" | ||
| }, | ||
| "prettier.requireConfig": true, | ||
| "eslint.validate": [ | ||
| "javascript", | ||
| "javascriptreact", | ||
| "typescript", | ||
| "typescriptreact" | ||
| ] | ||
| } | ||
| "editor.defaultFormatter": "esbenp.prettier-vscode", | ||
| "editor.formatOnSave": true, | ||
| "editor.codeActionsOnSave": { | ||
| "source.fixAll.eslint": "explicit", | ||
| "source.fixAll": "explicit" | ||
| }, | ||
| "[javascript]": { | ||
| "editor.defaultFormatter": "esbenp.prettier-vscode" | ||
| }, | ||
| "[javascriptreact]": { | ||
| "editor.defaultFormatter": "esbenp.prettier-vscode" | ||
| }, | ||
| "prettier.requireConfig": true, | ||
| "eslint.validate": [ | ||
| "javascript", | ||
| "javascriptreact", | ||
| "typescript", | ||
| "typescriptreact" | ||
| ] | ||
| } |
This file contains hidden or 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,2 +1,66 @@ | ||
| # Contract Pinger | ||
|
|
||
| Simple server that can request a signature from any supported network. Used in load and synthetic tests. | ||
|
|
||
| ## Getting Started | ||
|
|
||
| ### Prerequisites | ||
|
|
||
| - Node.js (v18+ recommended) | ||
| - pnpm | ||
|
|
||
| ### Install dependencies | ||
|
|
||
| ```sh | ||
| pnpm install | ||
| ``` | ||
|
|
||
| ### Development | ||
|
|
||
| Run the server in development mode (auto-reloads on changes): | ||
|
|
||
| ```sh | ||
| pnpm dev | ||
| ``` | ||
|
|
||
| ### Build | ||
|
|
||
| Transpile TypeScript to JavaScript: | ||
|
|
||
| ```sh | ||
| pnpm build | ||
| ``` | ||
|
|
||
| ### Run (Production) | ||
|
|
||
| ```sh | ||
| pnpm start | ||
| ``` | ||
|
|
||
| ### Run (Development) | ||
|
|
||
| ```sh | ||
| pnpm dev | ||
| ``` | ||
|
|
||
| ### Test | ||
|
|
||
| Run all integration and unit tests: | ||
|
|
||
| ```sh | ||
| pnpm test | ||
| ``` | ||
|
|
||
| ### Code Formatting | ||
|
|
||
| To format all code in the project using Prettier and your `.prettierrc` settings, run: | ||
|
|
||
| ```sh | ||
| pnpm format | ||
| ``` | ||
|
|
||
| This will automatically format your codebase according to the project's style rules. | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| Copy `.env.example` to `.env` and fill in the required values for your environment. |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.contractAddresses = exports.chainName = void 0; | ||
| exports.execute = execute; | ||
| const initEvm_1 = require("../utils/initEvm"); | ||
| const evmTransactions_1 = require("../utils/evmTransactions"); | ||
| const signet_js_1 = require("signet.js"); | ||
| exports.chainName = 'Ethereum'; | ||
| exports.contractAddresses = { | ||
| dev: signet_js_1.constants.CONTRACT_ADDRESSES.ETHEREUM.TESTNET_DEV, | ||
| testnet: signet_js_1.constants.CONTRACT_ADDRESSES.ETHEREUM.TESTNET, | ||
| mainnet: signet_js_1.constants.CONTRACT_ADDRESSES.ETHEREUM.MAINNET, | ||
| }; | ||
| async function execute({ check_signature, environment, }) { | ||
| const contractAddress = exports.contractAddresses[environment]; | ||
| const { chainSigContract, publicClient, walletClient } = (0, initEvm_1.initEthereum)({ | ||
| contractAddress, | ||
| environment, | ||
| }); | ||
| if (check_signature) { | ||
| // TODO: add ability to call with check=true on Ethereum | ||
| throw new Error(`Ethereum can not be called with check=true due to long finalization time`); | ||
| const signature = await (0, evmTransactions_1.createSignRequestAndWaitSignature)({ | ||
| chainSigContract, | ||
| publicClient, | ||
| walletClient, | ||
| }); | ||
| return { signature }; | ||
| } | ||
| else { | ||
| const signatureRequest = await (0, evmTransactions_1.createSignRequest)({ | ||
| chainSigContract, | ||
| publicClient, | ||
| walletClient, | ||
| }); | ||
| return { signatureRequest }; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.