Open faddat opened 3 years ago
Will consider it in next version
I may contribute it. My latest piece of code really needs this, so that it presents developers with a clearer, more concise API.
The goal with schema-handler is minimalism and extensability. I hope to use it alongside software like blurtjs, web3.js and cosmjs to allow other blockchains to use the V Systems database API endpoint to store compressed json objects.
// Get bytes
let bytes = tra.toBytes();
// Get signature
let signature = acc.getSignature(bytes);
// Get json for sending tx
let send_tx = tra.toJsonForSendingTx(signature);
If we start with a json object, we should allow the developer to finish with a json object as well. Here's the prototype for the schema handler, which allows users to read and write compressed json objects from vsys:
https://replit.com/@JacobGadikian/schema-handler#index.js
In there, we can find this:
insert = {
"sender":"ARKYdc1pgGSefeCjNNkzWwnoKBVVMDYzex7",
"dbKey":"BlogPost",
"dataType":"ByteArray",
"data":proj,
"fee":100000000,
"feeScale":100
}
We should be putting all calls into a vsys.* method and functions should be exposed like:
signedinsert = vsys.signjson(insert)
Or to take it even further:
vsys.commitdb(insert)
Breaking everything into acc. trx. and chain. makes the developer think more than otherwise would be necessary.
For documentation, we can go through each function exposed on the vsys method, and we should always favor approaches that result in the developer writing as few lines of code as possible.
We may want to simply add the schema-handler to the javascript SDK.
Should be one line of code:
const vsys = require("@virtualeconomy/js-v-sdk"); const constants = vsys.constants; const node_address = "https://wallet.v.systems/api"; // change to your node address const network_byte = constants.MAINNET_BYTE; var chain = new vsys.Blockchain(node_address, network_byte);