CityOfZion / neon-js

Javascript libraries that allow the applications to interact with NEO blockchain
https://docs.coz.io/neo3/neon-js/index.html
MIT License
184 stars 166 forks source link

nep5.getToken throws an error on no balance #104

Closed slipo closed 6 years ago

slipo commented 6 years ago

This may be a bug or may just be something we should document more. Below is a little snippet that shows an address working and returning a balance on TestNet. On MainNet this code throws an exception apparently because there's no balance. Is this expected or should it return the correct token info + a 0 balance?

    const [_ignore1, mainNetRpcEndpoint] = await asyncWrap(api.neonDB.getRPCEndpoint("MainNet"))
    const mainNetRpxScriptHash = 'ecc6b20d3ccac1ee9ef109af5a7cdb85706b1df9'
    const addressWithRpxTestNetOnly = 'ALq7AWrhAueN6mJNqk6FHJjnsEoPRytLdW'
    const [mainNetErr, mainNetTokenResults] = await asyncWrap(api.nep5.getToken(mainNetRpcEndpoint, mainNetRpxScriptHash, addressWithRpxTestNetOnly))
    if (mainNetErr) {
      console.log('We get here because on MainNet balance is empty')
    }

    const [_ignore2, testNetRpcEndpoint] = await asyncWrap(api.neonDB.getRPCEndpoint("TestNet"))
    const testNetRpxScriptHash = '5b7074e873973a6ed3708862f219a6fbf4d1c411'
    const [testNetErr, testNetTokenResults] = await asyncWrap(api.nep5.getToken(testNetRpcEndpoint, testNetRpxScriptHash, addressWithRpxTestNetOnly))
    if (testNetErr) {
      console.log('We DO NOT get here because on TestNet we have a balance')
    }
snowypowers commented 6 years ago

yes bug. I know whats wrong, will fix and patch

snowypowers commented 6 years ago

fixed with 2.2.1