-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lang: API for creating program derived addresses with instruction data #150
Comments
We can expand already existing
|
I agree with Norbert. I think expanding the init flags shows intent with more clarity and is more in-line with the existing patterns. |
I like the idea of an associated attribute. One limitation is that the attribute inside the
So the attribute becomes pub struct CreateExchangeAccount<'info> {
#[account(init, associated = authority)]
pub exchange_account: ProgramAccount<'info, ExchangeAccount>,
#[account(signer)]
pub authority: AccountInfo<'info>
pub rent: Sysvar<'info, Rent>,
} |
Moving the associated attribute to a separate issue #185. |
Perhaps a more elegant solution to the one originally proposed here is to extend + merge both the We can do this with a new #[pda]
pub struct MyProgramDerivedAddress {
....
}
impl MyProgramDerivedAddress {
pub fn new(ctx: Context<New>, input_data: &u8) -> Result<(Self, &[&[&[u8]]])> {
//
}
} Open questionsDo we want to change the Edit. The current consensus is to make a new macro. The Implementation detailsOne annoying thing here is how to deal with the seeds. They must be a |
An additional feature mentioned a couples times on discord, is that it would be desireable for one to specify static strings in the pda seeds. |
The API that I've landed on for the first version of this feature will look like this. #[derive(Accounts)]
#[instruction(domain: String)]
pub struct TestPdaInit<'info> {
#[account(init, seeds = [b"my-seed", domain.as_bytes()], payer = my_payer)]
my_pda: ProgramAccount<'info, DataU16>,
my_payer: AccountInfo<'info>,
rent: Sysvar<'info, Rent>,
system_program: AccountInfo<'info>,
} Where we extend the Note that one must redeclare the instruction api via |
Done by #386. |
Using program derived addresses for account data is cumbersome. One has to
8+
for the account discriminatorAn example of this taken from https://github.com/project-serum/anchor/pull/86/files#diff-20d471b8d1707e332b0dd96fe3ef98601ff2511362e4eeb3a94ff3c921a797edR167:
There should be an api or some codegen to make this more friendly.
For example
The text was updated successfully, but these errors were encountered: