MoralisWeb3 / Moralis-JS-SDK

Moralis Official Javascript SDK
https://docs.moralis.io
Other
368 stars 257 forks source link

Missing property `msg.sender` in `getContractEvents` #1013

Closed rudolfnep closed 1 year ago

rudolfnep commented 1 year ago

New Feature Request

Checklist

Current Limitation

The SDK feature getContractEvents is missing an important property from or the transaction sender. It takes an additional blockchain call [(await provider.getTransaction(hash)).from] to retrieve that data. For results that produce many records, it simply makes everything slower.

Do you have any plans to add from property to the getContractEvents and getContractLogs functions?

ErnoW commented 1 year ago

I'm not sure what you mean. You get the from address back under the data attribute.

For example, the response could return:

    [{
      "transaction_hash": "0x34d2376a3b379abcaf8d74ad2bd6a08dc1e0a70f3b0472dcb957626ec73b86cb",
      "address": "0x1f9840a85d5af5bf1d1762f925bdaddc4201f984",
      "block_timestamp": "2023-02-13T09:22:11.000Z",
      "block_number": "16618909",
      "block_hash": "0x498e6b625cb1aaa9ed6406e32a983b1ccfcce7bdfa1d37bc1d184a0bb6ba3d4c",
      "data": {
        "from": "0x28c6c06298d514db089934071355e5743bf21d60",
        "to": "0x0434b69fdc87d02a2633520bf0a84c33d581b0ba",
        "amount": "9380000000000000000"
      }
    }]

For more info see https://docs.moralis.io/web3-data-api/reference/get-contract-events

Also for better and faster support and feature requests, go to https://forum.moralis.io/, we use this board mainly for bug reports.

rudolfnep commented 1 year ago

Hi, instead of Transfer(from, to, amount) from your example, what about event OwnershipTransferred(previous, current)? Would the from value be available on the data attribute? Looking at the result of getContractEvents, how can one determine who the sent the transaction?

ErnoW commented 1 year ago

I see now what you mean. I think that this is not possible in 1 request at the moment. It's a good use-case to include it, I will forward the request to the api team, to see if it makes sense to include it in these responses.

Closing this issue as it's not a bug in the SDK.