-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: tentative CJS build + ethers v6 (#1280)
* chore(deps): bump ethers (#1242) * fix(deps): patch tests and package.json files after the ethers bump Co-authored-by: Dennis von der Bey <[email protected]>
- Loading branch information
1 parent
977662a
commit c37ee8c
Showing
56 changed files
with
19,244 additions
and
8,417 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
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
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
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
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 |
---|---|---|
@@ -1,34 +1,35 @@ | ||
import { Web3Provider, ExternalProvider } from '@ethersproject/providers' | ||
import { Wallet } from '@ethersproject/wallet' | ||
import { BrowserProvider, Eip1193Provider, Wallet } from 'ethers' | ||
|
||
export function createEthersProvider(): Web3Provider { | ||
export function createEthersProvider(): BrowserProvider { | ||
const privateKeyHex = '0x1da6847600b0ee25e9ad9a52abbd786dd2502fa4005dd5af9310b7cc7a3b25db' | ||
const wallet = new Wallet(privateKeyHex) | ||
const mockProvider = new MockWeb3Provider(wallet) | ||
const provider = new Web3Provider(mockProvider) | ||
const provider = new BrowserProvider(mockProvider) | ||
return provider | ||
} | ||
|
||
class MockWeb3Provider implements Eip1193Provider { | ||
constructor(private wallet: Wallet) {} | ||
|
||
class MockWeb3Provider implements ExternalProvider { | ||
constructor(private wallet: Wallet){ | ||
|
||
} | ||
async request(request: { method: string; params?: any[] }): Promise<any> { | ||
|
||
switch(request.method) { | ||
case 'personal_sign': | ||
//@ts-ignore | ||
return this.wallet.signMessage(request.params[1]) | ||
break | ||
case 'eth_signTypedData_v4': | ||
//@ts-ignore | ||
case 'eth_signTypedData_v4': | ||
// @ts-ignore | ||
const {domain, types, message} = JSON.parse(request.params[1]) | ||
delete(types.EIP712Domain) | ||
return this.wallet._signTypedData(domain, types, message) | ||
return this.wallet.signTypedData(domain, types, message) | ||
case 'eth_accounts': | ||
return [await this.wallet.getAddress()] | ||
case 'eth_chainId': | ||
return "1337" | ||
break | ||
default: | ||
throw Error(`not_available: method ${request.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
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
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
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
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
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
Oops, something went wrong.