-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up, add placeholders for Metamask
- Loading branch information
Showing
4 changed files
with
43 additions
and
22 deletions.
There are no files selected for viewing
19 changes: 5 additions & 14 deletions
19
apps/namada-interface/src/services/extensionEvents/handlers/metamask.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 |
---|---|---|
@@ -1,22 +1,13 @@ | ||
import { Dispatch } from "react"; | ||
|
||
import { chains } from "@anoma/chains"; | ||
import { Metamask } from "@anoma/integrations"; | ||
|
||
import { addAccounts, fetchBalances } from "slices/accounts"; | ||
|
||
export const MetamaskAccountChangedHandler = | ||
(dispatch: Dispatch<unknown>, integration: Metamask) => | ||
async (event: CustomEventInit) => { | ||
const chainId = event.detail?.chainId; | ||
const chain = chains[chainId]; | ||
|
||
if (chain.extension.id === "metamask") { | ||
const accounts = await integration.accounts(); | ||
(dispatch: Dispatch<unknown>, integration: Metamask) => async () => { | ||
const accounts = await integration.accounts(); | ||
|
||
if (accounts) { | ||
dispatch(addAccounts(accounts)); | ||
dispatch(fetchBalances()); | ||
} | ||
if (accounts) { | ||
dispatch(addAccounts(accounts)); | ||
dispatch(fetchBalances()); | ||
} | ||
}; |
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,8 +1,20 @@ | ||
// Constants defining events which may be subscribed to | ||
|
||
// Anoma extension events | ||
export enum Events { | ||
AccountChanged = "anoma-account-changed", | ||
TransferStarted = "anoma-transfer-started", | ||
TransferCompleted = "anoma-transfer-completed", | ||
UpdatedBalances = "anoma-updated-balances", | ||
} | ||
|
||
// Keplr extension events | ||
export enum KeplrEvents { | ||
AccountChanged = "keplr_keystorechange", | ||
} | ||
|
||
// Metamask extension window.ethereum events | ||
export enum MetamaskEvents { | ||
AccountChanged = "accountsChanged", | ||
NetworkChanged = "networkChanged", | ||
} |