-
Notifications
You must be signed in to change notification settings - Fork 280
DEVREL-126 feat: validate Solana admin address for delegate/owner when wiring #1538
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
Merged
nazreen
merged 20 commits into
main
from
codex/add-solana-contract-owner/delegate-check
Jul 16, 2025
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
587e18d
Improve Solana admin validation
nazreen 883b5c7
add dep
nazreen ddc10c5
lockfile
nazreen 29c32b4
Merge branch 'main' into codex/add-solana-contract-owner/delegate-check
nazreen a81edb0
Validate Solana admin vault ownership
nazreen d23b71d
Use io-devtools debug logger
nazreen b759489
Remove debug logger from Solana admin validation
nazreen 67e9692
changeset
nazreen b466e54
update target
nazreen 96823d9
bump
nazreen 3025825
Merge remote-tracking branch 'origin/main' into codex/add-solana-cont…
nazreen 55125a1
fix
nazreen e44a325
downgrade solana-developers/helpers
nazreen 65f3418
Fix Solana admin validation in config
nazreen f5be0b8
try fix
nazreen 80c487c
cleaner impl
nazreen db87caf
revert
nazreen bb4e751
changesets
nazreen 395aebb
no noise
nazreen 34e9251
Update packages/io-devtools/src/stdio/debugLogger.ts
nazreen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@layerzerolabs/ua-devtools-solana": minor | ||
| "@layerzerolabs/devtools-solana": minor | ||
| "@layerzerolabs/io-devtools": minor | ||
| --- | ||
|
|
||
| validate solana owner or delegate is valid before proceeding to set |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@layerzerolabs/ua-devtools": patch | ||
| --- | ||
|
|
||
| bump target version for tsconfig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| @solana-developers/helpers pinned to 2.8.0 due to this issue: https://solana.stackexchange.com/questions/21945/issue-with-solana-developers-helpers-package-in-browser-environments-anchors?utm_source=chatgpt.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| import { DebugLogger, KnownErrors } from '@layerzerolabs/io-devtools' | ||
| import { Connection, PublicKey, SystemProgram } from '@solana/web3.js' | ||
| import { PROGRAM_ID as SQUADS_PROGRAM_ID } from '@sqds/multisig' | ||
|
|
||
| /** | ||
| * Returns true if the provided address is a valid on-curve public key. This can mean the address is either a 'regular' Solana address or a Squads Vault PDA. | ||
| */ | ||
| export function isOnCurveAddress(address: string): boolean { | ||
| try { | ||
| return PublicKey.isOnCurve(new PublicKey(address).toBytes()) | ||
| } catch { | ||
| return false | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Returns true if the provided address could be a Squads vault PDA. | ||
| */ | ||
| export async function isPossibleSquadsVault(connection: Connection, address: string): Promise<boolean> { | ||
| try { | ||
| const pubkey = new PublicKey(address) | ||
| const accountInfo = await connection.getAccountInfo(pubkey) | ||
|
|
||
| return accountInfo != null && accountInfo.owner.equals(SystemProgram.programId) | ||
| } catch (error) { | ||
| return false | ||
| } | ||
| } | ||
|
|
||
| export async function assertValidSolanaAdmin(connection: Connection, address: string): Promise<void> { | ||
| const pubkey = new PublicKey(address) | ||
|
|
||
| try { | ||
| const accountInfo = await connection.getAccountInfo(pubkey) | ||
|
|
||
| if (accountInfo != null && accountInfo.owner.equals(SQUADS_PROGRAM_ID)) { | ||
| DebugLogger.printErrorAndFixSuggestion(KnownErrors.SOLANA_OWNER_OR_DELEGATE_CANNOT_BE_MULTISIG_ACCOUNT) | ||
| throw new Error( | ||
| `Invalid owner/delegate address ${address}. This is a Squads multisig account. Use the vault address instead.` | ||
| ) | ||
| } | ||
|
|
||
| if (!isOnCurveAddress(address) && !(await isPossibleSquadsVault(connection, address))) { | ||
| DebugLogger.printErrorAndFixSuggestion(KnownErrors.SOLANA_INVALID_OWNER_OR_DELEGATE) | ||
| throw new Error( | ||
| `Invalid owner/delegate address ${address}. Must be a valid on-curve address or a Squads Vault PDA.` | ||
| ) | ||
| } | ||
| } catch (error) { | ||
| if (error instanceof Error) { | ||
| throw error | ||
| } | ||
| throw new Error(String(error)) | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| export * from './accounts' | ||
| export * from './schema' | ||
| export * from './types' | ||
| export * from './addresses' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.