mahdiyari / hive-tx-js

Lightweight and complete JavaScript library for using Hive blockchain in Javascript environments such as Web or NodeJS.
MIT License
25 stars 12 forks source link

serializer #9

Closed alpertayfun closed 3 years ago

alpertayfun commented 3 years ago

Hello,

I've got serializer problem. I've tried too many request but I've got " Error: operations: No serializer for operation: c "

var params = {};
    params.username = "alpertayfun";
    const json = JSON.stringify([
        'follow',
        {
            follower: params.username,
            following: "axeman",
            what: [""], 
        },
    ]);

  const operations = [
    'custom_json',
    {
      id: 'follow',
      required_auths: [],
      required_posting_auths: [params.username],
      json: json
    }
  ]

  const tx = new hiveTx.Transaction()
  tx.create(operations).then(() => {
      console.log(tx.transaction)
      const myKey = ''
      const privateKey = hiveTx.PrivateKey.from(myKey)

      tx.sign(privateKey)
      console.log(tx.signedTransaction)
        tx.broadcast().then(res => {
            console.log("res >>>>>>")
            console.log(res)
            console.log("res >>>>>>")
        })
    })
mahdiyari commented 3 years ago

operations should be an array of operation arrays. Your operations is just one operation. Put that inside an array.

alpertayfun commented 3 years ago

But this is just one array.

 const operations = [
    'custom_json',
    {
      id: 'follow',
      required_auths: [],
      required_posting_auths: [params.username],
      json: json
    }
  ];

this is vote is working :

  const operations = [
    [
      'vote',
      {
        voter: 'alpertayfun',
        author: "steem",
        permlink: "132",
        weight: 10000
      }
    ]
  ]

My mind is confused :) Could you do an example please ?

Thanks.

mahdiyari commented 3 years ago

Your vote example is two arrays but the custom_json is one array, that's why it's not working.