@blockrun/franklin 3.40.0 → 3.41.0
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.
- package/dist/commands/setup.js +2 -1
- package/dist/config.js +13 -4
- package/dist/onramp/client.d.ts +15 -10
- package/dist/onramp/client.js +23 -17
- package/dist/panel/html.js +7 -7
- package/dist/panel/server.js +3 -9
- package/package.json +1 -1
package/dist/commands/setup.js
CHANGED
|
@@ -2,7 +2,8 @@ import chalk from 'chalk';
|
|
|
2
2
|
import { getOrCreateWallet, scanWallets, getOrCreateSolanaWallet, scanSolanaWallets, } from '@blockrun/llm';
|
|
3
3
|
import { saveChain } from '../config.js';
|
|
4
4
|
export async function setupCommand(chainArg) {
|
|
5
|
-
|
|
5
|
+
// Solana is the default chain; `franklin setup base` opts into Base.
|
|
6
|
+
const chain = chainArg === 'base' ? 'base' : 'solana';
|
|
6
7
|
if (chain === 'solana') {
|
|
7
8
|
const wallets = scanSolanaWallets();
|
|
8
9
|
if (wallets.length > 0) {
|
package/dist/config.js
CHANGED
|
@@ -37,11 +37,20 @@ export function loadChain() {
|
|
|
37
37
|
return 'base';
|
|
38
38
|
try {
|
|
39
39
|
const content = fs.readFileSync(CHAIN_FILE, 'utf-8').trim();
|
|
40
|
+
if (content === 'base')
|
|
41
|
+
return 'base';
|
|
40
42
|
if (content === 'solana')
|
|
41
43
|
return 'solana';
|
|
42
|
-
return 'base';
|
|
43
|
-
}
|
|
44
|
-
catch {
|
|
45
|
-
return 'base';
|
|
46
44
|
}
|
|
45
|
+
catch { /* no explicit choice on disk — fall through to the default */ }
|
|
46
|
+
// Default chain is Solana. Exception: a Base wallet with no Solana wallet
|
|
47
|
+
// means the user funded before the default flipped — silently moving their
|
|
48
|
+
// spending to an empty Solana wallet would strand their USDC, so keep them
|
|
49
|
+
// on Base until they choose explicitly (`franklin solana`, panel switch,
|
|
50
|
+
// setup). Pure read — every path that creates the other wallet also calls
|
|
51
|
+
// saveChain, so the heuristic is only ever the pre-choice fallback.
|
|
52
|
+
// (.session / .solana-session are the SDK's wallet key files.)
|
|
53
|
+
const hasBaseWallet = fs.existsSync(path.join(BLOCKRUN_DIR, '.session'));
|
|
54
|
+
const hasSolanaWallet = fs.existsSync(path.join(BLOCKRUN_DIR, '.solana-session'));
|
|
55
|
+
return hasBaseWallet && !hasSolanaWallet ? 'base' : 'solana';
|
|
47
56
|
}
|
package/dist/onramp/client.d.ts
CHANGED
|
@@ -1,22 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Coinbase Onramp link client.
|
|
3
3
|
*
|
|
4
|
-
* Exchanges the user's
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* never
|
|
4
|
+
* Exchanges the user's wallet address for a one-time Coinbase Onramp URL via
|
|
5
|
+
* the BlockRun gateway of the active chain (Base → blockrun.ai, Solana →
|
|
6
|
+
* sol.blockrun.ai). The gateway holds the CDP API key, signs the JWT, and
|
|
7
|
+
* mints a single-use `sessionToken` (Coinbase requires Secure Init since
|
|
8
|
+
* 2025-07-31 — plain appId URLs are deprecated). The returned URL is one-time
|
|
9
|
+
* and expires in ~5 minutes, so it must be minted at click time and never
|
|
10
|
+
* cached.
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
12
|
+
* USDC only, on the active chain. The $0 x402 handshake doubles as wallet
|
|
13
|
+
* authentication — postWithPayment signs with the active chain's wallet, and
|
|
14
|
+
* the gateway binds the funding address to that signer. Mirrors the
|
|
15
|
+
* gateway-call pattern in src/phone/client.ts and reuses the shared x402 POST
|
|
16
|
+
* helper.
|
|
13
17
|
*/
|
|
14
18
|
export interface OnrampLinkResult {
|
|
15
19
|
/** One-time https://pay.coinbase.com/... URL prefilled for this wallet. */
|
|
16
20
|
url: string;
|
|
17
21
|
}
|
|
18
22
|
/**
|
|
19
|
-
* Mint a one-time Coinbase Onramp link that funds `address`
|
|
20
|
-
* Throws if the gateway is unreachable, not configured, or
|
|
23
|
+
* Mint a one-time Coinbase Onramp link that funds `address` with USDC on the
|
|
24
|
+
* active chain. Throws if the gateway is unreachable, not configured, or
|
|
25
|
+
* returns no URL.
|
|
21
26
|
*/
|
|
22
27
|
export declare function getOnrampUrl(address: string): Promise<OnrampLinkResult>;
|
package/dist/onramp/client.js
CHANGED
|
@@ -1,31 +1,37 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Coinbase Onramp link client.
|
|
3
3
|
*
|
|
4
|
-
* Exchanges the user's
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* never
|
|
4
|
+
* Exchanges the user's wallet address for a one-time Coinbase Onramp URL via
|
|
5
|
+
* the BlockRun gateway of the active chain (Base → blockrun.ai, Solana →
|
|
6
|
+
* sol.blockrun.ai). The gateway holds the CDP API key, signs the JWT, and
|
|
7
|
+
* mints a single-use `sessionToken` (Coinbase requires Secure Init since
|
|
8
|
+
* 2025-07-31 — plain appId URLs are deprecated). The returned URL is one-time
|
|
9
|
+
* and expires in ~5 minutes, so it must be minted at click time and never
|
|
10
|
+
* cached.
|
|
10
11
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
12
|
+
* USDC only, on the active chain. The $0 x402 handshake doubles as wallet
|
|
13
|
+
* authentication — postWithPayment signs with the active chain's wallet, and
|
|
14
|
+
* the gateway binds the funding address to that signer. Mirrors the
|
|
15
|
+
* gateway-call pattern in src/phone/client.ts and reuses the shared x402 POST
|
|
16
|
+
* helper.
|
|
13
17
|
*/
|
|
14
18
|
import { API_URLS, loadChain } from '../config.js';
|
|
15
19
|
import { postWithPayment } from '../payments/post-with-payment.js';
|
|
16
20
|
/**
|
|
17
|
-
* Mint a one-time Coinbase Onramp link that funds `address`
|
|
18
|
-
* Throws if the gateway is unreachable, not configured, or
|
|
21
|
+
* Mint a one-time Coinbase Onramp link that funds `address` with USDC on the
|
|
22
|
+
* active chain. Throws if the gateway is unreachable, not configured, or
|
|
23
|
+
* returns no URL.
|
|
19
24
|
*/
|
|
20
25
|
export async function getOnrampUrl(address) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
throw new Error('Onramp is Base-only — switch to Base to buy USDC with a card.');
|
|
25
|
-
}
|
|
26
|
-
const endpoint = `${API_URLS.base}/v1/onramp/token`;
|
|
27
|
-
const result = await postWithPayment(endpoint, { address, network: 'base', asset: 'USDC' }, 'Mint a Coinbase Onramp session link to fund this wallet');
|
|
26
|
+
const chain = loadChain();
|
|
27
|
+
const endpoint = `${API_URLS[chain]}/v1/onramp/token`;
|
|
28
|
+
const result = await postWithPayment(endpoint, { address, network: chain, asset: 'USDC' }, 'Mint a Coinbase Onramp session link to fund this wallet');
|
|
28
29
|
if (!result.ok) {
|
|
30
|
+
// A 404 means this gateway has not shipped the onramp route yet (gateway
|
|
31
|
+
// deploys are manual) — name the real situation instead of a bare status.
|
|
32
|
+
if (result.status === 404) {
|
|
33
|
+
throw new Error(`Onramp is not available on the ${chain} gateway yet — try again later.`);
|
|
34
|
+
}
|
|
29
35
|
const msg = typeof result.body.error === 'string'
|
|
30
36
|
? result.body.error
|
|
31
37
|
: `gateway ${result.status}`;
|
package/dist/panel/html.js
CHANGED
|
@@ -712,7 +712,7 @@ a:hover { text-decoration:underline; }
|
|
|
712
712
|
<button class="btn btn-onramp" id="wallet-onramp-btn">💳 Buy USDC with card</button>
|
|
713
713
|
<span class="wallet-import-status" id="wallet-onramp-status"></span>
|
|
714
714
|
</div>
|
|
715
|
-
<p class="wallet-hint" id="wallet-onramp-hint">Powered by Coinbase Onramp ·
|
|
715
|
+
<p class="wallet-hint" id="wallet-onramp-hint">Powered by Coinbase Onramp · 60+ fiat currencies</p>
|
|
716
716
|
</div>
|
|
717
717
|
|
|
718
718
|
<div class="card">
|
|
@@ -1206,12 +1206,8 @@ async function loadWallet() {
|
|
|
1206
1206
|
solanaBtn.classList.toggle('active', w.chain === 'solana');
|
|
1207
1207
|
}
|
|
1208
1208
|
|
|
1209
|
-
// Coinbase Onramp
|
|
1210
|
-
|
|
1211
|
-
const onrampHint = document.getElementById('wallet-onramp-hint');
|
|
1212
|
-
const onBase = w.chain === 'base';
|
|
1213
|
-
if (onrampActions) onrampActions.style.display = onBase ? '' : 'none';
|
|
1214
|
-
if (onrampHint) onrampHint.style.display = onBase ? '' : 'none';
|
|
1209
|
+
// Coinbase Onramp works on both chains — the gateway of the active chain
|
|
1210
|
+
// mints the link, so the buy button stays visible on Base and Solana alike.
|
|
1215
1211
|
|
|
1216
1212
|
// QR via server — never leak address to third parties.
|
|
1217
1213
|
// Encode chain + USDC token in the QR payload so wallet apps land
|
|
@@ -1254,6 +1250,10 @@ async function loadWallet() {
|
|
|
1254
1250
|
baseBtn.disabled = true;
|
|
1255
1251
|
solanaBtn.disabled = true;
|
|
1256
1252
|
note.textContent = 'Switching to ' + target + '…';
|
|
1253
|
+
// The onramp status (e.g. a popup-blocked Coinbase link) belongs to the
|
|
1254
|
+
// previous chain's wallet — a stale link would fund the wrong chain.
|
|
1255
|
+
const onrampStatus = document.getElementById('wallet-onramp-status');
|
|
1256
|
+
if (onrampStatus) onrampStatus.textContent = '';
|
|
1257
1257
|
try {
|
|
1258
1258
|
const r = await fetch('/api/chain', {
|
|
1259
1259
|
method: 'POST',
|
package/dist/panel/server.js
CHANGED
|
@@ -335,21 +335,15 @@ export function createPanelServer(port) {
|
|
|
335
335
|
// Mints a one-time Coinbase Onramp link to fund the wallet with a card.
|
|
336
336
|
// Spends nothing locally, but it talks to the gateway with this wallet's
|
|
337
337
|
// identity and opens a payment flow, so it gets the same loopback +
|
|
338
|
-
// same-origin posture as the wallet-mutating routes.
|
|
339
|
-
//
|
|
338
|
+
// same-origin posture as the wallet-mutating routes. The gateway of the
|
|
339
|
+
// active chain mints a session token scoped to that chain's address.
|
|
340
340
|
if (p === '/api/wallet/onramp' && req.method === 'POST') {
|
|
341
341
|
if (!isLocalPanelRequest(req)) {
|
|
342
342
|
json(res, { error: 'forbidden' }, 403);
|
|
343
343
|
return;
|
|
344
344
|
}
|
|
345
345
|
try {
|
|
346
|
-
const
|
|
347
|
-
if (chain !== 'base') {
|
|
348
|
-
json(res, { error: 'Onramp currently supports Base only — switch to Base to buy USDC with a card.' }, 400);
|
|
349
|
-
return;
|
|
350
|
-
}
|
|
351
|
-
const { setupAgentWallet } = await import('@blockrun/llm');
|
|
352
|
-
const address = setupAgentWallet({ silent: true }).getWalletAddress();
|
|
346
|
+
const address = await currentWalletAddress();
|
|
353
347
|
const { getOnrampUrl } = await import('../onramp/client.js');
|
|
354
348
|
const { url } = await getOnrampUrl(address);
|
|
355
349
|
json(res, { url });
|
package/package.json
CHANGED