Skip to content

Commit

Permalink
Merge branch 'dev' into feat/deprecate-transfer
Browse files Browse the repository at this point in the history
  • Loading branch information
wei3erHase authored Sep 25, 2024
2 parents d860efa + 02684dc commit 081dc51
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 8 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Rust

on:
push:
branches:
- main
pull_request:
branches:
- "**"

env:
CARGO_TERM_COLOR: always

jobs:
build:

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: "recursive"
fetch-depth: 1

- name: Setup Rust
uses: actions-rust-lang/setup-rust-toolchain@v1

- name: Run tests
working-directory: program
run: cargo test --features test-bpf
8 changes: 4 additions & 4 deletions program/src/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ impl Arbitrary for VestingInstruction {
1 => {
let schedules: [Schedule; 10] = u.arbitrary()?;
let key_bytes: [u8; 32] = u.arbitrary()?;
let mint_address: Pubkey = Pubkey::new(&key_bytes);
let mint_address: Pubkey = Pubkey::new_from_array(key_bytes);
let key_bytes: [u8; 32] = u.arbitrary()?;
let destination_token_address: Pubkey = Pubkey::new(&key_bytes);
let destination_token_address: Pubkey = Pubkey::new_from_array(key_bytes);
return Ok(Self::Create {
seeds,
mint_address,
Expand Down Expand Up @@ -129,12 +129,12 @@ impl VestingInstruction {
let mint_address = rest
.get(32..64)
.and_then(|slice| slice.try_into().ok())
.map(Pubkey::new)
.map(Pubkey::new_from_array)
.ok_or(InvalidInstruction)?;
let destination_token_address = rest
.get(64..96)
.and_then(|slice| slice.try_into().ok())
.map(Pubkey::new)
.map(Pubkey::new_from_array)
.ok_or(InvalidInstruction)?;
let number_of_schedules = rest[96..].len() / SCHEDULE_SIZE;
let mut schedules: Vec<Schedule> = Vec::with_capacity(number_of_schedules);
Expand Down
10 changes: 6 additions & 4 deletions program/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use solana_program::{
pubkey::Pubkey,
};

use std::convert::TryInto;
use std::convert::{TryFrom, TryInto};
#[derive(Debug, PartialEq)]
pub struct VestingSchedule {
pub release_time: u64,
Expand Down Expand Up @@ -36,13 +36,15 @@ impl Pack for VestingScheduleHeader {

target[64] = self.is_initialized as u8;
}

fn unpack_from_slice(src: &[u8]) -> Result<Self, ProgramError> {
if src.len() < 65 {
return Err(ProgramError::InvalidAccountData)
}
let destination_address = Pubkey::new(&src[..32]);
let mint_address = Pubkey::new(&src[32..64]);
let destination_address = Pubkey::try_from(&src[..32])
.map_err(|_| ProgramError::InvalidArgument)?;
let mint_address = Pubkey::try_from(&src[32..64])
.map_err(|_| ProgramError::InvalidArgument)?;
let is_initialized = src[64] == 1;
Ok(Self {
destination_address,
Expand Down

0 comments on commit 081dc51

Please sign in to comment.