Skip to content

Commit be1b720

Browse files
committed
chore: use sha256 from @noble/hashes
1 parent 663b589 commit be1b720

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

app/scripts/migrations/105.test.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { v4 as uuid } from 'uuid';
2-
import { sha256FromString } from 'ethereumjs-util';
2+
import { sha256 } from '@noble/hashes/sha256';
33
import { InternalAccount } from '@metamask/keyring-api';
4+
import { toBuffer } from 'ethereumjs-util';
45
import { ETH_EOA_METHODS } from '../../../shared/constants/eth-methods';
56
import { migrate } from './105';
67

@@ -18,7 +19,7 @@ global.sentry = {
1819

1920
function addressToUUID(address: string): string {
2021
return uuid({
21-
random: sha256FromString(address).slice(0, 16),
22+
random: sha256(toBuffer(address)).slice(0, 16),
2223
});
2324
}
2425

app/scripts/migrations/105.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { EthAccountType, InternalAccount } from '@metamask/keyring-api';
2-
import { sha256FromString } from 'ethereumjs-util';
2+
import { sha256 } from '@noble/hashes/sha256';
3+
import { toBuffer } from 'ethereumjs-util';
34
import { v4 as uuid } from 'uuid';
45
import { cloneDeep } from 'lodash';
56
import { ETH_EOA_METHODS } from '../../../shared/constants/eth-methods';
@@ -87,7 +88,7 @@ function createInternalAccountsForAccountsController(
8788

8889
Object.values(identities).forEach((identity) => {
8990
const expectedId = uuid({
90-
random: sha256FromString(identity.address).slice(0, 16),
91+
random: sha256(toBuffer(identity.address)).slice(0, 16),
9192
});
9293

9394
accounts[expectedId] = {

0 commit comments

Comments
 (0)