virtualeconomy / js-v-sdk

[DEPRECATED and please use https://github.com/virtualeconomy/js-vsys instead] Java Script library for V Systems
https://www.npmjs.com/package/@virtualeconomy/js-v-sdk
MIT License
10 stars 5 forks source link

Readme / Docs #31

Open faddat opened 3 years ago

faddat commented 3 years ago

Currently, the documentation is not very clear, we should reorganize the readme.md file.

Is there a difference between height and last block?

Both return

Height:

{ height: 15191818 }
{ height: 15191818 }

If these do not do exactly the same thing then we need to explain that. If these do exactly the same things, sometime later we should remove one or the other.

We should compare competing library's for usability. In general, we require users to write too much code in order to do relatively simple things like send our native token. We should try to reduce simple tasks to just one line of code wherever possible. The amount of boiler plate that is currently necessary for each simple function it's too high and will likely slow development, we can reduce this with some abstraction.

SheldonYS commented 3 years ago

Could you show me the JS code? The last block should return block info, such like:

{
  "version": 1,
  "timestamp": 1604544900003762000,
  "reference": "2WvGt89qxhaeExpmMwFK9CxzXFn4Zi4PMAXAMBhDKt6zq9oLzLiMmHPHwZEqKnZbzLyFPUaPqBbeVDa3XT6oQV7j",
  "SPOSConsensus": {
    "mintTime": 1604544900000000000,
    "mintBalance": 11565742414304616
  },
  "resourcePricingData": {
    "computation": 0,
    "storage": 0,
    "memory": 0,
    "randomIO": 0,
    "sequentialIO": 0
  },
  "TransactionMerkleRoot": "FCiH7QNWj67NFHdz3TH3FNRPaeRPLREQzyJwD85Cdbpy",
  "transactions": [
    {
      "type": 5,
      "id": "8oeHKS1ZtwFX9NDgTpjgn1c1NTnvGiXUhTvrJN4sBdma",
      "recipient": "AR9HkoAwWns8NjruWoYJ2CEWGCYrjFZCVpE",
      "timestamp": 1604544900003762000,
      "amount": 3600000000,
      "currentBlockHeight": 15229571,
      "status": "Success",
      "feeCharged": 0
    }
  ],
  "generator": "ARAyzTJewPDkTy2SgoS4GAUc6Y6ugKpL5uu",
  "signature": "5AwAEECGTvkm2up9DDLTmaKQQTLLZrtYU8JRrqQZVrxHSN9mD1jq2TNCa3tk5TTWjtHnnzAREaYXPJqbbxsANdAW",
  "fee": 0,
  "blocksize": 330,
  "height": 15229571,
  "transaction count": 1
}

To manage both Hot Wallet and Cold Wallet usage cases, the SDK separates sending token into small unit actions. How would you like to reduce usage code? I'm glad to hear a solution.

faddat commented 3 years ago

This is just one example, I will create others in the next two weeks and we can figure out the best path:

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);

Could become

const vsys = require("@virtualeconomy/js-v-sdk"); var chain = new vsys.Blockchain("mainnet");

...or approximately that. The rest can be assumed as defaults.

We can do similar stuff for registercontract, etc

The goal is to make it more difficult for developers to make mistakes and to reduce the total lines of code needed to implement basic applications.