-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: add anchor bindings anchor-lang #3440
base: master
Are you sure you want to change the base?
Conversation
@mgild is attempting to deploy a commit to the coral-xyz Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been requested before, so thank you for adding this!
It would be very helpful to have some tests for these types. They don't need to be very complicated; just some tests to check compilation and basic functionality. Compilation tests are especially important given how easy it is to miss the idl-build
feature impl.
There are also a couple more issues that I mentioned in the comments, but it looks good otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. We also need to add the tests to the workflow file to make them run in CI.
The test folder looks like you may have uncommitted changes because there are unused keypairs and definitions (the test itself also doesn't work). I left some comments for those issues.
Lastly, this feature surely deserves a mention in the CHANGELOG — could you add an entry?
impl<'info> DerefMut for AddressLookupTableAccount<'info> { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.0 | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It wouldn't hurt to have this, but does it make sense to have it when the account is always going to be immutable in our usage?
@@ -0,0 +1,16 @@ | |||
{ | |||
"name": "address-lookup-table", | |||
"version": "0.24.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: other tests use the current version of the repo (0.30.1
) here, so it would be nice to keep things consistent when possible.
"version": "0.24.0", | |
"version": "0.30.1", |
@@ -0,0 +1,30 @@ | |||
use anchor_lang::prelude::*; | |||
|
|||
use crate::program::AddressLookupTableTest; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't look like this is being used anywhere. If so, could you remove it?
use crate::program::AddressLookupTableTest; |
#[error_code] | ||
pub enum CustomError { | ||
InvalidProgramDataAddress, | ||
AccountNotProgram, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Errors also don't seem to be used. Please remove if that's the case.
#[error_code] | |
pub enum CustomError { | |
InvalidProgramDataAddress, | |
AccountNotProgram, | |
} |
const tx = await program.rpc.test({ | ||
accounts: { | ||
authority: provider.wallet.publicKey, | ||
lutProgram: lutProgramAddress, | ||
table: lutProgramAddress, // Just a dummy value. fix | ||
}, | ||
signers: [settings], | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This syntax has been deprecated for a long time, and we plan to remove it soon — could you use the newer syntax?
const tx = await program.rpc.test({ | |
accounts: { | |
authority: provider.wallet.publicKey, | |
lutProgram: lutProgramAddress, | |
table: lutProgramAddress, // Just a dummy value. fix | |
}, | |
signers: [settings], | |
}); | |
const tx = await program.methods | |
.test() | |
.accounts({ table: lutProgramAddress }) | |
.rpc(); |
Also, settings
don't seem to be defined anywhere.
This change adds wrapper bindings for the AddressLookupTable program and AddressLookupTable Account.
Usage:
Tests:
cd lang cargo build