Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

SyntaxError: Unexpected identifier when using await. it shall be used along with async. Readme needs an update #91

Closed
SaifRehman opened this issue Mar 8, 2018 · 3 comments

Comments

@SaifRehman
Copy link

No description provided.

@SaifRehman
Copy link
Author

@keppel What are these function. I get these when i do this.
var connect = require('lotion')
let GCI = '91d61db1dce394931297b59d584eb723b8009c40d72bb8ec8aeccf4a9ba008b1'
async function send(){
return (await connect(GCI))
}

send().then(function(state){
var txs = async function(){
let result = await send ({ nonce: 0 }).then(function(data){
console.log(data);
})
}();
})
screen shot 2018-03-08 at 1 27 48 pm
So I can access blockchain

  1. tendermint rpc (this actually works)
  2. GCI (I can access through gci but not familiar on how to call the function to txs on blockchain, readme is not updated on this)

@ameeuw
Copy link

ameeuw commented Mar 8, 2018

The connect() method actually returns a few methods (getState() and send()) itself which you can utilise:

let { connect } = require('lotion')

async main() => {
    // Create lightclient via lotion's connect() method
    let lc = await connect(null, { genesis, nodes })

    // Get the current state via the lightclient's getState() method
    let currentState = await(lc.getState())
    console.log(currentState)

    // Send a transaction via the send() method
    let tx = {'key': 'your_tx_object_here'}
    let response = await lc.send(tx)
    console.log(response)
}

main()

I hope this helps.

@SaifRehman
Copy link
Author

@ameeuw I am getting this error
(node:40737) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Data must be a string or a buffer
(node:40737) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@keppel keppel closed this as completed Mar 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants