-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: default to eth_signTypedData_v4 (#9)
* feat: add walletconnect getPeerMeta * fix: default to eth_signTypedData_v4 with special casing * refactor: pull out wallets const
- Loading branch information
Showing
6 changed files
with
690 additions
and
96 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { JsonRpcProvider } from '@ethersproject/providers' | ||
|
||
import { getPeerMeta } from './walletconnect' | ||
|
||
describe('walletconnect', () => { | ||
describe('getPeerMeta', () => { | ||
it('returns undefined for a non-WalletConnect-derived JsonRpcProvider', () => { | ||
const provider = new JsonRpcProvider() | ||
expect(getPeerMeta(provider)).toBeUndefined() | ||
}) | ||
|
||
it('returns peerMeta for a WalletConnect-derived JsonRpcProvider', () => { | ||
const provider = new JsonRpcProvider() | ||
const peerMeta = {} | ||
provider['provider'] = { isWalletConnect: true, connector: { peerMeta } } | ||
expect(getPeerMeta(provider)).toBe(peerMeta) | ||
}) | ||
}) | ||
}) |
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,20 @@ | ||
import type { ExternalProvider, JsonRpcProvider, Web3Provider } from '@ethersproject/providers' | ||
import WalletConnectProvider from '@walletconnect/ethereum-provider' | ||
|
||
function isWeb3Provider(provider: JsonRpcProvider): provider is Web3Provider { | ||
return 'provider' in provider | ||
} | ||
|
||
function isWalletConnectProvider(provider: ExternalProvider): provider is WalletConnectProvider { | ||
return (provider as WalletConnectProvider).isWalletConnect | ||
} | ||
|
||
export type PeerMeta = NonNullable<WalletConnectProvider['connector']['peerMeta']> | ||
|
||
export function getPeerMeta(provider: JsonRpcProvider): PeerMeta | undefined { | ||
if (isWeb3Provider(provider) && isWalletConnectProvider(provider.provider)) { | ||
return provider.provider.connector.peerMeta ?? undefined | ||
} else { | ||
return | ||
} | ||
} |
Oops, something went wrong.