Skip to content

Fix: normalizer ensuring type is always present in TransactionParams#3817

Merged
vinistevam merged 2 commits intomainfrom
fix/normalizer-type-always-present-tx-params
Jan 24, 2024
Merged

Fix: normalizer ensuring type is always present in TransactionParams#3817
vinistevam merged 2 commits intomainfrom
fix/normalizer-type-always-present-tx-params

Conversation

@vinistevam
Copy link
Copy Markdown
Contributor

@vinistevam vinistevam commented Jan 23, 2024

Explanation

This PR aims to ensure type is always present in the TransactionParams by matching the old Extension Normalizer.

References

Changelog

@metamask/transaction-controller

  • FIXED: the type normalizer to use the addHexPrefix and do not set the type as undefined.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've highlighted breaking changes using the "BREAKING" category above as appropriate

@vinistevam vinistevam requested a review from a team as a code owner January 23, 2024 11:56
@vinistevam
Copy link
Copy Markdown
Contributor Author

@metamaskbot publish-preview

@github-actions
Copy link
Copy Markdown
Contributor

Preview builds have been published. See these instructions for more information about preview builds.

Expand for full list of packages and versions.
{
  "@metamask-previews/accounts-controller": "8.0.0-preview.57d41d4",
  "@metamask-previews/address-book-controller": "3.1.6-preview.57d41d4",
  "@metamask-previews/announcement-controller": "5.0.1-preview.57d41d4",
  "@metamask-previews/approval-controller": "5.1.1-preview.57d41d4",
  "@metamask-previews/assets-controllers": "24.0.0-preview.57d41d4",
  "@metamask-previews/base-controller": "4.1.0-preview.57d41d4",
  "@metamask-previews/build-utils": "1.0.1-preview.57d41d4",
  "@metamask-previews/composable-controller": "5.0.0-preview.57d41d4",
  "@metamask-previews/controller-utils": "8.0.1-preview.57d41d4",
  "@metamask-previews/ens-controller": "8.0.0-preview.57d41d4",
  "@metamask-previews/eth-json-rpc-provider": "2.3.1-preview.57d41d4",
  "@metamask-previews/gas-fee-controller": "12.0.0-preview.57d41d4",
  "@metamask-previews/json-rpc-engine": "7.3.1-preview.57d41d4",
  "@metamask-previews/json-rpc-middleware-stream": "6.0.1-preview.57d41d4",
  "@metamask-previews/keyring-controller": "12.0.0-preview.57d41d4",
  "@metamask-previews/logging-controller": "2.0.1-preview.57d41d4",
  "@metamask-previews/message-manager": "7.3.7-preview.57d41d4",
  "@metamask-previews/name-controller": "4.2.0-preview.57d41d4",
  "@metamask-previews/network-controller": "17.1.0-preview.57d41d4",
  "@metamask-previews/notification-controller": "4.0.1-preview.57d41d4",
  "@metamask-previews/permission-controller": "7.1.0-preview.57d41d4",
  "@metamask-previews/permission-log-controller": "0.0.0-preview.57d41d4",
  "@metamask-previews/phishing-controller": "8.0.1-preview.57d41d4",
  "@metamask-previews/polling-controller": "4.0.0-preview.57d41d4",
  "@metamask-previews/preferences-controller": "6.0.0-preview.57d41d4",
  "@metamask-previews/queued-request-controller": "0.3.0-preview.57d41d4",
  "@metamask-previews/rate-limit-controller": "4.0.1-preview.57d41d4",
  "@metamask-previews/selected-network-controller": "6.0.0-preview.57d41d4",
  "@metamask-previews/signature-controller": "10.0.0-preview.57d41d4",
  "@metamask-previews/transaction-controller": "20.0.0-preview.57d41d4",
  "@metamask-previews/user-operation-controller": "1.0.0-preview.57d41d4"
}

gasPrice: '0x1',
to: ACCOUNT_MOCK,
value: '0x0',
type: TransactionType.simpleSend,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Good spot 😄 It's a fun one having a type property in both the parameters and the options.

estimatedBaseFee: (maxPriorityFeePerGas: string) =>
addHexPrefix(maxPriorityFeePerGas),
type: (type: string) => (type === '0x0' ? '0x0' : undefined),
type: (type: string) => addHexPrefix(type),
Copy link
Copy Markdown
Member

@matthewwalsh0 matthewwalsh0 Jan 23, 2024

Choose a reason for hiding this comment

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

In a future PR, we could go one step further and always derive a type even if one wasn't provided by looking at whether there is gasPrice or maxFeePerGas etc.

That's what we already do on submission using isEIP1559Transaction.

Perhaps worth confirming by testing an older commit with the extension controller, but my understanding is if a dapp transaction doesn't specify type, it won't be in the parameters either since the extension sources the parameters from here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this would be a good addition yeah! 👍

Copy link
Copy Markdown
Member

@FrederikBolding FrederikBolding left a comment

Choose a reason for hiding this comment

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

Can confirm this fixed in the snaps issue!

@vinistevam vinistevam merged commit d0ada01 into main Jan 24, 2024
@vinistevam vinistevam deleted the fix/normalizer-type-always-present-tx-params branch January 24, 2024 13:09
vinistevam added a commit to MetaMask/metamask-extension that referenced this pull request Jan 30, 2024
## **Description**
The package `@metamask/transaction-controller` has been upgraded to
`v21.0.1`.

This version has the following fixes:
- Resolves transaction custodian promise when setting transaction status
to submitted or failed
([#3845](MetaMask/core#3845))
- Fix normalizer ensuring property type is always present in
TransactionParams ([#3817](MetaMask/core#3817))

See here for the changelog:
https://github.com/MetaMask/core/blob/main/packages/transaction-controller/CHANGELOG.md#2101
shane-t pushed a commit to MetaMask/metamask-extension that referenced this pull request Jan 30, 2024
The package `@metamask/transaction-controller` has been upgraded to
`v21.0.1`.

This version has the following fixes:
- Resolves transaction custodian promise when setting transaction status
to submitted or failed
([#3845](MetaMask/core#3845))
- Fix normalizer ensuring property type is always present in
TransactionParams ([#3817](MetaMask/core#3817))

See here for the changelog:
https://github.com/MetaMask/core/blob/main/packages/transaction-controller/CHANGELOG.md#2101
shane-t pushed a commit to MetaMask/metamask-extension that referenced this pull request Jan 30, 2024
The package `@metamask/transaction-controller` has been upgraded to
`v21.0.1`.

This version has the following fixes:
- Resolves transaction custodian promise when setting transaction status
to submitted or failed
([#3845](MetaMask/core#3845))
- Fix normalizer ensuring property type is always present in
TransactionParams ([#3817](MetaMask/core#3817))

See here for the changelog:
https://github.com/MetaMask/core/blob/main/packages/transaction-controller/CHANGELOG.md#2101
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