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

feature(node): ERC20 and ETH support #2325

Merged
merged 58 commits into from
Sep 17, 2019

Conversation

micahriggan
Copy link
Contributor

@micahriggan micahriggan commented Aug 9, 2019

Can now sync ETH and get wallet history for ERC20 tokens

Refactoring currency support into a module system. This allows the creation of 3rd party modules, and arbitrary currency support without forking.

ETH Syncing via

      "ETH": {
        "mainnet": {
          "chainSource": "p2p",
          "trustedPeers": [
            {
              "host": "127.0.0.1",
              "port": 30303
            }
          ],
          "provider": {
            "host": "127.0.0.1",
            "protocol":"ws",
            "port": 8546
          }
        }
      }

Testing

I've been testing with this local development node

alias parity-dev="/Users/micah/blockchains/eth/parity2.4.2 --config dev --base-path '/Users/micah/blockchains/eth/dev' --db-compaction ssd --cache-size 8192 --jsonrpc-cors=all --ws-origins=all --ws-apis=all"

and this private key
0x4d5db4107d237df6a3d58ee5f70ae63d73d7658d4026f2eefd2f204c81682cb7 imported into metamask

@micahriggan micahriggan force-pushed the feature/eth-module-squashed branch 2 times, most recently from e6e485b to 5f5eae6 Compare August 12, 2019 16:44
@matiu matiu mentioned this pull request Aug 12, 2019
Can now sync ETH and get wallet history for ERC20 tokens
@@ -115,7 +115,7 @@ router.get('/:pubKey/addresses/missing', authenticate, async (req: Authenticated
pubKey,
stream: res
};
return ChainStateProvider.streamMissingWalletAddresses(payload);
return await ChainStateProvider.streamMissingWalletAddresses(payload);
Copy link
Member

Choose a reason for hiding this comment

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

if this is streaming why does it await?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

eRRoR

@@ -134,7 +134,7 @@ router.get('/:pubKey/addresses', authenticate, async (req: AuthenticatedRequest,
req,
res
};
return ChainStateProvider.streamWalletAddresses(payload);
return await ChainStateProvider.streamWalletAddresses(payload);
Copy link
Member

Choose a reason for hiding this comment

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

if this is streaming why does it await?

@@ -188,7 +188,7 @@ router.post('/:pubKey', authenticate, async (req: AuthenticatedRequest, res) =>
router.get('/:pubKey/transactions', authenticate, async (req: AuthenticatedRequest, res) => {
let { chain, network } = req.params;
try {
return ChainStateProvider.streamWalletTransactions({
return await ChainStateProvider.streamWalletTransactions({
Copy link
Member

Choose a reason for hiding this comment

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

if this is streaming why does it await?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So interesting thing I learned. If there's a throw inside of an async method that streams, then you'll get an unhandled promise rejection if you don't await that method.


onConnect() {
super.onConnect();
this.collection.createIndex({ chain: 1, network: 1, to: 1 }, { background: true });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

sparse

This was referenced Aug 23, 2019
@micahriggan micahriggan force-pushed the feature/eth-module-squashed branch 3 times, most recently from 002b129 to e12cc24 Compare August 23, 2019 20:25
if (!initialSyncComplete) {
return;
}
let prunedTxs = {};
Copy link
Contributor

Choose a reason for hiding this comment

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

fix pruneTxs always empty object

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks!

@micahriggan micahriggan force-pushed the feature/eth-module-squashed branch 2 times, most recently from 1002638 to f8dac47 Compare September 16, 2019 19:46
@matiu matiu merged commit e825d60 into bitpay:master Sep 17, 2019
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.

4 participants