Skip to content
Merged
Show file tree
Hide file tree
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 May 27, 2025
3c2fb93
add test setup
volovyks May 27, 2025
140610a
add formatting
volovyks May 27, 2025
f66b67d
add ling generated for /dist
volovyks May 28, 2025
30a6123
JS - TS fin
volovyks May 28, 2025
55afb68
format ignore /dist
volovyks May 28, 2025
349884a
fix input parameter tets
volovyks May 28, 2025
b198550
close server after tests
volovyks May 28, 2025
f166b75
rewrite env setup
volovyks May 28, 2025
4d35829
add no check positive tests
volovyks May 29, 2025
e0556e5
throw only unexpected 500s
volovyks May 29, 2025
55e72fc
add solana test with check
volovyks May 29, 2025
eb86579
add laad test
volovyks May 29, 2025
de89766
CI
volovyks May 29, 2025
f2064e4
update lock file
volovyks May 29, 2025
b214775
ignore lock git diff
volovyks May 29, 2025
eb2bed1
ignore lock in formatting
volovyks May 29, 2025
852059d
add env variables in CI
volovyks May 29, 2025
6d73c13
debug ci env
volovyks May 29, 2025
6166b49
Update src/utils/initEvm.ts
volovyks May 29, 2025
e2cf1fc
Update src/handlers/ethereum.ts
volovyks May 29, 2025
a4fce8c
add environment to CI
volovyks May 30, 2025
82eb597
fix formatting
volovyks May 30, 2025
df2c4d0
fix file extension issue
volovyks May 30, 2025
da76e3f
added image push workflow, added healthcheck route
auto-mausx May 30, 2025
bd320b3
test fixes/linting
auto-mausx May 30, 2025
5ab9e38
prettier check
auto-mausx May 30, 2025
b7010a1
set api key
auto-mausx May 30, 2025
39c6642
build files
auto-mausx May 30, 2025
80cac3c
fix / tests
volovyks May 30, 2025
e279a28
fix / tests
volovyks May 30, 2025
5bbd2ec
fix return status
volovyks Jun 2, 2025
c139354
fix eth key rotation
volovyks Jun 2, 2025
5d51173
Update test/ping.integration.test.ts
volovyks Jun 2, 2025
e116a7c
add eth balance endpoint
volovyks Jun 2, 2025
04c1479
Merge pull request #23 from sig-net/serhii/acc-balances
volovyks Jun 2, 2025
1df68d4
Merge pull request #22 from sig-net/serhii/proper-rotation
volovyks Jun 2, 2025
3817973
eth test test
volovyks Jun 2, 2025
326d566
eth test test
volovyks Jun 2, 2025
6726f6b
remove test
volovyks Jun 2, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions .env.example
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=
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/dist/* linguist-generated=true
33 changes: 33 additions & 0 deletions .github/workflows/build-push-image.yaml
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'
79 changes: 79 additions & 0 deletions .github/workflows/ci.yml
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
/node_modules
.env
/dist
Comment thread
esaminu marked this conversation as resolved.
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist/
pnpm-lock.yaml
40 changes: 20 additions & 20 deletions .vscode/settings.json
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"
]
}
64 changes: 64 additions & 0 deletions README.md
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.
38 changes: 38 additions & 0 deletions dist/handlers/ethereum.js
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 };
}
}
Loading