-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
integration: improve metamask provider mock
- Loading branch information
1 parent
3ed5407
commit 471fe2f
Showing
4 changed files
with
26 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
integration/src/wallets/__mocks__/@metamask/detect-provider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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}`); | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
integration/src/wallets/mocks/@metamask/detect-provider.ts
This file was deleted.
Oops, something went wrong.