Skip to content

Commit

Permalink
chore: use sha256 from @noble/hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
legobeat committed Dec 22, 2024
1 parent c91b4ee commit 5a71630
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/scripts/migrations/105.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { v4 as uuid } from 'uuid';
import { sha256FromString } from 'ethereumjs-util';
import { sha256 } from '@noble/hashes/sha256';
import { InternalAccount } from '@metamask/keyring-internal-api';
import { toBuffer } from 'ethereumjs-util';
import { ETH_EOA_METHODS } from '../../../shared/constants/eth-methods';
import { migrate } from './105';

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

function addressToUUID(address: string): string {
return uuid({
random: sha256FromString(address).slice(0, 16),
random: sha256(toBuffer(address)).slice(0, 16),
});
}

Expand Down
5 changes: 3 additions & 2 deletions app/scripts/migrations/105.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { EthAccountType } from '@metamask/keyring-api';
import { InternalAccount } from '@metamask/keyring-internal-api';
import { sha256FromString } from 'ethereumjs-util';
import { sha256 } from '@noble/hashes/sha256';
import { toBuffer } from 'ethereumjs-util';
import { v4 as uuid } from 'uuid';
import { cloneDeep } from 'lodash';
import { ETH_EOA_METHODS } from '../../../shared/constants/eth-methods';
Expand Down Expand Up @@ -88,7 +89,7 @@ function createInternalAccountsForAccountsController(

Object.values(identities).forEach((identity) => {
const expectedId = uuid({
random: sha256FromString(identity.address).slice(0, 16),
random: sha256(toBuffer(identity.address)).slice(0, 16),
});

accounts[expectedId] = {
Expand Down

0 comments on commit 5a71630

Please sign in to comment.