*
* @param {(string|Block)} sendBlock - Corresponding send block or its hash
* @param {(bigint|number|string)} amount - Amount to be received from sender
- * @param {string} [unit] - Unit of measure for amount. Default: "NANO" (10³⁰ RAW)
+ * @param {string} [unit] - Unit of measure for amount (e.g. 'NANO' = 10³⁰ RAW). Default: "RAW"
* @returns {Block} This block with balance, link, and subtype configured
*/
receive (sendBlock: string | Block, amount: bigint | number | string, unit?: string): Block
if (typeof amount !== 'bigint' && typeof amount !== 'number' && typeof amount !== 'string') {
throw new TypeError('Invalid amount')
}
- this.balance += BigInt(amount) * (1n << BigInt(UNITS[unit.toUpperCase()]))
+ this.balance += BigInt(amount) * (10n ** BigInt(UNITS[unit.toUpperCase()]))
if (typeof sendBlock !== 'string' && !(sendBlock instanceof Block)) {
throw new TypeError('Invalid send block')
*
* @param {(string|Account)} account - Account to target or its address or public key
* @param {(bigint|number|string)} amount - Amount to send to recipient
- * @param {string} [unit] - Unit of measure for amount. Default: "NANO" (10³⁰ RAW)
+ * @param {string} [unit] - Unit of measure for amount (e.g. 'NANO' = 10³⁰ RAW). Default: "RAW"
* @returns {Block} This block with balance, link, and subtype configured
*/
send (account: string | Account, amount: bigint | number | string, unit?: string): Block
if (typeof amount !== 'bigint' && typeof amount !== 'number' && typeof amount !== 'string') {
throw new TypeError('Invalid amount')
}
- this.balance -= BigInt(amount) * (1n << BigInt(UNITS[unit.toUpperCase()]))
+ this.balance -= BigInt(amount) * (10n ** BigInt(UNITS[unit.toUpperCase()]))
if (this.balance < 0) {
throw new RangeError('Insufficient funds', { cause: this.balance })