@defichain/jellyfish-transaction
Advanced tools
Comparing version 0.34.2 to 0.34.3
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ComposableBuffer = void 0; | ||
const bignumber_js_1 = __importDefault(require("bignumber.js")); | ||
const smart_buffer_1 = require("smart-buffer"); | ||
@@ -493,10 +489,10 @@ const buffer_varuint_1 = require("./buffer_varuint"); | ||
const fraction = buffer_bignumber_1.readBigNumberUInt64(buffer); | ||
// Disabled as it's not enforced | ||
// NOTE(canonbrother): max price default value is max int64 (9223372036854775807) | ||
// https://github.com/DeFiCh/ain/blob/aed00d09075094a3a0cedebde5248c006216ba09/src/masternodes/rpc_poolpair.cpp#L115-L123 | ||
if (fraction.gt(new bignumber_js_1.default('99999999')) && !fraction.eq(buffer_bignumber_1.MAX_INT64)) { | ||
throw new Error('Too many decimals read from buffer. Will lose precision with more than 8 decimals'); | ||
} | ||
// if (fraction.gt(new BigNumber('99999999')) && !fraction.eq(MAX_INT64)) { | ||
// throw new Error('Too many decimals read from buffer. Will lose precision with more than 8 decimals') | ||
// } | ||
if (integer.eq(buffer_bignumber_1.MAX_INT64) && fraction.eq(buffer_bignumber_1.MAX_INT64)) { | ||
setter(integer); | ||
setter(fraction); | ||
setter(buffer_bignumber_1.MAX_INT64); | ||
} | ||
@@ -508,11 +504,12 @@ else { | ||
toBuffer: (buffer) => { | ||
if (getter().decimalPlaces() > 8) { | ||
const maxPrice = getter(); | ||
if (maxPrice.decimalPlaces() > 8) { | ||
throw new Error('Too many decimals to be correctly represented. Will lose precision with more than 8 decimals'); | ||
} | ||
if (getter().eq(buffer_bignumber_1.MAX_INT64)) { | ||
buffer_bignumber_1.writeBigNumberUInt64(getter(), buffer); | ||
buffer_bignumber_1.writeBigNumberUInt64(getter(), buffer); | ||
if (maxPrice.eq(buffer_bignumber_1.MAX_INT64)) { | ||
buffer_bignumber_1.writeBigNumberUInt64(buffer_bignumber_1.MAX_INT64, buffer); | ||
buffer_bignumber_1.writeBigNumberUInt64(buffer_bignumber_1.MAX_INT64, buffer); | ||
} | ||
else { | ||
const n = getter().multipliedBy(buffer_bignumber_1.ONE_HUNDRED_MILLION); | ||
const n = maxPrice.multipliedBy(buffer_bignumber_1.ONE_HUNDRED_MILLION); | ||
const fraction = n.mod(buffer_bignumber_1.ONE_HUNDRED_MILLION); | ||
@@ -519,0 +516,0 @@ const integer = n.minus(fraction).dividedBy(buffer_bignumber_1.ONE_HUNDRED_MILLION); |
{ | ||
"private": false, | ||
"name": "@defichain/jellyfish-transaction", | ||
"version": "0.34.2", | ||
"version": "0.34.3", | ||
"description": "A collection of TypeScript + JavaScript tools and libraries for DeFi Blockchain developers to build decentralized finance on Bitcoin", | ||
@@ -41,5 +41,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@defichain/jellyfish-crypto": "^0.34.2", | ||
"@defichain/jellyfish-crypto": "^0.34.3", | ||
"smart-buffer": "^4.1.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
308389
40
5714