Implement payments for app deployments #17
@ -157,7 +157,7 @@ const Configure = () => {
|
|||||||
const verifyTx = async (
|
const verifyTx = async (
|
||||||
senderAddress: string,
|
senderAddress: string,
|
||||||
txHash: string,
|
txHash: string,
|
||||||
amount: string
|
amount: string,
|
||||||
): Promise<boolean> => {
|
): Promise<boolean> => {
|
||||||
const isValid = await client.verifyTx(
|
const isValid = await client.verifyTx(
|
||||||
txHash,
|
txHash,
|
||||||
@ -176,7 +176,9 @@ const Configure = () => {
|
|||||||
|
|
||||||
const senderAddress = selectedAccount;
|
const senderAddress = selectedAccount;
|
||||||
const deployerLrn = createFormData.lrn;
|
const deployerLrn = createFormData.lrn;
|
||||||
const deployer = deployers.find(deployer => deployer.deployerLrn === deployerLrn);
|
const deployer = deployers.find(
|
||||||
|
(deployer) => deployer.deployerLrn === deployerLrn,
|
||||||
|
);
|
||||||
|
|
||||||
let amount: string;
|
let amount: string;
|
||||||
let txHash: string;
|
let txHash: string;
|
||||||
@ -193,10 +195,12 @@ const Configure = () => {
|
|||||||
if (createFormData.option === 'LRN') {
|
if (createFormData.option === 'LRN') {
|
||||||
amount = deployer?.minimumPayment!;
|
amount = deployer?.minimumPayment!;
|
||||||
} else {
|
} else {
|
||||||
amount = (createFormData.numProviders * createFormData.maxPrice).toString();
|
amount = (
|
||||||
|
createFormData.numProviders * createFormData.maxPrice
|
||||||
|
).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
const amountToBePaid = (amount.replace(/\D/g, '')).toString();
|
const amountToBePaid = amount.replace(/\D/g, '').toString();
|
||||||
|
|
||||||
const txHashResponse = await cosmosSendTokensHandler(
|
const txHashResponse = await cosmosSendTokensHandler(
|
||||||
selectedAccount,
|
selectedAccount,
|
||||||
@ -210,9 +214,13 @@ const Configure = () => {
|
|||||||
|
|
||||||
txHash = txHashResponse;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -232,7 +240,7 @@ const Configure = () => {
|
|||||||
const projectId = await createProject(
|
const projectId = await createProject(
|
||||||
createFormData,
|
createFormData,
|
||||||
environmentVariables,
|
environmentVariables,
|
||||||
senderAddress,
|
senderAddress.split(':')[2],
|
||||||
txHash,
|
txHash,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -411,7 +419,7 @@ const Configure = () => {
|
|||||||
key={deployer.deployerLrn}
|
key={deployer.deployerLrn}
|
||||||
value={deployer.deployerLrn}
|
value={deployer.deployerLrn}
|
||||||
>
|
>
|
||||||
{deployer.deployerLrn} {deployer.minimumPayment}
|
{`${deployer.deployerLrn} ${deployer.minimumPayment ? `(${deployer.minimumPayment})` : ''}`}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
|
@ -32,7 +32,7 @@ const ConnectWallet = ({
|
|||||||
>
|
>
|
||||||
{accounts.map((account, index) => (
|
{accounts.map((account, index) => (
|
||||||
<Option key={index} value={account.address}>
|
<Option key={index} value={account.address}>
|
||||||
{account.address.split(':')[2]}
|
{account.address}
|
||||||
</Option>
|
</Option>
|
||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
|
@ -40,7 +40,7 @@ const deployment: Deployment = {
|
|||||||
deployerApiUrl: 'https://webapp-deployer-api.example.com',
|
deployerApiUrl: 'https://webapp-deployer-api.example.com',
|
||||||
deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu',
|
deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu',
|
||||||
deployerLrn: 'lrn://example/deployers/webapp-deployer-api.example.com',
|
deployerLrn: 'lrn://example/deployers/webapp-deployer-api.example.com',
|
||||||
minimumPayment: '1000alnt'
|
minimumPayment: '1000alnt',
|
||||||
},
|
},
|
||||||
status: DeploymentStatus.Ready,
|
status: DeploymentStatus.Ready,
|
||||||
createdBy: {
|
createdBy: {
|
||||||
|
@ -106,7 +106,7 @@ export const deployment0: Deployment = {
|
|||||||
deployerApiUrl: 'https://webapp-deployer-api.example.com',
|
deployerApiUrl: 'https://webapp-deployer-api.example.com',
|
||||||
deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu',
|
deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu',
|
||||||
deployerLrn: 'lrn://deployer.apps.snowballtools.com ',
|
deployerLrn: 'lrn://deployer.apps.snowballtools.com ',
|
||||||
minimumPayment: '1000alnt'
|
minimumPayment: '1000alnt',
|
||||||
},
|
},
|
||||||
applicationDeploymentRequestId:
|
applicationDeploymentRequestId:
|
||||||
'bafyreiaycvq6imoppnpwdve4smj6t6ql5svt5zl3x6rimu4qwyzgjorize',
|
'bafyreiaycvq6imoppnpwdve4smj6t6ql5svt5zl3x6rimu4qwyzgjorize',
|
||||||
@ -133,7 +133,7 @@ export const project: Project = {
|
|||||||
deployerApiUrl: 'https://webapp-deployer-api.example.com',
|
deployerApiUrl: 'https://webapp-deployer-api.example.com',
|
||||||
deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu',
|
deployerId: 'bafyreicrtgmkir4evvvysxdqxddf2ftdq2wrzuodgvwnxr4rmubi4obdfu',
|
||||||
deployerLrn: 'lrn://deployer.apps.snowballtools.com ',
|
deployerLrn: 'lrn://deployer.apps.snowballtools.com ',
|
||||||
minimumPayment: '1000alnt'
|
minimumPayment: '1000alnt',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
paymentAddress: '0x657868687686rb4787987br8497298r79284797487',
|
paymentAddress: '0x657868687686rb4787987br8497298r79284797487',
|
||||||
|
Loading…
Reference in New Issue
Block a user