Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.WrappedTokenInfo = void 0;
const address_1 = require("@ethersproject/address");
const math_1 = require("@sushiswap/math");
/**
 * Token instances created from token info on a token list.
 */
class WrappedTokenInfo {
    constructor(tokenInfo, list) {
        this.isNative = false;
        this.isToken = true;
        this.rebase = { base: math_1.JSBI.BigInt(1), elastic: math_1.JSBI.BigInt(1) };
        this._checksummedAddress = null;
        this._tags = null;
        this.tokenInfo = tokenInfo;
        this.list = list;
    }
    get address() {
        if (this._checksummedAddress)
            return this._checksummedAddress;
        if (!(0, address_1.isAddress)(this.tokenInfo.address))
            throw new Error(`Invalid token address: ${this.tokenInfo.address}`);
        const checksummedAddress = (0, address_1.getAddress)(this.tokenInfo.address);
        return (this._checksummedAddress = checksummedAddress);
    }
    get chainId() {
        return this.tokenInfo.chainId;
    }
    get decimals() {
        return this.tokenInfo.decimals;
    }
    get name() {
        return this.tokenInfo.name;
    }
    get symbol() {
        return this.tokenInfo.symbol;
    }
    get logoURI() {
        return this.tokenInfo.logoURI;
    }
    get tags() {
        if (this._tags !== null)
            return this._tags;
        if (!this.tokenInfo.tags)
            return (this._tags = []);
        const listTags = this.list?.tags;
        if (!listTags)
            return (this._tags = []);
        return (this._tags = this.tokenInfo.tags.map((tagId) => {
            return {
                ...listTags[tagId],
                id: tagId,
            };
        }));
    }
    equals(other) {
        return other.chainId === this.chainId && other.isToken && other.address.toLowerCase() === this.address.toLowerCase();
    }
    sortsBefore(other) {
        if (this.equals(other))
            throw new Error('Addresses should not be equal');
        return this.address.toLowerCase() < other.address.toLowerCase();
    }
    get wrapped() {
        return this;
    }
}
exports.WrappedTokenInfo = WrappedTokenInfo;