Skip to content

Commit

Permalink
add create pool collateral validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Ridel1e committed Nov 6, 2023
1 parent 4267e52 commit df438f1
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/network/cardano/api/operations/createPool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,28 @@ const MIN_CREATE_POOL_LIQUIDITY = new Currency('500', networkAsset);

export const useCreatePoolValidators =
(): OperationValidator<CreatePoolFormModel>[] => {
const insufficientCollateral: OperationValidator<CreatePoolFormModel> =
() => {
return transactionBuilder$.pipe(
switchMap(
(transactionBuilder) =>
transactionBuilder['poolTxBuilder'][
'collateralSelector'
].getCollateral(5000000n) as Promise<FullTxIn[] | Error>,
),
map((collateralOrError) => {
console.log(collateralOrError);

Check warning on line 272 in src/network/cardano/api/operations/createPool.tsx

View workflow job for this annotation

GitHub Actions / Build Artifacts for Test

Unexpected console statement
if (collateralOrError instanceof Error) {
return t`Insufficient Collateral`;
}
if (!collateralOrError.length) {
return t`Insufficient Collateral`;
}
return undefined;
}),
);
};

const minLiquidityValidator: OperationValidator<CreatePoolFormModel> = (
form,
) => {
Expand Down Expand Up @@ -309,7 +331,11 @@ export const useCreatePoolValidators =
);
};

return [minLiquidityValidator, insufficientAssetForFeeValidator];
return [
minLiquidityValidator,
insufficientCollateral,
insufficientAssetForFeeValidator,
];
};

export const useHandleCreatePoolMaxButtonClick = () => {
Expand Down

0 comments on commit df438f1

Please sign in to comment.