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