How to use the bitsharesjs.FetchChain 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 GamechainSystem / GameChainBase / GameChainBlockWallet / app / api / ApplicationApi.js View on Github external
optional_nonce = null,
        propose_account = null,
        fee_asset_id = "1.3.0",
        otherOpt=null
    }) {
        let memo_sender = propose_account || from_account;

        let unlock_promise = WalletUnlockActions.unlock();
      
        return Promise.all([
            FetchChain("getAccount", from_account),
            FetchChain("getAccount", to_account),
            FetchChain("getAccount", memo_sender),
            FetchChain("getAccount", propose_account),
            FetchChain("getAsset", asset),
            FetchChain("getAsset", fee_asset_id),
            unlock_promise
        ]).then((res)=> {

            let [
                chain_from, chain_to, chain_memo_sender, chain_propose_account,
                chain_asset, chain_fee_asset
            ] = res;

            let memo_from_public, memo_to_public;
            if( memo && encrypt_memo  ) {

                memo_from_public = chain_memo_sender.getIn(["options","memo_key"]);
                // The 1s are base58 for all zeros (null)
                if( /111111111111111111111/.test(memo_from_public)) {
                    memo_from_public = null;
                }
github bitshares / bitshares-ui / app / components / Account / AccountSelectorAnt.jsx View on Github external
let {onChange, onAccountChanged, accountName} = this.props;

        let _accountName = this.getVerifiedAccountName(e);

        if (_accountName === accountName) {
            // nothing has changed, don't notify
            return;
        }

        // Synchronous onChange for input change
        if (!!onChange && (!!_accountName || _accountName === ""))
            onChange(_accountName);

        // asynchronous onAccountChanged for checking on chain
        if (!!onAccountChanged) {
            FetchChain("getAccount", _accountName, undefined, {
                [_accountName]: false
            })
                .then(_account => {
                    if (!!_account) {
                        onAccountChanged(_account);
                    }
                })
                .catch(err => {
                    // error fetching
                    console.log(err);
                });
        }
    }
github bitshares / bitshares-ui / app / api / ApplicationApi.js View on Github external
from_account,
        to_account,
        amount,
        asset,
        memo,
        propose_account = null, // should be called memo_sender, but is not for compatibility reasons with transfer. Is set to "from_account" for non proposals
        encrypt_memo = true,
        optional_nonce = null,
        fee_asset_id = "1.3.0",
        transactionBuilder = null
    }) {
        let unlock_promise = WalletUnlockActions.unlock();

        let memo_sender_account = propose_account || from_account;
        return Promise.all([
            FetchChain("getAccount", from_account),
            FetchChain("getAccount", to_account),
            FetchChain("getAccount", memo_sender_account),
            FetchChain("getAsset", asset),
            FetchChain("getAsset", fee_asset_id),
            unlock_promise
        ])
            .then(res => {
                let [
                    chain_from,
                    chain_to,
                    chain_memo_sender,
                    chain_asset,
                    chain_fee_asset
                ] = res;

                let chain_propose_account = null;
github bitshares / bitshares-ui / app / api / ApplicationApi.js View on Github external
to_account,
        amount,
        asset,
        memo,
        propose_account = null, // should be called memo_sender, but is not for compatibility reasons with transfer. Is set to "from_account" for non proposals
        encrypt_memo = true,
        optional_nonce = null,
        fee_asset_id = "1.3.0",
        transactionBuilder = null
    }) {
        let unlock_promise = WalletUnlockActions.unlock();

        let memo_sender_account = propose_account || from_account;
        return Promise.all([
            FetchChain("getAccount", from_account),
            FetchChain("getAccount", to_account),
            FetchChain("getAccount", memo_sender_account),
            FetchChain("getAsset", asset),
            FetchChain("getAsset", fee_asset_id),
            unlock_promise
        ])
            .then(res => {
                let [
                    chain_from,
                    chain_to,
                    chain_memo_sender,
                    chain_asset,
                    chain_fee_asset
                ] = res;

                let chain_propose_account = null;
                if (propose_account) {
github GamechainSystem / GameChainBase / GameChainBlockWallet / app / components / wallet / CreateAccount.js View on Github external
onFinishConfirm(confirm_store_state) {
        if (confirm_store_state.included && confirm_store_state.broadcasted_transaction) {
            TransactionConfirmStore.unlisten(this.onFinishConfirm);
            TransactionConfirmStore.reset();

            FetchChain("getAccount", this.state.accountName).then(() => {
                console.log("onFinishConfirm");
                this.props.router.push("/settings/backup");
            });
        }
    }
github bitshares / bitshares-ui / app / components / QuickTrade / QuickTrade.jsx View on Github external
async _setSellAsset(
        assetObjectIdOrSymbol,
        activeInput = "sellAsset",
        fireChanged = true
    ) {
        let asset = null;
        if (typeof assetObjectIdOrSymbol === "string") {
            asset = await FetchChain("getAsset", assetObjectIdOrSymbol);
        } else {
            asset = assetObjectIdOrSymbol;
        }
        if (__DEV__) {
            console.log("_setSellAsset", assetObjectIdOrSymbol, asset);
        }

        this.setState(
            {
                activeInput: activeInput
            },
            () => {
                this._routeTo(
                    asset.get("symbol"),
                    !!this.props.assetToReceive
                        ? this.props.assetToReceive.get("symbol")
github GamechainSystem / GameChainBase / GameChainBlockWallet / app / actions / WalletActions.js View on Github external
return new Promise((resolve, reject) => {

            let db = Apis.instance().db_api();
            let address_publickey_map = {};

            let account_lookup = FetchChain("getAccount", account_name_or_id);
            let unlock = WalletUnlockActions.unlock();

            let p = Promise.all([unlock, account_lookup]).then((results) => {
                let account = results[1];
                //DEBUG console.log('... account',account)
                if (account == void 0)
                    return Promise.reject("Unknown account " + account_name_or_id);

                let balance_claims = [];
                let signer_pubkeys = {};
                for (let balance of balances) {
                    let {vested_balance, public_key_string} = balance;

                    //DEBUG console.log('... balance',b)
                    let total_claimed;
                    if (vested_balance) {
github bitshares / bitshares-ui / app / components / Utility / FeeAssetSelector.jsx View on Github external
async onAssetChange(selectedAssetId) {
        const asset = await FetchChain("getAsset", selectedAssetId);
        this.setState(
            {
                feeAsset: asset
            },
            this._calculateFee.bind(this)
        );
    }
github bitshares / bitshares-ui / app / stores / AccountStore.js View on Github external
.then(data => {
                    this.state.linkedAccounts = Immutable.fromJS(
                        data || []
                    ).toSet();

                    /*
                    * If we're in cloud wallet mode, only fetch the currently
                    * used cloud mode account, if in wallet mode fetch all the
                    * accounts of that wallet for the current chain
                    */

                    let accountPromises =
                        !!this.state.passwordLogin &&
                        !!this.state.passwordAccount
                            ? [
                                  FetchChain(
                                      "getAccount",
                                      this.state.passwordAccount
                                  )
                              ]
                            : !!this.state.passwordLogin
                                ? []
                                : data
                                      .filter(a => {
                                          if (a.chainId) {
                                              return a.chainId === chainId;
                                          } else {
                                              return true;
                                          }
                                      })
                                      .map(a => {
                                          return FetchChain(
github bitshares / bitshares-ui / app / lib / common / trxHelper.js View on Github external
return new Promise(res => {
        if (assetID === "1.3.0") {
            res(true);
        } else {
            Promise.all([
                estimateFeeAsync(type, options, data),
                FetchChain("getObject", assetID.replace(/^1\./, "2."))
            ]).then(result => {
                const [fee, dynamicObject] = result;
                res(parseInt(dynamicObject.get("fee_pool"), 10) >= fee);
            });
        }
    });
}