Socket
Socket
Sign inDemoInstall

@moralisweb3/evm-utils

Package Overview
Dependencies
Maintainers
8
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@moralisweb3/evm-utils - npm Package Compare versions

Comparing version 2.0.0-beta.7 to 2.0.0-beta.8

8

lib/dataTypes/Erc20/Erc20.d.ts

@@ -35,2 +35,10 @@ import { MoralisDataObject } from '@moralisweb3/core';

static equals(valueA: Erc20Tokenish, valueB: Erc20Tokenish): boolean;
get decimals(): number;
get name(): string;
get symbol(): string;
get contractAddress(): EvmAddress;
get chain(): EvmChain;
get logo(): string | null | undefined;
get logoHash(): string | null | undefined;
get thumbnail(): string | null | undefined;
equals(value: Erc20Tokenish): boolean;

@@ -37,0 +45,0 @@ toJSON(): {

@@ -43,2 +43,58 @@ "use strict";

};
Object.defineProperty(Erc20Token.prototype, "decimals", {
get: function () {
return this._value.decimals;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Erc20Token.prototype, "name", {
get: function () {
return this._value.name;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Erc20Token.prototype, "symbol", {
get: function () {
return this._value.symbol;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Erc20Token.prototype, "contractAddress", {
get: function () {
return this._value.contractAddress;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Erc20Token.prototype, "chain", {
get: function () {
return this._value.chain;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Erc20Token.prototype, "logo", {
get: function () {
return this._value.logo;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Erc20Token.prototype, "logoHash", {
get: function () {
return this._value.logoHash;
},
enumerable: false,
configurable: true
});
Object.defineProperty(Erc20Token.prototype, "thumbnail", {
get: function () {
return this._value.thumbnail;
},
enumerable: false,
configurable: true
});
Erc20Token.prototype.equals = function (value) {

@@ -45,0 +101,0 @@ return Erc20Token.equals(this, value);

38

lib/dataTypes/Erc20Value/Erc20Value.d.ts
import { BigNumber, BigNumberish, MoralisData } from '@moralisweb3/core';
import { Erc20Token, Erc20Tokenish } from '../Erc20/Erc20';
export declare type Erc20ValueInputAmount = BigNumberish;

@@ -6,5 +7,9 @@ export declare type Erc20ValueInputDecimals = number | string;

export declare type Erc20ValueData = {
amount: BigNumberish;
amount: BigNumber;
decimals: number;
};
export declare type Erc20Options = {
decimals?: Erc20ValueInputDecimals;
token?: Erc20Tokenish;
};
/**

@@ -16,16 +21,37 @@ * The Erc20Value class is a MoralisData that references to a the value of an Erc20Token

private _value;
constructor(amount: Erc20ValueInputAmount, decimals?: Erc20ValueInputDecimals);
static parse: (value: {
private _token?;
constructor(amount: Erc20ValueInputAmount, options?: Erc20Options);
static parse: ({ amount, decimals, token, }: {
amount: Erc20ValueInputAmount;
decimals: Erc20ValueInputDecimals;
token?: Erc20Tokenish | undefined;
}) => Erc20ValueData;
static create(value: Erc20Valueish, decimals?: Erc20ValueInputDecimals): Erc20Value;
static create(value: Erc20Valueish, options?: Erc20Options): Erc20Value;
static equals(valueA: Erc20Valueish, valueB: Erc20Valueish): boolean;
equals(value: Erc20Valueish): boolean;
get decimals(): number;
get amount(): BigNumberish;
get value(): BigNumber;
get amount(): BigNumber;
get value(): string;
get token(): Erc20Token | null;
toNumber(): number;
toString(): string;
display: () => string;
format(): string;
toJSON(): {
value: string;
token: {
contractAddress: string;
chain: string | number;
decimals: number;
name: string;
symbol: string;
logo?: string | null | undefined;
logoHash?: string | null | undefined;
thumbnail?: string | null | undefined;
};
} | {
value: string;
token?: undefined;
};
}
//# sourceMappingURL=Erc20Value.d.ts.map

@@ -5,2 +5,3 @@ "use strict";

var core_1 = require("@moralisweb3/core");
var Erc20_1 = require("../Erc20/Erc20");
var EVM_ERC20_DEFAULT_DECIMALS = 18;

@@ -12,14 +13,25 @@ /**

var Erc20Value = /** @class */ (function () {
function Erc20Value(amount, decimals) {
if (decimals === void 0) { decimals = EVM_ERC20_DEFAULT_DECIMALS; }
function Erc20Value(amount, options) {
var _this = this;
var _a, _b, _c;
this.display = function () {
if (!_this._token) {
return "".concat(_this.value);
}
return "".concat(_this.value, " ").concat(_this._token.symbol);
};
this._value = Erc20Value.parse({
amount: amount,
decimals: decimals,
decimals: (_c = (_a = options === null || options === void 0 ? void 0 : options.decimals) !== null && _a !== void 0 ? _a : (_b = options === null || options === void 0 ? void 0 : options.token) === null || _b === void 0 ? void 0 : _b.decimals) !== null && _c !== void 0 ? _c : EVM_ERC20_DEFAULT_DECIMALS,
token: options === null || options === void 0 ? void 0 : options.token,
});
if (options === null || options === void 0 ? void 0 : options.token) {
this._token = Erc20_1.Erc20Token.create(options.token);
}
}
Erc20Value.create = function (value, decimals) {
Erc20Value.create = function (value, options) {
if (value instanceof Erc20Value) {
return value;
}
return new Erc20Value(value, decimals);
return new Erc20Value(value, options);
};

@@ -29,3 +41,3 @@ Erc20Value.equals = function (valueA, valueB) {

var erc20ValueB = Erc20Value.create(valueB);
return erc20ValueA.value.equals(erc20ValueB.value);
return erc20ValueA.value === erc20ValueB.value;
};

@@ -51,3 +63,3 @@ Erc20Value.prototype.equals = function (value) {

get: function () {
return core_1.BigNumber.fromDecimal(this._value.amount.toString(), this._value.decimals);
return this._value.amount.toDecimal(this.decimals);
},

@@ -57,4 +69,15 @@ enumerable: false,

});
Object.defineProperty(Erc20Value.prototype, "token", {
get: function () {
var _a;
return (_a = this._token) !== null && _a !== void 0 ? _a : null;
},
enumerable: false,
configurable: true
});
Erc20Value.prototype.toNumber = function () {
return +this.value;
};
Erc20Value.prototype.toString = function () {
return this.value.toString();
return this.value;
};

@@ -64,6 +87,21 @@ Erc20Value.prototype.format = function () {

};
Erc20Value.parse = function (value) { return ({
amount: value.amount,
decimals: +value.decimals,
}); };
Erc20Value.prototype.toJSON = function () {
if (this.token) {
return { value: this.value, token: this.token.toJSON() };
}
return { value: this.value };
};
Erc20Value.parse = function (_a) {
var amount = _a.amount, decimals = _a.decimals, token = _a.token;
if (token && token.decimals !== decimals) {
throw new core_1.MoralisCoreError({
code: core_1.CoreErrorCode.INVALID_DATA,
message: 'Decimals do not match',
});
}
return {
amount: core_1.BigNumber.create(amount),
decimals: +decimals,
};
};
return Erc20Value;

@@ -70,0 +108,0 @@ }());

4

package.json
{
"name": "@moralisweb3/evm-utils",
"author": "Moralis",
"version": "2.0.0-beta.7",
"version": "2.0.0-beta.8",
"license": "MIT",

@@ -33,4 +33,4 @@ "private": false,

"@ethersproject/transactions": "^5.6.0",
"@moralisweb3/core": "^2.0.0-beta.7"
"@moralisweb3/core": "^2.0.0-beta.8"
}
}

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

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