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

possible bug with using on decoding Json #68

Closed
kingsleyh opened this issue Aug 7, 2018 · 2 comments
Closed

possible bug with using on decoding Json #68

kingsleyh opened this issue Aug 7, 2018 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@kingsleyh
Copy link

kingsleyh commented Aug 7, 2018

I have a some Records used for Decoding:

record AddressTransactionsResponse {
  result : Array(Kajiki.Transaction),
  status : String
}

record Kajiki.Sender {
  address : String,
  publicKey : String using "public_key",
  amount : Number,
  fee : Number,
  signr : String using "sign_r",
  signs : String using "sign_s"
}

record Kajiki.Recipient {
  address : String,
  amount : Number
}

record Kajiki.Transaction {
  id : String,
  action : String,
  senders : Array(Kajiki.Sender),
  recipients : Array(Kajiki.Recipient),
  message : String,
  token : String,
  prevHash : String using "prev_hash",
  timestamp : Number,
  scaled : Number
}

and then using it:

  json =
        Json.parse(response.body)
        |> Maybe.toResult("Json parsing error")

      item =
        decode json as TransactionResponse

      txn =
        item.result

      next {transaction1 = Maybe.just(txn) }
    } catch Http.ErrorResponse => error {
      next { error = "Could not retrieve remote wallet information" }
    } catch String => error {
      next { error = "Could not parse json response" }
    } catch Object.Error => error {
      next { error = "could not decode json" }
    }

the json looks fine - but it cannot decode. Instead I get a cryptic javascript error in the console saying

 ReferenceError: $$Kajiki is not defined
    at Function.$$AddressTransactionsResponse.decode (index.js:34460)
    at index.js:37451

the catch lines don't catch anything. this was working fine with from so I suspect it's a bug with using

@kingsleyh
Copy link
Author

I found a workaround for this now - which is to not separate the record names with dots: so

Kajiki.Transaction becomes KajikiTransaction etc

I don't know if this behaviour is intended - but it was working before the update.

@gdotdesign gdotdesign added the bug Something isn't working label Aug 8, 2018
@gdotdesign gdotdesign self-assigned this Aug 8, 2018
@gdotdesign
Copy link
Member

Thanks for reporting! Fixed by 477c629

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants