buddy-link

Crates.iobuddy-link
lib.rsbuddy-link
version0.4.0
sourcesrc
created_at2023-08-03 21:57:09.140701
updated_at2024-12-04 17:44:51.855275
descriptionLibrary to interact with the BuddyLink on-chain referral system
homepage
repository
max_upload_size
id934528
size4,488,358
Wagg (WaggMe)

documentation

README

Here is an example of how you would call the SDK for SPL

Here the transfer is made by the signer directly, if your "from account" is owned by a PDA, then transfer seeds would need to be provided.

let cpi_context = CpiContext::new(
    buddy_link_program.to_account_info(),
    buddy_link::cpi::TransferCheckedGlobalOnlyReward {
        buddy_link_program: buddy_link_program.to_account_info(),
        authority: authority.to_account_info(),
        system_program: None,
        mint:  Some(mint.to_account_info()),
        token_program: Some(token_program.to_account_info()),
        from_token_account: Some(user_token_account.to_account_info()),
        referrer_token_account: Some(remaining_accounts[0].to_account_info()),
        global_referrer_treasury: referrer_treasury.to_account_info(),
        global_referrer_treasury_for_reward: referrer_treasury_for_reward.to_account_info(),
        referee_buddy_profile: buddy_profile.to_account_info(),
        referee_buddy: buddy.to_account_info(),
    },
);

buddy_link::cpi::transfer_checked_global_only_reward(
    cpi_context,
    amount_referral,
    & [],
);

Here is an example of how you would call the SDK for SOL

Here the transfer is made by the signer directly, if your "from account" is owned by a PDA, then transfer seeds would need to be provided.

let cpi_context = CpiContext::new(
    buddy_link_program.to_account_info(),
    buddy_link::cpi::TransferCheckedGlobalOnlyReward {
        buddy_link_program: buddy_link_program.to_account_info(),
        authority: authority.to_account_info(),
        system_program: Some(system_program.to_account_info()),
        mint: None,
        token_program: None,
        from_token_account: None,
        referrer_token_account: None,
        global_referrer_treasury: referrer_treasury.to_account_info(),
        global_referrer_treasury_for_reward: referrer_treasury_for_reward.to_account_info(),
        referee_buddy_profile: buddy_profile.to_account_info(),
        referee_buddy: buddy.to_account_info(),
    },
);

buddy_link::cpi::transfer_checked_global_only_reward(
    cpi_context,
    amount_referral,
    &[],
)

How to test

  1. yarn install
  2. amman start
  3. cargo test
Commit count: 0

cargo fmt