-
Notifications
You must be signed in to change notification settings - Fork 868
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wallet): Shield ZCash Account Modal
- Loading branch information
1 parent
c71fdd5
commit 01c6c75
Showing
20 changed files
with
511 additions
and
122 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
74 changes: 74 additions & 0 deletions
74
components/brave_wallet_ui/common/slices/endpoints/zcash.endpoints.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,74 @@ | ||
// Copyright (c) 2024 The Brave Authors. All rights reserved. | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
// You can obtain one at https://mozilla.org/MPL/2.0/. | ||
|
||
// Types | ||
import { BraveWallet } from '../../../constants/types' | ||
|
||
// Utils | ||
import { handleEndpointError } from '../../../utils/api-utils' | ||
import { WalletApiEndpointBuilderParams } from '../api-base.slice' | ||
|
||
export const zcashEndpoints = ({ | ||
query, | ||
mutation | ||
}: WalletApiEndpointBuilderParams) => { | ||
return { | ||
makeAccountShielded: mutation<true, BraveWallet.AccountId>({ | ||
queryFn: async (args, { endpoint }, _extraOptions, baseQuery) => { | ||
try { | ||
const { zcashWalletService } = baseQuery(undefined).data | ||
|
||
const { errorMessage } = await zcashWalletService.makeAccountShielded( | ||
args | ||
) | ||
|
||
if (errorMessage) { | ||
return handleEndpointError( | ||
endpoint, | ||
'Error making account shielded: ', | ||
errorMessage | ||
) | ||
} | ||
|
||
return { | ||
data: true | ||
} | ||
} catch (error) { | ||
return handleEndpointError( | ||
endpoint, | ||
'Error making account shielded: ', | ||
error | ||
) | ||
} | ||
}, | ||
invalidatesTags: ['ZCashAccountInfo'] | ||
}), | ||
getZCashAccountInfo: query< | ||
BraveWallet.ZCashAccountInfo | null, | ||
BraveWallet.AccountId | ||
>({ | ||
queryFn: async (args, { endpoint }, _extraOptions, baseQuery) => { | ||
try { | ||
const { zcashWalletService } = baseQuery(undefined).data | ||
|
||
const { accountInfo } = await zcashWalletService.getZCashAccountInfo( | ||
args | ||
) | ||
|
||
return { | ||
data: accountInfo | ||
} | ||
} catch (error) { | ||
return handleEndpointError( | ||
endpoint, | ||
'Error getting ZCash account info: ', | ||
error | ||
) | ||
} | ||
}, | ||
providesTags: ['ZCashAccountInfo'] | ||
}) | ||
} | ||
} |
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.