Skip to content

Commit 7010be4

Browse files
committed
fix prompts and default page
1 parent 516e2db commit 7010be4

File tree

4 files changed

+91
-25
lines changed

4 files changed

+91
-25
lines changed

apps/quick-dapp/src/App.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function App(): JSX.Element {
2222
messages: null,
2323
})
2424
const [appState, dispatch] = useReducer(appReducer, appInitialState);
25+
const [isAiLoading, setIsAiLoading] = useState(false);
2526
useEffect(() => {
2627
updateState(appState);
2728
}, [appState]);
@@ -43,6 +44,20 @@ function App(): JSX.Element {
4344
remixClient.on('locale', 'localeChanged', (locale: any) => {
4445
setLocale(locale)
4546
})
47+
// @ts-ignore
48+
remixClient.on('ai-dapp-generator', 'generationProgress', (progress: any) => {
49+
if (progress.status === 'started') {
50+
setIsAiLoading(true);
51+
}
52+
});
53+
// @ts-ignore
54+
remixClient.on('ai-dapp-generator', 'dappGenerated', () => {
55+
setIsAiLoading(false);
56+
});
57+
// @ts-ignore
58+
remixClient.on('ai-dapp-generator', 'dappUpdated', () => {
59+
setIsAiLoading(false);
60+
});
4661
});
4762
}, []);
4863
return (
@@ -64,7 +79,7 @@ function App(): JSX.Element {
6479
</div>
6580
) : (
6681
<div className="row m-0 pt-3">
67-
<CreateInstance />
82+
<CreateInstance isAiLoading={isAiLoading} />
6883
</div>
6984
)}
7085
<LoadingScreen />

apps/quick-dapp/src/components/CreateInstance/index.tsx

Lines changed: 34 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,44 @@ import React from 'react';
22
import { Alert } from 'react-bootstrap';
33
import { FormattedMessage } from 'react-intl';
44

5-
const CreateInstance: React.FC = () => {
5+
interface CreateInstanceProps {
6+
isAiLoading: boolean;
7+
}
8+
9+
const CreateInstance: React.FC<CreateInstanceProps> = ({ isAiLoading }) => {
610

711
return (
812
<div className="text-center">
9-
10-
<Alert
11-
className="mt-4 d-flex align-items-center justify-content-center"
12-
variant="info"
13-
data-id="quickDappTooltips"
14-
>
15-
16-
<div className="flex-shrink-0 me-3">
17-
<img
18-
src='./assets/sparkling.png'
19-
style={{ width: '300px' }}
20-
alt="Sparkling star icon"
21-
/>
22-
</div>
23-
<div className="text-start">
24-
<FormattedMessage id="quickDapp.text1" />
25-
<br />
26-
<FormattedMessage id="quickDapp.text2" />
13+
{isAiLoading ? (
14+
<div className="mt-4 mb-3 p-4">
15+
<i className="fas fa-spinner fa-spin me-2"></i>
16+
Your dapp is being created by RemixAI Assistant.
2717
</div>
28-
</Alert>
29-
<div className="mt-4 mb-3">
30-
<FormattedMessage id="quickDapp.text7" />
31-
</div>
18+
) : (
19+
<>
20+
<Alert
21+
className="mt-4 d-flex align-items-center justify-content-center"
22+
variant="info"
23+
data-id="quickDappTooltips"
24+
>
25+
<div className="flex-shrink-0 me-3">
26+
<img
27+
src='./assets/sparkling.png'
28+
style={{ width: '300px' }}
29+
alt="Sparkling star icon"
30+
/>
31+
</div>
32+
<div className="text-start">
33+
<FormattedMessage id="quickDapp.text1" />
34+
<br />
35+
<FormattedMessage id="quickDapp.text2" />
36+
</div>
37+
</Alert>
38+
<div className="mt-4 mb-3">
39+
<FormattedMessage id="quickDapp.text7" />
40+
</div>
41+
</>
42+
)}
3243
</div>
3344
);
3445
};

apps/quick-dapp/src/components/DeployPanel/index.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const REMIX_REGISTRAR_ABI = [
2828
function DeployPanel(): JSX.Element {
2929
const intl = useIntl()
3030
const { appState, dispatch } = useContext(AppContext);
31-
const { title, details } = appState.instance;
31+
const { title, details, logo } = appState.instance;
3232
const [showIpfsSettings, setShowIpfsSettings] = useState(false);
3333
const [ipfsHost, setIpfsHost] = useState('');
3434
const [ipfsPort, setIpfsPort] = useState('');
@@ -182,6 +182,30 @@ function DeployPanel(): JSX.Element {
182182

183183
let modifiedHtml = indexHtmlContent;
184184

185+
let logoDataUrl = '';
186+
if (logo && logo.byteLength > 0) {
187+
try {
188+
const base64data = btoa(
189+
new Uint8Array(logo).reduce((data, byte) => data + String.fromCharCode(byte), '')
190+
);
191+
logoDataUrl = 'data:image/jpeg;base64,' + base64data;
192+
} catch (err) {
193+
console.error('Logo conversion failed during deploy:', err);
194+
}
195+
}
196+
197+
const injectionScript = `
198+
<script>
199+
window.__QUICK_DAPP_CONFIG__ = {
200+
logo: "${logoDataUrl}",
201+
title: ${JSON.stringify(title || '')},
202+
details: ${JSON.stringify(details || '')}
203+
};
204+
</script>
205+
`;
206+
207+
modifiedHtml = modifiedHtml.replace('</head>', `${injectionScript}\n</head>`);
208+
185209
modifiedHtml = modifiedHtml.replace(
186210
/<script type="module"[^>]*src="(?:\/|\.\/)?src\/main\.jsx"[^>]*><\/script>/,
187211
'<script type="module" src="./app.js"></script>'

apps/remix-ide/src/app/plugins/ai-dapp-generator.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ export class AIDappGenerator extends Plugin {
176176

177177
private createInitialMessage(options: GenerateDappOptions): string {
178178
const providerCode = this.getProviderCode()
179+
179180
return `
180181
You MUST generate a new DApp based on the following requirements.
181182
@@ -188,6 +189,21 @@ export class AIDappGenerator extends Plugin {
188189
- Contract Address: ${options.address}
189190
- Network (Chain ID): ${options.chainId}
190191
- Contract ABI: ${JSON.stringify(options.abi)}
192+
193+
**ROBUST NETWORK CHECK:**
194+
When generating the network check logic in \`src/App.jsx\`, you MUST implement a robust comparison that handles both Hexadecimal (e.g., "0x...") and Decimal formats.
195+
196+
**Do NOT compare strings directly.** Instead, convert both values to \`BigInt\` for comparison.
197+
198+
**Required Code Pattern:**
199+
\`\`\`javascript
200+
const TARGET_CHAIN_ID = "${options.chainId}"; // Decimal from Remix
201+
// ... inside connectWallet ...
202+
const chainId = await window.ethereum.request({ method: 'eth_chainId' });
203+
if (BigInt(chainId) !== BigInt(TARGET_CHAIN_ID)) {
204+
// Switch network logic...
205+
}
206+
\`\`\`
191207
192208
**User's Design Request:**
193209
Please build the DApp based on this description:

0 commit comments

Comments
 (0)