@blockrun/franklin 3.28.0 → 3.28.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,13 +11,18 @@
11
11
  * Base / USDC only. Mirrors the gateway-call pattern in src/phone/client.ts
12
12
  * and reuses the shared x402 POST helper.
13
13
  */
14
- import { API_URLS } from '../config.js';
14
+ import { API_URLS, loadChain } from '../config.js';
15
15
  import { postWithPayment } from '../payments/post-with-payment.js';
16
16
  /**
17
17
  * Mint a one-time Coinbase Onramp link that funds `address` (Base USDC).
18
18
  * Throws if the gateway is unreachable, not configured, or returns no URL.
19
19
  */
20
20
  export async function getOnrampUrl(address) {
21
+ // postWithPayment signs with the active chain's wallet; on Solana that
22
+ // would crash confusingly against this Base-only endpoint. Fail clearly.
23
+ if (loadChain() !== 'base') {
24
+ throw new Error('Onramp is Base-only — switch to Base to buy USDC with a card.');
25
+ }
21
26
  const endpoint = `${API_URLS.base}/v1/onramp/token`;
22
27
  const result = await postWithPayment(endpoint, { address, network: 'base', asset: 'USDC' }, 'Mint a Coinbase Onramp session link to fund this wallet');
23
28
  if (!result.ok) {
@@ -1246,8 +1246,24 @@ document.getElementById('wallet-onramp-btn').addEventListener('click', async ()
1246
1246
  const r = await fetch('/api/wallet/onramp', { method: 'POST' });
1247
1247
  const data = await r.json().catch(() => ({}));
1248
1248
  if (!r.ok || !data.url) throw new Error(data.error || r.statusText || 'failed');
1249
- window.open(data.url, '_blank', 'noopener');
1250
- status.textContent = '';
1249
+ // The mint round-trip can outlive the browser's transient user-activation
1250
+ // window, so popup blockers may eat this open. The token stays valid for
1251
+ // ~5 min — on block, hand the user a real link (a fresh gesture).
1252
+ const win = window.open(data.url, '_blank', 'noopener');
1253
+ if (win) {
1254
+ status.textContent = '';
1255
+ } else {
1256
+ status.textContent = 'Popup blocked — ';
1257
+ const a = document.createElement('a');
1258
+ a.href = data.url;
1259
+ a.target = '_blank';
1260
+ a.rel = 'noopener';
1261
+ a.textContent = 'click here to open Coinbase';
1262
+ status.appendChild(a);
1263
+ }
1264
+ // Funding an empty wallet creates it server-side on first mint — re-render
1265
+ // so the address/QR/balance reflect the wallet Coinbase is about to fund.
1266
+ loadWallet().catch(() => {});
1251
1267
  } catch (err) {
1252
1268
  status.textContent = err && err.message ? err.message : 'Failed to open Coinbase';
1253
1269
  } finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blockrun/franklin",
3
- "version": "3.28.0",
3
+ "version": "3.28.1",
4
4
  "description": "Franklin Agent — The AI agent with a wallet. Spends USDC autonomously to get real work done. Pay per action, no subscriptions.",
5
5
  "type": "module",
6
6
  "exports": {