Skip to content

Commit 16ef3ed

Browse files
author
ci-bot
committed
update value
1 parent eadb0c7 commit 16ef3ed

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

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)