mnin / coinbase-moneymoney

Fetches balances from Coinbase API and returns them as securities
MIT License
23 stars 3 forks source link

Currency error in line 70 #16

Open itst opened 6 months ago

itst commented 6 months ago

Hi Martin!

When I try to update my Coinbase account, some data transformation regarding the currency as returned from Coinbase breaks the script.

The Log reads as follows:

21:21:04  Lade Kontenliste ...
          Web Banking Engine: Using user-supplied extension Coinbase.lua version 1.80.`
          Protocol version: Web Scraping
          Server address: https://api.coinbase.com
          Sending: GET https://api.coinbase.com/v2/user
21:21:05  Received: {"data":{"id":"XXX","name":"XXX","username":null,"profile_location":null,"profile_bio":null,"profile_url":null,"avatar_url":"https://images.coinbase.com/XXX","resource":"user","resource_path":null}}
          Web Banking account: Coinbase (Main)
          Lade Wertpapierbestand für Coinbase ...
          Sending: GET https://api.coinbase.com/v2/accounts?limit=100
21:21:06  Received:

{"data":[{"id":"XXX","name":"FET Wallet"{
  "data": [
    {
      "id": "XXX",
      "name": "FET Wallet",
      "primary": true,
      "type": "wallet",
      "balance": {
        "amount": "0.00000000",
        "currency": "FET"
      },
      "created_at": "2021-12-23T21:09:02Z",
      "updated_at": "2024-02-24T23:47:16Z",
      "resource": "account",
      "resource_path": "/v2/accounts/08bb7d13-3dde-5e89-ad3a-cdc6451af44d",
      "currency": {
        "asset_id": "3672ab4a-25e0-57a8-b029-99239c081958",
        "code": "FET",
        "color": "#1D2743",
        "exponent": 8,
        "name": "Fetch.ai",
        "slug": "fetch",
        "type": "crypto",
        "rewards": null
      },
      "allow_deposits": true,
      "allow_withdrawals": true
    }
  ],
  "pagination": {
    "ending_before": null,
    "limit": 100,
    "next_starting_after": null,
    "next_uri": null,
    "order": "desc",
    "previous_ending_before": null,
    "previous_uri": null,
    "starting_after": null
  },
  ...
}
           Coinbase.lua:70: attempt to concatenate upvalue 'currency' (a nil value)

Is this an issue with the Coinbase API?

Any hints appreciated!

Best Sascha

mnin commented 5 months ago

Hey Sascha,

I tested a few things but could not reproduce this error. Can you share the first call response (anonymized) to https://api.coinbase.com/v2/user?

Thanks, Martin

itst commented 5 months ago

Here you go:

{
  "data": {
    "id": "1de9adbe-7976-5bb1-98db-XXXXXXXXXXXX",
    "name": "Sascha Carlin",
    "username": null,
    "profile_location": null,
    "profile_bio": null,
    "profile_url": null,
    "avatar_url": "https://images.coinbase.com/avatar?h=5a228bad2c9c39031e3cbxpHWpBugIBfvxBwAo8HTOWOz43LlJSR0tGyB1RW%0A0pRS&s=128",
    "resource": "user",
    "resource_path": null
  }
}

Seems ok to me?

mnin commented 5 months ago

Thank you, do you have a Currency on the https://accounts.coinbase.com/profile page?

Like this:

Screenshot 2024-05-02 at 20 45 18
itst commented 5 months ago

Yep, same as in your example:

image
mnin commented 5 months ago

Interesting, how old is your account at Coinbase?

mnin commented 5 months ago

And which API version do you see on this page? https://www.coinbase.com/settings/api

mnin commented 5 months ago

May we need to adopt the new API and OAuth too, the call is somehow removed and legacy: https://docs.cloud.coinbase.com/sign-in-with-coinbase/docs/api-users

itst commented 5 months ago

API-Version: 2024-01-17

My account is … at least nine years old.

itst commented 5 months ago

BTW, I am experiencing this error since Jan 17th 2024.

mnin commented 5 months ago

Okay, thank you for sharing. I need to investigate here with the new API version.