-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef20340
commit 7cf02a1
Showing
19 changed files
with
2,759 additions
and
322 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 |
---|---|---|
@@ -1,6 +1,10 @@ | ||
# RSK RPC URL for logs scanning which is not supported by the public RPCs | ||
VITE_RSK_LOG_SCAN_ENDPOINT= | ||
|
||
# WalletConnect project id | ||
# WalletConnect option will not be visible if not set | ||
VITE_WALLETCONNECT_PROJECT_ID= | ||
|
||
# Token for the Chatwoot website inbox | ||
# The chat widget will not be loaded if not set | ||
VITE_CHATWOOT_TOKEN= |
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
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
File renamed without changes
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,92 @@ | ||
import { BrowserProvider } from "ethers"; | ||
import log from "loglevel"; | ||
import { createEffect, createResource } from "solid-js"; | ||
|
||
import { config } from "../config"; | ||
import { RBTC } from "../consts/Assets"; | ||
import { useWeb3Signer } from "../context/Web3"; | ||
import loader from "../lazy/walletConnect"; | ||
import WalletConnectProvider from "../utils/WalletConnectProvider"; | ||
|
||
const getLocation = () => { | ||
const { protocol, host } = window.location; | ||
return `${protocol}//${host}`; | ||
}; | ||
|
||
export const WalletConnect = () => { | ||
const { openWalletConnectModal, setOpenWalletConnectModal } = | ||
useWeb3Signer(); | ||
|
||
const [createdKit] = createResource(async () => { | ||
const configRsk = config.assets[RBTC]; | ||
|
||
const { appKit, EthersAdapter } = await loader.get(); | ||
const created = appKit.createAppKit({ | ||
themeMode: "dark", | ||
enableEIP6963: false, | ||
enableInjected: false, | ||
adapters: [new EthersAdapter()], | ||
projectId: import.meta.env.VITE_WALLETCONNECT_PROJECT_ID as string, | ||
networks: [ | ||
{ | ||
id: configRsk.network.chainId, | ||
name: configRsk.network.chainName, | ||
nativeCurrency: { | ||
name: RBTC, | ||
symbol: RBTC, | ||
decimals: 18, | ||
}, | ||
rpcUrls: { | ||
default: { | ||
http: configRsk.network.rpcUrls, | ||
}, | ||
}, | ||
blockExplorers: { | ||
default: { | ||
name: "Explorer", | ||
url: configRsk.blockExplorerUrl.normal, | ||
}, | ||
}, | ||
}, | ||
], | ||
metadata: { | ||
name: "Boltz", | ||
description: "Boltz Web App", | ||
url: getLocation(), | ||
icons: [`${getLocation()}/android-chrome-512x512.png`], | ||
}, | ||
features: { | ||
email: false, | ||
socials: false, | ||
analytics: true, | ||
}, | ||
}); | ||
|
||
created.subscribeEvents(async (ev) => { | ||
log.debug(`WalletConnect event: ${ev.data.event}`); | ||
|
||
if (ev.data.event !== "MODAL_CLOSE") { | ||
setOpenWalletConnectModal(false); | ||
return; | ||
} | ||
|
||
const address = created.getAddress(); | ||
const provider = new BrowserProvider( | ||
await created.getUniversalProvider(), | ||
); | ||
|
||
WalletConnectProvider.resolveClosePromise(provider, address); | ||
}); | ||
|
||
return created; | ||
}); | ||
|
||
// eslint-disable-next-line solid/reactivity | ||
createEffect(async () => { | ||
if (openWalletConnectModal()) { | ||
await createdKit().open(); | ||
} | ||
}); | ||
|
||
return <></>; | ||
}; |
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
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,16 @@ | ||
import Loader from "./Loader"; | ||
|
||
export default new Loader("WalletConnect", async () => { | ||
const [appKit, EthersAdapter] = await Promise.all([ | ||
import("@reown/appkit"), | ||
(async () => { | ||
const ethersAdapter = await import("@reown/appkit-adapter-ethers"); | ||
return ethersAdapter.EthersAdapter; | ||
})(), | ||
]); | ||
|
||
return { | ||
appKit, | ||
EthersAdapter, | ||
}; | ||
}); |
Oops, something went wrong.