Skip to content

feat(nft-meta-data-pointer): migrate frontend to @solana/kit - #673

Open
Harsh-H-Shah wants to merge 3 commits into
solana-foundation:mainfrom
Harsh-H-Shah:feat/nft-meta-data-pointer-kit-migration
Open

feat(nft-meta-data-pointer): migrate frontend to @solana/kit#673
Harsh-H-Shah wants to merge 3 commits into
solana-foundation:mainfrom
Harsh-H-Shah:feat/nft-meta-data-pointer-kit-migration

Conversation

@Harsh-H-Shah

Copy link
Copy Markdown
Contributor

Follow-up to #657, where dev-jodee asked for web3.js to be dropped in favor of kit. Replaces @anchor-lang/core with a Codama-generated @solana/kit client (from a real anchor-build-extracted IDL, not the hand-maintained one), and @solana/wallet-adapter-react with @solana/connector for wallet connection.

@magicblock-labs/gum-react-sdk (the session-key feature) is pinned to @solana/web3.js and @solana/wallet-adapter-react in its own published API and predates kit, so full removal isn't possible while keeping that feature. That stays as a single, documented legacy boundary (utils/legacyBridge.ts, contexts/SessionProvider.tsx) bridging the one connected wallet into the shape gum-sdk needs, rather than running two separately-connected wallet instances.

Follow-up to solana-foundation#657, where dev-jodee asked for web3.js to be dropped in favor of
kit. Replaces @anchor-lang/core with a Codama-generated @solana/kit client
(from a real anchor-build-extracted IDL, not the hand-maintained one), and
@solana/wallet-adapter-react with @solana/connector for wallet connection.

@magicblock-labs/gum-react-sdk (the session-key feature) is pinned to
@solana/web3.js and @solana/wallet-adapter-react in its own published API and
predates kit, so full removal isn't possible while keeping that feature. That
stays as a single, documented legacy boundary (utils/legacyBridge.ts,
contexts/SessionProvider.tsx) bridging the one connected wallet into the shape
gum-sdk needs, rather than running two separately-connected wallet instances.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Harsh-H-Shah
Harsh-H-Shah requested a review from dev-jodee as a code owner August 5, 2026 08:32
@greptile-apps

greptile-apps Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR migrates the NFT metadata-pointer frontend’s primary Solana integration from Anchor and wallet-adapter APIs to a Codama-generated @solana/kit client while retaining a narrow legacy bridge for the session-key SDK.

  • Adds generated-client tooling and instruction, account, and PDA consumption through @solana/kit.
  • Replaces wallet connection and transaction submission with @solana/connector and Kit-native flows.
  • Updates account subscriptions, NFT queries, airdrops, and session-wallet interoperability.
  • Fixes the previously reported local energy projection and maximum-energy countdown behavior.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the current timer publishes refilled energy through a new state object and explicitly clears the countdown when maximum energy is reached.

Important Files Changed

Filename Overview
tokens/token-2022/nft-meta-data-pointer/app/contexts/GameStateProvider.tsx Migrates account fetching and subscriptions to Kit and correctly publishes projected refill state while clearing the countdown at maximum energy.
tokens/token-2022/nft-meta-data-pointer/app/hooks/useSendInstruction.ts Adds a shared Kit transaction-message construction, signing, confirmation, and signature-return flow.
tokens/token-2022/nft-meta-data-pointer/app/contexts/SessionProvider.tsx Bridges the connector-provided Kit signer into the legacy AnchorWallet interface required by the session-key SDK.
tokens/token-2022/nft-meta-data-pointer/app/contexts/WalletContextProvider.tsx Replaces wallet-adapter providers with a devnet-configured Solana connector provider.
tokens/token-2022/nft-meta-data-pointer/app/scripts/generate-client.ts Adds Codama client generation from the Anchor-derived IDL for development and production builds.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    Wallet["Wallet Standard wallet"] --> Connector["@solana/connector"]
    Connector --> Signer["Kit transaction signer"]
    Signer --> Client["Codama-generated @solana/kit client"]
    Client --> RPC["Solana devnet RPC"]
    Signer --> Bridge["Legacy AnchorWallet bridge"]
    Bridge --> Gum["@magicblock-labs/gum-react-sdk"]
    Gum --> RPC
Loading

Reviews (3): Last reviewed commit: "fix: clear energy countdown once max ene..." | Re-trigger Greptile

Comment on lines +110 to 114
let energy = playerState.energy;
while (timePassed >= Number(TIME_TO_REFILL_ENERGY) && energy < MAX_ENERGY) {
energy += 1n;
timePassed -= Number(TIME_TO_REFILL_ENERGY);
}

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.

P1 Refilled energy remains stale

When a connected player has less than maximum energy and a refill interval elapses, this loop increments only the local energy variable while the provider continues exposing the unchanged playerState, causing the displayed energy counter to remain stale until another account notification arrives.

Greptile caught this on review: the refill-tick loop computed incremented
energy/lastLogin into local variables but never wrote them back to
playerState, so the displayed energy counter stayed stale between real
account-change notifications. The previous BN-based version got away with
mutating playerState.energy in place and relying on the same effects
setTimePassed/setEnergyNextIn calls to force a re-render - that trick got
dropped when the local let variables were introduced. Now commits the
computed values via setPlayerState explicitly, only when something changed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Comment on lines 102 to 104
if (playerState == null || playerState.lastLogin === undefined || playerState.energy >= MAX_ENERGY) {
return;
}

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.

P1 Maximum energy leaves stale countdown

When the final refill raises playerState.energy to MAX_ENERGY, the next timer callbacks return without clearing nextEnergyIn, causing the UI to display a pending refill countdown indefinitely beside maximum energy.

Suggested change
if (playerState == null || playerState.lastLogin === undefined || playerState.energy >= MAX_ENERGY) {
return;
}
if (playerState == null || playerState.lastLogin === undefined) {
return;
}
if (playerState.energy >= MAX_ENERGY) {
setEnergyNextIn(0);
return;
}

Greptile flagged this on review. Pre-existing behavior (the same early
return existed before this migration) surfaced by having Greptile look
closely at code already being touched here: once playerState.energy hits
MAX_ENERGY, the interval returned early without ever calling
setEnergyNextIn(0), so the last computed countdown stayed on screen next
to a full energy bar indefinitely. Splits the guard so the max-energy
case explicitly clears the countdown before returning.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

1 participant