New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@saberhq/spl-token

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@saberhq/spl-token - npm Package Compare versions

Comparing version 0.1.0-beta.6 to 0.1.0-beta.7

12

dist/spl-token.cjs.development.js

@@ -10,2 +10,3 @@ 'use strict';

var web3_js = require('@solana/web3.js');
var Decimal = _interopDefault(require('decimal.js'));
var BN = _interopDefault(require('bn.js'));

@@ -125,3 +126,14 @@

}
/**
* Parses a token amount from a decimal representation.
* @param token
* @param uiAmount
* @returns
*/
TokenAmount.parse = function parse(token, uiAmount) {
return new TokenAmount(token, JSBI.BigInt(new Decimal(uiAmount).times(new Decimal(10).pow(token.decimals)).floor().toString()));
};
var _proto = TokenAmount.prototype;

@@ -128,0 +140,0 @@

2

dist/spl-token.cjs.production.min.js

@@ -1,2 +0,2 @@

"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var n=t(require("jsbi")),e=require("@ubeswap/token-math"),r=t(require("tiny-invariant")),i=require("@solana/spl-token"),o=require("@solana/web3.js"),u=t(require("bn.js")),a=n.BigInt("0xffffffffffffffff"),s=n.BigInt(0),c=n.BigInt(1),l=n.BigInt(10);function f(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function d(t,n,e){return n&&f(t.prototype,n),e&&f(t,e),t}function p(){return(p=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t}).apply(this,arguments)}function h(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,(Object.setPrototypeOf||function(t,n){return t.__proto__=n,t})(t,n)}var y=function(t,n){return void 0!==t&&void 0!==n&&t.mintAccount.equals(n.mintAccount)&&t.cluster===n.cluster},m={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({},m,{cluster:"mainnet-beta"}),devnet:p({},m,{cluster:"devnet"}),testnet:p({},m,{cluster:"testnet"})};function g(t){return t instanceof n?t:n.BigInt("bigint"==typeof t||t instanceof i.u64||t instanceof u?t.toString():t)}var b=function(t){return n.exponentiate(l,n.BigInt(t))};function w(t){n.greaterThanOrEqual(t,s)||r(!1),n.lessThanOrEqual(t,a)||r(!1)}var k=function(t){function o(n,e){var r,i=g(e);return w(i),(r=t.call(this,i,b(n.decimals))||this).token=void 0,r.token=n,r}h(o,t);var u=o.prototype;return u.toSignificant=function(n,r,i){return void 0===n&&(n=6),void 0===i&&(i=e.Rounding.ROUND_DOWN),t.prototype.toSignificant.call(this,n,r,i)},u.toFixed=function(n,i,o){return void 0===n&&(n=this.token.decimals),void 0===o&&(o=e.Rounding.ROUND_DOWN),n<=this.token.decimals||r(!1),t.prototype.toFixed.call(this,n,i,o)},u.toExact=function(t){return void 0===t&&(t={groupSeparator:""}),e.Big.DP=this.token.decimals,new e.Big(this.numerator).div(this.denominator.toString()).toFormat(t)},u.add=function(t){return y(this.token,t.token)||r(!1),new o(this.token,n.add(this.raw,t.raw))},u.subtract=function(t){return y(this.token,t.token)||r(!1),new o(this.token,n.subtract(this.raw,t.raw))},u.divideByAmount=function(t){y(this.token,t.token)||r(!1);var n=this.divide(t);return new e.Percent(n.numerator,n.denominator)},u.divideBy=function(t){var n=this.divide(t);return new e.Percent(n.numerator,n.denominator)},u.toU64=function(){return new i.u64(this.raw.toString())},u.multiplyBy=function(t){return new o(this.token,t.asFraction.multiply(this.raw).toFixed(0))},u.reduceBy=function(t){return this.multiplyBy(new e.Percent(1,1).subtract(t))},d(o,[{key:"raw",get:function(){return this.numerator}}]),o}(e.Fraction),x=function(t){function n(n,r,i,o){var u;return(u=t.call(this,g(o),g(i))||this).baseCurrency=void 0,u.quoteCurrency=void 0,u.scalar=void 0,u.baseCurrency=n,u.quoteCurrency=r,u.scalar=new e.Fraction(b(n.decimals),b(r.decimals)),u}h(n,t);var i=n.prototype;return i.invert=function(){return new n(this.quoteCurrency,this.baseCurrency,this.numerator,this.denominator)},i.multiply=function(e){y(this.quoteCurrency,e.baseCurrency)||r(!1);var i=t.prototype.multiply.call(this,e);return new n(this.baseCurrency,e.quoteCurrency,i.denominator,i.numerator)},i.quote=function(n){return y(n.token,this.baseCurrency)||r(!1),new k(this.quoteCurrency,t.prototype.multiply.call(this,n.raw).quotient)},i.toSignificant=function(t,n,e){return void 0===t&&(t=6),this.adjusted.toSignificant(t,n,e)},i.toFixed=function(t,n,e){return void 0===t&&(t=4),this.adjusted.toFixed(t,n,e)},d(n,[{key:"raw",get:function(){return new e.Fraction(this.numerator,this.denominator)}},{key:"adjusted",get:function(){return t.prototype.multiply.call(this,this.scalar)}}]),n}(e.Fraction);exports.MAX_U64=a,exports.ONE=c,exports.Price=x,exports.SOL=v,exports.TEN=l,exports.TokenAmount=k,exports.ZERO=s,exports.makeDecimalMultiplier=b,exports.parseBigintIsh=g,exports.tokensEqual=y,exports.validateU64=w;
"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"),u=t(require("decimal.js")),a=t(require("bn.js")),s=e.BigInt("0xffffffffffffffff"),c=e.BigInt(0),l=e.BigInt(1),f=e.BigInt(10);function d(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 p(t,e,n){return e&&d(t.prototype,e),n&&d(t,n),t}function h(){return(h=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 y(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},v={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)},g={"mainnet-beta":h({},v,{cluster:"mainnet-beta"}),devnet:h({},v,{cluster:"devnet"}),testnet:h({},v,{cluster:"testnet"})};function w(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(f,e.BigInt(t))};function k(t){e.greaterThanOrEqual(t,c)||r(!1),e.lessThanOrEqual(t,s)||r(!1)}var q=function(t){function o(e,n){var r,i=w(n);return k(i),(r=t.call(this,i,b(e.decimals))||this).token=void 0,r.token=e,r}y(o,t),o.parse=function(t,n){return new o(t,e.BigInt(new u(n).times(new u(10).pow(t.decimals)).floor().toString()))};var a=o.prototype;return a.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)},a.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)},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 m(this.token,t.token)||r(!1),new o(this.token,e.add(this.raw,t.raw))},a.subtract=function(t){return m(this.token,t.token)||r(!1),new o(this.token,e.subtract(this.raw,t.raw))},a.divideByAmount=function(t){m(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 i.u64(this.raw.toString())},a.multiplyBy=function(t){return new o(this.token,t.asFraction.multiply(this.raw).toFixed(0))},a.reduceBy=function(t){return this.multiplyBy(new n.Percent(1,1).subtract(t))},p(o,[{key:"raw",get:function(){return this.numerator}}]),o}(n.Fraction),x=function(t){function e(e,r,i,o){var u;return(u=t.call(this,w(o),w(i))||this).baseCurrency=void 0,u.quoteCurrency=void 0,u.scalar=void 0,u.baseCurrency=e,u.quoteCurrency=r,u.scalar=new n.Fraction(b(e.decimals),b(r.decimals)),u}y(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 q(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)},p(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=s,exports.ONE=l,exports.Price=x,exports.SOL=g,exports.TEN=f,exports.TokenAmount=q,exports.ZERO=c,exports.makeDecimalMultiplier=b,exports.parseBigintIsh=w,exports.tokensEqual=m,exports.validateU64=k;
//# sourceMappingURL=spl-token.cjs.production.min.js.map

@@ -6,2 +6,3 @@ import JSBI from 'jsbi';

import { LAMPORTS_PER_SOL } from '@solana/web3.js';
import Decimal from 'decimal.js';
import BN from 'bn.js';

@@ -121,3 +122,14 @@

}
/**
* Parses a token amount from a decimal representation.
* @param token
* @param uiAmount
* @returns
*/
TokenAmount.parse = function parse(token, uiAmount) {
return new TokenAmount(token, JSBI.BigInt(new Decimal(uiAmount).times(new Decimal(10).pow(token.decimals)).floor().toString()));
};
var _proto = TokenAmount.prototype;

@@ -124,0 +136,0 @@

@@ -10,2 +10,9 @@ import { u64 } from "@solana/spl-token";

constructor(token: Token, amount: BigintIsh);
/**
* Parses a token amount from a decimal representation.
* @param token
* @param uiAmount
* @returns
*/
static parse(token: Token, uiAmount: string): TokenAmount;
get raw(): JSBI;

@@ -12,0 +19,0 @@ toSignificant(significantDigits?: number, format?: NumberFormat, rounding?: Rounding): string;

{
"name": "@saberhq/spl-token",
"version": "0.1.0-beta.6",
"version": "0.1.0-beta.7",
"repository": "git@github.com:saber-hq/use-solana.git",

@@ -25,2 +25,3 @@ "author": "Ian Macalinao <ian@saber.so>",

"@ubeswap/token-math": "^0.1.3",
"decimal.js": "^10.2.1",
"jsbi": "^3.1.4",

@@ -40,3 +41,3 @@ "tiny-invariant": "^1.1.0"

},
"gitHead": "639fb9a2bb1dedaedff2cd47cf6626fbcbfcfc62"
"gitHead": "a5108b3067225f0097dc63ca2912754d5a580f3a"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc