eos-common
Advanced tools
Comparing version 0.7.3 to 0.7.4
@@ -1,4 +0,4 @@ | ||
## TO-DO | ||
## 2020-04-06 | ||
- add test cases for `Symbol` | ||
- support adding `asset` as param to `asset` | ||
@@ -5,0 +5,0 @@ ## 2020-03-07 |
@@ -41,7 +41,4 @@ import { Sym } from "./symbol"; | ||
* Construct a new asset given the symbol name and the amount | ||
* | ||
* @param amount - The amount of the asset | ||
* @param sym - The name of the symbol | ||
*/ | ||
constructor(amount?: string | number | BigInteger | bigint, sym?: Sym); | ||
constructor(obj1?: string | number | BigInteger | bigint | Asset, obj2?: Sym); | ||
/** | ||
@@ -206,2 +203,27 @@ * Check if the amount doesn't exceed the max amount | ||
} | ||
export declare function asset(amount?: string | number | BigInteger, sym?: Sym): Asset; | ||
export declare const asset: { | ||
/** | ||
* String | ||
* | ||
* @example | ||
* | ||
* asset("1.0000 EOS") | ||
*/ | ||
(asset?: string): Asset; | ||
/** | ||
* Asset | ||
* | ||
* @example | ||
* | ||
* asset( asset("1.0000 EOS") ) | ||
*/ | ||
(asset?: Asset): Asset; | ||
/** | ||
* Amount & Sym | ||
* | ||
* @example | ||
* | ||
* asset( 10000, symbol("4,EOS") ) | ||
*/ | ||
(amount?: number | bigint | BigInteger, sym?: Sym): Asset; | ||
}; |
@@ -28,7 +28,4 @@ "use strict"; | ||
* Construct a new asset given the symbol name and the amount | ||
* | ||
* @param amount - The amount of the asset | ||
* @param sym - The name of the symbol | ||
*/ | ||
constructor(amount, sym) { | ||
constructor(obj1, obj2) { | ||
/** | ||
@@ -42,7 +39,7 @@ * {int64_t} The amount of the asset | ||
this.symbol = symbol_1.symbol(); | ||
if (utils_1.isNull(amount) && utils_1.isNull(sym)) { | ||
if (utils_1.isNull(obj1) && utils_1.isNull(obj2)) { | ||
return; | ||
} | ||
else if (typeof amount == "string") { | ||
const [amount_str, symbol_str] = amount.split(" "); | ||
if (typeof obj1 == "string") { | ||
const [amount_str, symbol_str] = obj1.split(" "); | ||
const precision = (amount_str.split(".")[1] || []).length; | ||
@@ -52,6 +49,13 @@ this.amount = utils_1.number_to_bigint(Number(amount_str) * Math.pow(10, precision)); | ||
} | ||
else if (sym) { | ||
this.amount = utils_1.getAmount(amount); | ||
this.symbol = sym; | ||
else if (utils_1.getType(obj1) == "asset") { | ||
const _sym = utils_1.getSymbol(obj1); | ||
if (!_sym) | ||
throw new Error("[sym] is required"); | ||
this.amount = utils_1.getAmount(obj1); | ||
this.symbol = _sym; | ||
} | ||
else if (obj2) { | ||
this.amount = utils_1.getAmount(obj1); | ||
this.symbol = obj2; | ||
} | ||
else { | ||
@@ -338,5 +342,4 @@ throw new Error("[sym] is required"); | ||
Asset.max_amount = (big_integer_1.default(1).shiftLeft(62)).minus(1); | ||
function asset(amount, sym) { | ||
return new Asset(amount, sym); | ||
} | ||
exports.asset = asset; | ||
exports.asset = (obj1, obj2) => { | ||
return new Asset(obj1, obj2); | ||
}; |
{ | ||
"name": "eos-common", | ||
"version": "0.7.3", | ||
"version": "0.7.4", | ||
"description": "EOSIO Smart Contract common library used for Typescript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91960
2038