Skip to content

Commit 74d0455

Browse files
committed
chore: add CIs for lazer
1 parent 9c5a20b commit 74d0455

File tree

12 files changed

+227
-61
lines changed

12 files changed

+227
-61
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "Lazer Rust Test Suite"
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- lazer/**
8+
pull_request:
9+
paths:
10+
- lazer/**
11+
12+
jobs:
13+
lazer-rust-test-suite:
14+
name: Lazer Rust Test Suite
15+
runs-on: ubuntu-22.04
16+
defaults:
17+
run:
18+
working-directory: lazer
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
submodules: recursive
23+
- uses: actions-rust-lang/setup-rust-toolchain@v1
24+
with:
25+
toolchain: 1.81.0
26+
- name: Install Foundry
27+
uses: foundry-rs/foundry-toolchain@v1
28+
- name: install extra tools
29+
run: |
30+
cargo install --locked [email protected]
31+
sudo apt-get install -y protobuf-compiler
32+
- name: Install Solana Cli
33+
run: |
34+
sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"
35+
echo "$HOME/.local/share/solana/install/active_release/bin" >> "$GITHUB_PATH"
36+
- name: check Cargo.toml formatting
37+
run: find . -name Cargo.toml -exec taplo fmt --check --diff {} \;
38+
- name: Build Solana programs
39+
run: cargo build-sbf
40+
- name: test
41+
run: cargo test
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: "Lazer EVM Test Suite"
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- lazer/contracts/evm/**
8+
pull_request:
9+
paths:
10+
- lazer/contracts/evm/**
11+
12+
jobs:
13+
lazer-evm-test-suite:
14+
name: Lazer EVM Test Suite
15+
runs-on: ubuntu-22.04
16+
defaults:
17+
run:
18+
working-directory: lazer/contracts/evm
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
submodules: recursive
23+
- name: Install Foundry
24+
uses: foundry-rs/foundry-toolchain@v1
25+
- name: Check build
26+
run: forge build --sizes
27+
- name: Run tests
28+
run: forge test -vvv
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: "Lazer JS SDK Test Suite"
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- lazer/sdk/js/**
8+
pull_request:
9+
paths:
10+
- lazer/sdk/js/**
11+
12+
jobs:
13+
lazer-js-sdk-test-suite:
14+
name: Lazer JS SDK Test Suite
15+
runs-on: ubuntu-22.04
16+
defaults:
17+
run:
18+
working-directory: lazer/sdk/js
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version: 20.18.0
24+
- run: npm install --global [email protected]
25+
- run: pnpm install --frozen-lockfile
26+
- run: pnpm run test
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: "Lazer Solana contract test"
2+
on:
3+
push:
4+
branches:
5+
- main
6+
paths:
7+
- lazer/**
8+
pull_request:
9+
paths:
10+
- lazer/**
11+
12+
jobs:
13+
lazer-solana-contract-test:
14+
name: Lazer Solana contract test
15+
runs-on: ubuntu-22.04
16+
defaults:
17+
run:
18+
working-directory: lazer/contracts/solana
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions-rust-lang/setup-rust-toolchain@v1
22+
with:
23+
toolchain: 1.81.0
24+
- name: install taplo
25+
run: cargo install --locked [email protected]
26+
- uses: actions/setup-node@v4
27+
with:
28+
node-version: 20.18.0
29+
- name: Install Solana Cli
30+
run: |
31+
sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"
32+
echo "$HOME/.local/share/solana/install/active_release/bin" >> "$GITHUB_PATH"
33+
- name: Set Solana Cli version
34+
run: agave-install init 1.18.26
35+
- name: Create Solana key
36+
run: solana-keygen new --no-bip39-passphrase
37+
- name: Install Anchor
38+
run: RUSTFLAGS= cargo install --git https://github.com/coral-xyz/anchor --tag v0.30.1 anchor-cli
39+
- name: Install pnpm
40+
run: npm install --global [email protected]
41+
- name: Install test dependencies
42+
run: pnpm install --frozen-lockfile
43+
- name: Run tests
44+
run: pnpm run test

.pre-commit-config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,16 @@ repos:
150150
files: express_relay/sdk/python/express_relay
151151
exclude: express_relay/sdk/python/express_relay/svm/generated/
152152
language: "system"
153+
# For Lazer
154+
- id: cargo-fmt-lazer
155+
name: Cargo format for Lazer
156+
language: "rust"
157+
entry: cargo +1.82.0 fmt --manifest-path ./lazer/Cargo.toml --all
158+
pass_filenames: false
159+
files: lazer
160+
- id: cargo-clippy-lazer
161+
name: Cargo clippy for Lazer
162+
language: "rust"
163+
entry: cargo +1.82.0 clippy --manifest-path ./lazer/Cargo.toml --all-targets -- --deny warnings
164+
pass_filenames: false
165+
files: lazer

lazer/contracts/evm/src/PythLazer.sol

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ contract PythLazer is OwnableUpgradeable, UUPSUpgradeable {
2020

2121
function _authorizeUpgrade(address) internal override onlyOwner {}
2222

23-
function updateTrustedSigner(address trustedSigner, uint256 expiresAt) external onlyOwner {
23+
function updateTrustedSigner(
24+
address trustedSigner,
25+
uint256 expiresAt
26+
) external onlyOwner {
2427
if (expiresAt == 0) {
2528
for (uint8 i = 0; i < trustedSigners.length; i++) {
2629
if (trustedSigners[i].pubkey == trustedSigner) {
@@ -58,7 +61,9 @@ contract PythLazer is OwnableUpgradeable, UUPSUpgradeable {
5861
return false;
5962
}
6063

61-
function verifyUpdate(bytes calldata update) external view returns (bytes calldata payload, address signer) {
64+
function verifyUpdate(
65+
bytes calldata update
66+
) external view returns (bytes calldata payload, address signer) {
6267
if (update.length < 71) {
6368
revert("input too short");
6469
}
@@ -74,7 +79,12 @@ contract PythLazer is OwnableUpgradeable, UUPSUpgradeable {
7479
}
7580
payload = update[71:71 + payload_len];
7681
bytes32 hash = keccak256(payload);
77-
signer = ecrecover(hash, uint8(update[68]) + 27, bytes32(update[4:36]), bytes32(update[36:68]));
82+
signer = ecrecover(
83+
hash,
84+
uint8(update[68]) + 27,
85+
bytes32(update[4:36]),
86+
bytes32(update[36:68])
87+
);
7888
if (signer == address(0)) {
7989
revert("invalid signature");
8090
}

lazer/contracts/evm/src/PythLazerLib.sol

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ library PythLazerLib {
1818
FixedRate200
1919
}
2020

21-
function parsePayloadHeader(bytes calldata update)
21+
function parsePayloadHeader(
22+
bytes calldata update
23+
)
2224
public
2325
pure
2426
returns (uint64 timestamp, Channel channel, uint8 feedsLen, uint16 pos)
@@ -39,7 +41,10 @@ library PythLazerLib {
3941
pos += 1;
4042
}
4143

42-
function parseFeedHeader(bytes calldata update, uint16 pos)
44+
function parseFeedHeader(
45+
bytes calldata update,
46+
uint16 pos
47+
)
4348
public
4449
pure
4550
returns (uint32 feed_id, uint8 num_properties, uint16 new_pos)
@@ -51,27 +56,28 @@ library PythLazerLib {
5156
new_pos = pos;
5257
}
5358

54-
function parseFeedProperty(bytes calldata update, uint16 pos)
55-
public
56-
pure
57-
returns (PriceFeedProperty property, uint16 new_pos)
58-
{
59+
function parseFeedProperty(
60+
bytes calldata update,
61+
uint16 pos
62+
) public pure returns (PriceFeedProperty property, uint16 new_pos) {
5963
property = PriceFeedProperty(uint8(update[pos]));
6064
pos += 1;
6165
new_pos = pos;
6266
}
6367

64-
function parseFeedValueUint64(bytes calldata update, uint16 pos)
65-
public
66-
pure
67-
returns (uint64 value, uint16 new_pos)
68-
{
68+
function parseFeedValueUint64(
69+
bytes calldata update,
70+
uint16 pos
71+
) public pure returns (uint64 value, uint16 new_pos) {
6972
value = uint64(bytes8(update[pos:pos + 8]));
7073
pos += 8;
7174
new_pos = pos;
7275
}
7376

74-
function parseFeedValueUint8(bytes calldata update, uint16 pos) public pure returns (uint8 value, uint16 new_pos) {
77+
function parseFeedValueUint8(
78+
bytes calldata update,
79+
uint16 pos
80+
) public pure returns (uint8 value, uint16 new_pos) {
7581
value = uint8(update[pos]);
7682
pos += 1;
7783
new_pos = pos;

lazer/rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.81.0
1+
1.82.0

lazer/sdk/js/examples/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ client.addMessageListener((message) => {
1111
"stream updated for subscription",
1212
message.value.subscriptionId,
1313
":",
14-
message.value.parsed?.priceFeeds,
14+
message.value.parsed?.priceFeeds
1515
);
1616
}
1717
break;

lazer/sdk/js/package.json

Lines changed: 38 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,40 @@
11
{
2-
"name": "pyth-lazer-sdk",
3-
"version": "1.0.0",
4-
"description": "pyth-lazer-sdk",
5-
"private": "true",
6-
"scripts": {
7-
"build:cjs": "tsc --project tsconfig.json --verbatimModuleSyntax false --module commonjs --outDir ./dist/cjs && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
8-
"build:esm": "tsc --project tsconfig.json --outDir ./dist/esm && echo '{\"type\":\"module\"}' > dist/esm/package.json",
9-
"example": "node --loader ts-node/esm examples/index.js",
10-
"test": "pnpm run test:format && pnpm run test:lint && pnpm run build:cjs && pnpm run build:esm",
11-
"doc": "typedoc --out docs/typedoc src",
12-
"fix:format": "prettier --write **/*.*",
13-
"test:format": "prettier --check **/*.*",
14-
"test:lint": "eslint .",
15-
"fix:lint": "eslint --fix .",
16-
"publish": "pnpm run script -- publish"
17-
},
18-
"devDependencies": {
19-
"@cprussin/eslint-config": "^3.0.0",
20-
"@cprussin/tsconfig": "^3.0.1",
21-
"@eslint/js": "^9.12.0",
22-
"@types/eslint__js": "^8.42.3",
23-
"@types/node": "^18.19.54",
24-
"@types/ws": "^8.5.12",
25-
"eslint": "^9.12.0",
26-
"prettier": "^3.3.3",
27-
"ts-node": "^10.9.2",
28-
"typedoc": "^0.26.8",
29-
"typescript": ">=5.5.0 < 5.6.0",
30-
"typescript-eslint": "^8.8.0"
31-
},
32-
"bugs": {
33-
"url": "https://github.com/pyth-lazer-sdk/pyth-lazer-sdk/issues"
34-
},
35-
"type": "module",
36-
"homepage": "https://github.com/pyth-lazer-sdk/pyth-lazer-sdk#readme",
37-
"keywords": [],
38-
"dependencies": {
39-
"isomorphic-ws": "^5.0.0",
40-
"ws": "^8.18.0"
41-
}
2+
"name": "pyth-lazer-sdk",
3+
"version": "1.0.0",
4+
"description": "pyth-lazer-sdk",
5+
"private": "true",
6+
"scripts": {
7+
"build:cjs": "tsc --project tsconfig.json --verbatimModuleSyntax false --module commonjs --outDir ./dist/cjs && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
8+
"build:esm": "tsc --project tsconfig.json --outDir ./dist/esm && echo '{\"type\":\"module\"}' > dist/esm/package.json",
9+
"example": "node --loader ts-node/esm examples/index.js",
10+
"test": "pnpm run test:lint && pnpm run build:cjs && pnpm run build:esm",
11+
"doc": "typedoc --out docs/typedoc src",
12+
"test:lint": "eslint .",
13+
"fix:lint": "eslint --fix .",
14+
"publish": "pnpm run script -- publish"
15+
},
16+
"devDependencies": {
17+
"@cprussin/eslint-config": "^3.0.0",
18+
"@cprussin/tsconfig": "^3.0.1",
19+
"@eslint/js": "^9.12.0",
20+
"@types/eslint__js": "^8.42.3",
21+
"@types/node": "^18.19.54",
22+
"@types/ws": "^8.5.12",
23+
"eslint": "^9.12.0",
24+
"prettier": "^3.3.3",
25+
"ts-node": "^10.9.2",
26+
"typedoc": "^0.26.8",
27+
"typescript": ">=5.5.0 < 5.6.0",
28+
"typescript-eslint": "^8.8.0"
29+
},
30+
"bugs": {
31+
"url": "https://github.com/pyth-lazer-sdk/pyth-lazer-sdk/issues"
32+
},
33+
"type": "module",
34+
"homepage": "https://github.com/pyth-lazer-sdk/pyth-lazer-sdk#readme",
35+
"keywords": [],
36+
"dependencies": {
37+
"isomorphic-ws": "^5.0.0",
38+
"ws": "^8.18.0"
39+
}
4240
}

0 commit comments

Comments
 (0)