diff --git a/.github/actions/setup/action.yml b/.github/actions/setup/action.yml index 83fe397..f4a32b3 100644 --- a/.github/actions/setup/action.yml +++ b/.github/actions/setup/action.yml @@ -10,9 +10,6 @@ inputs: cargo-cache-local-key: description: The key to cache local cargo dependencies. Skips local cargo caching if not provided. required: false - rust: - description: Install Rust if `true`. Defaults to `false`. - required: false solana: description: Install Solana if `true`. Defaults to `false`. required: false @@ -23,6 +20,9 @@ inputs: runs: using: 'composite' steps: + - name: Install Protoc + uses: arduino/setup-protoc@v3 + - name: Setup pnpm uses: pnpm/action-setup@v3 @@ -41,14 +41,13 @@ runs: run: pnpm zx ./scripts/ci/set-env.mjs - name: Install Rust - if: ${{ inputs.rust == 'true' }} - uses: dtolnay/rust-toolchain@master + uses: actions-rust-lang/setup-rust-toolchain@v1 with: toolchain: ${{ env.RUST_TOOLCHAIN }} components: rustc, cargo, rustfmt, clippy + cache: true - name: Install Solana - if: ${{ inputs.solana == 'true' }} uses: metaplex-foundation/actions/install-solana@v1 with: version: ${{ env.SOLANA_VERSION }} @@ -98,5 +97,6 @@ runs: .cargo/registry/index/ .cargo/registry/cache/ .cargo/git/db/ + ~/.cache/solana/ key: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }}-${{ hashFiles('**/Cargo.lock') }} restore-keys: ${{ runner.os }}-${{ inputs.cargo-cache-local-key }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3703c9b..df5ea70 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,8 +16,6 @@ jobs: - name: Setup Environment uses: ./.github/actions/setup - with: - rust: true - name: Format Programs run: pnpm programs:format @@ -50,8 +48,6 @@ jobs: - name: Setup Environment uses: ./.github/actions/setup - with: - rust: true - name: Format Client Rust run: pnpm clients:rust:format @@ -71,8 +67,6 @@ jobs: uses: ./.github/actions/setup with: cargo-cache-key: cargo-programs - rust: true - solana: true - name: Build Programs run: pnpm programs:build @@ -93,7 +87,7 @@ jobs: test_programs: name: Test Programs runs-on: ubuntu-latest - needs: format_and_lint_programs + needs: build_programs steps: - name: Git Checkout uses: actions/checkout@v4 @@ -103,8 +97,6 @@ jobs: with: cargo-cache-key: cargo-program-tests cargo-cache-fallback-key: cargo-programs - rust: true - solana: true - name: Test Programs run: pnpm programs:test diff --git a/.github/workflows/publish-rust-client.yml b/.github/workflows/publish-rust-client.yml index 64a6b0a..7a97dcb 100644 --- a/.github/workflows/publish-rust-client.yml +++ b/.github/workflows/publish-rust-client.yml @@ -44,8 +44,6 @@ jobs: uses: ./.github/actions/setup with: cargo-cache-key: cargo-rust-client - rust: true - solana: true - name: Format Rust Client run: pnpm clients:rust:format @@ -74,7 +72,6 @@ jobs: with: cargo-cache-key: cargo-publish-rust-client cargo-cache-fallback-key: cargo-rust-client - rust: true - name: Install Cargo Release run: which cargo-release || cargo install cargo-release diff --git a/Cargo.toml b/Cargo.toml index 959eea4..528273e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ repository = "https://github.com/dephy-io/dephy-id" license = "Apache-2.0" [workspace.metadata.cli] -solana = "2.0.13" +solana = "1.18.25" [workspace.dependencies] anchor-lang = "0.30.1" diff --git a/cli/src/main.rs b/cli/src/main.rs index 08749d3..71e73d4 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -6,10 +6,10 @@ use arrayref::array_ref; use clap::{Args, Parser, Subcommand, ValueEnum}; use dephy_id_program_client::{ instructions::{ - ActivateDeviceBuilder, CreateDeviceBuilder, CreateProductBuilder, InitializeBuilder, - CreateActivatedDeviceNonSignerBuilder, + ActivateDeviceBuilder, CreateActivatedDeviceNonSignerBuilder, CreateDeviceBuilder, + CreateProductBuilder, InitializeBuilder, }, - types::{self, DeviceActivationSignature, CreateActivatedDeviceArgs}, + types::{self, CreateActivatedDeviceArgs, DeviceActivationSignature}, DEVICE_MESSAGE_PREFIX, DEVICE_MINT_SEED_PREFIX, EIP191_MESSAGE_PREFIX, ID as PROGRAM_ID, PRODUCT_MINT_SEED_PREFIX, PROGRAM_PDA_SEED_PREFIX, }; @@ -80,9 +80,9 @@ enum DeviceSigningAlgorithm { Secp256k1, } -impl Into for DeviceSigningAlgorithm { - fn into(self) -> types::DeviceSigningAlgorithm { - match self { +impl From for types::DeviceSigningAlgorithm { + fn from(val: DeviceSigningAlgorithm) -> Self { + match val { DeviceSigningAlgorithm::Ed25519 => types::DeviceSigningAlgorithm::Ed25519, DeviceSigningAlgorithm::Secp256k1 => types::DeviceSigningAlgorithm::Secp256k1, } @@ -146,9 +146,9 @@ enum SignatureType { EthSecp256k1, } -impl Into for SignatureType { - fn into(self) -> DeviceSigningAlgorithm { - match self { +impl From for DeviceSigningAlgorithm { + fn from(val: SignatureType) -> Self { + match val { SignatureType::Ed25519 => DeviceSigningAlgorithm::Ed25519, SignatureType::Secp256k1 => DeviceSigningAlgorithm::Secp256k1, SignatureType::EthSecp256k1 => DeviceSigningAlgorithm::Secp256k1, @@ -257,13 +257,13 @@ fn get_client(url: &String) -> RpcClient { let timeout = Duration::from_secs(10); let commitment_config = CommitmentConfig::processed(); let confirm_transaction_initial_timeout = Duration::from_secs(10); - let client = RpcClient::new_with_timeouts_and_commitment( + + RpcClient::new_with_timeouts_and_commitment( url, timeout, commitment_config, confirm_transaction_initial_timeout, - ); - client + ) } fn read_key(path: &String) -> Keypair { @@ -486,7 +486,7 @@ fn dev_create_activated_device(args: DevCreateActivatedDeviceCliArgs) { .instruction()], Some(&payer.pubkey()), &[&payer, &vendor], - latest_block + latest_block, ); match client.send_and_confirm_transaction(&transaction) { @@ -496,7 +496,10 @@ fn dev_create_activated_device(args: DevCreateActivatedDeviceCliArgs) { eprintln!("Device: {}", device_pubkey); eprintln!("Mint: {}", did_mint_pubkey); eprintln!("AToken: {}", did_atoken_pubkey); - println!("{},{},{}", device_pubkey, did_mint_pubkey, did_atoken_pubkey); + println!( + "{},{},{}", + device_pubkey, did_mint_pubkey, did_atoken_pubkey + ); } Err(err) => { eprintln!("Error: {:?}", err); @@ -698,8 +701,8 @@ fn sign_message(args: SignMessageCliArgs) { | DeviceActivationSignature::EthSecp256k1(signature_bytes, recovery_id) => { println!( "{}{}", - hex::encode(&signature_bytes), - hex::encode(&[recovery_id]) + hex::encode(signature_bytes), + hex::encode([recovery_id]) ); } } diff --git a/clients/rust/src/utils.rs b/clients/rust/src/utils.rs index f01aef2..ba207bc 100644 --- a/clients/rust/src/utils.rs +++ b/clients/rust/src/utils.rs @@ -34,16 +34,16 @@ pub fn find_product_mint( pub fn get_product_atoken(product_mint: &Pubkey, device: &Pubkey) -> Pubkey { spl_associated_token_account::get_associated_token_address_with_program_id( - &device, - &product_mint, + device, + product_mint, &spl_token_2022::id(), ) } pub fn get_device_atoken(user: &Pubkey, device_mint: &Pubkey) -> Pubkey { spl_associated_token_account::get_associated_token_address_with_program_id( - &user, - &device_mint, + user, + device_mint, &spl_token_2022::id(), ) } diff --git a/scripts/program/build.mjs b/scripts/program/build.mjs index df63a47..5726034 100644 --- a/scripts/program/build.mjs +++ b/scripts/program/build.mjs @@ -14,10 +14,17 @@ import './dump.mjs'; const buildArgs = cliArguments(); // Build the programs. -await Promise.all( - getProgramFolders().map(async (folder) => { +// await Promise.all( +// getProgramFolders().map(async (folder) => { +// const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml'); +// +// await $`cargo-build-sbf --manifest-path ${manifestPath} ${buildArgs}`; +// }) +// ); + +// Build the programs. +for await (const folder of getProgramFolders()) { const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml'); await $`cargo-build-sbf --manifest-path ${manifestPath} ${buildArgs}`; - }) -); +}