Skip to content

Commit e9fc527

Browse files
committed
chore: use sha256 from @noble/hashes
1 parent 87c524e commit e9fc527

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

app/scripts/migrations/105.test.ts

Lines changed: 3 additions & 2 deletions
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-internal-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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { EthAccountType } from '@metamask/keyring-api';
22
import { InternalAccount } from '@metamask/keyring-internal-api';
3-
import { sha256FromString } from 'ethereumjs-util';
3+
import { sha256 } from '@noble/hashes/sha256';
4+
import { toBuffer } from 'ethereumjs-util';
45
import { v4 as uuid } from 'uuid';
56
import { cloneDeep } from 'lodash';
67
import { ETH_EOA_METHODS } from '../../../shared/constants/eth-methods';
@@ -88,7 +89,7 @@ function createInternalAccountsForAccountsController(
8889

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

9495
accounts[expectedId] = {

0 commit comments

Comments
 (0)