Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Add (basic) custom chain support (e.g. Görli) #261

Merged
merged 1 commit into from
Jul 21, 2019

Conversation

JamesLefrere
Copy link
Contributor

This PR adds basic support for custom chains (i.e. anything but the default for ethereumjs-tx, which is mainnet). This is done by using the ethereumjs-common package to define a chain definition based on a default: either mainnet for chain IDs 1 (mainnet) and 1337 (local/private), or 5 for goerli. Other chain IDs are sent as-is, which may cause validation errors if they are not supported by ethereumjs-common.

Ideally, all chain definition should all be configurable when signing a transaction, but that would require a fairly significant API change.

Additions

  • Add (limited) support for custom chains
  • Add ethereumjs-common dependency (also a dependency of ethereumjs-tx)
  • Define getChainDefinition helper in purser-core

Changes

  • Implement custom chains in ethereumjs-tx transactions and update tests, for purser-metamask, purser-ledger and purser-trezor.

* Add (limited) support for custom chains
* Add `ethereumjs-common` dependency (also a dependency of `ethereumjs-tx`)
* Define `getChainDefinition` helper
* Implement custom chains in `ethereumjs-tx` transactions and update tests
Copy link
Member

@rdig rdig left a comment

Choose a reason for hiding this comment

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

This is good to go.

A minor tidbit, that getChainDefinition should have used the core defaults constants, but in the interest of time, I'm going to publish it as-is. We can deal with those at a later date.

Also, I feel like this is pretty significant change internally (even though it's technically more of a fix), so I'm going to push this as a MINOR release.

* @TODO Provide a means to specify all chain properties for transactions
*/
case 1:
case 1337:
Copy link
Member

Choose a reason for hiding this comment

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

These case values should have been taken from the core defaults:

export const NETWORK_IDS: Object = {

* using the current default for this property. This is also an
* assumption, and this should be made configurable.
*/
'petersburg',
Copy link
Member

Choose a reason for hiding this comment

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

As above, this should have been added to the core defaults

@rdig rdig added this to the Sprint 30 milestone Jul 21, 2019
@rdig rdig merged commit a33b9af into master Jul 21, 2019
@rdig rdig deleted the fix/support-goerli-and-local-chains branch July 21, 2019 20:00
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants