Skip to content

Add migrate scan command - #91

Merged
mcintyre94 merged 1 commit into
mainfrom
migrate-scan
Oct 29, 2026
Merged

mcintyre94 merged 1 commit into
mainfrom
migrate-scan

Conversation

@mcintyre94

@mcintyre94 mcintyre94 commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

This command allows scanning for authorities/assets belonging to an address that can be migrated using our migrate CLI commands

We use getAccountInfo for the SOL balance, getTokenAccountsByOwner for the token balances, and getProgramAccounts for the authorities.

Output includes the items that can be migrated, and the migrate commands that can be run for them. An optional --new-authority-signing-pubkey arg sets that arg in each migrate command. Otherwise it is left out, so each command defaults to moving to the owner's own programmatic signer, or a placeholder is used if the owner is not on curve.

Note that in my testing both Triton and Helius fail on scanning mints, but work for the others. I assume this is because they block GPA on the token programs. But I've included the feature to cover everything we have migrate commands for, and I figure that some users of durable nonces/this CLI might have some custom RPC infrastructure. The command is structured to do each scan independently and display which ones errored, while providing the data for those that succeeded.

@mcintyre94
mcintyre94 added this pull request to stack #88 October 20, 2026 17:22
@mcintyre94
mcintyre94 requested a review from joncinque October 20, 2026 17:43
@mcintyre94
mcintyre94 force-pushed the migrate-scan branch 2 times, most recently from 7d6da90 to 4282c5b Compare October 21, 2026 18:10
@mcintyre94
mcintyre94 force-pushed the migrate-scan branch 3 times, most recently from 6972700 to 3bedc4f Compare October 22, 2026 09:31
Base automatically changed from migrate-sol to main October 22, 2026 09:58

@joncinque joncinque left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Just a few questions, nothing stopping this from merging though

Comment on lines +394 to +396
if amount == 0 {
continue;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned in the previous PR on token accounts, we should still report accounts with 0 balance, but this can be changed at the same time as the token command

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, added a note on the tracking issue to update scan when we change migrate token there

}
}
}
if scanned("sol") {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry if I'm being dense, but why is this check only done here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because all the others return a Option<Vec>, that can distinguish between "error scanning tokens" (None), and "successful scan, nothing found" (empty Vec). Sol is an Option<SolScanItem>

I think a better model would be to keep the Result types to distinguish between Error and Ok(empty) consistently in each category, I'll try refactoring this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yeah, that probably would be better, but we don't need to block landing this if you want to do it in a follow-up

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored to better use Result throughout, which I think makes this simpler. We now just check if Ok(...) for each one, which is consistent.

I also made the command on SolScanItem optional, so we give the correct SOL balance even if migrate sol can't migrate it.

@joncinque joncinque left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance you could un-force-push this so I can see the changes between the last iteration and this one?

@mcintyre94

Copy link
Copy Markdown
Member Author

@joncinque Sorry about that, I've split the changes into a fixup commit

@mcintyre94

Copy link
Copy Markdown
Member Author

Cherry-picked from #98 to avoid needing another rebase/force push

@joncinque joncinque left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

This command allows scanning for authorities/assets belonging to an
address that can be migrated using our `migrate` CLI commands

We use `getAccountInfo` for the SOL balance, `getTokenAccountsByOwner`
for the token balances, and `getProgramAccounts` for the authorities.

Output includes the items that can be migrated, and the `migrate`
commands that can be run for them. An optional
`--new-authority-signing-pubkey` arg sets that arg in each migrate
command. Otherwise it is left out, so each command defaults to moving
to the owner's own programmatic signer, or a placeholder is used if the
owner is not on curve.
@mcintyre94
mcintyre94 merged commit 325026f into main Oct 29, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants