Skip to content

feat(cct-sdk): Add get token pool state config solana op#306

Open
mervin-link wants to merge 44 commits into
cct-sdkfrom
feat/DAPP-10574-get-state
Open

feat(cct-sdk): Add get token pool state config solana op#306
mervin-link wants to merge 44 commits into
cct-sdkfrom
feat/DAPP-10574-get-state

Conversation

@mervin-link

@mervin-link mervin-link commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

What

  • DAPP-10574
  • Add getTokenPoolState to the Solana CCT token manager for Burn/Mint and Lock/Release pools
  • Return serialized pool configuration and pool-type-specific state fields

Why

  • Enable SDK consumers to inspect canonical Solana token pool configuration without manually fetching and decoding the state account

Note

  • Custom pool program address does not recognize lock-release type so lock-release fields will not be included.

@mervin-link
mervin-link requested a review from a team as a code owner July 21, 2026 13:03
@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown

You must have Developer access to commit code to Chainlink Labs on Vercel. If you contact an administrator and receive Developer access, commit again to see your changes.

Learn more: https://vercel.com/docs/accounts/team-members-and-roles/access-roles#team-level-roles

Base automatically changed from feat/DAPP-10507-deploy-token-pool to cct-sdk July 21, 2026 16:10
@mervin-link
mervin-link force-pushed the feat/DAPP-10574-get-state branch from 3a36363 to b702787 Compare July 21, 2026 16:49
@mervin-link
mervin-link changed the base branch from cct-sdk to feat/DAPP-10522-create-token-account July 21, 2026 16:50
Comment thread ccip-sdk/src/cct/solana/token-pool/operations/get-token-pool-state.ts Outdated
Comment thread ccip-sdk/src/cct/solana/token-pool/operations/get-token-pool-state.ts Outdated
Comment thread ccip-sdk/src/cct/solana/programs/token-pool.ts Outdated
Comment thread ccip-sdk/src/cct/solana/programs/token-pool.ts Outdated

@aelmanaa aelmanaa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Heads-up on a maintainability angle that crosses core and CCT — not a blocker for this PR, but worth deciding before the next CCT read op lands.

The token-pool state account is decoded in two places that have to agree byte-for-byte: core (solana/index.ts — getTokenPoolRemotes uses tokenPoolCoder.accounts.decode) and CCT (programs/token-pool.ts — decodeTokenPoolState). Both build the same TOKEN_POOL_IDL = { ...BURN_MINT_IDL, types: BASE.types } merge and the same BorshCoder. The IDL data files themselves are already shared (both import solana/idl/1.6.0/{BASE,BURN_MINT}_TOKEN_POOL.ts), so the account layout is single-sourced and won't drift. But the merge recipe + coder construction are duplicated, and the version pin (1.6.0) is independent in each — those can drift.

The two obvious fixes are both wrong here: importing core's coder would force a runtime import of the 1929-line solana/index.ts into the CCT op layer (which today only type-imports core — that's the load-bearing separation), and pushing the read into core would fatten getTokenPoolConfig for every core user who never touches CCT.

A third option that honors both separation and DRY: extract the merge + coder into a small neutral leaf under solana/idl/ (e.g. token-pool-coder.ts) that depends only on @coral-xyz/anchor and the IDL data files — never on solana/index.ts or cct/**. Core and CCT both import it; each keeps its own result projection (core's 4-field view, CCT's 15-field view). The load-bearing types-splice comment lives once, in one place.

With more CCT read ops coming (registry state, chain config, rate limits), establishing the leaf now — at the first duplication — is cheaper than retrofitting it at the third. If it feels premature for this PR, the fallback is just adding the merge comment to both copies and aligning the version pin. Either way, worth a decision before the next read op duplicates the coder again.

Comment thread ccip-sdk/src/cct/solana/token-pool/operations/get-token-pool-state.test.ts Outdated
@mervin-link

Copy link
Copy Markdown
Collaborator Author

Heads-up on a maintainability angle that crosses core and CCT — not a blocker for this PR, but worth deciding before the next CCT read op lands.

The token-pool state account is decoded in two places that have to agree byte-for-byte: core (solana/index.ts — getTokenPoolRemotes uses tokenPoolCoder.accounts.decode) and CCT (programs/token-pool.ts — decodeTokenPoolState). Both build the same TOKEN_POOL_IDL = { ...BURN_MINT_IDL, types: BASE.types } merge and the same BorshCoder. The IDL data files themselves are already shared (both import solana/idl/1.6.0/{BASE,BURN_MINT}_TOKEN_POOL.ts), so the account layout is single-sourced and won't drift. But the merge recipe + coder construction are duplicated, and the version pin (1.6.0) is independent in each — those can drift.

The two obvious fixes are both wrong here: importing core's coder would force a runtime import of the 1929-line solana/index.ts into the CCT op layer (which today only type-imports core — that's the load-bearing separation), and pushing the read into core would fatten getTokenPoolConfig for every core user who never touches CCT.

A third option that honors both separation and DRY: extract the merge + coder into a small neutral leaf under solana/idl/ (e.g. token-pool-coder.ts) that depends only on @coral-xyz/anchor and the IDL data files — never on solana/index.ts or cct/**. Core and CCT both import it; each keeps its own result projection (core's 4-field view, CCT's 15-field view). The load-bearing types-splice comment lives once, in one place.

With more CCT read ops coming (registry state, chain config, rate limits), establishing the leaf now — at the first duplication — is cheaper than retrofitting it at the third. If it feels premature for this PR, the fallback is just adding the merge comment to both copies and aligning the version pin. Either way, worth a decision before the next read op duplicates the coder again.

I extracted the shared IDL merge and token-pool coder into solana/idl/token-pool-coder.ts. Solana CCT now imports it.

@mervin-link
mervin-link requested a review from aelmanaa July 22, 2026 12:04
Base automatically changed from feat/DAPP-10522-create-token-account to cct-sdk July 23, 2026 10:54
Comment thread ccip-sdk/src/errors/recovery.ts Outdated
Comment on lines +35 to +45
/**
* Asserts `value` is a valid Solana public key string.
* @throws CCTParamsInvalidError if `value` is not a valid Solana public key string.
*/
export function validatePublicKey(
operation: string,
param: string,
value: unknown,
): asserts value is string {
parsePublicKey(operation, param, value)
}

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.

Should we use parsePublicKey directly?

@mervin-link mervin-link Jul 23, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I kept validatePublicKey for validation-only paths. This keeps validate() methods readable, while call ops that need a PublicKey use parsePublicKey directly.

@mervin-link
mervin-link requested a review from apedrob July 23, 2026 14:15
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.

3 participants