@waves/data-entities
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -34,2 +34,5 @@ import { Asset } from './Asset'; | ||
static convert(money: Money, asset: Asset, exchangeRate: BigNumber | string): Money; | ||
static fromTokens(count: number | string | BigNumber, asset: Asset): Money; | ||
static fromCoins(count: number | string | BigNumber, asset: Asset): Money; | ||
private static _toBigNumber(some); | ||
private static _checkAmount(amount); | ||
@@ -36,0 +39,0 @@ private static _tokensToCoins(tokens, precision); |
@@ -10,3 +10,3 @@ "use strict"; | ||
this.asset = asset; | ||
this._coins = coins instanceof bignumber_1.BigNumber ? coins : new bignumber_1.BigNumber(coins); | ||
this._coins = Money._toBigNumber(coins); | ||
this._tokens = this._coins.div(divider); | ||
@@ -112,2 +112,12 @@ } | ||
}; | ||
Money.fromTokens = function (count, asset) { | ||
var tokens = Money._toBigNumber(count); | ||
return new Money(tokens.div(new bignumber_1.BigNumber(10).pow(asset.precision)), asset); | ||
}; | ||
Money.fromCoins = function (count, asset) { | ||
return new Money(count, asset); | ||
}; | ||
Money._toBigNumber = function (some) { | ||
return some instanceof bignumber_1.BigNumber ? some : new bignumber_1.BigNumber(some); | ||
}; | ||
Money._checkAmount = function (amount) { | ||
@@ -114,0 +124,0 @@ if (!(typeof amount === 'string' || amount instanceof bignumber_1.BigNumber)) { |
@@ -81,3 +81,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.dataEntities = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ | ||
this.asset = asset; | ||
this._coins = coins instanceof bignumber_1.BigNumber ? coins : new bignumber_1.BigNumber(coins); | ||
this._coins = Money._toBigNumber(coins); | ||
this._tokens = this._coins.div(divider); | ||
@@ -183,2 +183,12 @@ } | ||
}; | ||
Money.fromTokens = function (count, asset) { | ||
var tokens = Money._toBigNumber(count); | ||
return new Money(tokens.div(new bignumber_1.BigNumber(10).pow(asset.precision)), asset); | ||
}; | ||
Money.fromCoins = function (count, asset) { | ||
return new Money(count, asset); | ||
}; | ||
Money._toBigNumber = function (some) { | ||
return some instanceof bignumber_1.BigNumber ? some : new bignumber_1.BigNumber(some); | ||
}; | ||
Money._checkAmount = function (amount) { | ||
@@ -185,0 +195,0 @@ if (!(typeof amount === 'string' || amount instanceof bignumber_1.BigNumber)) { |
{ | ||
"name": "@waves/data-entities", | ||
"description": "Waves data types", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "private": false, |
Sorry, the diff of this file is not supported yet
34769
665