QOSGroup / qweb

qos-js-sdk
Apache License 2.0
3 stars 4 forks source link

QOS JS SDK provide via GopherJS #22

Closed ewagmig closed 5 years ago

ewagmig commented 5 years ago
ewagmig commented 5 years ago

tx :

{
  "type": "qbase/txs/stdtx",
  "value": {
    "itx": [
      {
        "type": "transfer/txs/TxTransfer",
        "value": {
          "senders": [
            {
              "addr": "address1l6juaqy9fk0dps0fn5dcg4fpy36zmryp8my4ux",
              "qos": "100000",
              "qscs": null
            }
          ],
          "receivers": [
            {
              "addr": "address10xwx06gnrt3dlz7hfrx6a8wx3gyeghxm54rv7a",
              "qos": "100000",
              "qscs": null
            }
          ]
        }
      }
    ],
    "sigature": [
      {
        "pubkey": {
          "type": "tendermint/PubKeyEd25519",
          "value": "h/a8Rcm87kf2/Od5UPGffcGFMht6kDoeEr/4C8RcPuU="
        },
        "signature": "ekTFe+0JdwS41RaO+9JUtqzb4NPdoPNqPEE/CLnicXzxJUAup/X5P8Htp5hfmlwvtWoZtPDvH/8iSPwVHMUSAg==",
        "nonce": "3"
      }
    ],
    "chainid": "capricorn-3000",
    "maxgas": "100000"
  }
}
ewagmig commented 5 years ago
ewagmig commented 5 years ago

Gopherjs build large js file which could not be used by the front end. So the other step is in need to extend the cosmos/amino-js project with qos/qbase codec. Let see what would happen next~

ewagmig commented 5 years ago

The flow is clear with iteration with Wenshun and the agreements are as below:

  1. The message type could be declared and registered in cosmos/amino-js extension part with QOS special characters.

  2. Encode the message into type as input of below sign method

    // Sign a message.
    var message = nacl.util.decodeUTF8('Hello!');
    var signedMessage = nacl.sign(message, myKeyPair.secretKey);
  3. Use the corresponding marshal method e.g. QosMarshaTx to marshal the tx body into Amino Bytes

  4. Broadcast the Amino Bytes to the chain

ewagmig commented 5 years ago

The compiled js body is too large to be employed! Refer to other native js library: https://github.com/cybercongress/js-amino

ewagmig commented 5 years ago

Transaction transfer done. Continue with delegation transaction type.

ewagmig commented 5 years ago

tx :

{
    "type": "qbase/txs/stdtx",
    "value": {
      "itx": [
        {
          "type": "stake/txs/TxCreateDelegation",
          "value": {
            "Delegator": "address1u6g62jxqcjla9yzffs9kpwlyvtwyd0fk44vd8a",
            "ValidatorOwner": "address1u6g62jxqcjla9yzffs9kpwlyvtwyd0fk44vd8a",
            "Amount": "800000000",
            "IsCompound": false
          }
        }
      ],
      "sigature": [
        {
          "pubkey": {
            "type": "tendermint/PubKeyEd25519",
            "value": "39DIZhCJ8A6WBM3M9btt6kuH8yXm2l7Vm7z3R/XJsbs="
          },
          "signature": "3yfl9gCTY3YI2AHInBXYhPNje6JfAD4DfM128Rm2+zz3DFaa0/1DzEU2eqPI3mptMd1JDn7tsikD/t/TTi92Bg==",
          "nonce": "2"
        }
      ],
      "chainid": "aquarius-1000",
      "maxgas": "9223372036854775807"
    }
  }
ewagmig commented 5 years ago

then the re-delegation transaction type. tx:

{
    "type": "qbase/txs/stdtx",
    "value": {
      "itx": [
        {
          "type": "stake/txs/TxCreateReDelegation",
          "value": {
            "Delegator": "address1nrm24vxav0u58jpt04v7vtavrjjxww60x9ym7p",
            "FromValidatorOwner": "address1nrm24vxav0u58jpt04v7vtavrjjxww60x9ym7p",
            "ToValidatorOwner": "address1kv9pn2snpmue4gjr787lhaznjuxpj9vt0t34mf",
            "Amount": "10000000",
            "IsRedelegateAll": false,
            "IsCompound": false
          }
        }
      ],
      "sigature": [
        {
          "pubkey": {
            "type": "tendermint/PubKeyEd25519",
            "value": "9fpQTirTSpYNHw4qu6CdN456oEZeb5AM0PxIMRZre2s="
          },
          "signature": "Xz5rEgMr2ZYfNRnjjgk1P8WP3l+WhaJozqv4p9ykSBYO5swMHJFQ3vn/9qT/8+gUoROmlmu0pBZJVnfUGZjkAA==",
          "nonce": "7"
        }
      ],
      "chainid": "aquarius-1000",
      "maxgas": "9223372036854775807"
    }
  }
ewagmig commented 5 years ago

to be continued with the following new tx types:

ewagmig commented 5 years ago

Tianfei well continue with the latest code restructuring in QOS chain

zhangwen9229 commented 5 years ago

The Delegation transaction has been completed

ewagmig commented 5 years ago

approve tx:

{"type":"qbase/txs/stdtx","value":{"itx":[{"type":"approve/txs/TxCreateApprove","value":{"Approve":{"from":"address1v26ael2jh0q7aetuk45yqf3jcyyywg2g6wq2tv","to":"address1nzv9awha9606jp5rpqe2kujckddpyauggu56ru","qos":"10000","qscs":null}}}],"sigature":[{"pubkey":{"type":"tendermint/PubKeyEd25519","value":"lUW+X+53gcSLC1B4DvtdzoN/JmjthOJM+eZF/uKGx1k="},"signature":"e5cpV8nkb673gNiDMu+rPZEvZE3deURPunS8Up3fz1givqHWS6rRQWkOj9MLhATelywwV1NYOE06iNyiiifqAQ==","nonce":"10"}],"chainid":"aquarius-1000","maxgas":"2000000"}}
zhangwen9229 commented 5 years ago

All tx types had completed.