Skip to content

Commit

Permalink
format and update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
luu-alex committed Oct 24, 2023
1 parent 2a30055 commit c4896e7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
4 changes: 4 additions & 0 deletions packages/web3-core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,7 @@ Documentation:
- Fix the issue: "Uncaught TypeError: Class extends value undefined is not a constructor or null #6371". (#6398)

## [Unreleased]

### Added

- Added `isMetaMaskProvider` function to check if provider is metamask (#6534)
4 changes: 2 additions & 2 deletions packages/web3-core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
SupportedProviders,
Web3APISpec,
Web3BaseProvider,
MetamaskProvider,
MetaMaskProvider,
} from 'web3-types';

export const isWeb3Provider = <API extends Web3APISpec>(
Expand All @@ -32,7 +32,7 @@ export const isWeb3Provider = <API extends Web3APISpec>(

export const isMetaMaskProvider = <API extends Web3APISpec>(
provider: SupportedProviders<API>,
): provider is MetamaskProvider<API> =>{
): provider is MetaMaskProvider<API> =>{
return typeof provider !== 'string' &&
'request' in provider &&
provider.request.constructor.name === 'AsyncFunction' && 'isMetaMask' in provider && provider.isMetaMask;
Expand Down
6 changes: 5 additions & 1 deletion packages/web3-eth-contract/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -314,4 +314,8 @@ Documentation:

- The `events` property was added to the `receipt` object (#6410)

## [Unreleased]
## [Unreleased]

### Fixed

- Will populate `data` for transactions in contract for metamask provider instead of `input` (#6534)
6 changes: 5 additions & 1 deletion packages/web3-types/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,4 +170,8 @@ Documentation:

- Interface `EventLog` was added. (#6410)

## [Unreleased]
## [Unreleased]

### Added

- Interface `MetaMaskProvider` added and is part of `SupportedProviders` (#6534)
11 changes: 2 additions & 9 deletions packages/web3-types/src/web3_base_provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export interface EIP1193Provider<API extends Web3APISpec> extends SimpleProvider
removeListener(event: 'accountsChanged', listener: (accounts: ProviderAccounts) => void): void;
}

export interface MetamaskProvider<API extends Web3APISpec> extends SimpleProvider<API> {
export interface MetaMaskProvider<API extends Web3APISpec> extends SimpleProvider<API> {
on(event: 'connect', listener: (info: ProviderInfo) => void): void;
on(event: 'disconnect', listener: (error: ProviderRpcError) => void): void;
on(event: 'message', listener: (message: ProviderMessage) => void): void;
Expand Down Expand Up @@ -175,13 +175,6 @@ export abstract class Web3BaseProvider<API extends Web3APISpec = EthExecutionAPI
);
}

public static isMetamaskProvider(provider: unknown) {
return (
provider &&
Boolean(provider && (provider as { [symbol]: boolean })[symbol])
);
}

// To match an object "instanceof" does not work if
// matcher class and object is using different package versions
// to overcome this bottleneck used this approach.
Expand Down Expand Up @@ -350,7 +343,7 @@ export type SupportedProviders<API extends Web3APISpec = Web3EthExecutionAPI> =
| LegacySendProvider
| LegacySendAsyncProvider
| SimpleProvider<API>
| MetamaskProvider<API>;
| MetaMaskProvider<API>;

export type Web3BaseProviderConstructor = new <API extends Web3APISpec>(
url: string,
Expand Down

0 comments on commit c4896e7

Please sign in to comment.