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
5 changes: 3 additions & 2 deletions Anchor.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ world = "WorLD15A7CrDwLcLy4fRqtaTb9fbd8o8iqiEMUDse2n"
bolt-component = "CmP2djJgABZ4cRokm4ndxuq6LerqpNHLBsaUv2XKEJua"
bolt-system = "7X4EFsDJ5aYTcEjKzJ94rD8FRKgQeXC89fkpeTS4KaqP"
component-small = "9yBADAhoTWCkNRB6hbfpwUgPpxyJiF9uEiWVPR6k7A4y"
escrow-funding = "4Um2d8SvyfWyLLtfu2iJMFhM77DdjjyQusEy7K3VhPkd"
position = "Fn1JzzEdyb55fsyduWS94mYHizGhJZuhvjX6DVvrmGbQ"
system-apply-velocity = "6LHhFVwif6N9Po3jHtSmMVtPjF6zRfL3xMosSzcrQAS8"
system-fly = "HT2YawJjkNmqWcLNfPAMvNsLdWwPvvvbKA5bpMw4eUpq"
system-simple-movement = "FSa6qoJXFBR3a7ThQkTAMrC15p6NkchPEjBdd4n6dXxA"
velocity = "CbHEFbSQdRN4Wnoby9r16umnJ1zWbULBHg4yqzGQonU1"
with-1-component = "BsVKJF2H9GN1P9WrexdgEY4ztiweKvfQo6ydLWUEw6n7"
with-10-components = "C69UYWaXBQXUbhHQGtG8pB7DHSgh2z5Sm9ifyAnM1kkt"
with-2-components = "X5wTvz1i6ocNXzfrEB8JmhFCniojUZxqk3TXDq98fZX"
with-3-components = "9R7rvEwCuZ6iow1Ch3sdUQKib4LBvftyBmyvSnPaAZkG"
with-4-components = "2w9pkZoCfEciHLLDhG3zrZRprcYH7nojhyBQMnD3PtUU"
Expand All @@ -25,7 +27,6 @@ with-6-components = "3ndvNAg4moKeLhuWQtDmcN43PuvvGsigQWRBPthfWEN3"
with-7-components = "4ESiD77Gjjfuywhw8NBnryHezXtwDSA27ustL29JdX7i"
with-8-components = "EbTAEnrVV4f8W7Fd4TxW3jLjfpyhr74wQf7rSHRQ8u78"
with-9-components = "GKdPXW7pGhFNRdMPHWNsrmqc7haXQk4VFCAyZKsrgYQG"
with-10-components = "C69UYWaXBQXUbhHQGtG8pB7DHSgh2z5Sm9ifyAnM1kkt"

[registry]
url = "https://api.apr.dev"
Expand All @@ -35,7 +36,7 @@ cluster = "localnet"
wallet = "./tests/fixtures/provider.json"

[workspace]
members = ["crates/programs/bolt-component", "crates/programs/bolt-system", "crates/programs/world", "examples/component-position", "examples/component-velocity", "examples/system-apply-velocity", "examples/system-fly", "examples/system-simple-movement", "examples/component-small", "examples/system-with-1-component", "examples/system-with-2-components", "examples/system-with-3-components", "examples/system-with-4-components", "examples/system-with-5-components", "examples/system-with-6-components", "examples/system-with-7-components", "examples/system-with-8-components", "examples/system-with-9-components", "examples/system-with-10-components"]
members = ["crates/programs/bolt-component", "crates/programs/bolt-system", "crates/programs/world", "examples/component-position", "examples/component-velocity", "examples/system-apply-velocity", "examples/system-fly", "examples/system-simple-movement", "examples/component-small", "examples/system-with-1-component", "examples/system-with-2-components", "examples/system-with-3-components", "examples/system-with-4-components", "examples/system-with-5-components", "examples/system-with-6-components", "examples/system-with-7-components", "examples/system-with-8-components", "examples/system-with-9-components", "examples/system-with-10-components", "examples/escrow-funding"]

[scripts]
test = "tests/script.sh"
Expand Down
9 changes: 9 additions & 0 deletions Cargo.lock

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

16 changes: 10 additions & 6 deletions crates/bolt-lang/attribute/system/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ impl VisitMut for SystemTransform {
impl SystemTransform {
fn add_variadic_execute_function(content: &mut Vec<syn::Item>) {
content.push(syn::parse2(quote! {
pub fn bolt_execute<'info>(ctx: Context<'_, '_, 'info, 'info, VariadicBoltComponents<'info>>, args: Vec<u8>) -> Result<Vec<Vec<u8>>> {
pub fn bolt_execute<'a, 'b, 'info>(ctx: Context<'a, 'b, 'info, 'info, VariadicBoltComponents<'info>>, args: Vec<u8>) -> Result<Vec<Vec<u8>>> {
let mut components = Components::try_from(&ctx)?;
let bumps = ComponentsBumps {};
let context = Context::new(ctx.program_id, &mut components, ctx.remaining_accounts, bumps);
Expand Down Expand Up @@ -317,11 +317,15 @@ impl VisitMut for Extractor {
let last_segment = type_path.path.segments.last().unwrap();
if last_segment.ident == "Context" {
if let PathArguments::AngleBracketed(args) = &last_segment.arguments {
if let Some(syn::GenericArgument::Type(syn::Type::Path(type_path))) =
args.args.first()
{
let ident = &type_path.path.segments.first().unwrap().ident;
self.context_struct_name = Some(ident.to_string());
// Find the first generic argument that is a Type::Path (e.g., Components)
for ga in args.args.iter() {
if let syn::GenericArgument::Type(syn::Type::Path(type_path)) = ga {
if let Some(first_seg) = type_path.path.segments.first() {
self.context_struct_name =
Some(first_seg.ident.to_string());
break;
}
}
}
}
}
Expand Down
26 changes: 26 additions & 0 deletions examples/escrow-funding/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[package]
name = "escrow-funding"
version = "0.2.4"
description = "Created with Bolt"
edition = "2021"

[lib]
crate-type = ["cdylib", "lib"]
name = "escrow_funding"

[features]
no-entrypoint = []
no-idl = []
no-log-ix-name = []
cpi = ["no-entrypoint"]
default = []
idl-build = ["bolt-lang/idl-build"]
anchor-debug = ["bolt-lang/anchor-debug"]
custom-heap = []
custom-panic = []


[dependencies]
bolt-lang.workspace = true
serde = { version = "1.0", features = ["derive"] }
component-small.workspace = true
2 changes: 2 additions & 0 deletions examples/escrow-funding/Xargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[target.bpfel-unknown-unknown.dependencies.std]
features = []
44 changes: 44 additions & 0 deletions examples/escrow-funding/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
use bolt_lang::anchor_lang::*;
use bolt_lang::*;
use component_small::Small;

declare_id!("4Um2d8SvyfWyLLtfu2iJMFhM77DdjjyQusEy7K3VhPkd");

#[system]
pub mod escrow_funding {
pub fn execute<'info>(
ctx: Context<'_, '_, '_, 'info, Components<'info>>,
args: Args,
) -> Result<Components<'info>> {
let receiver = ctx.accounts.receiver.to_account_info();
let sender = ctx.sender()?.clone();
let system_program = ctx.system_program()?.clone();

let cpi_accounts = system_program::Transfer {
from: sender,
to: receiver,
};
let cpi_ctx = CpiContext::new(system_program, cpi_accounts);
system_program::transfer(cpi_ctx, args.amount)?;

Ok(ctx.accounts)
}

#[system_input]
pub struct Components {
pub receiver: Small,
}

#[arguments]
pub struct Args {
amount: u64,
}

#[extra_accounts]
pub struct ExtraAccounts {
#[account(mut)]
pub sender: AccountInfo,
#[account(address = bolt_lang::solana_program::system_program::id())]
pub system_program: AccountInfo,
}
}
Loading