Skip to content

Commit

Permalink
Merge branch 'main' into STAKE-817-fe-show-staked-eth-position-in-hom…
Browse files Browse the repository at this point in the history
…epage-along-with-other-tokens
  • Loading branch information
nickewansmith authored Oct 31, 2024
2 parents 4d90470 + eb2ae98 commit d6c3ee7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 45 deletions.
61 changes: 17 additions & 44 deletions packages/transaction-controller/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,15 +542,14 @@ export enum WalletDevice {
OTHER = 'other_device',
}

/* eslint-disable @typescript-eslint/naming-convention */
/**
* The type of the transaction.
*/
export enum TransactionType {
/**
* A transaction that bridges tokens to a different chain through Metamask Bridge.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
bridge = 'bridge',

/**
Expand All @@ -559,59 +558,43 @@ export enum TransactionType {
* of the user for the MetaMask Bridge contract. The first bridge for any token
* will have an accompanying bridgeApproval transaction.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
bridgeApproval = 'bridgeApproval',

/**
* A transaction sending a network's native asset to a recipient.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
cancel = 'cancel',

/**
* A transaction that is interacting with a smart contract's methods that we
* have not treated as a special case, such as approve, transfer, and
* transferfrom.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
contractInteraction = 'contractInteraction',

/**
* A transaction that deployed a smart contract.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
deployContract = 'contractDeployment',

/**
* A transaction for Ethereum decryption.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
ethDecrypt = 'eth_decrypt',

/**
* A transaction for getting an encryption public key.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
ethGetEncryptionPublicKey = 'eth_getEncryptionPublicKey',

/**
* An incoming (deposit) transaction.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
incoming = 'incoming',

/**
* A transaction for personal sign.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
personalSign = 'personal_sign',

/**
Expand All @@ -620,43 +603,46 @@ export enum TransactionType {
* to speed up pending transactions. This is accomplished by creating a new tx with
* the same nonce and higher gas fees.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
retry = 'retry',

/**
* A transaction sending a network's native asset to a recipient.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
simpleSend = 'simpleSend',

/**
* A transaction that is signing typed data.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
signTypedData = 'eth_signTypedData',

/**
* A transaction sending a network's native asset to a recipient.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
smart = 'smart',

/**
* A transaction that claims staking rewards.
*/
stakingClaim = 'stakingClaim',

/**
* A transaction that deposits tokens into a staking contract.
*/
stakingDeposit = 'stakingDeposit',

/**
* A transaction that unstakes tokens from a staking contract.
*/
stakingUnstake = 'stakingUnstake',

/**
* A transaction swapping one token for another through MetaMask Swaps.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
swap = 'swap',

/**
* A transaction swapping one token for another through MetaMask Swaps, then sending the swapped token to a recipient.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
swapAndSend = 'swapAndSend',

/**
Expand All @@ -665,16 +651,12 @@ export enum TransactionType {
* of the user for the MetaMask Swaps contract. The first swap for any token
* will have an accompanying swapApproval transaction.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
swapApproval = 'swapApproval',

/**
* A token transaction requesting an allowance of the token to spend on
* behalf of the user.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
tokenMethodApprove = 'approve',

/**
Expand All @@ -683,42 +665,33 @@ export enum TransactionType {
* this method the contract checks to ensure that the receiver is an address
* capable of handling the token being sent.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
tokenMethodSafeTransferFrom = 'safetransferfrom',

/**
* A token transaction where the user is sending tokens that they own to
* another address.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
tokenMethodTransfer = 'transfer',

/**
* A token transaction transferring tokens from an account that the sender
* has an allowance of. For more information on allowances, see the approve
* type.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
tokenMethodTransferFrom = 'transferfrom',

/**
* A token transaction requesting an allowance of all of a user's tokens to
* spend on behalf of the user.
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
tokenMethodSetApprovalForAll = 'setapprovalforall',

/**
* Increase the allowance by a given increment
*/
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
tokenMethodIncreaseAllowance = 'increaseAllowance',
}
/* eslint-enable @typescript-eslint/naming-convention */

/**
* Standard data concerning a transaction to be processed by the blockchain.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable jest/expect-expect */

import { TransactionType } from '@metamask/transaction-controller';
import { cloneDeep } from 'lodash';

import type {
Expand Down Expand Up @@ -341,7 +342,9 @@ describe('validation', () => {
'type',
'wrong type',
123,
'Expected one of `"bridge","bridgeApproval","cancel","contractInteraction","contractDeployment","eth_decrypt","eth_getEncryptionPublicKey","incoming","personal_sign","retry","simpleSend","eth_signTypedData","smart","swap","swapAndSend","swapApproval","approve","safetransferfrom","transfer","transferfrom","setapprovalforall","increaseAllowance"`, but received: 123',
`Expected one of \`${Object.values(TransactionType)
.map((value) => `"${value as string}"`)
.join(',')}\`, but received: 123`,
],
])(
'throws if %s is %s',
Expand Down

0 comments on commit d6c3ee7

Please sign in to comment.