-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove Ethereum account from wallet context (#379)
Depends on: #371 This PR removes the Ethereum account from the dapp context to implement Bitcoin native experience. Since the signing Bitcoin messages doesn't work in the Ledger Live Wallet API we temporarily removed this step from the deposit flow.
- Loading branch information
Showing
23 changed files
with
88 additions
and
315 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
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
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 |
---|---|---|
@@ -1,19 +1,24 @@ | ||
import { useEffect } from "react" | ||
import { ETHEREUM_NETWORK } from "#/constants" | ||
import { BITCOIN_NETWORK, ETHEREUM_NETWORK } from "#/constants" | ||
import { logPromiseFailure } from "#/utils" | ||
import { useAcreContext } from "#/acre-react/hooks" | ||
import { LedgerLiveWalletApiBitcoinProvider } from "@acre-btc/sdk/dist/src/lib/bitcoin/providers" | ||
import { useWalletContext } from "../useWalletContext" | ||
|
||
export function useInitializeAcreSdk() { | ||
const { ethAccount } = useWalletContext() | ||
const { btcAccount } = useWalletContext() | ||
const { init } = useAcreContext() | ||
|
||
useEffect(() => { | ||
if (!ethAccount?.address) return | ||
if (!btcAccount?.id) return | ||
|
||
const initSDK = async (ethAddress: string) => { | ||
await init(ethAddress, ETHEREUM_NETWORK) | ||
const initSDK = async (bitcoinAccountId: string) => { | ||
const bitcoinProvider = await LedgerLiveWalletApiBitcoinProvider.init( | ||
bitcoinAccountId, | ||
BITCOIN_NETWORK, | ||
) | ||
await init(bitcoinProvider, ETHEREUM_NETWORK) | ||
} | ||
logPromiseFailure(initSDK(ethAccount.address)) | ||
}, [ethAccount?.address, init]) | ||
logPromiseFailure(initSDK(btcAccount.id)) | ||
}, [btcAccount?.id, init]) | ||
} |
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,5 @@ | ||
import { useShowWalletErrorToast } from "./useShowWalletErrorToast" | ||
|
||
export function useInitGlobalToasts() { | ||
useShowWalletErrorToast("ethereum") | ||
useShowWalletErrorToast("bitcoin") | ||
} |
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 |
---|---|---|
@@ -1,18 +1,25 @@ | ||
import { useMemo } from "react" | ||
import { ZeroAddress } from "ethers" | ||
import { useWalletContext } from "./useWalletContext" | ||
import { useRequestBitcoinAccount } from "./useRequestBitcoinAccount" | ||
import { useRequestEthereumAccount } from "./useRequestEthereumAccount" | ||
|
||
export function useWallet() { | ||
const { btcAccount, ethAccount } = useWalletContext() | ||
const { btcAccount, ethAccount, setEthAccount } = useWalletContext() | ||
const { requestAccount: requestBitcoinAccount } = useRequestBitcoinAccount() | ||
const { requestAccount: requestEthereumAccount } = useRequestEthereumAccount() | ||
|
||
return useMemo( | ||
() => ({ | ||
bitcoin: { account: btcAccount, requestAccount: requestBitcoinAccount }, | ||
ethereum: { account: ethAccount, requestAccount: requestEthereumAccount }, | ||
bitcoin: { | ||
account: btcAccount, | ||
requestAccount: async () => { | ||
await requestBitcoinAccount() | ||
// TODO: Temporary solution - we do not need the eth account and we | ||
// want to create the Acre SDK w/o passing the Ethereum Account. | ||
setEthAccount(ZeroAddress) | ||
}, | ||
}, | ||
ethereum: { account: ethAccount }, | ||
}), | ||
[btcAccount, requestBitcoinAccount, ethAccount, requestEthereumAccount], | ||
[btcAccount, requestBitcoinAccount, ethAccount, setEthAccount], | ||
) | ||
} |
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.