Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Dexaran/a1a6ec949fb87f31b157ad3c575bd823 to your computer and use it in GitHub Desktop.
Save Dexaran/a1a6ec949fb87f31b157ad3c575bd823 to your computer and use it in GitHub Desktop.

1. DexNS improvement: token registration.

It is necessary to improve the DexNS tab functionality. "I am a token developer and I want to register my token" button should be enabled. CEW must provide a UI for registering tokens via DexNS. This includes:

  • token name (DexNS name)
  • optional token parameters: ABI, link, source code, info
  • token network

For more info read https://github.com/EthereumCommonwealth/DexNS/#how-do-i-register-my-erc20erc223-token-on-dexns

info should represent a brief description of the token.

2. Change token support functionality.

It is needed to add additional fields for tokens that are displayed at CEW. Each token should have the "info" property which will serve as a brief description of the token. Info should be implemented similarly to "question mark" that serve to display extended information about CEW UI functions (example). We will add "info" for a number of well-known tokens later. If the token is registered and loaded by DexNS, then the "info" property from DexNS must be loaded for this token.

3. Crosschain ENS/DexNS lookups.

There should be four radial buttons at the top of "Send Ether & Tokens" unlocked wallet tab: None , ENS , ECNS and DexNS. Automatic name search will be performed by that name service, which is currently selected regardless of the network.

NOTE: default network for ENS is ETH, default network for ECNS and DexNS is ETC.

4. DexNS: name management.

It is necessary to implement the possibility of managing the content of the Name of DexNS. This includes the UI for extending name, appending metadata and changing the properties of a Name. "I have a Name and I want to extend the terms of ownership" button of DexNS tab should be replaced by the button with the following text: "I want to manage my DexNS name(s)".

5. Display DexNS names.

It is necessary to display the assigned name at the unlocked balance tab / view wallet info tab.If the user does not have any name assigned, then the following link should be displayed: "You don't have a Name yet. You can register one for your address here"

@j-chimienti
Copy link

CEW Weekly Update

Summary

[x] DexNS: token registration
[x] DexNS: name management
[x] uiFunc gen / send tx to contract
[x] contract class

Note: for dev purposes, working w/ testnet contract, and added reset button.

work location: https://github.com/j-chimienti/etherwallet/tree/update/dexns

screen shot 2018-07-05 at 9 44 55 pm

  • extending name, appending metadata and changing the properties of a Name.

  • "I have a Name and I want to extend the terms of ownership" button of DexNS tab should be replaced by the button with the following text: "I want to manage my DexNS name(s)".

  • Added a reset button ( for dev purposes) which clears data and returns to home screen

DexNS: name management

screen shot 2018-07-06 at 9 21 05 am

Write:

Writing to contract generates tx and displays to user. Upon verification, it is broadcasted to network.

screen shot 2018-07-05 at 9 46 52 pm

Model

screen shot 2018-07-05 at 9 46 34 pm

https://rinkeby.etherscan.io/tx/0x933f6e55a85ad3c67eb8602bdcb845e433907e273a93268bb982ab6b2c7f57c1

Read

screen shot 2018-07-05 at 9 45 54 pm

Token Registration

Form Validation:

  • Token name is required for submittal
  • If a field is blank, is is not included in metadata link.
  • Warning is displayed if error parsing ABI.
  • input type for sourceCode and link == url.
  • nodes are option from nodes.nodesTypes

screen shot 2018-07-05 at 9 47 21 pm

https://rinkeby.etherscan.io/tx/0x5f4130dce527a589d5726c101d1f42b1c7b6613945144d660a099cc52a8993bb

Contract Class

This class provides a wrapper for contracts to handle network calls.

There is also InitContract, which get / set view properties w/ 0 inputs when created.


class Contract {


    constructor(abi, address, network) {


        this.init(abi, address, network);
    }

    init(abi, address, network) {

        this.setNetwork(network);
        this.setNode();
        this.setAbi(abi);
        this.at(address);
    }

    get contract() {

        return {
            abi: this.abi,
            address: this.address,
            network: this.network,
            node: this.node,

        };
    }


    setNetwork(_network) {

        this.network = _network.toUpperCase();
    }

    setNode(network = this.network) {


        const node = Object.values(nodes.nodeList).find(_node => _node.type === network);

        if (!node) {

            throw new Error('Invalid Request');
        } else {

            this.node = node;
        }
    }


    setAbi(_abi) {

        if (typeof _abi === 'string') {


            try {

                this.abi = JSON.parse(_abi);

            } catch (e) {


                throw new Error(`Invalid Abi \n Abi: ${_abi}`);
            }
        } else {

            if (!Array.isArray(_abi)) {

                throw new Error(`Invalid Abi, Abi is not an array: ${_abi}`);
            }
            this.abi = _abi;

        }


    }


    at(address) {


        // const validAddr = WAValidator.validate(address, this.network);
        //
        // if (!validAddr) {
        //
        //     throw new Error(`Invalid Address \n
        //     Addr: ${address}\t Network: ${this.network}`
        //     );
        // }

        // todo: remove for other networks besides eth
        this.address = ethUtil.toChecksumAddress(address);

    }

    setAddress(address) {

        this.at(address);
    }

    /*

        get balance of contract address

       @returns Promise<balance : wei | Error>
    */

    getBalance() {

        return new Promise((resolve, reject) => {


            this.node.lib.getBalance(this.address, (result) => {


                if (result.error) {

                    reject(result);

                } else {

                    const {data: {address, balance}} = result;

                    this.balance = balance;

                    resolve(this.balance);
                }
            })
        })
    }

    toString() {

        return JSON.stringify(this.contract);
    }


    // Wrapper functions for network calls


    /*

        @param funcName: string
        @param inputs Array<any>

        @param tx
        @returns Promise<>


     */
    call(funcName, {inputs = [], value = 0, unit = 'ether', from = null} = {}) {

        const tx_ = {inputs, to: this.address, network: this.network, value, unit, from};

        return ethFuncs.call(funcName, this, tx_);

    }

    genTxContract(funcName, wallet, {inputs = [], value = 0, unit = 'ether', from = null} = {}) {


        return uiFuncs.genTxContract(
            funcName,
            this,
            wallet,
            Object.assign({}, {inputs, network: this.network, to: this.address, value, unit, from})
        );


    }


    sendTx(tx) {

        return uiFuncs.sendTxContract({node: this.node, network: this.network}, tx);
    }

    handleSendTx(funcName, wallet, {inputs = [], value = 0, unit = 'ether', from = null} = {}) {

        return this.genTxContract(funcName, wallet, {inputs, value, unit, from})
            .then(tx => this.sendTx(tx));

    }

    estGasLimit(funcName, tx) {

        return ethFuncs.estGasContract(funcName, this, tx);
    }


}

@Dexaran
Copy link
Author

Dexaran commented Jul 10, 2018

@j-chimienti

  1. Please, send a Pull Request so that I can merge the updates into CEW repo.

  2. Name expire date is not human-readable. It is necessary to display (1) name expire date in date format (not unix seconds) and (2) remaining time in days/ hours/ minutes format (example before the name ownership expires: 10 days 11 hours 48 minutes)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment