@@ -39,7 +39,6 @@ func (app *App) AddCosmosEventsToEVMReceiptIfApplicable(ctx sdk.Context, tx sdk.
39
39
return
40
40
}
41
41
logs := []* ethtypes.Log {}
42
- ownerReplacements := map [uint ]common.Hash {}
43
42
// Note: txs with a very large number of WASM events may run out of gas due to
44
43
// additional gas consumption from EVM receipt generation and event translation
45
44
wasmToEvmEventGasLimit := app .EvmKeeper .GetDeliverTxHookWasmGasLimit (ctx .WithGasMeter (sdk .NewInfiniteGasMeter (1 , 1 )))
@@ -61,13 +60,10 @@ func (app *App) AddCosmosEventsToEVMReceiptIfApplicable(ctx sdk.Context, tx sdk.
61
60
// check if there is a ERC721 pointer to contract Addr
62
61
pointerAddr , _ , exists = app .EvmKeeper .GetERC721CW721Pointer (wasmToEvmEventCtx , contractAddr )
63
62
if exists {
64
- log , realOwner , eligible := app .translateCW721Event (wasmToEvmEventCtx , wasmEvent , pointerAddr , contractAddr , response )
63
+ log , eligible := app .translateCW721Event (wasmToEvmEventCtx , wasmEvent , pointerAddr , contractAddr , response )
65
64
if eligible {
66
65
log .Index = uint (len (logs ))
67
66
logs = append (logs , log )
68
- if (realOwner != common.Hash {}) {
69
- ownerReplacements [log .Index ] = realOwner
70
- }
71
67
}
72
68
continue
73
69
}
@@ -81,22 +77,15 @@ func (app *App) AddCosmosEventsToEVMReceiptIfApplicable(ctx sdk.Context, tx sdk.
81
77
}
82
78
var bloom ethtypes.Bloom
83
79
if r , err := app .EvmKeeper .GetTransientReceipt (wasmToEvmEventCtx , txHash ); err == nil && r != nil {
84
- existingLogCnt := len (r .Logs )
85
80
r .Logs = append (r .Logs , utils .Map (logs , evmkeeper .ConvertSyntheticEthLog )... )
86
81
for i , l := range r .Logs {
87
82
l .Index = uint32 (i )
88
83
}
89
84
bloom = ethtypes .CreateBloom (ethtypes.Receipts {& ethtypes.Receipt {Logs : evmkeeper .GetLogsForTx (r )}})
90
85
r .LogsBloom = bloom [:]
91
- for i , o := range ownerReplacements {
92
- r .Logs [existingLogCnt + int (i )].Topics [1 ] = o .Hex ()
93
- }
94
86
_ = app .EvmKeeper .SetTransientReceipt (wasmToEvmEventCtx , txHash , r )
95
87
} else {
96
88
bloom = ethtypes .CreateBloom (ethtypes.Receipts {& ethtypes.Receipt {Logs : logs }})
97
- for i , o := range ownerReplacements {
98
- logs [int (i )].Topics [1 ] = o
99
- }
100
89
receipt := & evmtypes.Receipt {
101
90
TxType : ShellEVMTxType ,
102
91
TxHashHex : txHash .Hex (),
@@ -184,17 +173,17 @@ func (app *App) translateCW20Event(ctx sdk.Context, wasmEvent abci.Event, pointe
184
173
return nil , false
185
174
}
186
175
187
- func (app * App ) translateCW721Event (ctx sdk.Context , wasmEvent abci.Event , pointerAddr common.Address , contractAddr string , response sdk.DeliverTxHookInput ) (* ethtypes.Log , common. Hash , bool ) {
176
+ func (app * App ) translateCW721Event (ctx sdk.Context , wasmEvent abci.Event , pointerAddr common.Address , contractAddr string , response sdk.DeliverTxHookInput ) (* ethtypes.Log , bool ) {
188
177
action , found := GetAttributeValue (wasmEvent , "action" )
189
178
if ! found {
190
- return nil , common. Hash {}, false
179
+ return nil , false
191
180
}
192
181
var topics []common.Hash
193
182
switch action {
194
183
case "transfer_nft" , "send_nft" , "burn" :
195
184
tokenID := GetTokenIDAttribute (wasmEvent )
196
185
if tokenID == nil {
197
- return nil , common. Hash {}, false
186
+ return nil , false
198
187
}
199
188
sender := common.Hash {}
200
189
// unfortunately CW721 transfer events differ from ERC721 transfer events
@@ -204,17 +193,15 @@ func (app *App) translateCW721Event(ctx sdk.Context, wasmEvent abci.Event, point
204
193
// synthetic ERC721 event.
205
194
ownerEvents := GetEventsOfType (response , wasmtypes .EventTypeCW721PreTransferOwner )
206
195
for _ , ownerEvent := range ownerEvents {
207
- if len (ownerEvent .Attributes ) != 3 {
208
- continue
209
- }
210
- if string (ownerEvent .Attributes [0 ].Key ) != wasmtypes .AttributeKeyContractAddr || string (ownerEvent .Attributes [0 ].Value ) != contractAddr {
196
+ if len (ownerEvent .Attributes ) != 3 ||
197
+ string (ownerEvent .Attributes [0 ].Key ) != wasmtypes .AttributeKeyContractAddr ||
198
+ string (ownerEvent .Attributes [0 ].Value ) != contractAddr {
211
199
continue
212
200
}
213
201
tokenIDStr , _ := GetAttributeValue (wasmEvent , "token_id" )
214
- if string (ownerEvent .Attributes [1 ].Key ) != wasmtypes .AttributeKeyTokenId || string (ownerEvent .Attributes [1 ].Value ) != tokenIDStr {
215
- continue
216
- }
217
- if string (ownerEvent .Attributes [2 ].Key ) != wasmtypes .AttributeKeyOwner {
202
+ if string (ownerEvent .Attributes [1 ].Key ) != wasmtypes .AttributeKeyTokenId ||
203
+ string (ownerEvent .Attributes [1 ].Value ) != tokenIDStr ||
204
+ string (ownerEvent .Attributes [2 ].Key ) != wasmtypes .AttributeKeyOwner {
218
205
continue
219
206
}
220
207
ownerAcc , err := sdk .AccAddressFromBech32 (string (ownerEvent .Attributes [2 ].Value ))
@@ -226,19 +213,19 @@ func (app *App) translateCW721Event(ctx sdk.Context, wasmEvent abci.Event, point
226
213
}
227
214
topics = []common.Hash {
228
215
ERC721TransferTopic ,
229
- app . GetEvmAddressAttribute ( ctx , wasmEvent , " sender" ) ,
216
+ sender ,
230
217
app .GetEvmAddressAttribute (ctx , wasmEvent , "recipient" ),
231
218
common .BigToHash (tokenID ),
232
219
}
233
220
return & ethtypes.Log {
234
221
Address : pointerAddr ,
235
222
Topics : topics ,
236
223
Data : EmptyHash .Bytes (),
237
- }, sender , true
224
+ }, true
238
225
case "mint" :
239
226
tokenID := GetTokenIDAttribute (wasmEvent )
240
227
if tokenID == nil {
241
- return nil , common. Hash {}, false
228
+ return nil , false
242
229
}
243
230
topics = []common.Hash {
244
231
ERC721TransferTopic ,
@@ -250,11 +237,11 @@ func (app *App) translateCW721Event(ctx sdk.Context, wasmEvent abci.Event, point
250
237
Address : pointerAddr ,
251
238
Topics : topics ,
252
239
Data : EmptyHash .Bytes (),
253
- }, common. Hash {}, true
240
+ }, true
254
241
case "approve" :
255
242
tokenID := GetTokenIDAttribute (wasmEvent )
256
243
if tokenID == nil {
257
- return nil , common. Hash {}, false
244
+ return nil , false
258
245
}
259
246
topics = []common.Hash {
260
247
ERC721ApprovalTopic ,
@@ -266,11 +253,11 @@ func (app *App) translateCW721Event(ctx sdk.Context, wasmEvent abci.Event, point
266
253
Address : pointerAddr ,
267
254
Topics : topics ,
268
255
Data : EmptyHash .Bytes (),
269
- }, common. Hash {}, true
256
+ }, true
270
257
case "revoke" :
271
258
tokenID := GetTokenIDAttribute (wasmEvent )
272
259
if tokenID == nil {
273
- return nil , common. Hash {}, false
260
+ return nil , false
274
261
}
275
262
topics = []common.Hash {
276
263
ERC721ApprovalTopic ,
@@ -282,7 +269,7 @@ func (app *App) translateCW721Event(ctx sdk.Context, wasmEvent abci.Event, point
282
269
Address : pointerAddr ,
283
270
Topics : topics ,
284
271
Data : EmptyHash .Bytes (),
285
- }, common. Hash {}, true
272
+ }, true
286
273
case "approve_all" :
287
274
topics = []common.Hash {
288
275
ERC721ApproveAllTopic ,
@@ -293,7 +280,7 @@ func (app *App) translateCW721Event(ctx sdk.Context, wasmEvent abci.Event, point
293
280
Address : pointerAddr ,
294
281
Topics : topics ,
295
282
Data : TrueHash .Bytes (),
296
- }, common. Hash {}, true
283
+ }, true
297
284
case "revoke_all" :
298
285
topics = []common.Hash {
299
286
ERC721ApproveAllTopic ,
@@ -304,9 +291,9 @@ func (app *App) translateCW721Event(ctx sdk.Context, wasmEvent abci.Event, point
304
291
Address : pointerAddr ,
305
292
Topics : topics ,
306
293
Data : EmptyHash .Bytes (),
307
- }, common. Hash {}, true
294
+ }, true
308
295
}
309
- return nil , common. Hash {}, false
296
+ return nil , false
310
297
}
311
298
312
299
func (app * App ) GetEvmAddressAttribute (ctx sdk.Context , event abci.Event , attribute string ) common.Hash {
0 commit comments