-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Front] Show only compatible wallet providers in wallet connect (#356)
- Loading branch information
Showing
17 changed files
with
15,601 additions
and
8,359 deletions.
There are no files selected for viewing
23,680 changes: 15,413 additions & 8,267 deletions
23,680
packages/demo/usecase-demo/package-lock.json
Large diffs are not rendered by default.
Oops, something went wrong.
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
26 changes: 0 additions & 26 deletions
26
packages/demo/usecase-demo/src/externals/getEnsForAddress.ts
This file was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
packages/demo/usecase-demo/src/modules/activeSubscriptions.query.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
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
2 changes: 1 addition & 1 deletion
2
packages/demo/usecase-demo/src/routes/_explore/content.$protectedDataAddress.tsx
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 @@ | ||
export type Address = `0x${string}`; |
File renamed without changes.
39 changes: 39 additions & 0 deletions
39
packages/demo/usecase-demo/src/utils/injected-wallet-provider/injected-wallet-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,39 @@ | ||
import { EventEmitter } from 'eventemitter3'; | ||
import { | ||
EIP6963AnnounceProviderEvent, | ||
EIP6963ProviderDetail, | ||
EIP6963RequestProviderEvent, | ||
} from './types'; | ||
|
||
// This class extends EventEmitter to be able to emit events and give our DApp an interface to subscribe to | ||
export class InjectedWalletProvider extends EventEmitter { | ||
// This will hold the details of the providers received | ||
providerDetails: EIP6963ProviderDetail[]; | ||
|
||
constructor() { | ||
super(); | ||
this.providerDetails = []; | ||
} | ||
|
||
// This method processes the provider details announced and adds them to the providerDetails array | ||
private providerReceived(providerDetail: EIP6963ProviderDetail): void { | ||
this.providerDetails.push(providerDetail); | ||
this.emit('providerDetailsUpdated'); | ||
} | ||
|
||
// This method listens for the 'announceProvider' event and processes the provider details announced | ||
subscribe(): void { | ||
window.addEventListener( | ||
'eip6963:announceProvider', | ||
(event: EIP6963AnnounceProviderEvent) => { | ||
this.providerReceived(event.detail); | ||
} | ||
); | ||
} | ||
|
||
// This method is used to request wallet providers by firing a 'EIP6963RequestProviderEvent' | ||
requestProviders(): void { | ||
this.providerDetails = []; | ||
window.dispatchEvent(new EIP6963RequestProviderEvent()); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
packages/demo/usecase-demo/src/utils/injected-wallet-provider/types.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,43 @@ | ||
// Please refer to EIP-6963 specs: https://eips.ethereum.org/EIPS/eip-6963 | ||
// Declare a global interface to extend the WindowEventMap with a custom event "eip6963:announceProvider" | ||
declare global { | ||
interface WindowEventMap { | ||
'eip6963:announceProvider': EIP6963AnnounceProviderEvent; | ||
} | ||
} | ||
|
||
// Define a class for the "eip6963:requestProvider" event | ||
export class EIP6963RequestProviderEvent extends Event { | ||
constructor() { | ||
super('eip6963:requestProvider'); | ||
} | ||
} | ||
|
||
// Define an interface for the "eip6963:announceProvider" event | ||
export interface EIP6963AnnounceProviderEvent extends Event { | ||
type: 'eip6963:announceProvider'; | ||
detail: EIP6963ProviderDetail; | ||
} | ||
|
||
// Define an interface for the provider details | ||
export interface EIP6963ProviderDetail { | ||
info: EIP6963ProviderInfo; | ||
provider: EIP1193Provider; | ||
} | ||
|
||
// Define an interface for the provider information | ||
export interface EIP6963ProviderInfo { | ||
uuid: string; // Unique identifier of the wallet extension announcement, keep in mind it changes on every request-announcement cycle | ||
name: string; // Name of the wallet extension | ||
icon: string; // Icon for the wallet extension | ||
rdns: string; // Reverse DNS name of the wallet extension | ||
} | ||
|
||
// Define an interface for the EIP1193 provider. | ||
// It's the same interface we are used to access with 'window.ethereum' | ||
export interface EIP1193Provider { | ||
request(request: { | ||
method: string; | ||
params?: Array<unknown> | Record<string, unknown>; | ||
}): Promise<unknown>; | ||
} |
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.