feat(nft-meta-data-pointer): migrate frontend to @solana/kit - #673
feat(nft-meta-data-pointer): migrate frontend to @solana/kit#673Harsh-H-Shah wants to merge 3 commits into
Conversation
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>
Greptile SummaryThis PR migrates the NFT metadata-pointer frontend’s primary Solana integration from Anchor and wallet-adapter APIs to a Codama-generated
Confidence Score: 5/5The 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
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
Reviews (3): Last reviewed commit: "fix: clear energy countdown once max ene..." | Re-trigger Greptile |
| let energy = playerState.energy; | ||
| while (timePassed >= Number(TIME_TO_REFILL_ENERGY) && energy < MAX_ENERGY) { | ||
| energy += 1n; | ||
| timePassed -= Number(TIME_TO_REFILL_ENERGY); | ||
| } |
There was a problem hiding this comment.
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>
| if (playerState == null || playerState.lastLogin === undefined || playerState.energy >= MAX_ENERGY) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
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.
| 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>
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.