Giter Site home page Giter Site logo

lens's People

Contributors

ajay-prak avatar arthelon avatar claudiucelfilip avatar doug-perlin avatar iwasaki-kenta avatar pisuthd avatar yayalu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lens's Issues

Opt for using Lens with a different private key.

Upon opening up Lens, we should prompt users for their private key which may be specified in a text input box as a hex string.

The private key will be passed to the Perlin instance, and all API calls/session instantiation will thereafter be done under a given private key.

Balance is not accurately reflected

In the Himitsu branch, the account api is returning

{
"public_key":"e919a3626df31b6114ec79567726e9a31c600a5d192e871de1b862412ae8e4c0",
"balance":9999999383999825315,
"gas_balance":0,"stake":0,"reward":0,"is_contract":false
}

but the resulting balance displayed is 9,999,999,383.999826 PERLs
2019-12-06-113601_1322x85_scrot

Most probably a rounding error somewhere, but definitely problematic.

Unable to logout until connection fails

Lens does not allow to logout if you enter an incorrect API URL by mistake until the request has failed. A minor issue but can be annoying.

Steps to reproduce:
1 - Login to Lens using an incorrect API URL such as test.perlin.net
2 - Try to logout. It should fail
3 - wait for a few moments until you see the red connection error.
4 - Try again and now you can logout successfully.

Gas price for transactions are no longer fixed values

As of Wavelet v0.2.0, the gas cost of a transaction has increased to be proportional to its size instead of the single fixed value of 2 (in units of kens) in versions prior to v0.2.0

Currently, a transfer operation takes 15 kens and it might be sufficient to use that value instead of 2 for the gas cost of a transfer, but smart contract calls will need to be handled in a more complex way.

Move codebase to new Create React App project

There have been some dependency problems appearing around wavelet-dev-server.
Since it's harder to manually fix each dependency it's better to create a new CRA project and copy current codebase into it.

First load results in blank screen

Currently, on the Himitsu branch, when you open lens for the first time it results in a blank blue screen.
2019-12-06-120043_1919x978_scrot

Console has a couple of "Max call stack exceeded" errors:

2.45465cb8.chunk.js:1 [mobx] Encountered an uncaught exception that was thrown by a reaction or observer component, in: 'Reaction[Reaction@8]' RangeError: Maximum call stack size exceeded
    at L (2.45465cb8.chunk.js:1)
    at t.get [as notification] (2.45465cb8.chunk.js:1)
    at t.get [as notification] (2.45465cb8.chunk.js:1)
    at t.get [as notification] (2.45465cb8.chunk.js:1)
    at t.get [as notification] (2.45465cb8.chunk.js:1)
    at t.get [as notification] (2.45465cb8.chunk.js:1)
    at t.get [as notification] (2.45465cb8.chunk.js:1)
    at t.get [as notification] (2.45465cb8.chunk.js:1)
    at t.get [as notification] (2.45465cb8.chunk.js:1)
    at t.get [as notification] (2.45465cb8.chunk.js:1)
A.reportExceptionInDerivation @ 2.45465cb8.chunk.js:1
A.track @ 2.45465cb8.chunk.js:1
v @ 2.45465cb8.chunk.js:1
(anonymous) @ 2.45465cb8.chunk.js:1
A.runReaction @ 2.45465cb8.chunk.js:1
...
(anonymous) @ main.e33f414b.chunk.js:1
Show 6 more frames
2.45465cb8.chunk.js:1 RangeError: Maximum call stack size exceeded
    at L (2.45465cb8.chunk.js:1)
    at t.get [as api] (2.45465cb8.chunk.js:1)
    at t.get [as api] (2.45465cb8.chunk.js:1)
    at t.get [as api] (2.45465cb8.chunk.js:1)
    at t.get [as api] (2.45465cb8.chunk.js:1)
    at t.get [as api] (2.45465cb8.chunk.js:1)
    at t.get [as api] (2.45465cb8.chunk.js:1)
    at t.get [as api] (2.45465cb8.chunk.js:1)
    at t.get [as api] (2.45465cb8.chunk.js:1)
    at t.get [as api] (2.45465cb8.chunk.js:1)
vo @ 2.45465cb8.chunk.js:1
So.t.callback @ 2.45465cb8.chunk.js:1
xi @ 2.45465cb8.chunk.js:1
_i @ 2.45465cb8.chunk.js:1
Da @ 2.45465cb8.chunk.js:1
e.unstable_runWithPriority @ 2.45465cb8.chunk.js:1
...
(anonymous) @ main.e33f414b.chunk.js:1
2.45465cb8.chunk.js:1 Uncaught RangeError: Maximum call stack size exceeded
    at L (2.45465cb8.chunk.js:1)
    at t.get [as api] (2.45465cb8.chunk.js:1)
    at t.get [as api] (2.45465cb8.chunk.js:1)
    at t.get [as api] (2.45465cb8.chunk.js:1)
    at t.get [as api] (2.45465cb8.chunk.js:1)
    at t.get [as api] (2.45465cb8.chunk.js:1)
    at t.get [as api] (2.45465cb8.chunk.js:1)
    at t.get [as api] (2.45465cb8.chunk.js:1)
    at t.get [as api] (2.45465cb8.chunk.js:1)
    at t.get [as api] (2.45465cb8.chunk.js:1)

Run smart contract functions.

Here is a function, given a WebAssembly smart contract as a file input, that will list out all exported contract functions of said contract.

private onLoadContract = async (event: any) => {
        if (this.store.file === null) {
            return;
        }

        const reader = new FileReader();

        const bytes = await new Promise((resolve, reject) => {
            reader.onerror = () => {
                reader.abort();
                reject(new DOMException("Failed to parse contract file."))
            }

            reader.onload = () => {
                resolve(reader.result as any);
            }

            reader.readAsArrayBuffer(this.store.file as Blob);
        });

        // @ts-ignore
        const contract = await WebAssembly.instantiate(bytes, {
            env: {
                _payload_len: () => 0, _payload: () => 0, _provide_result: () => 0, _send_transaction: () => 0
            }
        });

        const contractPrefix = "_contract_";

        let exportedFunctions = _.filter(Object.keys(contract.instance.exports), exp => exp.startsWith(contractPrefix));
        exportedFunctions = _.map(exportedFunctions, exp => exp.substr(contractPrefix.length));
        console.log(exportedFunctions);
    }

Smart contract functions have parameters and return payloads as byte arrays. They are executed in the context of the transactions sender.

A UI component is needed to specify a list of parameters, and to parse the return payloads of a contracts execution. The return payload of a transaction is collected by locally executing the smart contract function on the client-side.

An option exists to also directly send the smart contract function call transaction as-is to the ledger via /transaction/send.

Example parameters and result for a function that sends some money to a recipient:

Function name: _contract_transfer
Function params: [(String) "recipient wallet address here", (unsigned int 64) 100]
Function return results: [(boolean which is an unsigned 8-bit int) true]

All data types are laid out to be little-endian.

The smart contract function transfer is defined in Rust as:

 fn transfer(&mut self, params: &mut Parameters) -> Option<Payload> {
        let recipient: Vec<u8> = params.read();
        let amount: u64 = params.read();

        let mut result = Payload::new();

        let sender_balance = match self.balances.get(&params.sender) {
            Some(balance) => *balance,
            None => 0
        };

        // Throw an error if the sender does not have enough balance.
        if sender_balance < amount {
            result.write(&false);
            return Some(result);
        }

        let recipient_balance = match self.balances.get(&recipient) {
            Some(balance) => *balance,
            None => 0
        };

        // Modify balances.
        self.balances.insert(params.sender.clone(), sender_balance - amount);
        self.balances.insert(recipient, recipient_balance + amount);

        // Return `true` to the sender that the transfer was successful.
        result.write(&true);
        return Some(result);
    }

Strings are laid out to end with a termination character \0:

impl Writeable for String {
    fn write_to(&self, buffer: &mut Vec<u8>) {
        for x in self.chars() {
            x.write_to(buffer);
        }

        '\0'.write_to(buffer);
    }
}

Byte arrays (Vec) are prefixed with their length:

impl<T: Writeable> Writeable for Vec<T> {
    fn write_to(&self, buffer: &mut Vec<u8>) {
        self.len().write_to(buffer);

        for x in self {
            x.write_to(buffer);
        }
    }
}

Booleans are 8-bit unsigned integers that are either 0 or 1.

Select different API endpoints to connect to.

Right now the API endpoint for Wavelet is hard-coded in.

We should provide a prompt to input and connect to different Wavelet HTTP API endpoints, and also save all endpoints down to browser local storage.

Developers page: Sync Contract with URL

If there's a contract ID in the URL, the page will load and highlight that Contract.
Searching for a contract ID will move the user to the Developer page with the contract highlighted.

Remove JSBI use in Lens

Since wavelet-client can now accept strings for numeric parameters, and there's another similar purpose library (bignumber.js) we should remove JSBI to simplify the code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.