Skip to content

Commit 9ac96f2

Browse files
authored
Merge pull request #6580 from remix-project-org/fix_update_value
update value
2 parents 78fa432 + 6829c69 commit 9ac96f2

File tree

4 files changed

+26
-16
lines changed

4 files changed

+26
-16
lines changed

libs/remix-ai-core/src/inferencers/mcp/toolApiGenerator.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ const modified = fileContent.replace('old', 'new');
2525
const compiled = await callMCPTool('solidity_compile', { file: 'contract.sol' });
2626
const deployed = await callMCPTool('deploy_contract', { contractName: 'MyToken' });
2727
28-
// Multiple tasks 2
29-
const fileContent = await callMCPTool('file_read', { path:'contract.sol' });
30-
const content = JSON.parse(fileContent.content[0].text).content
31-
const updatedContent = fileContent.replace('contract Subscription', 'contract MySubscriptionContract');
32-
await callMCPTool('file_write', { path: 'ccontract.sol', content: updatedContent });
33-
3428
3529
// With loops for batch operations
3630
const files = ['contracts/Token.sol', 'contracts/NFT.sol', 'contracts/DAO.sol'];

libs/remix-ai-core/src/inferencers/remote/remoteInference.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ export class RemoteInferencer implements ICompletions, IGeneration {
2424
protected sanitizePromptByteSize(prompt: string, provider?: string): string {
2525
// Provider-specific max byte limits
2626
const providerLimits: Record<string, number> = {
27-
'mistralai': 80000,
28-
'anthropic': 80000,
29-
'openai': 80000
27+
'mistralai': 70000,
28+
'anthropic': 70000,
29+
'openai': 70000
3030
};
3131

32-
// Get max bytes based on provider, default to 80KB
33-
const maxBytes = provider ? (providerLimits[provider.toLowerCase()] || 80000) : 80000;
32+
// Get max bytes based on provider, default to 70KB
33+
const maxBytes = provider ? (providerLimits[provider.toLowerCase()] || 70000) : 70000;
3434

3535
const encoder = new TextEncoder();
3636
const promptBytes = encoder.encode(prompt); // rough estimation, real size might be 10% more

libs/remix-ai-core/src/remix-mcp-server/handlers/DeploymentHandler.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import {
2020
import { Plugin } from '@remixproject/engine';
2121
import { getContractData } from '@remix-project/core-plugin'
2222
import type { TxResult } from '@remix-project/remix-lib';
23-
import { BrowserProvider } from "ethers"
24-
import { toNumber, ethers } from 'ethers'
23+
import { BrowserProvider, formatEther } from "ethers"
24+
import { toNumber } from 'ethers'
2525
import { execution } from '@remix-project/remix-lib';
2626
const { txFormat, txHelper: { makeFullTypeDefinition } } = execution;
2727

@@ -104,6 +104,12 @@ export class DeployContractHandler extends BaseToolHandler {
104104
if (!data) {
105105
return this.createErrorResult(`Could not retrieve contract data for '${args.contractName}'`);
106106
}
107+
await plugin.call('sidePanel', 'showContent', 'udapp' )
108+
plugin.emit('setValueRequest', args.value || '0', 'wei')
109+
if (args.value && args.value !== '0') {
110+
plugin.call('notification', 'toast', `Value of ${formatEther(args.value)} ETH will be sent with the deployment`)
111+
await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait a moment for the toast to be seen
112+
}
107113

108114
let txReturn
109115
try {
@@ -141,8 +147,7 @@ export class DeployContractHandler extends BaseToolHandler {
141147
logs: receipt.logs,
142148
contractAddress: receipt.contractAddress,
143149
success: receipt.status === 1 ? true : false
144-
};
145-
await plugin.call('sidePanel', 'showContent', 'udapp' )
150+
}
146151
plugin.call('udapp', 'addInstance', result.contractAddress, data.abi, args.contractName, data)
147152

148153
return this.createSuccessResult(result);
@@ -256,6 +261,13 @@ export class CallContractHandler extends BaseToolHandler {
256261
const isView = funcABI.stateMutability === 'view' || funcABI.stateMutability === 'pure';
257262
let txReturn
258263
try {
264+
await plugin.call('sidePanel', 'showContent', 'udapp' )
265+
plugin.emit('setValueRequest', args.value || '0', 'wei')
266+
if (args.value && args.value !== '0') {
267+
plugin.call('notification', 'toast', `Value of ${formatEther(args.value)} ETH will be sent with the deployment`)
268+
await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait a moment for the toast to be seen
269+
}
270+
259271
txReturn = await new Promise((resolve, reject) => {
260272
const params = funcABI.type !== 'fallback' ? (args.args? args.args.join(',') : ''): ''
261273
plugin.call('blockchain', 'runOrCallContractMethod',

libs/remix-ui/run-tab/src/lib/actions/events.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { RunTab } from "../types/run-tab"
33
import { trackMatomoEvent } from '@remix-api'
44
import { setExecutionContext, setFinalContext, updateAccountBalances, fillAccountsList } from "./account"
55
import { setAccount, addExternalProvider, addInstance, addNewProxyDeployment, removeExternalProvider, setNetworkNameFromProvider, setPinnedChainId, setExecEnv } from "./actions"
6-
import { addDeployOption, clearAllInstances, clearRecorderCount, setSelectedAccount, fetchContractListSuccess, resetProxyDeployments, resetUdapp, setCurrentContract, setCurrentFile, setLoadType, setRecorderCount, setRemixDActivated, setSendValue, fetchAccountsListSuccess, fetchAccountsListRequest } from "./payload"
6+
import { addDeployOption, clearAllInstances, clearRecorderCount, setSelectedAccount, fetchContractListSuccess, resetProxyDeployments, resetUdapp, setCurrentContract, setCurrentFile, setLoadType, setRecorderCount, setRemixDActivated, setSendValue, fetchAccountsListSuccess, fetchAccountsListRequest, setSendUnit } from "./payload"
77
import { updateInstanceBalance } from './deploy'
88
import { CompilerAbstract } from '@remix-project/remix-solidity'
99
import BN from 'bn.js'
@@ -26,6 +26,10 @@ export const setupEvents = (plugin: RunTab) => {
2626
provider: null,
2727
chainId: null
2828
}
29+
plugin.on('remixAI', 'setValueRequest', (value, unit) => {
30+
dispatch(setSendUnit(unit))
31+
dispatch(setSendValue(value))
32+
})
2933
plugin.blockchain.events.on('newTransaction', (tx, receipt) => {
3034
plugin.emit('newTransaction', tx, receipt)
3135
})

0 commit comments

Comments
 (0)