From c96af5158db20c015a6b5ff926b5b10af54d2c12 Mon Sep 17 00:00:00 2001 From: George Kudrayvtsev Date: Tue, 16 May 2023 10:50:46 -0700 Subject: [PATCH] Adds Operation.isValidAmount jsdoc, closes #568 --- src/operation.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/operation.js b/src/operation.js index fdb62e0c..bd747b60 100644 --- a/src/operation.js +++ b/src/operation.js @@ -380,6 +380,21 @@ export class Operation { return result; } + /** + * Validates that a given amount is possible for a Stellar asset. + * + * Specifically, this means that the amount is well, a valid number, but also + * that it is within the int64 range and has no more than 7 decimal levels of + * precision. + * + * Note that while smart contracts allow larger amounts, this is oriented + * towards validating the standard Stellar operations. + * + * @param {string} value the amount to validate + * @param {[boolean]} allowZero whether or not zero is valid (default: no) + * + * @returns {boolean} + */ static isValidAmount(value, allowZero = false) { if (!isString(value)) { return false;