Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: return proper transaction receipt #293

Merged
merged 3 commits into from
Jul 29, 2019

Conversation

troggy
Copy link
Member

@troggy troggy commented Jul 15, 2019

Resolves #256

Requires:

Attempt to properly implement getTransactionReceipt RPC.

As a result, no hacks should be needed anymore for sending transactions.

Web3:

// create some LeapTransaction
const tx = Tx.transfer(
  ...
);

// tx should be signed
tx.signAll(wallet.privateKey);

const plasmaWeb3 = helpers.extendWeb3(new Web3('https://testnet-node.leapdao.org'));

// send with regular `sendSignedTransaction`
const receipt = await plasmaWeb3.eth.sendSignedTransaction(tx.hex());
// tx is included at this point\

Ethers requires a special provider due to strict checks:

const LeapProvider = require('leap-provider');
const provider = new LeapProvider('https://testnet-node.leapdao.org');

// create some LeapTransaction
const tx = Tx.transfer(
  ...
);

// tx should be signed
tx.signAll(wallet.privateKey);

// send via provider
const resp = await wallet.provider.sendTransaction(tx);

// wait for inclusion, you will get a proper TransactionReceipt once tx is included in a block
const receipt = await resp.wait();
console.log(receipt);
// tx is included at this point\

@codecov
Copy link

codecov bot commented Jul 15, 2019

Codecov Report

Merging #293 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #293      +/-   ##
==========================================
+ Coverage    94.2%   94.22%   +0.01%     
==========================================
  Files          63       65       +2     
  Lines         932      935       +3     
  Branches      175      174       -1     
==========================================
+ Hits          878      881       +3     
  Misses         49       49              
  Partials        5        5
Impacted Files Coverage Δ
src/api/methods/txResponse.js 100% <100%> (ø) ⬆️
src/api/methods/getBlockByHash.js 100% <100%> (ø) ⬆️
src/api/methods/utils/getPrevTx.js 100% <100%> (ø)
src/api/methods/getTransactionReceipt.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a99a059...03a779c. Read the comment docs.

Copy link
Member

@sunify sunify left a comment

Choose a reason for hiding this comment

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

One tiny change required. 🌮

contractAddress: null,
logs: [],
logsBloom: '0x',
status: 1,
Copy link
Member

Choose a reason for hiding this comment

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

Should be a hex string (according web3 docs and geth code)

from = prevTx.outputs[outputIndex].address;
}
}
const prevTx = await getPrevTx(db, tx);
Copy link
Member

Choose a reason for hiding this comment

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

👍

@troggy troggy force-pushed the feat/proper-transaction-receipt branch from 72e6332 to fb9b87c Compare July 29, 2019 12:04
@troggy troggy merged commit 0ff5911 into master Jul 29, 2019
@troggy troggy deleted the feat/proper-transaction-receipt branch July 29, 2019 12:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement getTransactionReceipt RPC
2 participants