nos / create-nos-dapp

CLI tool to generate a new nOS dApp
53 stars 35 forks source link

Invoking Smart Contract from dApp #5

Closed syedasifraza closed 6 years ago

syedasifraza commented 6 years ago

Invoketest SC from dApps via nOS client: When trying to invoke domain service SC and passed following args: const neoAuth = "0xe60a3fa8149a853eb4dff4f6ed93c931646a9e22"; const operation = "RegisterDomain"; const args = [ 'AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y', 'bucket.nos', 'AK2nJJpJr6o664CWJKi1QRXjqeic2zRp8y', 'https://ihasabucket.com/' ];

Expected Behavior

It should invoke SC and write the new entries (as given in args) on blockchian and return results properly. Such as True in case operation successful or False in case operation failed.

Current Behavior

At present, I think args from dApp is not properly readable by nOS client.

Possible Solution

We need to change the following thing in our dApp starter kit:

  1. "const neoAuth" to "const contractHash" because it is contract hash.
  2. In /src/nos/index.js changes: // Smart Contract Actions testInvoke: (scriptHash, operation, args) => nos.testInvoke(scriptHash, operation, ...args), invoke: (scriptHash, operation, args) => nos.invoke(scriptHash, operation, ...args),
  3. Instead of return hexString in popup windows, nOS client should return True or False.

Context

I am trying to test dApp full functionality via nOS client but still facing some issues of communication with blockchain by using nOS client.

Your Environment

DalderupMaurice commented 6 years ago

I thought @jeroenptrs was already trying to find a solution as many people seem to encounter this problem, what's the status of this? @jeroenptrs

Anyways, thank you very much for reporting it and following the issue template. We'll lock our eyes on fixing this issue :)

syedasifraza commented 6 years ago

@DalderupMaurice thanks, yes he almost resolved that issue and guided me. But still we have to check why entries are not written on blockchain when submitting invoketest requests.

jeroenptrs commented 6 years ago

@syedasifraza testinvokes are never persisted to the blockchain, only regular invokes. This will be updated this week. I'm externalizing the nOS functions to an NPM package to support starter kits in other frameworks as well and the starter kit will be updated alongside it.

Can you verify it DOES persist when using an actual invoke?

syedasifraza commented 6 years ago

In normal case when I perform invoketest directly from NEO> prompt, invoketest is not persistent until and unless I provide the correct password of wallet. But when we provides the correct wallet's password then it will be persistent on blockchain. Do we really need such password option in nOS or dApp? Wallet password: coz

DalderupMaurice commented 6 years ago

testInvoke simulates the results of persisting to the blockchain but does NOT actually persist to the blockchain

jeroenptrs commented 6 years ago

@syedasifraza testinvoke in nOS is different than testinvoke in neo-python, where entering your password resends it as an actual invoke. In neon-js, and thus in nOS as well, those functions are separated: testinvoke and invoke are two separate functions in the nOS client.

jeroenptrs commented 6 years ago

There changes are now added to the starter kit with our own NPM package @nosplatform/api-functions. Should any errors occur we can reopen this issue but for now I'm closing this.