@@ -55,7 +55,8 @@ const profile = {
55
55
'addInstance' ,
56
56
'resolveContractAndAddInstance' ,
57
57
'showPluginDetails' ,
58
- 'getRunTabAPI'
58
+ 'getRunTabAPI' ,
59
+ 'getDeployedContracts'
59
60
]
60
61
}
61
62
@@ -73,6 +74,8 @@ export class RunTab extends ViewPlugin {
73
74
recorder : any
74
75
REACT_API : any
75
76
el : any
77
+ transactionHistory : Map < string , any > = new Map ( )
78
+
76
79
constructor ( blockchain : Blockchain , config : any , fileManager : any , editor : any , filePanel : any , compilersArtefacts : CompilerArtefacts , networkModule : any , fileProvider : any , engine : any ) {
77
80
super ( profile )
78
81
this . event = new EventManager ( )
@@ -97,6 +100,34 @@ export class RunTab extends ViewPlugin {
97
100
} )
98
101
}
99
102
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
+
100
131
getSettings ( ) {
101
132
return new Promise ( ( resolve , reject ) => {
102
133
resolve ( {
@@ -116,11 +147,13 @@ export class RunTab extends ViewPlugin {
116
147
if ( canCall ) {
117
148
env = typeof env === 'string' ? { context : env } : env
118
149
this . emit ( 'setEnvironmentModeReducer' , env , this . currentRequest . from )
150
+ this . transactionHistory . clear ( )
119
151
}
120
152
}
121
153
122
154
clearAllInstances ( ) {
123
155
this . emit ( 'clearAllInstancesReducer' )
156
+ this . transactionHistory . clear ( )
124
157
}
125
158
126
159
addInstance ( address , abi , name , contractData ?) {
@@ -144,6 +177,46 @@ export class RunTab extends ViewPlugin {
144
177
return this . REACT_API ;
145
178
}
146
179
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
+
147
220
pendingTransactionsCount ( ) {
148
221
return this . blockchain . pendingTransactionsCount ( )
149
222
}
0 commit comments