@saberhq/spl-token
Advanced tools
Comparing version 0.1.0-beta.4 to 0.1.0-beta.5
@@ -198,8 +198,9 @@ 'use strict'; | ||
/** | ||
* Gets this token amount as a fraction divided by the given decimal places. | ||
* Converts this to the raw u64 used by the SPL library | ||
* @returns | ||
*/ | ||
; | ||
_proto.asDecimalFraction = function asDecimalFraction() { | ||
return new tokenMath.Fraction(this.raw, makeDecimalMultiplier(this.token.decimals)); | ||
_proto.toU64 = function toU64() { | ||
return new splToken.u64(this.raw.toString()); | ||
}; | ||
@@ -206,0 +207,0 @@ |
@@ -1,2 +0,2 @@ | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var e=t(require("jsbi")),n=require("@ubeswap/token-math"),r=t(require("tiny-invariant")),i=require("@solana/spl-token"),o=require("@solana/web3.js"),a=t(require("bn.js")),u=e.BigInt("0xffffffffffffffff"),s=e.BigInt(0),c=e.BigInt(1),l=e.BigInt(10);function f(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function d(t,e,n){return e&&f(t.prototype,e),n&&f(t,n),t}function p(){return(p=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function h(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,(Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var m=function(t,e){return void 0!==t&&void 0!==e&&t.mintAccount.equals(e.mintAccount)&&t.cluster===e.cluster},y={tokenSymbol:"SOL",tokenName:"Solana",icon:"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/solana/info/logo.png",mintAccount:i.NATIVE_MINT,decimals:Math.log10(o.LAMPORTS_PER_SOL)},v={"mainnet-beta":p({},y,{cluster:"mainnet-beta"}),devnet:p({},y,{cluster:"devnet"}),testnet:p({},y,{cluster:"testnet"})};function g(t){return t instanceof e?t:e.BigInt("bigint"==typeof t||t instanceof i.u64||t instanceof a?t.toString():t)}var b=function(t){return e.exponentiate(l,e.BigInt(t))};function k(t){e.greaterThanOrEqual(t,s)||r(!1),e.lessThanOrEqual(t,u)||r(!1)}var w=function(t){function i(e,n){var r,i=g(n);return k(i),(r=t.call(this,i,b(e.decimals))||this).token=void 0,r.token=e,r}h(i,t);var o=i.prototype;return o.toSignificant=function(e,r,i){return void 0===e&&(e=6),void 0===i&&(i=n.Rounding.ROUND_DOWN),t.prototype.toSignificant.call(this,e,r,i)},o.toFixed=function(e,i,o){return void 0===e&&(e=this.token.decimals),void 0===o&&(o=n.Rounding.ROUND_DOWN),e<=this.token.decimals||r(!1),t.prototype.toFixed.call(this,e,i,o)},o.toExact=function(t){return void 0===t&&(t={groupSeparator:""}),n.Big.DP=this.token.decimals,new n.Big(this.numerator).div(this.denominator.toString()).toFormat(t)},o.add=function(t){return m(this.token,t.token)||r(!1),new i(this.token,e.add(this.raw,t.raw))},o.subtract=function(t){return m(this.token,t.token)||r(!1),new i(this.token,e.subtract(this.raw,t.raw))},o.divideByAmount=function(t){m(this.token,t.token)||r(!1);var e=this.divide(t);return new n.Percent(e.numerator,e.denominator)},o.divideBy=function(t){var e=this.divide(t);return new n.Percent(e.numerator,e.denominator)},o.asDecimalFraction=function(){return new n.Fraction(this.raw,b(this.token.decimals))},d(i,[{key:"raw",get:function(){return this.numerator}}]),i}(n.Fraction),O=function(t){function e(e,r,i,o){var a;return(a=t.call(this,g(o),g(i))||this).baseCurrency=void 0,a.quoteCurrency=void 0,a.scalar=void 0,a.baseCurrency=e,a.quoteCurrency=r,a.scalar=new n.Fraction(b(e.decimals),b(r.decimals)),a}h(e,t);var i=e.prototype;return i.invert=function(){return new e(this.quoteCurrency,this.baseCurrency,this.numerator,this.denominator)},i.multiply=function(n){m(this.quoteCurrency,n.baseCurrency)||r(!1);var i=t.prototype.multiply.call(this,n);return new e(this.baseCurrency,n.quoteCurrency,i.denominator,i.numerator)},i.quote=function(e){return m(e.token,this.baseCurrency)||r(!1),new w(this.quoteCurrency,t.prototype.multiply.call(this,e.raw).quotient)},i.toSignificant=function(t,e,n){return void 0===t&&(t=6),this.adjusted.toSignificant(t,e,n)},i.toFixed=function(t,e,n){return void 0===t&&(t=4),this.adjusted.toFixed(t,e,n)},d(e,[{key:"raw",get:function(){return new n.Fraction(this.numerator,this.denominator)}},{key:"adjusted",get:function(){return t.prototype.multiply.call(this,this.scalar)}}]),e}(n.Fraction);exports.MAX_U64=u,exports.ONE=c,exports.Price=O,exports.SOL=v,exports.TEN=l,exports.TokenAmount=w,exports.ZERO=s,exports.makeDecimalMultiplier=b,exports.parseBigintIsh=g,exports.tokensEqual=m,exports.validateU64=k; | ||
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var e=t(require("jsbi")),n=require("@ubeswap/token-math"),r=t(require("tiny-invariant")),o=require("@solana/spl-token"),i=require("@solana/web3.js"),a=t(require("bn.js")),u=e.BigInt("0xffffffffffffffff"),s=e.BigInt(0),c=e.BigInt(1),l=e.BigInt(10);function f(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function d(t,e,n){return e&&f(t.prototype,e),n&&f(t,n),t}function p(){return(p=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function h(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,(Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}var y=function(t,e){return void 0!==t&&void 0!==e&&t.mintAccount.equals(e.mintAccount)&&t.cluster===e.cluster},m={tokenSymbol:"SOL",tokenName:"Solana",icon:"https://raw.githubusercontent.com/trustwallet/assets/master/blockchains/solana/info/logo.png",mintAccount:o.NATIVE_MINT,decimals:Math.log10(i.LAMPORTS_PER_SOL)},v={"mainnet-beta":p({},m,{cluster:"mainnet-beta"}),devnet:p({},m,{cluster:"devnet"}),testnet:p({},m,{cluster:"testnet"})};function g(t){return t instanceof e?t:e.BigInt("bigint"==typeof t||t instanceof o.u64||t instanceof a?t.toString():t)}var b=function(t){return e.exponentiate(l,e.BigInt(t))};function k(t){e.greaterThanOrEqual(t,s)||r(!1),e.lessThanOrEqual(t,u)||r(!1)}var w=function(t){function i(e,n){var r,o=g(n);return k(o),(r=t.call(this,o,b(e.decimals))||this).token=void 0,r.token=e,r}h(i,t);var a=i.prototype;return a.toSignificant=function(e,r,o){return void 0===e&&(e=6),void 0===o&&(o=n.Rounding.ROUND_DOWN),t.prototype.toSignificant.call(this,e,r,o)},a.toFixed=function(e,o,i){return void 0===e&&(e=this.token.decimals),void 0===i&&(i=n.Rounding.ROUND_DOWN),e<=this.token.decimals||r(!1),t.prototype.toFixed.call(this,e,o,i)},a.toExact=function(t){return void 0===t&&(t={groupSeparator:""}),n.Big.DP=this.token.decimals,new n.Big(this.numerator).div(this.denominator.toString()).toFormat(t)},a.add=function(t){return y(this.token,t.token)||r(!1),new i(this.token,e.add(this.raw,t.raw))},a.subtract=function(t){return y(this.token,t.token)||r(!1),new i(this.token,e.subtract(this.raw,t.raw))},a.divideByAmount=function(t){y(this.token,t.token)||r(!1);var e=this.divide(t);return new n.Percent(e.numerator,e.denominator)},a.divideBy=function(t){var e=this.divide(t);return new n.Percent(e.numerator,e.denominator)},a.toU64=function(){return new o.u64(this.raw.toString())},d(i,[{key:"raw",get:function(){return this.numerator}}]),i}(n.Fraction),O=function(t){function e(e,r,o,i){var a;return(a=t.call(this,g(i),g(o))||this).baseCurrency=void 0,a.quoteCurrency=void 0,a.scalar=void 0,a.baseCurrency=e,a.quoteCurrency=r,a.scalar=new n.Fraction(b(e.decimals),b(r.decimals)),a}h(e,t);var o=e.prototype;return o.invert=function(){return new e(this.quoteCurrency,this.baseCurrency,this.numerator,this.denominator)},o.multiply=function(n){y(this.quoteCurrency,n.baseCurrency)||r(!1);var o=t.prototype.multiply.call(this,n);return new e(this.baseCurrency,n.quoteCurrency,o.denominator,o.numerator)},o.quote=function(e){return y(e.token,this.baseCurrency)||r(!1),new w(this.quoteCurrency,t.prototype.multiply.call(this,e.raw).quotient)},o.toSignificant=function(t,e,n){return void 0===t&&(t=6),this.adjusted.toSignificant(t,e,n)},o.toFixed=function(t,e,n){return void 0===t&&(t=4),this.adjusted.toFixed(t,e,n)},d(e,[{key:"raw",get:function(){return new n.Fraction(this.numerator,this.denominator)}},{key:"adjusted",get:function(){return t.prototype.multiply.call(this,this.scalar)}}]),e}(n.Fraction);exports.MAX_U64=u,exports.ONE=c,exports.Price=O,exports.SOL=v,exports.TEN=l,exports.TokenAmount=w,exports.ZERO=s,exports.makeDecimalMultiplier=b,exports.parseBigintIsh=g,exports.tokensEqual=y,exports.validateU64=k; | ||
//# sourceMappingURL=spl-token.cjs.production.min.js.map |
@@ -194,8 +194,9 @@ import JSBI from 'jsbi'; | ||
/** | ||
* Gets this token amount as a fraction divided by the given decimal places. | ||
* Converts this to the raw u64 used by the SPL library | ||
* @returns | ||
*/ | ||
; | ||
_proto.asDecimalFraction = function asDecimalFraction() { | ||
return new Fraction(this.raw, makeDecimalMultiplier(this.token.decimals)); | ||
_proto.toU64 = function toU64() { | ||
return new u64(this.raw.toString()); | ||
}; | ||
@@ -202,0 +203,0 @@ |
@@ -0,1 +1,2 @@ | ||
import { u64 } from "@solana/spl-token"; | ||
import { Fraction, NumberFormat, Percent, Rounding } from "@ubeswap/token-math"; | ||
@@ -28,5 +29,6 @@ import JSBI from "jsbi"; | ||
/** | ||
* Gets this token amount as a fraction divided by the given decimal places. | ||
* Converts this to the raw u64 used by the SPL library | ||
* @returns | ||
*/ | ||
asDecimalFraction(): Fraction; | ||
toU64(): u64; | ||
} |
{ | ||
"name": "@saberhq/spl-token", | ||
"version": "0.1.0-beta.4", | ||
"version": "0.1.0-beta.5", | ||
"repository": "git@github.com:saber-hq/use-solana.git", | ||
@@ -39,3 +39,3 @@ "author": "Ian Macalinao <ian@saber.so>", | ||
}, | ||
"gitHead": "58671bf82961b54b95efe54c0e8847ddb970c603" | ||
"gitHead": "30fdba0961774f43441b419c7e71b3b152244cbb" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
597
67882