How to use the bitsharesjs.ChainValidation.is_account_name 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 / stores / AccountStore.js View on Github external
_unlinkAccount(name) {
        if (!ChainValidation.is_account_name(name, true))
            throw new Error("Invalid account name: " + name);

        // Unlink
        iDB.remove_from_store("linked_accounts", name);
        // this.state.myActiveAccounts = this.state.myActiveAccounts.delete(name);

        // Update current account if no accounts are linked
        // if (this.state.myActiveAccounts.size === 0) {
        //     this.setCurrentAccount(null);
        // }
    }
github bitshares / bitshares-ui / app / components / Utility / ChainTypes.js View on Github external
function accountNameChecker(props, propName, componentName) {
    componentName = componentName || "ANONYMOUS";
    if (props[propName]) {
        let value = props[propName];
        if (ChainValidation.is_account_name(value)) {
            return null;
        } else {
            return new Error(
                `${propName} value of ${value} in ${componentName} is not a valid account name`
            );
        }
    }
    // assume all ok
    return null;
}
github bitshares / bitshares-ui / app / components / Account / AccountSelectorAnt.jsx View on Github external
getInputType(value) {
        // OK
        if (!value) return null;
        if (value[0] === "#" && utils.is_object_id("1.2." + value.substring(1)))
            return "id";
        if (ChainValidation.is_account_name(value, true)) return "name";
        if (this.props.allowPubKey && PublicKey.fromPublicKeyString(value))
            return "pubkey";
        return null;
    }
github bitshares / bitshares-ui / app / stores / AccountStore.js View on Github external
_linkAccount(name) {
        if (!ChainValidation.is_account_name(name, true))
            throw new Error("Invalid account name: " + name);

        // Link
        const linkedEntry = {
            name,
            chainId: Apis.instance().chain_id
        };
        try {
            iDB.add_to_store("linked_accounts", linkedEntry);
            this.state.linkedAccounts = this.state.linkedAccounts.add(
                Immutable.fromJS(linkedEntry)
            ); 
            // Keep the local linkedAccounts in sync with the db
            if (!this.state.myHiddenAccounts.has(name))
                this.state.myActiveAccounts = this.state.myActiveAccounts.add(
                    name
github bitshares / bitshares-ui / app / components / Account / AccountSelector.jsx View on Github external
getInputType(value) {
        // OK
        if (!value) return null;
        if (value[0] === "#" && utils.is_object_id("1.2." + value.substring(1)))
            return "id";
        if (ChainValidation.is_account_name(value, true)) return "name";
        if (this.props.allowPubKey && PublicKey.fromPublicKeyString(value))
            return "pubkey";
        return null;
    }
github bitshares / bitshares-ui / app / stores / AccountStore.js View on Github external
onCreateAccount(name_or_account) {
        let account = name_or_account;
        if (typeof account === "string") {
            account = {
                name: account
            };
        }

        if (account["toJS"]) account = account.toJS();

        if (account.name == "" || this.state.myActiveAccounts.get(account.name))
            return Promise.resolve();

        if (!ChainValidation.is_account_name(account.name))
            throw new Error("Invalid account name: " + account.name);

        return iDB
            .add_to_store("linked_accounts", {
                name: account.name,
                chainId: Apis.instance().chain_id
            })
            .then(() => {
                console.log(
                    "[AccountStore.js] ----- Added account to store: ----->",
                    account.name
                );
                this.state.myActiveAccounts = this.state.myActiveAccounts.add(
                    account.name
                );
                if (this.state.myActiveAccounts.size === 1) {
github GamechainSystem / GameChainBase / GameChainBlockWallet / app / components / wallet / AccountSelectInput.js View on Github external
getNameType(value) {
        if (!value) return null;
        if (value[0] === "#" && utils.is_object_id("1.2." + value.substring(1))) return "id";
        if (ChainValidation.is_account_name(value, true)) return "name";
        if (this.props.allowPubKey && PublicKey.fromPublicKeyString(value)) return "pubkey";
        return null;
    }
github bitshares / bitshares-ui / app / stores / AccountStore.js View on Github external
onRemoveAccountContact(name) {
        if (!ChainValidation.is_account_name(name, true))
            throw new Error("Invalid account name: " + name);

        if (this.state.accountContacts.has(name)) {
            const accountContacts = this.state.accountContacts.remove(name);

            ss.set(this._getStorageKey("accountContacts"), accountContacts);

            this.setState({
                accountContacts: accountContacts
            });
        }
    }
github bitshares / bitshares-ui / app / stores / AccountStore.js View on Github external
onAddAccountContact(name) {
        if (!ChainValidation.is_account_name(name, true))
            throw new Error("Invalid account name: " + name);

        if (!this.state.accountContacts.has(name)) {
            const accountContacts = this.state.accountContacts.add(name);
            ss.set(
                this._getStorageKey("accountContacts"),
                accountContacts.toArray()
            );
            this.setState({
                accountContacts: accountContacts
            });
        }
    }