diff --git a/packages/plugin-coinbase/advanced-sdk-ts/src/rest/accounts.ts b/packages/plugin-coinbase/advanced-sdk-ts/src/rest/accounts.ts index 04cec4b934..0ff05efc5c 100644 --- a/packages/plugin-coinbase/advanced-sdk-ts/src/rest/accounts.ts +++ b/packages/plugin-coinbase/advanced-sdk-ts/src/rest/accounts.ts @@ -14,11 +14,16 @@ export function getAccount( this: RESTBase, { accountUuid }: GetAccountRequest ): Promise { - return this.request({ - method: method.GET, - endpoint: `${API_PREFIX}/accounts/${accountUuid}`, - isPublic: false, - }); + try { + return this.request({ + method: method.GET, + endpoint: `${API_PREFIX}/accounts/${accountUuid}`, + isPublic: false, + }); + } catch (error) { + console.error('Error fetching account:', error); + throw error; + } } // [GET] List Accounts @@ -27,10 +32,15 @@ export function listAccounts( this: RESTBase, requestParams: ListAccountsRequest ): Promise { - return this.request({ - method: method.GET, - endpoint: `${API_PREFIX}/accounts`, - queryParams: requestParams, - isPublic: false, - }); + try { + return this.request({ + method: method.GET, + endpoint: `${API_PREFIX}/accounts`, + queryParams: requestParams, + isPublic: false, + }); + } catch (error) { + console.error('Error listing accounts:', error); + throw error; + } } diff --git a/packages/plugin-coinbase/advanced-sdk-ts/src/rest/converts.ts b/packages/plugin-coinbase/advanced-sdk-ts/src/rest/converts.ts index 435a807e28..670f63fc1a 100644 --- a/packages/plugin-coinbase/advanced-sdk-ts/src/rest/converts.ts +++ b/packages/plugin-coinbase/advanced-sdk-ts/src/rest/converts.ts @@ -16,12 +16,17 @@ export function createConvertQuote( this: RESTBase, requestParams: CreateConvertQuoteRequest ): Promise { - return this.request({ - method: method.POST, - endpoint: `${API_PREFIX}/convert/quote`, - bodyParams: requestParams, - isPublic: false, - }); + try { + return this.request({ + method: method.POST, + endpoint: `${API_PREFIX}/convert/quote`, + bodyParams: requestParams, + isPublic: false, + }); + } catch (error) { + console.error('Error creating convert quote:', error); + throw error; + } } // [GET] Get Convert Trade @@ -30,24 +35,34 @@ export function getConvertTrade( this: RESTBase, { tradeId, ...requestParams }: GetConvertTradeRequest ): Promise { - return this.request({ - method: method.GET, - endpoint: `${API_PREFIX}/convert/trade/${tradeId}`, - queryParams: requestParams, - isPublic: false, - }); + try { + return this.request({ + method: method.GET, + endpoint: `${API_PREFIX}/convert/trade/${tradeId}`, + queryParams: requestParams, + isPublic: false, + }); + } catch (error) { + console.error('Error fetching convert trade:', error); + throw error; + } } -// [POST] Commit Connvert Trade +// [POST] Commit Convert Trade // https://docs.cdp.coinbase.com/advanced-trade/reference/retailbrokerageapi_commitconverttrade export function commitConvertTrade( this: RESTBase, { tradeId, ...requestParams }: CommitConvertTradeRequest ): Promise { - return this.request({ - method: method.POST, - endpoint: `${API_PREFIX}/convert/trade/${tradeId}`, - bodyParams: requestParams, - isPublic: false, - }); + try { + return this.request({ + method: method.POST, + endpoint: `${API_PREFIX}/convert/trade/${tradeId}`, + bodyParams: requestParams, + isPublic: false, + }); + } catch (error) { + console.error('Error committing convert trade:', error); + throw error; + } } diff --git a/packages/plugin-coinbase/advanced-sdk-ts/src/rest/dataAPI.ts b/packages/plugin-coinbase/advanced-sdk-ts/src/rest/dataAPI.ts index 2adc646607..ded686edbc 100644 --- a/packages/plugin-coinbase/advanced-sdk-ts/src/rest/dataAPI.ts +++ b/packages/plugin-coinbase/advanced-sdk-ts/src/rest/dataAPI.ts @@ -1,6 +1,5 @@ import { API_PREFIX } from '../constants'; import { RESTBase } from './rest-base'; - import { method } from './types/request-types'; import { GetAPIKeyPermissionsResponse } from './types/dataAPI-types'; @@ -9,9 +8,14 @@ import { GetAPIKeyPermissionsResponse } from './types/dataAPI-types'; export function getAPIKeyPermissions( this: RESTBase ): Promise { - return this.request({ - method: method.GET, - endpoint: `${API_PREFIX}/key_permissions`, - isPublic: false, - }); + try { + return this.request({ + method: method.GET, + endpoint: `${API_PREFIX}/key_permissions`, + isPublic: false, + }); + } catch (error) { + console.error('Error fetching API Key Permissions:', error); + throw error; + } }