Skip to content

Commit

Permalink
chore: refactor & improve (#15)
Browse files Browse the repository at this point in the history
* chore: refactor & improve

* chore: lint

* chore: pin toolchain

* chore: pin toolchain 1.82

* chore: update CI

* chore: update CI workflow

* chore: Fix lifetimes

* chore: setup node

* chore: add lock file

* chore: add lock file

* chore: upgrade ts

* chore: upgrade sdk packaging

* chore: update version
  • Loading branch information
GabrielePicco authored Jan 2, 2025
1 parent d6934f0 commit e0612cc
Show file tree
Hide file tree
Showing 16 changed files with 1,377 additions and 3,606 deletions.
64 changes: 64 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Build SDKs
on:
push:
branches:
- 'main'
pull_request:
branches:
- 'main'
env:
rust_version: 1.83.0
node_version: 23

jobs:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache-dependency-path: ts/package-lock.json
node-version: ${{ env.node_version }}
cache: 'npm'

- name: Install Rust
shell: "bash"
run: rustup toolchain install ${{ env.rust_version }} --profile minimal

- name: Cache rust
uses: Swatinem/rust-cache@v2

lint:
needs: install
runs-on: ubuntu-latest
defaults:
run:
working-directory: rust/

steps:
- uses: actions/checkout@v4
- name: Run fmt
run: cargo fmt -- --check

- name: Run clippy
run: cargo clippy -- --deny=warnings

build:
needs: [install, lint]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: run build
working-directory: rust/
run: |
cargo build
- name: npm run build
working-directory: ts/
run: |
npm install
npm run build
38 changes: 4 additions & 34 deletions .github/workflows/publish-crates-and-sdk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,43 +8,27 @@ on:
workflow_dispatch:

env:
solana_version: v1.18.8
rust_version: 1.83.0

jobs:
install:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
name: cache solana cli
id: cache-solana
with:
path: |
~/.cache/solana/
~/.local/share/solana/
key: solana-${{ runner.os }}-v0000-${{ env.solana_version }}

- name: install essentials
run: |
sudo apt-get update
sudo apt-get install -y pkg-config build-essential libudev-dev
npm install --global yarn
- name: install rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Install Rust
shell: "bash"
run: rustup toolchain install ${{ env.rust_version }} --profile minimal

- name: Cache rust
uses: Swatinem/rust-cache@v2

- name: install solana
if: steps.cache-solana.outputs.cache-hit != 'true'
run: |
sh -c "$(curl -sSfL https://release.solana.com/${{ env.solana_version }}/install)"
export PATH="$HOME/.local/share/solana/install/active_release/bin:$PATH"
solana --version
lint:
needs: install
runs-on: ubuntu-latest
Expand All @@ -66,20 +50,6 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
name: cache solana cli
id: cache-solana
with:
path: |
~/.cache/solana/
~/.local/share/solana/
key: solana-${{ runner.os }}-v0000-${{ env.solana_version }}

- name: setup solana
run: |
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
solana --version
solana-keygen new --silent --no-bip39-passphrase

- name: run build
working-directory: rust/
Expand Down
10 changes: 5 additions & 5 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ members = [
resolver = "2"

[workspace.package]
version = "0.1.2"
version = "0.1.4"
authors = ["Magicblock Labs <[email protected]>"]
edition = "2021"
license = "MIT"
Expand All @@ -21,9 +21,9 @@ readme = "../README.md"
keywords = ["solana", "crypto", "delegation", "ephemeral-rollups", "magicblock"]

[workspace.dependencies]
ephemeral-rollups-sdk-attribute-ephemeral-v2 = { path = "ephemeral", version = "=0.1.2" }
ephemeral-rollups-sdk-attribute-delegate-v2 = { path = "delegate", version = "=0.1.2" }
ephemeral-rollups-sdk-attribute-commit-v2 = { path = "commit-attribute", version = "=0.1.2" }
ephemeral-rollups-sdk-attribute-ephemeral-v2 = { path = "ephemeral", version = "=0.1.4" }
ephemeral-rollups-sdk-attribute-delegate-v2 = { path = "delegate", version = "=0.1.4" }
ephemeral-rollups-sdk-attribute-commit-v2 = { path = "commit-attribute", version = "=0.1.4" }

## External crates
anchor-lang = "0.30.1"
Expand Down
2 changes: 1 addition & 1 deletion rust/resolver/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub struct AccountValue<'a> {
pub data: SmallVec<[&'a str; 2]>,
}

impl<'a> AccountValue<'a> {
impl AccountValue<'_> {
/// Check if owner account is Delegation Program, and that account is not closed
pub fn is_delegated(&self) -> bool {
self.owner == DELEGATION_PROGRAM_ID && self.lamports != 0
Expand Down
1 change: 0 additions & 1 deletion rust/sdk/src/pda.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use solana_program::pubkey::Pubkey;

/// NOTE: Copy/Pasted from delegation-program/src/pda.rs (modify there if needed)
#[macro_export]
macro_rules! delegation_record_seeds_from_delegated_account {
($delegated_account: expr) => {
Expand Down
1 change: 1 addition & 0 deletions ts/.eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ parserOptions:
sourceType: module
project: [./tsconfig.json]
rules:
"@typescript-eslint/consistent-type-imports": "off"
"@typescript-eslint/strict-boolean-expressions":
- error
- allowNullableObject: true
Expand Down
Loading

0 comments on commit e0612cc

Please sign in to comment.