Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
824 changes: 410 additions & 414 deletions Cargo.lock

Large diffs are not rendered by default.

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

[workspace.package]
version = "3.0.11"
version = "3.1.0"
authors = ["Magicblock Labs <dev@magicblock.gg>"]
edition = "2021"
license = "MIT"
Expand All @@ -18,11 +18,20 @@ repository = "https://github.com/magicblock-labs/session-keys"
readme = "README.md"

[workspace.dependencies]
session-keys = { path = "programs/gpl_session", version = "=3.0.11" }
session-keys-macros = { path = "programs/gpl_session/macros", version = "=3.0.11" }
session-keys-macros-attribute = { path = "programs/gpl_session/macros/attribute", version = "=3.0.11" }
session-keys = { path = "programs/gpl_session", version = "=3.1.0" }
session-keys-macros = { path = "programs/gpl_session/macros", version = "=3.1.0" }
session-keys-macros-attribute = { path = "programs/gpl_session/macros/attribute", version = "=3.1.0" }

# Magicblock
# Anchor — single broad-range dep so the consumer's workspace pin (1.0.x or 0.28-0.32.x) wins.
# `proc-macro-crate` (used by anchor's derive macros) inspects the Cargo.toml literally and
# can't handle two renamed deps both pointing at the same package, so we deliberately keep
# only one entry.
anchor-lang = { version = ">=0.28, <2.0" }

# Proc-macro helpers
proc-macro2 = "1.0"
quote = "1.0"
syn = { version = "2.0.117", features = ["full"] }

[profile.release]
overflow-checks = true
Expand Down
15 changes: 12 additions & 3 deletions programs/gpl_session/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,23 @@ crate-type = ["cdylib", "lib"]
name = "session_keys"

[features]
# The actual anchor version is decided by the consumer's Cargo workspace pin on
# `anchor-lang`. session-keys' own dep is a wide range, so cargo resolves it to
# whatever the user has already pinned. No anchor-version flag is needed — the
# program does its single CPI via solana_program directly, which has a stable
# signature across Anchor 0.28 - 1.x.
#
# anchor-lang = "1.0" # or "0.32", "0.30", ...
# session-keys = { version = "...", features = ["no-entrypoint"] }

default = []
no-entrypoint = ["session-keys-macros"]
no-idl = []
no-log-ix-name = []
cpi = ["no-entrypoint"]
default = []
idl-build = ["anchor-lang/idl-build"]

[dependencies]
anchor-lang = "^0"
anchor-lang = { workspace = true }
solana-security-txt = "^1.1.1"
session-keys-macros = { workspace = true, path = "macros", optional = true }
session-keys-macros = { workspace = true, optional = true }
2 changes: 1 addition & 1 deletion programs/gpl_session/macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ repository = "https://github.com/magicblock-labs/gum-program-library"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
session-keys-macros-attribute = { workspace = true , path = "attribute" }
session-keys-macros-attribute = { workspace = true }
6 changes: 3 additions & 3 deletions programs/gpl_session/macros/attribute/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ repository = "https://github.com/magicblock-labs/gum-program-library"
proc-macro = true

[dependencies]
proc-macro2 = "1.0.32"
quote = "1.0.10"
syn = { version = "1.0.60", features = ["full"] }
proc-macro2 = { workspace = true }
quote = { workspace = true }
syn = { workspace = true }
2 changes: 1 addition & 1 deletion programs/gpl_session/macros/attribute/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Parse for SessionArgs {
}

fn is_session(attr: &syn::Attribute) -> bool {
attr.path.is_ident("session")
attr.path().is_ident("session")
}

#[derive(Copy, Clone, Eq, PartialEq)]
Expand Down
34 changes: 12 additions & 22 deletions programs/gpl_session/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(unexpected_cfgs)]

use anchor_lang::prelude::*;
use anchor_lang::system_program;
use anchor_lang::solana_program::{program::invoke, system_instruction};

const LAMPORTS_PER_SOL: u64 = 1_000_000_000;

Expand Down Expand Up @@ -99,7 +99,7 @@ pub struct CreateSessionToken<'info> {

/// CHECK the target program is actually a program.
#[account(executable)]
pub target_program: AccountInfo<'info>,
pub target_program: UncheckedAccount<'info>,

pub system_program: Program<'info, System>,
}
Expand Down Expand Up @@ -141,15 +141,10 @@ fn create_session_token_internal<'info>(

// Top up the session signer account with some lamports to pay for the transaction fees
if top_up {
system_program::transfer(
CpiContext::new(
system_program,
system_program::Transfer {
from: payer,
to: session_signer_account,
},
),
lamports.unwrap_or(LAMPORTS_PER_SOL / 100),
let amount = lamports.unwrap_or(LAMPORTS_PER_SOL / 100);
invoke(
&system_instruction::transfer(payer.key, session_signer_account.key, amount),
&[payer, session_signer_account, system_program],
)?;
}

Expand Down Expand Up @@ -204,7 +199,7 @@ pub struct CreateSessionTokenWithPayer<'info> {

/// CHECK the target program is actually a program.
#[account(executable)]
pub target_program: AccountInfo<'info>,
pub target_program: UncheckedAccount<'info>,

pub system_program: Program<'info, System>,
}
Expand Down Expand Up @@ -295,7 +290,7 @@ pub struct CreateSessionTokenV2<'info> {

/// CHECK the target program is actually a program.
#[account(executable)]
pub target_program: AccountInfo<'info>,
pub target_program: UncheckedAccount<'info>,

pub system_program: Program<'info, System>,
}
Expand Down Expand Up @@ -340,15 +335,10 @@ fn create_session_token_v2_internal<'info>(

// Top up the session signer account with some lamports to pay for the transaction fees
if top_up {
system_program::transfer(
CpiContext::new(
system_program,
system_program::Transfer {
from: payer,
to: session_signer_account,
},
),
lamports.unwrap_or(LAMPORTS_PER_SOL / 100),
let amount = lamports.unwrap_or(LAMPORTS_PER_SOL / 100);
invoke(
&system_instruction::transfer(payer.key, session_signer_account.key, amount),
&[payer, session_signer_account, system_program],
)?;
}

Expand Down
6 changes: 4 additions & 2 deletions version_align.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ esac

echo "Updating ..."

# Update the version for all crates in the Cargo.toml workspace.dependencies section
sed "${sedi[@]}" -e '/\[workspace.dependencies\]/,/# Magicblock/s/version = ".*"/version = "='$version'"/' Cargo.toml
# Update the version pin only on internal `session-keys*` workspace deps. The narrow
# pattern means third-party deps in the same section (anchor-lang, syn, ...) are never
# touched, regardless of any fence comment.
sed "${sedi[@]}" -e '/^session-keys[a-zA-Z0-9_-]* = /s/version = "[^"]*"/version = "='$version'"/' Cargo.toml
Comment thread
GabrielePicco marked this conversation as resolved.

# Potential for collisions in Cargo.lock, use cargo update to update it
cargo update --workspace --manifest-path ./Cargo.toml
Expand Down