Closed snowypowers closed 7 years ago
Sounds great! One way we might want to generalize API
is to give it enough flexibility to support multiple light wallet backends (e.g., maybe neoscan in addition to api.neonwallet). Not to be implemented now per se, but to make such integration easy in future. This would dramatically reduce the probability of the library (and wallet) breaking for end users
This refactor will split the NeonDB's API methods away from NEO RPC methods, allowing this library to be more flexible and less biased. NeonDB's methods can be seen as examples on how to use NeonJS methods.
RPC
Exposed as
Neon.rpc
orimport {rpc} from 'neon-js
RPCClient
Client.getBlock(1)
Client.query(customRequest)
.Client.execute(customQueryObject)
Client.history
Query
parseWith(parsingMethod)
to parse the response.Query.getBlock(1)
is equivalent tonew Query({method: 'getBlock, params: [1]})
Query.getBlock(1).execute('https://seed1.neo.org:10332)
API
import {api} from 'neon-js'
getAPIEndpoint
withgetRPCEndpoint
)