Skip to content

Enterprise wallet integration (rebased on testnet) - #409

Open
matt-o-how wants to merge 16 commits into
mainfrom
enterprise_wallet_integration_testnet
Open

Enterprise wallet integration (rebased on testnet)#409
matt-o-how wants to merge 16 commits into
mainfrom
enterprise_wallet_integration_testnet

Conversation

@matt-o-how

@matt-o-how matt-o-how commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Note

High Risk
Introduces OAuth token handling, GraphQL spend/broadcast paths, and widens Electron popup/network policy—security-sensitive wallet and desktop surfaces.

Overview
Adds Cloud Wallet as a third blockchainType (simulator | walletconnect | cloud), wired through the same InternalBlockchainInterface / Shell connection lifecycle as the other backends.

Player app: New CloudBlockchainInterface drives OAuth (PKCE popup + /oauth/callback handoff via OAuthCallback), persisted config (cloudWalletConfig) and tokens (cloudWalletAuth), GraphQL for balance/coins/broadcast, and gaming funding via createGamingFundingSpend plus an approval popup. Hub play readiness treats Cloud like the simulator (ready when connected). SimulatorSetupModal is replaced by a generic ConnectionSetupModal with typed setup fields; Shell uses needsWalletPairing / needsConnectionSetupPrompt so WalletConnect still shows QR, the simulator can skip the balance modal on silent reconnect, and Cloud never auto-finalizes without OAuth config (including resume).

Desktop: Simulator is hidden but WalletConnect and Cloud remain. cloudWalletOrigins extends CSP and egress; OAuth uses chiagaming://app/oauth/callback (protocol handler serves index.html); Cloud popups get an empty preload and restricted window.open / navigation rules.

Docs and session save validation accept cloud as a persisted wallet preference.

Reviewed by Cursor Bugbot for commit c82f6f7. Bugbot is set up for automated code reviews on this repo. Configure here.

@matt-o-how
matt-o-how force-pushed the enterprise_wallet_integration_testnet branch 4 times, most recently from 2c8a0b7 to c50866b Compare August 20, 2026 14:57
@matt-o-how
matt-o-how temporarily deployed to windows-code-signing August 25, 2026 14:52 — with GitHub Actions Inactive
@matt-o-how
matt-o-how marked this pull request as ready for review August 25, 2026 14:58
Comment thread front-end/src/hooks/cloudWalletOAuth.ts
Comment thread front-end/src/components/Shell.tsx
Comment thread front-end/src/hooks/CloudBlockchainInterface.ts
@matt-o-how
matt-o-how temporarily deployed to windows-code-signing August 25, 2026 16:13 — with GitHub Actions Inactive
@matt-o-how
matt-o-how temporarily deployed to windows-code-signing August 26, 2026 10:02 — with GitHub Actions Inactive
@matt-o-how
matt-o-how temporarily deployed to windows-code-signing August 26, 2026 10:26 — with GitHub Actions Inactive
@matt-o-how
matt-o-how force-pushed the enterprise_wallet_integration_testnet branch from e117d3a to c82f6f7 Compare August 27, 2026 10:37
@matt-o-how
matt-o-how temporarily deployed to windows-code-signing August 27, 2026 10:37 — with GitHub Actions Inactive

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using high effort and found 4 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit c82f6f7. Configure here.

);
}
return { status: 'error', message };
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

OAuth pending state not shared

High Severity

The OAuth callback reads appState_cloudWalletOAuthPending from sessionStorage and treats a miss as a state mismatch. That key is written in the opener, but the callback runs in a popup that first loaded a cross-origin authorize URL, so it has a separate empty sessionStorage. Login then posts an error instead of the authorization code, and Cloud Wallet connect cannot complete.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c82f6f7. Configure here.

<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link rel="icon" href="favicon.svg" type="image/svg+xml" />
<base href="/" />

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Callback page scripts fail to load

High Severity

The desktop OAuth callback is served as index.html at chiagaming://app/oauth/callback, while scripts and styles stay relative (index.js, bootstrap.mjs). The new <base href="/" /> is ignored because CSP sets base-uri 'none', so those assets resolve under /oauth/ and 404. The callback bundle never runs, so no postMessage reaches the opener.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c82f6f7. Configure here.

this.monitoringReady = false;
this.fireConnectionChange(false);
throw e;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reconnect clears Cloud auth tokens

Medium Severity

Stored-session finalize calls clearCloudWalletAuth() on any failure from token refresh, resolveWalletId(), or startMonitoring(). A transient GraphQL or network error during silent resume therefore wipes durable OAuth tokens and forces a full popup login. resolveWalletId also turns a stored-id read error into the same fatal path instead of retrying or listing consented wallets.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c82f6f7. Configure here.

const feeValue = fee || 0n;
if (feeValue !== 0n) {
throw new Error('Cloud Wallet v1 does not support nonzero external fees');
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cloud spend rejects configured fees

Medium Severity

spend throws when fee is any nonzero bigint, while the connected Wallet tab still exposes the shared transaction-fee control for Cloud Wallet. A player who leaves or sets a default fee will fail broadcasts and on-chain resolution even though the UI accepted the fee.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit c82f6f7. Configure here.

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