bennycode/coinbase-pro-node

Is TransferInformation Interface Incorrect?

Closed this issue · 2 comments

Hello again, it may be rooting in the same situation - server-side key, but I have to ask of you know anything about it.

I'm retrieving the withdrawals like this:

const auth = {
    apiKey: process.env.COINBASE_API_KEY || "",
    apiSecret: process.env.COINBASE_API_SECRET || "",
    passphrase: process.env.COINBASE_API_PASSPHRASE || "",
    useSandbox: false,
};

const coinbase = new CoinbasePro(auth);
const withdrawals = await coinbase.rest.transfer.getTransfers(TransferType.WITHDRAW, profile?.id)

The TransferInformation interface looks like this (notice there is no optional fee or network or subtotal or tx_service_transaction_id attribute in details):

export interface TransferInformation {
    account_id: string;
    amount: string;
    canceled_at?: ISO_8601_MS_UTC;
    completed_at?: ISO_8601_MS_UTC;
    created_at: ISO_8601_MS_UTC;
    details: {
        coinbase_account_id?: string;
        coinbase_payment_method_id?: string;
        coinbase_transaction_id?: string;
        coinbase_withdrawal_id?: string;
        crypto_address?: string;
        crypto_transaction_hash?: string;
        crypto_transaction_id?: string;
        destination_tag: string;
        destination_tag_name?: string;
        sent_to_address?: string;
    };
    id: string;
    processed_at?: ISO_8601_MS_UTC;
    type: string;
    user_id: string;
    user_nonce?: string;
}

But the transaction looks like this:
Those fields are present.

{
  "id": "00000000-0000-0000-a249-9f72b3e373b4",
  "type": "withdraw",
  "created_at": "2023-00-00 20:07:49.929025+00",
  "completed_at": "2023-00-00 20:12:09.972825+00",
  "account_id": "00000000-0000-0000-8b8b-5065a0a3c1e5",
  "user_id": "000000000000000000087b7a",
  "amount": "904.26148600",
  "details": {
    "fee": "4.261486",
    "network": "ethereum",
    "subtotal": "900",
    "sent_to_address": "0xe000000000000000000058f8494b3bdf7cedd516",
    "coinbase_account_id": "00000000-0000-0000-8ac2-fd4cb3ec5b64",
    "crypto_transaction_hash": "000000000000000000002cd52e3178b503dbebacf800ba19cf2992349452506e61",
    "tx_service_transaction_id": "00000000060",
    "coinbase_payment_method_id": ""
  },
  "canceled_at": null,
  "processed_at": "2023-00-00 20:12:09.976673+00",
  "user_nonce": "1685649938128",
  "idem": "00000000-0000-0000-877a-09d42dd82201",
  "profile_id": "00000000-0000-0000-80b9-5c5281357c65",
  "currency": "USDT"
}

@AutomationD your observation is correct. There are attributes that Coinbase has added over time. Unfortunately, they don't have a complete documentation on their own website as it just lists there properties:

image

Saying that, it is very helpful that you reported your observation and I am accepting Pull Requests to add the missing properties. 👍

@AutomationD I will create a new major version of "coinbase-pro-node" with response validation using Zod. This will make the code defensive and flag unmatched properties. Latest changes are in #874.