-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 503-bridge-back-to-stellar-max-amount-chosen…
…-by-the-user-allow-for-the-amount-that-is-incompatible
- Loading branch information
Showing
98 changed files
with
9,820 additions
and
856 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"arrowParens": "always", | ||
"printWidth": 120, | ||
"tabWidth": 2, | ||
"useTabs": false, | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "all", | ||
"bracketSpacing": true, | ||
"proseWrap": "always", | ||
"plugins": ["prettier-plugin-tailwindcss"], | ||
"tailwindConfig": "./tailwind.config.js" | ||
} |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { getWalletBySource, WalletAccount } from '@talismn/connect-wallets'; | ||
import { getSdkError } from '@walletconnect/utils'; | ||
import { storageService } from '../services/storage/local'; | ||
import { walletConnectService } from '../services/walletConnect'; | ||
import { initiateMetamaskInjectedAccount } from '../services/metamask'; | ||
import { chainIds } from '../config/walletConnect'; | ||
import { TenantName } from '../models/Tenant'; | ||
import { LocalStorageKeys } from '../hooks/useLocalStorage'; | ||
|
||
const initTalisman = async (dAppName: string, selected?: string) => { | ||
const name = storageService.get(LocalStorageKeys.SELECTED_WALLET_NAME); | ||
if (!name?.length) return; | ||
const wallet = getWalletBySource(name); | ||
if (!wallet) return; | ||
await wallet.enable(dAppName); | ||
const accounts = await wallet.getAccounts(); | ||
const selectedWallet = accounts.find((a) => a.address === selected) || accounts[0]; | ||
return selectedWallet; | ||
}; | ||
|
||
const initWalletConnect = async (chainId: string) => { | ||
const provider = await walletConnectService.getProvider(); | ||
if (!provider?.session) return; | ||
return await walletConnectService.init(provider?.session, chainId); | ||
}; | ||
|
||
const initMetamask = async (tenantName: TenantName) => { | ||
const metamaskWalletAddress = storageService.get(LocalStorageKeys.SELECTED_WALLET_NAME); | ||
if (metamaskWalletAddress) { | ||
const injectedAccounts = await initiateMetamaskInjectedAccount(tenantName); | ||
return injectedAccounts[0]; | ||
} | ||
}; | ||
|
||
export const initSelectedWallet = async (dAppName: TenantName, tenantName: TenantName, storageAddress: string) => { | ||
const appName = dAppName || TenantName.Amplitude; | ||
return (await initTalisman(appName, storageAddress)) || | ||
(await initWalletConnect(chainIds[tenantName])) || | ||
(await initMetamask(tenantName)); | ||
} | ||
|
||
export const handleWalletConnectDisconnect = async (walletAccount: WalletAccount | undefined) => { | ||
if (walletAccount?.wallet?.extensionName === 'WalletConnect') { | ||
const topic = walletConnectService.session?.topic; | ||
if (topic) { | ||
await walletConnectService.provider?.client.disconnect({ | ||
topic, | ||
reason: getSdkError('USER_DISCONNECTED'), | ||
}); | ||
} | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.