-
Notifications
You must be signed in to change notification settings - Fork 857
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
Feature suggestion: allow more seed types to be provided to getProgramDerivedAddress() #2312
Labels
enhancement
New feature or request
Comments
mikemaccana
changed the title
Feature suggestion: allow more seed types to be provided getProgramDerivedAddress()
Feature suggestion: allow more seed types to be provided to getProgramDerivedAddress()
Mar 12, 2024
We can firstly change the type Seed to
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For
solana-web3.js/packages/addresses/src/program-derived-address.ts
Line 80 in 273bc9e
Buffer.from("someString")
when runninggetProgramDerivedAddress()
sinceProgramDerivedAddressInput
includes strings so I can just provide the string directly, avoiding the need to write boilerplate.What if we allowed Addresses, BigInts etc? If an Address is provided as a seed, encode it as a byte array.
Motivation + Example use case
When working with web3.js 1.x code, I notice a lot of boilerplate encoding code:
Before
So wrote a little wrapper that follows this technique, checking for different types end consistently encoding them:
After
Details
For your own reference, this is what my own
getPDAAndBump()
looked like, I'm sure you could write something better though:The text was updated successfully, but these errors were encountered: