harmony-one / bounties

Bounty program is to help the community take part in the development of the Harmony blockchain. It covers from core feature to validator tooling, from dApp development to DeFi integration.
MIT License
59 stars 23 forks source link

Make @truffle/hdwallet-provider work for Harmony #23

Closed gupadhyaya closed 3 years ago

gupadhyaya commented 3 years ago

Description

Currently we are unable to use @truffle/hdwallet-provider (https://www.npmjs.com/package/@truffle/hdwallet-provider) for harmony network. Somehow the network_id/chain_id is omitted when signing txs using Harmony's ETH compatible chain ids (https://docs.harmony.one/home/network/wallets/browser-extensions-wallets/metamask-wallet).

Context

The error is as shown below, when you run: truffle migrate --reset --network testnet

Starting migrations...
======================
> Network name:    'testnet'
> Network id:      1666700000
> Block gas limit: 80000000 (0x4c4b400)

1_initial_migration.js
======================

   Deploying 'Migrations'
   ----------------------

Error:  *** Deployment Failed ***

"Migrations" -- blockchain chain id:2, given 0: invalid chain id for signer.

    at ./.nvm/versions/node/v10.17.0/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:364:1
    at process._tickCallback (internal/process/next_tick.js:68:7)
Truffle v5.1.33 (core: 5.1.33)
Node v10.21.0

the testnet entry in truffle-config.js is:

const HDWalletProvider = require('@truffle/hdwallet-provider');
...
testnet: {
      provider: () => {
         if (!privateKeyTest.trim()) {
            throw new Error(
               'Please enter a private key with funds, you can use the default one'
            );
         }
         return new HDWalletProvider(
            privateKeyTest,
            'https://api.s0.b.hmny.io'
         );
      },
      network_id: 1666700000,
},

More context:

Acceptance Criteria

Reward

$1000 equivalent in ONE tokens

gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


This issue now has a funding of 6864.9452 ONE (998.47 USD @ $0.15/ONE) attached to it.

gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 6864.9452 ONE (998.47 USD @ $0.15/ONE) has been submitted by:


gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


Work for 6864.9452 ONE (1038.49 USD @ $0.16/ONE) has been submitted by:

  1. @noahfigueras

@papiofficial please take a look at the submitted work:


gitcoinbot commented 3 years ago

Issue Status: 1. Open 2. Started 3. Submitted 4. Done


The funding of 6864.9452 ONE (990.26 USD @ $0.14/ONE) attached to this issue has been approved & issued to @noahfigueras.