Remove deep link path and prevent re-render from useEffect (#7)

Part of [laconicd testnet validator enrollment](https://www.notion.so/laconicd-testnet-validator-enrollment-6fc1d3cafcc64fef8c5ed3affa27c675)
- Remove path config used for deep links

Co-authored-by: Shreerang Kale <shreerangkale@gmail.com>
Reviewed-on: #7
This commit is contained in:
nabarun 2024-08-01 06:18:02 +00:00
parent cd0f6fa5d2
commit 504badebb8
4 changed files with 15 additions and 30 deletions

View File

@ -15,14 +15,7 @@ import { WalletConnectProvider } from './context/WalletConnectContext';
globalThis.Buffer = Buffer; globalThis.Buffer = Buffer;
const linking = { const linking = {
prefixes: ['https://wallet.laconic.com'], prefixes: ['https://wallet.laconic.com']
config: {
screens: {
SignRequest: {
path: 'sign/:namespace/:chaindId/:address/:message',
},
},
},
}; };
const theme = { const theme = {

View File

@ -50,7 +50,7 @@ const ApproveTransaction = ({ route }: ApproveTransactionProps) => {
const [account, setAccount] = useState<Account>(); const [account, setAccount] = useState<Account>();
const [cosmosStargateClient, setCosmosStargateClient] = const [cosmosStargateClient, setCosmosStargateClient] =
useState<LaconicClient>(); useState<LaconicClient>();
const [cosmosGasLimit, setCosmosGasLimit] = useState<string>(); const [cosmosGasLimit, setCosmosGasLimit] = useState<string>('');
const [fees, setFees] = useState<string>(); const [fees, setFees] = useState<string>();
const [txError, setTxError] = useState<string>(); const [txError, setTxError] = useState<string>();
const [isTxErrorDialogOpen, setIsTxErrorDialogOpen] = useState(false); const [isTxErrorDialogOpen, setIsTxErrorDialogOpen] = useState(false);
@ -201,7 +201,7 @@ const ApproveTransaction = ({ route }: ApproveTransactionProps) => {
denom: requestedNetwork!.nativeDenom!, denom: requestedNetwork!.nativeDenom!,
}, },
], ],
gas: cosmosGasLimit!, gas: cosmosGasLimit,
}, },
txMsg: transactionMessage, txMsg: transactionMessage,
}; };

View File

@ -70,8 +70,8 @@ const ApproveTransfer = ({ route }: SignRequestProps) => {
const [isTxLoading, setIsTxLoading] = useState(false); const [isTxLoading, setIsTxLoading] = useState(false);
const [cosmosStargateClient, setCosmosStargateClient] = const [cosmosStargateClient, setCosmosStargateClient] =
useState<SigningStargateClient>(); useState<SigningStargateClient>();
const [fees, setFees] = useState<string>(); const [fees, setFees] = useState<string>('');
const [cosmosGasLimit, setCosmosGasLimit] = useState<string>(); const [cosmosGasLimit, setCosmosGasLimit] = useState<string>('');
const [txError, setTxError] = useState<string>(); const [txError, setTxError] = useState<string>();
const [isTxErrorDialogOpen, setIsTxErrorDialogOpen] = useState(false); const [isTxErrorDialogOpen, setIsTxErrorDialogOpen] = useState(false);
const [ethGasPrice, setEthGasPrice] = useState<BigNumber | null>(); const [ethGasPrice, setEthGasPrice] = useState<BigNumber | null>();
@ -212,7 +212,7 @@ const ApproveTransfer = ({ route }: SignRequestProps) => {
// If requested chain is EVM compatible, set loading to false when ethMaxFee and ethPriorityFee have been populated // If requested chain is EVM compatible, set loading to false when ethMaxFee and ethPriorityFee have been populated
(ethMaxFee !== undefined && ethMaxPriorityFee !== undefined) || (ethMaxFee !== undefined && ethMaxPriorityFee !== undefined) ||
// Or if requested chain is a cosmos chain, set loading to false when cosmosGasLimit has been populated // Or if requested chain is a cosmos chain, set loading to false when cosmosGasLimit has been populated
cosmosGasLimit !== undefined !cosmosGasLimit
) { ) {
setIsLoading(false); setIsLoading(false);
} }
@ -311,11 +311,11 @@ const ApproveTransfer = ({ route }: SignRequestProps) => {
// This amount is total fees required for transaction // This amount is total fees required for transaction
amount: [ amount: [
{ {
amount: fees!, amount: fees,
denom: requestedNetwork!.nativeDenom!, denom: requestedNetwork!.nativeDenom!,
}, },
], ],
gas: cosmosGasLimit!, gas: cosmosGasLimit,
}, },
sendMsg, sendMsg,
memo: MEMO, memo: MEMO,

View File

@ -49,7 +49,7 @@ const SignRequest = ({ route }: SignRequestProps) => {
const isCosmosSignDirect = useMemo(() => { const isCosmosSignDirect = useMemo(() => {
const requestParams = route.params.requestEvent; const requestParams = route.params.requestEvent;
if (!requestParams) { if (!requestParams?.id) {
return false; return false;
} }
@ -59,7 +59,7 @@ const SignRequest = ({ route }: SignRequestProps) => {
const isEthSendTransaction = useMemo(() => { const isEthSendTransaction = useMemo(() => {
const requestParams = route.params.requestEvent; const requestParams = route.params.requestEvent;
if (!requestParams) { if (!requestParams?.id) {
return false; return false;
} }
@ -86,21 +86,13 @@ const SignRequest = ({ route }: SignRequestProps) => {
return; return;
} }
if (requestAccount !== account) { setAccount(requestAccount);
setAccount(requestAccount); setMessage(decodeURIComponent(requestMessage));
} setNamespace(requestNamespace);
if (requestMessage !== message) { setChainId(requestChainId);
setMessage(decodeURIComponent(requestMessage));
}
if (requestNamespace !== namespace) {
setNamespace(requestNamespace);
}
if (requestChainId !== chainId) {
setChainId(requestChainId);
}
setIsLoading(false); setIsLoading(false);
}, },
[account, message, navigation, namespace, chainId], [navigation],
); );
const sanitizePath = useCallback( const sanitizePath = useCallback(