Skip to content

Commit 771ee54

Browse files
committed
fix
1 parent 8389f46 commit 771ee54

File tree

4 files changed

+30
-8
lines changed

4 files changed

+30
-8
lines changed

ui/__mocks__/ethereumjs-util.js

+25-5
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,29 @@
1-
const zeroAddress = function() {
2-
const addressLength = 20
3-
const addr = zeros(addressLength)
4-
return bufferToHex(addr)
5-
}
1+
// Vendored from [email protected]
62

3+
/**
4+
* Converts a `Buffer` into a `0x`-prefixed hex `String`.
5+
*
6+
* @param buf - `Buffer` object to convert
7+
*/
8+
const bufferToHex = function (buf) {
9+
// buf = toBuffer(buf);
10+
return `0x${buf.toString('hex')}`;
11+
};
12+
13+
/**
14+
* Returns a buffer filled with 0s.
15+
*
16+
* @param bytes - the number of bytes the buffer should be
17+
*/
18+
const zeros = function (bytes) {
19+
return Buffer.allocUnsafe(bytes).fill(0);
20+
};
21+
22+
const zeroAddress = function () {
23+
const addressLength = 20;
24+
const addr = zeros(addressLength);
25+
return bufferToHex(addr);
26+
};
727

828
module.exports = {
929
zeroAddress,

ui/hooks/bridge/useLatestBalance.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { BigNumber } from 'ethers';
22
import { renderHookWithProvider } from '../../../test/lib/render-helpers';
33
import { CHAIN_IDS } from '../../../shared/constants/network';
44
import { createBridgeMockStore } from '../../../test/jest/mock-store';
5-
import { zeroAddress } from '../../__mocks__/util';
5+
import { zeroAddress } from '../../__mocks__/ethereumjs-util';
66
import { createTestProviderTools } from '../../../test/stub/provider';
77
import * as tokenutil from '../../../shared/lib/token-util';
88
import useLatestBalance from './useLatestBalance';

ui/pages/bridge/bridge.util.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fetchWithCache from '../../../shared/lib/fetch-with-cache';
22
import { CHAIN_IDS } from '../../../shared/constants/network';
33
import mockBridgeQuotesErc20Erc20 from '../../../test/data/bridge/mock-quotes-erc20-erc20.json';
44
import mockBridgeQuotesNativeErc20 from '../../../test/data/bridge/mock-quotes-native-erc20.json';
5-
import { zeroAddress } from '../../__mocks__/util';
5+
import { zeroAddress } from '../../__mocks__/ethereumjs-util';
66
import {
77
fetchBridgeFeatureFlags,
88
fetchBridgeQuotes,

ui/pages/confirmations/components/transaction-alerts/transaction-alerts.stories.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ const customTransaction = ({
4444
};
4545
// just simulate hash if not provided
4646
if (!props?.hash) {
47-
tx.hash = `0x${Buffer.from(keccak256(Buffer.from(JSON.stringify(tx)))).toString('hex')}`;
47+
tx.hash = `0x${Buffer.from(
48+
keccak256(Buffer.from(JSON.stringify(tx))),
49+
).toString('hex')}`;
4850
}
4951
return tx;
5052
};

0 commit comments

Comments
 (0)