Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proper way to find out transaction type in BNB block response #2

Open
YordanPavlov opened this issue Aug 5, 2019 · 4 comments
Open
Labels
enhancement New feature or request

Comments

@YordanPavlov
Copy link
Contributor

This is more of a question than a bug report. I am investigating the proper way to find out that a transaction is either Transfer, PlaceOrder or CancelOrder. For example the response for block number 1675624 looks like so:

  "data": {
    "txs": [
      "0QHwYl3uClcWbmgbChQuWkaHZ7auJklLB/2D3jU9pDqcGBIMTUlUSC1DNzZfQk5CGi0yRTVBNDY4NzY3QjZBRTI2NDk0QjA3RkQ4M0RFMzUzREE0M0E5QzE4LTEzOTMScAom61rphyEDOF/+FGN7KGHRLSAjgklqmU2HytDmBpVzSQel4mPXhK0SQJ1VWVNwyZcVP4jdU5BkmasjCvj9XXh+kVav22mbzgkIRYxRnzUQFeFr+f5g3PrJp5Muhv+m5Pf8rl8g7Bcean0Y8gUg/QogAw==",
      "4gHwYl3uCmjObcBDChQ5gxX3iAGQO700xCvwmaTWpeXTlxItMzk4MzE1Rjc4ODAxOTAzQkJEMzRDNDJCRjA5OUE0RDZBNUU1RDM5Ny0xMTI1GgxNSVRILUM3Nl9CTkIgAigBMISRDjiA0I3AkhhAARJwCibrWumHIQMsx1J1eWZeFQP1hDa5pZlEFbtWX3ZxVnAPFLQJ8TPbshJA58WuHDJfFc1Km5dxUIkT97lvByNfYyEqxTzr34BfS2IGbDl4/esmVpNUwTcCew+naYpN+uPazjFyaXjY4HpMYhjzBSDkCCAD",
      "4gHwYl3uCmjObcBDChTkgZtIllLDN+FImM1f4L0nY3PhJRItRTQ4MTlCNDg5NjUyQzMzN0UxNDg5OENENUZFMEJEMjc2MzczRTEyNS0xNjE3GgxNSVRILUM3Nl9CTkIgAigBMJnQDjiApOiujxJAARJwCibrWumHIQMuE8JaXBNga6hZX+nAihtky08q1hO5WZohXAdgwsUbGBJAi+fInpJE4dv6xR8pPnUMokRG2vgKXHDptW4Lw0pT3ApDEqKAUg6IcX5d2J12KMFCpeZdWRnBAeG0IdeHZ4LHhhj0BSDQDCAD"
    ]

Trying to decode the first of those transactions as all of the possible types returns meaningful result. The results are like so:

Transfer is { inputs: [ { address: , coins: [Array] } ],
outputs: [ { address: , coins: [Array] } ],
msgType: 'MsgSend' }
Place order is: { sender: <Buffer 2e 5a 46 87 67 b6 ae 26 49 4b 07 fd 83 de 35 3d a4 3a 9c 18>,
id: 'MITH-C76_BNB',
symbol: '2E5A468767B6AE26494B07FD83DE353DA43A9C18-1393',
ordertype: 112,
side: 38,
price: 0,
quantity: 0,
timeinforce: 0,
msgType: 'NewOrderMsg' }
Cancel order is: { sender: <Buffer 2e 5a 46 87 67 b6 ae 26 49 4b 07 fd 83 de 35 3d a4 3a 9c 18>,
symbol: 'MITH-C76_BNB',
refid: '2E5A468767B6AE26494B07FD83DE353DA43A9C18-1393',
msgType: 'CancelOrderMsg' }
{}

As there is nothing in the response specifying the type, what would be the proper way to find it out.

Thanks!

@antoncoding
Copy link
Owner

I'm thinking about adding a try-catch logic to iterate through all the types. Any better idea?

@antoncoding antoncoding added the enhancement New feature or request label Sep 13, 2019
@antoncoding
Copy link
Owner

@YordanPavlov I've updated the decoder as a separate npm library.
The new interface here use different functions to handle different type of tx, and change decode into a try-catch test for all available types.
I'm also thinking about adding more types and run it with a loop.

@YordanPavlov
Copy link
Contributor Author

@antoncoding Thanks Anton, but I guess my original question still stands, what would be the way to know if I should call decodeTransfer or decodePlaceOrder or other. Thanks!

@antoncoding
Copy link
Owner

@YordanPavlov you're right. I guess I must support all the tx types to solve this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants