Skip to content

Commit d87189a

Browse files
committed
deployment ressources initial ipml
1 parent cc46733 commit d87189a

File tree

8 files changed

+627
-311
lines changed

8 files changed

+627
-311
lines changed

apps/remix-ide/src/app/plugins/remixAIPlugin.tsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const profile = {
2424
'getAssistantThrId', 'getAssistantProvider', 'setAssistantProvider', 'setModel',
2525
'addMCPServer', 'removeMCPServer', 'getMCPConnectionStatus', 'getMCPResources', 'getMCPTools', 'executeMCPTool',
2626
'enableMCPEnhancement', 'disableMCPEnhancement', 'isMCPEnabled', 'getIMCPServers',
27-
'loadMCPServersFromSettings'
27+
'loadMCPServersFromSettings', 'clearCaches'
2828
],
2929
events: [],
3030
icon: 'assets/img/remix-logo-blue.png',
@@ -115,9 +115,13 @@ export class RemixAIPlugin extends Plugin {
115115
this.setAssistantProvider(this.assistantProvider) // propagate the provider to the remote inferencer
116116
this.aiIsActivated = true
117117

118+
this.on('blockchain', 'transactionExecuted', async () => {
119+
this.clearCaches()
120+
})
121+
122+
118123
// initialize the remix MCP server
119124
this.remixMCPServer = await createRemixMCPServer(this)
120-
console.log(this)
121125
return true
122126
}
123127

@@ -709,6 +713,13 @@ export class RemixAIPlugin extends Plugin {
709713
return this.mcpServers;
710714
}
711715

716+
clearCaches(){
717+
if (this.mcpInferencer){
718+
this.mcpInferencer.resetResourceCache()
719+
console.log(`[RemixAI Plugin] clearing mcp inference resource cache `)
720+
}
721+
}
722+
712723
// private async enrichWithMCPContext(prompt: string, params: IParams): Promise<string> {
713724
// if (!this.mcpEnabled || !this.mcpInferencer) {
714725
// console.log(`[RemixAI Plugin] MCP context enrichment skipped (enabled: ${this.mcpEnabled}, inferencer: ${!!this.mcpInferencer})`);

apps/remix-ide/src/app/udapp/run-tab.tsx

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ const profile = {
5555
'addInstance',
5656
'resolveContractAndAddInstance',
5757
'showPluginDetails',
58-
'getRunTabAPI'
58+
'getRunTabAPI',
59+
'getDeployedContracts'
5960
]
6061
}
6162

@@ -73,6 +74,8 @@ export class RunTab extends ViewPlugin {
7374
recorder: any
7475
REACT_API: any
7576
el: any
77+
transactionHistory: Map<string, any> = new Map()
78+
7679
constructor(blockchain: Blockchain, config: any, fileManager: any, editor: any, filePanel: any, compilersArtefacts: CompilerArtefacts, networkModule: any, fileProvider: any, engine: any) {
7780
super(profile)
7881
this.event = new EventManager()
@@ -97,6 +100,34 @@ export class RunTab extends ViewPlugin {
97100
})
98101
}
99102

103+
onActivation(): void {
104+
// Listen for transaction execution events to collect deployment data
105+
this.on('blockchain','transactionExecuted', (error, from, to, data, useCall, result, timestamp, payload) => {
106+
console.log('[UDAPP] Transaction execution detected:', result.receipt.contractAddress)
107+
108+
if (!error && result && result.receipt && result.receipt.contractAddress) {
109+
110+
// Store deployment transaction data
111+
const deploymentData = {
112+
transactionHash: result.receipt.transactionHash,
113+
blockHash: result.receipt.blockHash,
114+
blockNumber: result.receipt.blockNumber,
115+
gasUsed: result.receipt.gasUsed,
116+
gasPrice: result.receipt.gasPrice || result.receipt.effectiveGasPrice || '0',
117+
from: from,
118+
to: to,
119+
timestamp: timestamp,
120+
status: result.receipt.status ? 'success' : 'failed',
121+
constructorArgs: payload?.contractGuess?.constructorArgs || [],
122+
contractName: payload?.contractData?.name || payload?.contractGuess?.name || 'Unknown',
123+
value: result.receipt.value || '0'
124+
}
125+
126+
this.transactionHistory.set(result.receipt.contractAddress, deploymentData)
127+
}
128+
})
129+
}
130+
100131
getSettings() {
101132
return new Promise((resolve, reject) => {
102133
resolve({
@@ -116,11 +147,13 @@ export class RunTab extends ViewPlugin {
116147
if (canCall) {
117148
env = typeof env === 'string' ? { context: env } : env
118149
this.emit('setEnvironmentModeReducer', env, this.currentRequest.from)
150+
this.transactionHistory.clear()
119151
}
120152
}
121153

122154
clearAllInstances() {
123155
this.emit('clearAllInstancesReducer')
156+
this.transactionHistory.clear()
124157
}
125158

126159
addInstance(address, abi, name, contractData?) {
@@ -144,6 +177,46 @@ export class RunTab extends ViewPlugin {
144177
return this.REACT_API;
145178
}
146179

180+
getDeployedContracts() {
181+
// Return deployed contract instances from the React API with enhanced transaction data
182+
if (!this.REACT_API || !this.REACT_API.instances) {
183+
return {};
184+
}
185+
const instances = this.REACT_API.instances.instanceList || [];
186+
const deployedContracts = {};
187+
const currentProvider = this.REACT_API.selectExEnv || 'vm-london';
188+
189+
deployedContracts[currentProvider] = {};
190+
191+
instances.forEach((instance, index) => {
192+
if (instance && instance.address) {
193+
const txData = this.transactionHistory.get(instance.address)
194+
195+
const contractInstance = {
196+
name: instance.name || txData?.contractName || 'Unknown',
197+
address: instance.address,
198+
abi: instance.contractData?.abi || instance.abi || [],
199+
timestamp: txData?.timestamp ? new Date(txData.timestamp).toISOString() : new Date().toISOString(),
200+
from: txData?.from || this.REACT_API.accounts?.selectedAccount || 'unknown',
201+
transactionHash: txData?.transactionHash || 'unknown',
202+
blockHash: txData?.blockHash,
203+
blockNumber: Number(txData?.blockNumber) || 0,
204+
gasUsed: Number(txData?.gasUsed)|| 0,
205+
gasPrice: txData?.gasPrice || '0',
206+
value: txData?.value || '0',
207+
status: txData?.status || 'unknown',
208+
constructorArgs: txData?.constructorArgs || [],
209+
verified: false,
210+
index: index
211+
}
212+
213+
deployedContracts[currentProvider][instance.address] = contractInstance
214+
}
215+
});
216+
217+
return deployedContracts;
218+
}
219+
147220
pendingTransactionsCount() {
148221
return this.blockchain.pendingTransactionsCount()
149222
}

libs/remix-ai-core/src/agents/workspaceAgent.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export class workspaceAgent {
2727
});
2828
})
2929
this.plugin.on('solidity', 'compilationFinished', async (file: string, source, languageVersion, data, input, version) => {
30-
3130
this.localUsrFiles = await this.getLocalUserImports({
3231
file,
3332
source,

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ export class MCPInferencer extends RemoteInferencer implements ICompletions, IGe
395395
this.resourceCache.clear();
396396
}
397397

398+
async resetResourceCache(){
399+
this.resourceCache.clear()
400+
}
401+
398402
async addMCPServer(server: IMCPServer): Promise<void> {
399403
console.log(`[MCP Inferencer] Adding MCP server: ${server.name}`);
400404
if (this.mcpClients.has(server.name)) {
@@ -579,6 +583,8 @@ export class MCPInferencer extends RemoteInferencer implements ICompletions, IGe
579583
this.resourceCache.delete(resource.uri);
580584
}, this.cacheTimeout);
581585
}
586+
} else {
587+
console.log('using cached resource content for ', resource.uri, content)
582588
}
583589

584590
if (content?.text) {

libs/remix-ai-core/src/remix-mcp-server/RemixMCPServer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,10 +495,10 @@ export class RemixMCPServer extends EventEmitter implements IRemixMCPServer {
495495
this._resources.register(compilationProvider);
496496
console.log(`Registered compilation resource provider: ${compilationProvider.name}`, 'info');
497497

498-
// // Register deployment resource provider
499-
// const deploymentProvider = new DeploymentResourceProvider();
500-
// this._resources.register(deploymentProvider);
501-
// console.log(`Registered deployment resource provider: ${deploymentProvider.name}`, 'info');
498+
// Register deployment resource provider
499+
const deploymentProvider = new DeploymentResourceProvider();
500+
this._resources.register(deploymentProvider);
501+
console.log(`Registered deployment resource provider: ${deploymentProvider.name}`, 'info');
502502

503503
const totalProviders = this._resources.list().length;
504504
console.log(`Total resource providers registered: ${totalProviders}`, 'info');

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,11 +424,11 @@ export class GetDeployedContractsHandler extends BaseToolHandler {
424424
// TODO: Get deployed contracts from Remix storage/state
425425
const mockDeployedContracts = [
426426
{
427-
name: 'MyToken',
428-
address: '0x' + Math.random().toString(16).substr(2, 40),
429-
network: args.network || 'local',
430-
deployedAt: new Date().toISOString(),
431-
transactionHash: '0x' + Math.random().toString(16).substr(2, 64)
427+
name: '',
428+
address: '0x' ,
429+
network: '',
430+
deployedAt: '',
431+
transactionHash: '0x'
432432
}
433433
];
434434

0 commit comments

Comments
 (0)