CityOfZion / neon-js

Javascript libraries that allow the applications to interact with NEO blockchain
https://docs.coz.io/neo3/neon-js/index.html
MIT License
184 stars 166 forks source link

[NEO 3.0] neon-js should support the coming NEO 3.0 #441

Closed MorganDream closed 2 years ago

MorganDream commented 5 years ago

NEO 3.0 road map is released. And hopefully NEO 3.0 testNet will come out in this July. NEO plans to draw lots of communities and developers to develop tools and dApps on 3.0 testNet, in which SDK will act an important role.

Now NGD members are developing 3.0 C# SDK in project neo: https://github.com/neo-project/neo/pull/850. I think neon-js should be upgraded for 3.0 at the same time, because neon-js developers could request support from developers of C# SDK, as they could modify core codes properly to support SDK if necessary.

MorganDream commented 5 years ago
_**UPDATED ON 26/07/19**_

NEO3 Proposal for NEON-JS

Current Structure of neon-js

neon-js NEO3 version

Targets:

To support NEO3 in neon-js.

NEO3 features

Documents: https://github.com/Tommo-L/NEO3-Development-Guide NEO3 are still in development phase. Below I list some already-merged change.

Timeline

Plan

Structure of neon-js for NEO3

neon-js NEO3 version (1)

Any suggestions and comments would be appreciated.

snowypowers commented 5 years ago

I think depending on how the native assets are reimplemented, we might consider merging nep5 into the core set of modules.

Also, with regards to publishing, we can either use a new namespace (cityofzion/neon3-js?) or just do a breaking change with v5 being the the compatible version with neo 3.x.

I doubt smartContract will end up under neon-api as that is a module for data integration.

neon-js itself actually contains the fluent method naming structure, not neon-api.

MorganDream commented 5 years ago

@snowypowers Thanks for your reply.

I think depending on how the native assets are reimplemented, we might consider merging nep5 into the core set of modules.

Core part of NEO3 is already implemented. NEO and GAS are nep5 for sure. NEO & GAS are native contract, which meets NEP5 standard. And they have extra methods.

Also, with regards to publishing, we can either use a new namespace (cityofzion/neon3-js?) or just do a breaking change with v5 being the the compatible version with neo 3.x.

I suggest the latter. Here's my plan:

I doubt smartContract will end up under neon-api as that is a module for data integration. neon-js itself actually contains the fluent method naming structure, not neon-api.

I plan to integrate sc, tx and rpc in SmartContract module. Every smart contract can be a SmartContract instance. To invoke a smart contract function, just call SmartContractInstance.invoke(method, params). NEP5 module will extend SmartContract. Invoke it like NEP5Instance.transfer(from, to, amount); NEO and GAS will be NEP5 instances for user to invoke.

So SmartContract is kind of high level API, so I put it into neon-api.

snowypowers commented 5 years ago
  1. Will there be a need to support neo2 and neo3 together in a single release? The alternative here is to continue publish neo2 under latest tag and neo3 under neo3 tag until we do the flip. It is possible to install 2 versions of the same package with npm for those who wish to support both chains together.

  2. From the way you describe it, SmartContract sounds like a low level module but I guess I can see what is inside before I comment.

MorganDream commented 5 years ago

@snowypowers

  1. The idea of using tags to separate neo2 and neo3 sounds good.
  2. Yes. SmartContract is kind of combination of high level and low level, because NEP5 will extend it. And instance design is not fit for multiple intents transaction. I'll think more and start from core level API.
MorganDream commented 5 years ago

https://github.com/CityOfZion/neon-js/blob/8972f6fefdf8dcc452afdaf637355a4a9615659b/packages/neon-api/src/funcs/main.ts#L42-L50 @snowypowers How about employing generator to replace this promise style in NEO3 high level API? So that user can have more control over the flow(like using different param according to certain middle state), and he can add parameters gradually instead of passing params all at once.

MorganDream commented 5 years ago

Now that low level APIs are merged into next branch. And I have now several design points which need suggestions:

Any suggestions would be welcomed.

snowypowers commented 5 years ago

For fees, since its going to be inaccurate to calculate the fees, I rather not do anything offline. We can add another step after constructing the transaction to add the fees.

With regards to 469, its too many features. Lets start with the TransactionBuilder which is pretty essential and build up the workflow first.

Not clear on the structure of NetProvider, it looks a little weird that you have Entity Provider inherit off it. Having a facade is a good use case though.

MorganDream commented 5 years ago

@snowypowers A NetProvider instance is a net-specific(mainnet, testnet, privatenet) provider that can deal with some read request(e.g. balance, height) with neo, in which case an account(private key) is not needed. An EntityProvider is not just net-specific, but also account-specific, which can also write data on neo - sending transactions.

Considering most cases where user use sdk with specific net and specific accounts, it is not necessary to isolate all the requests, the network info and account info are usually fixed. That's the point for this design.

Tommo-L commented 4 years ago

It's recommend to set the contact information about the contract in manifest file, as neo3 have moved those properties, replaced by Extra field in manifest file.

neo-project/neo#1246