Handle deployer minimum payment being null

This commit is contained in:
IshaVenikar 2024-10-25 16:08:32 +05:30
parent c52514e833
commit 9e9e8f34aa

View File

@ -164,6 +164,7 @@ const Configure = () => {
`${amount.toString()}alnt`,
senderAddress,
);
return isValid;
};
@ -174,41 +175,46 @@ const Configure = () => {
}
const senderAddress = selectedAccount;
let amount: string;
if(createFormData.option === 'LRN') {
const deployerLrn = createFormData.lrn;
const deployer = deployers.find(deployer => deployer.deployerLrn === deployerLrn);
if (!deployer?.minimumPayment) {
let amount: string;
let txHash: string;
if (createFormData.option === 'LRN' && !deployer?.minimumPayment) {
toast({
id: 'no-payment-required',
title: 'No payment',
title: 'No payment required. Deploying app...',
variant: 'info',
onDismiss: dismiss,
});
amount = ''
txHash = '';
} else {
amount = deployer!.minimumPayment
}
if (createFormData.option === 'LRN') {
amount = deployer?.minimumPayment!;
} else {
amount = (createFormData.numProviders * createFormData.maxPrice).toString();
}
const txHash = await cosmosSendTokensHandler(
const amountToBePaid = (amount.replace(/\D/g, '')).toString();
const txHashResponse = await cosmosSendTokensHandler(
selectedAccount,
amount,
amountToBePaid,
);
if(!txHash) {
if (!txHashResponse) {
console.error('Tx not successful');
return;
}
txHash = txHashResponse;
const isTxHashValid = verifyTx(senderAddress, txHash, amount.toString());
if (!isTxHashValid) {
console.error("Invalid Tx hash", txHash)
return
return;
}
}
const environmentVariables = createFormData.variables.map(
@ -227,7 +233,7 @@ const Configure = () => {
createFormData,
environmentVariables,
senderAddress,
txHash!,
txHash,
);
await client.getEnvironmentVariables(projectId);