Skip to content
This repository has been archived by the owner on Sep 5, 2020. It is now read-only.

Transaction receipt contractAddress injection #3265

Merged
merged 2 commits into from
Nov 16, 2017

Conversation

evertonfraga
Copy link
Member

What does it do?

Overrides eth_getTransactionReceipt to properly add contractAddress.

It comes in handy as the light client currently doesn't return that for now.

@evertonfraga
Copy link
Member Author

TODO: add support to batch requests

@ghost
Copy link

ghost commented Nov 10, 2017

Thank you for this, can you explain how to use it?

@evertonfraga
Copy link
Member Author

@ni2k10 you can try to build Mist from source, or wait for a release, that will happen ~2 days after this has been merged.

@bliekp
Copy link

bliekp commented Nov 13, 2017

Please merge this ASAP. This is a real showstopper and it would be great if this is fixed...

@evertonfraga
Copy link
Member Author

evertonfraga commented Nov 13, 2017 via email

Copy link
Member

@wolovim wolovim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit: successfully resolves hanging contracts in tandem with ethereum/meteor-dapp-wallet#427

@evertonfraga evertonfraga merged commit c58353f into develop Nov 16, 2017
@evertonfraga evertonfraga deleted the transactionReceipt-injection branch November 16, 2017 21:45
@pokjs
Copy link

pokjs commented Dec 29, 2017

@@ -0,0 +1,60 @@
+const _ = global._;
+const BaseProcessor = require('./base');
+const eth = require('ethereumjs-util');
+
+/**

    • Process method: eth_getTransactionReceipt
  • */

+module.exports = class extends BaseProcessor {
+

  • sanitizeRequestPayload(conn, payload, isPartOfABatch) {
  •    return super.sanitizeRequestPayload(conn, payload, isPartOfABatch);
    
  • }
  • async exec(conn, payload) {
  •    const txHash = payload.params[0];
    
  •    // Sends regular eth_getTransactionReceipt request
    
  •    const ret = await conn.socket.send(payload, {
    
  •        fullResult: true
    
  •    });
    
  •    // If that contains a contractAddress already, fine.
    
  •    if (ret.result.result.contractAddress != null) {
    
  •        return ret.result;
    
  •    }
    
  •    // Due to a geth's light client v1 bug, it does not return
    
  •    // contractAddress value on the receipts. Let's fix that.
    
  •    // 1. GET TRANSACTION from AND nonce VALUES
    
  •    const transactionInfo = await conn.socket.send({
    
  •        jsonrpc: '2.0',
    
  •        id: _.uuid(),
    
  •        method: 'eth_getTransactionByHash',
    
  •        params: [txHash]
    
  •    }, { fullResult: true });
    
  •    const fromAddress = transactionInfo.result.result.from;
    
  •    const nonce = parseInt(transactionInfo.result.result.nonce, 16);
    
  •    const possibleContractAddress = `0x${eth.generateAddress(fromAddress, nonce).toString('hex')}`;
    
  •    // 2. GET CODE FROM ADDRESS
    
  •    const contractCode = await conn.socket.send({
    
  •        jsonrpc: '2.0',
    
  •        id: _.uuid(),
    
  •        method: 'eth_getCode',
    
  •        params: [possibleContractAddress, 'latest']
    
  •    }, { fullResult: true });
    
  •    const contractCodeResult = contractCode.result.result;
    
  •    // 3. IF IT EXISTS, ASSIGN TO RETURN VALUE
    
  •    if (contractCodeResult && contractCodeResult.length > 2) {
    
  •        ret.result.result.contractAddress = possibleContractAddress;
    
  •    }
    
  •    return ret.result;
    
  • }
    +};

@lock
Copy link

lock bot commented Mar 29, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked and limited conversation to collaborators Mar 29, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants