How to use the bitsharesjs.ChainStore.getAsset function in bitsharesjs

To help you get started, we’ve selected a few bitsharesjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bitshares / bitshares-ui / app / components / Account / AccountAssetCreate.jsx View on Github external
// let asset = props.asset.toJS();
        let isBitAsset = false;
        let precision = utils.get_asset_precision(4);
        let corePrecision = utils.get_asset_precision(
            props.core.get("precision")
        );

        let {flagBooleans, permissionBooleans} = this._getPermissions({
            isBitAsset
        });

        // let flags = assetUtils.getFlags(flagBooleans);
        // let permissions = assetUtils.getPermissions(permissionBooleans, isBitAsset);
        // console.log("all permissions:", permissionBooleans, permissions)

        let coreRateBaseAssetName = ChainStore.getAsset("1.3.0").get("symbol");

        return {
            update: {
                symbol: "",
                precision: 4,
                max_supply: 100000,
                max_market_fee: 0,
                market_fee_percent: 0,
                description: {main: ""}
            },
            errors: {
                max_supply: null
            },
            isValid: true,
            flagBooleans: flagBooleans,
            permissionBooleans: permissionBooleans,
github GamechainSystem / GameChainBase / GameChainBlockWallet / app / actions / AssetActions.js View on Github external
createAsset(account_id, createObject, flags, permissions, cer, isBitAsset, is_prediction_market, bitasset_opts, description) {
        // Create asset action here...
        console.log("create asset:", createObject, "flags:", flags, "isBitAsset:", isBitAsset, "bitasset_opts:", bitasset_opts);
        let tr = wallet_api.new_transaction();
        let precision = utils.get_asset_precision(createObject.precision);

        big.config({DECIMAL_PLACES: createObject.precision});
        let max_supply = (new big(createObject.max_supply)).times(precision).toString();
        let max_market_fee = (new big(createObject.max_market_fee || 0)).times(precision).toString();
        // console.log("max_supply:", max_supply);
        // console.log("max_market_fee:", max_market_fee);

        let corePrecision = utils.get_asset_precision(ChainStore.getAsset(cer.base.asset_id).get("precision"));

        let operationJSON = {
            "fee": {
                amount: 0,
                asset_id: 0
            },
            "issuer": account_id,
            "symbol": createObject.symbol,
            "precision": parseInt(createObject.precision, 10),
            "common_options": {
                "max_supply": max_supply,
                "market_fee_percent": createObject.market_fee_percent * 100 || 0,
                "max_market_fee": max_market_fee,
                "issuer_permissions": permissions,
                "flags": flags,
                "core_exchange_rate": {
github bitshares / bitshares-ui / app / components / Exchange / MyMarkets.jsx View on Github external
gatewayPrefixes.forEach(prefix => {
                let possibleGatewayAssetName = `${prefix}.${currentBase}`;
                let gatewayAsset = ChainStore.getAsset(
                    possibleGatewayAssetName
                );
                /* If the gateway offers an asset for this base, add it to the list */
                if (!!gatewayAsset) {
                    let gatewayMarkets = activeMarkets
                        .map(m => {
                            if (m.quote === m.base) return null;
                            let newID = `${
                                m.quote
                            }_${possibleGatewayAssetName}`;
                            if (activeMarkets.has(newID)) return null;
                            return {
                                base: possibleGatewayAssetName,
                                quote: m.quote
                            };
                        }, {})
github bitshares / bitshares-ui / app / components / Blockchain / Asset.jsx View on Github external
let urlTest = /(http?):\/\/(www\.)?[a-z0-9\.:].*?(?=\s)/g;

        // Regexp needs a whitespace after a url, so add one to make sure
        desc = desc && desc.length > 0 ? desc + " " : desc;
        let urls = desc.match(urlTest);

        // Add market link
        const core_asset = ChainStore.getAsset("1.3.0");
        let preferredMarket = description.market
            ? description.market
            : core_asset
                ? core_asset.get("symbol")
                : "BTS";
        if (isPrediction) {
            preferredMarket = ChainStore.getAsset(
                asset.bitasset.options.short_backing_asset
            );
            if (preferredMarket) {
                preferredMarket = preferredMarket.get("symbol");
            } else {
                preferredMarket = core_asset.get("symbol");
            }
        }
        if (asset.symbol === core_asset.get("symbol")) preferredMarket = "USD";
        if (urls && urls.length) {
            urls.forEach(url => {
                let markdownUrl = `<a href="${url}" rel="noopener noreferrer" class="external-link">${url}</a>`;
                desc = desc.replace(url, markdownUrl);
            });
        }
github bitshares / bitshares-ui / app / components / Utility / BindToChainState.jsx View on Github external
new_state[key] = new_obj;
                    ++all_objects_counter;
                    if (new_obj !== undefined) ++resolved_objects_counter;
                } else {
                    if (this.state[key]) new_state[key] = null;
                }
            }

            /* Resolve assets */
            for (let key of this.chain_assets) {
                let prop =
                    props[key] ||
                    this.dynamic_props[key] ||
                    this.default_props[key];
                if (prop) {
                    let new_obj = ChainStore.getAsset(prop);

                    if (
                        new_obj === undefined &&
                        this.required_props.indexOf(key) === -1 &&
                        new_obj !== this.state[key]
                    )
                        new_state[key] = new_obj;
                    else if (
                        (new_obj && new_obj !== this.state[key]) ||
                        new_obj === null
                    )
                        new_state[key] = new_obj;

                    ++all_objects_counter;
                    if (new_obj !== undefined) ++resolved_objects_counter;
                } else {
github bitshares / bitshares-ui / app / components / Blockchain / AssetResolvePrediction.jsx View on Github external
onSubmit() {
        const {asset, account} = this.props;

        let base = new Asset({
            real: this.state.globalSettlementPrice,
            asset_id: this.props.asset.id,
            precision: this.props.asset.precision
        });
        let quoteAsset = ChainStore.getAsset(
            asset.bitasset.options.short_backing_asset
        );
        let quote = new Asset({
            real: 1,
            asset_id: this.props.asset.bitasset.options.short_backing_asset,
            precision: quoteAsset.get("precision")
        });

        let price = new Price({
            quote,
            base
        });

        AssetActions.assetGlobalSettle(asset, account.get("id"), price).then(
            () => {
                this.onReset();
github bitshares / bitshares-ui / app / components / PredictionMarkets / PredictionMarkets.jsx View on Github external
async getMarketOpinions(market) {
        if (this.state.subscribedMarket) {
            await MarketsActions.unSubscribeMarket(
                this.state.subscribedMarket.quote.get("id"),
                this.state.subscribedMarket.base.get("id")
            );
        }
        const base = ChainStore.getAsset(
            market.options.core_exchange_rate.base.asset_id
        );
        const quote = ChainStore.getAsset(
            market.options.core_exchange_rate.quote.asset_id
        );
        await MarketsActions.subscribeMarket(
            base,
            quote,
            this.props.bucketSize,
            this.props.currentGroupOrderLimit
        );
        this.setState({
            subscribedMarket: {
                base,
                quote
            }
        });
    }
github bitshares / bitshares-ui / app / components / PredictionMarkets / CreateMarketModal.jsx View on Github external
handleAssetChange(asset) {
        if (asset) {
            let newBitassetOpts = this.state.bitasset_opts;
            let newMarketOptions = this.state.marketOptions;
            let newCoreExchangeRate = this.state.core_exchange_rate;
            newBitassetOpts.short_backing_asset = asset;
            newMarketOptions.precision = ChainStore.getAsset(asset).get(
                "precision"
            );
            newCoreExchangeRate.base.asset_id = asset;
            this.setState({
                bitasset_opts: newBitassetOpts,
                core_exchange_rate: newCoreExchangeRate,
                marketOptions: newMarketOptions
            });
        }
    }
github bitshares / bitshares-ui / app / components / Exchange / ScaledOrder.jsx View on Github external
);

        const priceUpperInput = getFieldDecorator("priceUpper", {
            validateFirst: true,
            rules: [Validation.Rules.required(), Validation.Rules.number()]
        })(
            <input autocomplete="off" style="{{width:">
        );

        const feeCurrencySelect = getFieldDecorator("feeCurrency", {
            initialValue:
                ChainStore.getAsset("1.3.0") &amp;&amp;
                ChainStore.getAsset("1.3.0").get &amp;&amp;
                ChainStore.getAsset("1.3.0").get("symbol")
        })(
            <select style="{{minWidth:">
                {this.state.feeAssets &amp;&amp;
                    this.state.feeAssets.map &amp;&amp;
                    this.state.feeAssets.map(feeAsset =&gt; {
                        return (
                            </select>