File tree Expand file tree Collapse file tree 8 files changed +49
-262
lines changed
extension/src/background/keyring Expand file tree Collapse file tree 8 files changed +49
-262
lines changed Original file line number Diff line number Diff line change @@ -722,10 +722,11 @@ export class KeyRing {
722722 : await this . getSigningKey ( signer ) ;
723723
724724 // If disposable key is provided, use it to map real address to spending key
725- const spendingKeys =
726- disposableKey ?
727- [ await this . getSpendingKey ( disposableKey . realAddress ) ]
728- : [ ] ;
725+ const spendingKeys = [
726+ await this . getSpendingKey (
727+ disposableKey ? disposableKey . realAddress : signer
728+ ) ,
729+ ] ;
729730
730731 const { signing } = this . sdkService . getSdk ( ) ;
731732
Original file line number Diff line number Diff line change 22 ActionButton ,
33 AmountInput ,
44 Modal ,
5+ Stack ,
56 StyledSelectBox ,
7+ ToggleButton ,
68} from "@namada/components" ;
79import { chainAssetsMapAtom , nativeTokenAddressAtom } from "atoms/chain" ;
810import { GasPriceTable , GasPriceTableItem } from "atoms/fees/atoms" ;
@@ -92,8 +94,10 @@ export const GasFeeModal = ({
9294 gasConfig,
9395 gasEstimate,
9496 gasPriceTable,
97+ gasSource,
9598 onChangeGasLimit,
9699 onChangeGasToken,
100+ onChangeGasSource,
97101 } = feeProps ;
98102
99103 const sortByNativeToken = useSortByNativeToken ( ) ;
@@ -165,7 +169,28 @@ export const GasFeeModal = ({
165169 } ) }
166170 </ div >
167171
168- < div className = "text-sm mt-4 mb-1" > Fee Token</ div >
172+ < Stack
173+ direction = "horizontal"
174+ className = "justify-between align-middle mt-4 mb-1"
175+ >
176+ < div className = "text-sm" > Fee Token</ div >
177+ < ToggleButton
178+ label = {
179+ gasSource === "shielded" ? "Shielded Balance" : (
180+ "Transparent Balance"
181+ )
182+ }
183+ color = "white"
184+ activeColor = "yellow"
185+ checked = { gasSource === "shielded" }
186+ onChange = { ( ) =>
187+ onChangeGasSource (
188+ gasSource === "shielded" ? "transparent" : "shielded"
189+ )
190+ }
191+ containerProps = { { className : "gap-3 text-xs" } }
192+ />
193+ </ Stack >
169194 < StyledSelectBox
170195 id = "fee-token-select"
171196 value = { gasConfig . gasToken }
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -122,11 +122,6 @@ export const createUnshieldingTransferAtom = atomWithMutation((get) => {
122122 signer,
123123 memo,
124124 } : BuildTxAtomParams < UnshieldingTransferMsgValue > ) => {
125- invariant (
126- signer ,
127- "Disposable signer is required for unshielding transfers"
128- ) ;
129-
130125 await sync (
131126 allViewingKeys ,
132127 chainId ,
@@ -187,12 +182,11 @@ const sync = async (
187182 invariant ( chainId , "Chain ID is required for shielded sync" ) ;
188183 invariant ( namTokenAddress , "NAM token address is required for shielded sync" ) ;
189184 invariant ( rpcUrl , "RPC URL is required for shielded sync" ) ;
190- invariant ( maspIndexerUrl , "Masp indexer URL is required for shielded sync" ) ;
191185
192186 const { set } = getDefaultStore ( ) ;
193187 await shieldedSync ( {
194188 rpcUrl,
195- maspIndexerUrl,
189+ maspIndexerUrl : maspIndexerUrl || "" ,
196190 token : namTokenAddress ,
197191 viewingKeys : allViewingKeys ,
198192 chainId,
Original file line number Diff line number Diff line change @@ -176,13 +176,15 @@ export const createUnshieldingTransferTx = async (
176176 props : UnshieldingTransferMsgValue [ ] ,
177177 gasConfig : GasConfig ,
178178 rpcUrl : string ,
179- disposableSigner : GenDisposableSignerResponse ,
179+ signer ? : GenDisposableSignerResponse ,
180180 memo ?: string
181181) : Promise < EncodedTxData < UnshieldingTransferProps > | undefined > => {
182182 const source = props [ 0 ] ?. source ;
183183 const destination = props [ 0 ] ?. data [ 0 ] ?. target ;
184184 const token = props [ 0 ] ?. data [ 0 ] ?. token ;
185185 const amount = props [ 0 ] ?. data [ 0 ] ?. amount ;
186+ const accountWithSigner =
187+ signer ? { ...account , publicKey : signer . publicKey } : account ;
186188
187189 return await workerBuildTxPair ( {
188190 rpcUrl,
@@ -196,10 +198,7 @@ export const createUnshieldingTransferTx = async (
196198 const msg : Unshield = {
197199 type : "unshield" ,
198200 payload : {
199- account : {
200- ...account ,
201- publicKey : disposableSigner . publicKey ,
202- } ,
201+ account : accountWithSigner ,
203202 gasConfig,
204203 props : [ msgValue ] ,
205204 chain,
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ export type UseTransactionPropsEvents<T> = {
4444export type UseTransactionProps < T > = {
4545 params : T [ ] ;
4646 createTxAtom : AtomType < T > ;
47- useDisposableSigner ?: boolean ;
47+ canUseDisposableSigner ?: boolean ;
4848 eventType : TransactionEventsClasses ;
4949 parsePendingTxNotification ?: ( tx : TransactionPair < T > ) => PartialNotification ;
5050 parseErrorTxNotification ?: ( ) => PartialNotification ;
@@ -66,7 +66,7 @@ export type UseTransactionOutput<T> = {
6666export const useTransaction = < T , > ( {
6767 params,
6868 createTxAtom,
69- useDisposableSigner ,
69+ canUseDisposableSigner ,
7070 eventType,
7171 parsePendingTxNotification,
7272 parseErrorTxNotification,
@@ -126,6 +126,8 @@ export const useTransaction = <T,>({
126126 ) ;
127127
128128 const txAdditionalParams = { ...additionalParams } ;
129+ const useDisposableSigner =
130+ canUseDisposableSigner && feeProps . gasSource === "shielded" ;
129131 if ( useDisposableSigner ) {
130132 onBeforeCreateDisposableSigner ?.( ) ;
131133 txAdditionalParams . signer = await getDisposableSigner ( ) ;
You can’t perform that action at this time.
0 commit comments