This repository has been archived by the owner on Oct 7, 2024. It is now read-only.
generated from MetaMask/metamask-module-template
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add isEVMAccount helper (#297)
* feat: add isEvmAccount helper * fix: 4337 methods * fix: create InternalAccountType * fix: naming of isEvmAccount * revert: Signing methods for 4337 except SignTransaction * fix: update logic to pass in account type rather than account object * refactor: move to utils in eth folder * chore: update lint * revert: removal of sign to another PR * fix: update jsdoc
- Loading branch information
1 parent
e004d46
commit 0f028b0
Showing
4 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './erc4337'; | ||
export * from './types'; | ||
export * from './utils'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { EthAccountType } from '.'; | ||
import { BtcAccountType } from '../btc'; | ||
import { isEvmAccountType } from './utils'; | ||
|
||
describe('isEvmAccountType', () => { | ||
it.each([ | ||
[EthAccountType.Eoa, true], | ||
[EthAccountType.Erc4337, true], | ||
[BtcAccountType.P2wpkh, false], | ||
[{}, false], | ||
[null, false], | ||
['bitcoin', false], | ||
])('%s should return %s', (account, result) => { | ||
// @ts-expect-error for error cases | ||
expect(isEvmAccountType(account)).toBe(result); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import type { InternalAccountType } from '../internal'; | ||
import { EthAccountType } from './types'; | ||
|
||
/** | ||
* Checks if the given type is an EVM account type. | ||
* @param type - The type to check. | ||
* @returns Returns true if the type is an EVM account type, false otherwise. | ||
*/ | ||
export function isEvmAccountType(type: InternalAccountType): boolean { | ||
return type === EthAccountType.Eoa || type === EthAccountType.Erc4337; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters