Skip to content

Name every setup handler initialize_x() - #117

Open
mikemaccana wants to merge 1 commit into
mainfrom
claude/review-fixes-reorder-and-conclusion-px8rd3
Open

Name every setup handler initialize_x()#117
mikemaccana wants to merge 1 commit into
mainfrom
claude/review-fixes-reorder-and-conclusion-px8rd3

Conversation

@mikemaccana

Copy link
Copy Markdown
Collaborator

Bringing an account into existence had four names across these examples: init_ in lending, create_ in token-swap, order-book and betting-market, initialize_ in perpetual-futures, prop-amm and vault-strategy, and a bare initialize in the fundraiser. Two programs disagreed about the same concept: token-swap said create_config() where betting-market said initialize_config().

The rule

If the domain has a word for it, use the domain's word; if the handler only stamps out a container, it is initialize_.

Domain verbs are what make these programs read like finance, and they come in pairs, so make_offer()/take_offer(), open_position()/close_position(), place_order()/cancel_order(), borrow, repay, liquidate, contribute and refund are all untouched. add_x() still means extending a container that already exists, so add_liquidity(), add_outcome() and add_asset() are untouched too. Setup has no domain meaning, so it is always initialize_x(), naming what it initializes.

The test is whether the handler moves money or takes a market action, or only writes parameters into a new account.

The renames

before after program
init_lending_market initialize_lending_market lending
init_reserve initialize_reserve lending
init_obligation initialize_obligation lending
create_config initialize_config token-swap
create_pool initialize_pool token-swap
create_market_user initialize_market_user order-book
create_event initialize_event betting-market
initialize initialize_fundraiser token-fundraiser

Each carries its CamelCase account structs, its handle_ prefix, its test names, and its source file. No checked-in IDL contains any of these names, so nothing needs regenerating.

Verification, and what is not verified

  • cargo check passes on all five renamed Anchor programs.
  • ⚠️ Test crates were not compiled. They include_bytes! a .so fixture that needs cargo build-sbf, and this environment has no Solana toolchain. Call sites and test function names were renamed and grep-verified complete, but CI should confirm they build.
  • ⚠️ Quasar crates were not compiled. They already fail on a clean tree here, 4 to 12 errors each, before any change, so they could not serve as a signal either way. They were renamed consistently with the Anchor side and need the same CI pass.

Pairs with quicknode/solana-book#13, whose prose cites these handler names, and quicknode/solana-finance-claude-plugin#37, which records the rule.


Generated by Claude Code

Bringing an account into existence had four names across these examples:
init_ in lending, create_ in token-swap, order-book and betting-market,
initialize_ in perpetual-futures, prop-amm and vault-strategy, and a
bare initialize in the fundraiser. Two programs disagreed about the same
concept: token-swap said create_config() where betting-market said
initialize_config().

One rule now: if the domain has a word for it, use the domain's word;
if the handler only stamps out a container, it is initialize_. So
make_offer(), open_position(), place_order(), contribute() and refund()
are untouched, because those verbs are what make the code read like
finance, and add_x() still means extending a container that exists.
Setup has no domain meaning, so it is always initialize_x(), naming what
it initializes.

Eight renames: init_lending_market, init_reserve, init_obligation,
create_config, create_pool, create_market_user, create_event, and the
fundraiser's bare initialize. Each carries its CamelCase account structs,
its handle_ prefix, its test names and its source file.

Verified: cargo check passes on all five renamed Anchor programs. Test
crates need the Solana SBF toolchain to build their .so fixture and
could not be compiled here, and the Quasar crates already fail to
compile on a clean tree (4 to 12 errors each), so both want a CI run.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BDUxWXgCA5TsoPPxHzRNen
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