diff --git a/integration/src/integration.ts b/integration/src/integration.ts index b3c7c816b..82e8349bf 100644 --- a/integration/src/integration.ts +++ b/integration/src/integration.ts @@ -21,10 +21,6 @@ import { terraTests } from "./terra"; import { kavaTests } from "./kava"; import { WalletSuite } from "./wallets/suite"; -import { ethereum } from "./wallets/mocks/@metamask/detect-provider"; - -jest.mock("@metamask/detect-provider", () => async () => Promise.resolve(ethereum)); - /** * We run all the integration tests against every device, even though some * devices might not support a given Coin mixin. Tests in the various suites diff --git a/integration/src/wallets/__mocks__/@metamask/detect-provider.ts b/integration/src/wallets/__mocks__/@metamask/detect-provider.ts new file mode 100644 index 000000000..a7bd36953 --- /dev/null +++ b/integration/src/wallets/__mocks__/@metamask/detect-provider.ts @@ -0,0 +1,24 @@ +export default async function detectEthereumProvider() { + return { + request: jest.fn(({ method, params }: any) => { + switch (method) { + case "eth_accounts": + case "eth_requestAccounts": + return ["0x3f2329C9ADFbcCd9A84f52c906E936A42dA18CB8"]; + case "personal_sign": + const [message] = params; + + if (message === '48656c6c6f20576f726c64') + return '0x29f7212ecc1c76cea81174af267b67506f754ea8c73f144afa900a0d85b24b21319621aeb062903e856352f38305710190869c3ce5a1425d65ef4fa558d0fc251b' + + throw new Error('unknown message'); + case "eth_sendTransaction": + const [{ to }] = params; + + return `txHash-${to}`; + default: + throw new Error(`ethereum: Unkown method ${method}`); + } + }) + } +} diff --git a/integration/src/wallets/metamask.ts b/integration/src/wallets/metamask.ts index f63aac2b4..9c6076cd1 100644 --- a/integration/src/wallets/metamask.ts +++ b/integration/src/wallets/metamask.ts @@ -1,3 +1,5 @@ +jest.mock("@metamask/detect-provider"); + import * as core from "@shapeshiftoss/hdwallet-core"; import * as metamask from "@shapeshiftoss/hdwallet-metamask"; diff --git a/integration/src/wallets/mocks/@metamask/detect-provider.ts b/integration/src/wallets/mocks/@metamask/detect-provider.ts deleted file mode 100644 index 619aef2e5..000000000 --- a/integration/src/wallets/mocks/@metamask/detect-provider.ts +++ /dev/null @@ -1,21 +0,0 @@ -export const ethereum = { - request: jest.fn(({ method, params }: any) => { - switch (method) { - case "eth_accounts": - return ["0x3f2329C9ADFbcCd9A84f52c906E936A42dA18CB8"]; - case "personal_sign": - const [message] = params; - - if (message === '48656c6c6f20576f726c64') - return '0x29f7212ecc1c76cea81174af267b67506f754ea8c73f144afa900a0d85b24b21319621aeb062903e856352f38305710190869c3ce5a1425d65ef4fa558d0fc251b' - - throw new Error('unknown message'); - case "eth_sendTransaction": - const [{ to }] = params; - - return `txHash-${to}`; - default: - throw new Error(`ethereum: Unkown method ${method}`); - } - }) -} \ No newline at end of file