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: allow to sendTransaction and get TransactionReceipt #1

Merged
merged 3 commits into from
Jul 29, 2019
Merged

Conversation

troggy
Copy link
Member

@troggy troggy commented Jul 26, 2019

For the provider to work, leap-node requires to run this change: leapdao/leap-node#293

Then it should be possible to send transactions normally without hacks:

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);

Relates leapdao/leap-node#256

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.

Nice!

index.js Outdated
let params = { signedTransaction: signedTransaction.hex() };
return this.perform('sendTransaction', params).then((hash) => {
return this._wrapTransaction({ hash: signedTransaction.hash() }, hash);
}, function (error) {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe use arrow function here as well?

package.json Outdated
"author": "Kosta Korenkov <[email protected]>",
"license": "MIT",
"dependencies": {
"ethers": "^4.0.33"
Copy link
Member

Choose a reason for hiding this comment

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

Move ethers to peer deps may be a good idea to avoid double bundling for browser code

https://nodejs.org/es/blog/npm/peer-dependencies/#the-problem-plugins

@troggy troggy merged commit 8ea799f into master Jul 29, 2019
@troggy troggy deleted the feat/v1 branch July 29, 2019 10:32
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.

2 participants