From 3a3a2105d68578bed60bc040733f22f61f85f291 Mon Sep 17 00:00:00 2001 From: heyolaniran Date: Mon, 29 Jun 2026 18:01:36 +0100 Subject: [PATCH 1/3] fix: delegate account-scoped crypto receive info to ibex-client 3.1.x ibex-client 3.1.x exposes the same contract, so replace the raw ibexPost wrapper with the SDK and align CryptoReceiveInfo types with the library. --- package.json | 6 ++-- src/services/ibex/client.ts | 68 ++++++++++--------------------------- 2 files changed, 21 insertions(+), 53 deletions(-) diff --git a/package.json b/package.json index d98a1bbc9..77e928c4e 100644 --- a/package.json +++ b/package.json @@ -95,7 +95,7 @@ "graphql-ws": "^5.13.1", "gt3-server-node-express-sdk": "https://github.com/GaloyMoney/gt3-server-node-express-bypass#master", "i18n": "^0.15.1", - "ibex-client": "^3.0.0", + "ibex-client": "^3.1.0", "invoices": "^3.0.0", "ioredis": "^5.3.2", "ioredis-cache": "^2.0.0", @@ -182,11 +182,11 @@ "eslint-plugin-jest": "^27.4.0", "eslint-plugin-prettier": "^5.0.0", "graphql-subscriptions": "^2.0.0", - "grpc_tools_node_protoc_ts": "^5.3.3", "grpc-tools": "^1.12.4", + "grpc_tools_node_protoc_ts": "^5.3.3", "jest": "^29.7.0", - "jest_workaround": "^0.79.19", "jest-junit": "^16.0.0", + "jest_workaround": "^0.79.19", "lodash.difference": "^4.5.0", "lodash.find": "^4.6.0", "madge": "^6.1.0", diff --git a/src/services/ibex/client.ts b/src/services/ibex/client.ts index b9b06a584..f91f4fee9 100644 --- a/src/services/ibex/client.ts +++ b/src/services/ibex/client.ts @@ -18,6 +18,8 @@ import IbexClient, { SendToAddressCopyBodyParam, SendToAddressCopyResponse200, IbexUrls, + CryptoReceiveInfo, + CryptoReceiveOption, } from "ibex-client" import { IbexConfig } from "@config" @@ -39,15 +41,11 @@ import { IbexFeeEstimation, IbexInvoiceArgs, PayInvoiceArgs, - CryptoReceiveOption, - CryptoReceiveInfo, - CreateCryptoReceiveInfoRequest, CreateCryptoSendInfoBodyParam, CryptoSendBodyParam, CryptoSendInfo, CryptoSendRequirements, CryptoSendResponse, - IbexCurrency, UsdWalletAmount, } from "./types" @@ -433,40 +431,14 @@ const getCryptoReceiveBalance = async ( } } -const getCryptoReceiveOptions = async (): Promise => { - try { - const token = await getIbexToken() - if (token instanceof IbexError) return token - const data = await ibexGet( - token, - "/crypto/receive-infos/options", - ) - - if (data instanceof IbexError) return data - return data - } catch (err) { - return new IbexError(err instanceof Error ? err : new Error(String(err))) - } -} +const getCryptoReceiveOptions = async (): Promise => + Ibex.getCryptoReceiveOptions().then(errorHandler) const createCryptoReceiveInfo = async ( accountId: IbexAccountId, - option: Pick, + option: CryptoReceiveOption, ): Promise => { - try { - const token = await getIbexToken() - if (token instanceof IbexError) return token - const data = await ibexPost( - token, - `/accounts/${accountId}/crypto/receive-infos`, - { name: option.name, network: option.network } as CreateCryptoReceiveInfoRequest, - ) - if (data instanceof IbexError) return data - if (!data.data.address) return new UnexpectedIbexResponse("Address not found") - return data - } catch (err) { - return new IbexError(err instanceof Error ? err : new Error(String(err))) - } + return Ibex.createCryptoReceiveInfo(accountId, option).then(errorHandler) } const getTronUsdtOption = async (): Promise => { @@ -485,16 +457,12 @@ const getTronUsdtOption = async (): Promise => return tronUsdt } -const getEthereumUsdtOption = async (): Promise => { - const options = await getCryptoReceiveOptions() - if (options instanceof IbexError) return options - - const UsdtCurrencyId = await getIbexCurrencyId(WalletCurrency.Usdt) - if (UsdtCurrencyId instanceof IbexError) return UsdtCurrencyId as IbexError - +const findEthereumUsdtReceiveOption = ( + options: CryptoReceiveOption[], +): CryptoReceiveOption | IbexError => { const ethereumUsdt = options.find( (opt) => - opt.currencyId === UsdtCurrencyId && opt.network.toLowerCase() === "ethereum", + opt.currencyId === USDTAmount.currencyId && opt.network.toLowerCase() === "ethereum", ) if (!ethereumUsdt) { @@ -504,17 +472,17 @@ const getEthereumUsdtOption = async (): Promise return ethereumUsdt } +const getEthereumUsdtOption = async (): Promise => { + const options = await getCryptoReceiveOptions() + if (options instanceof IbexError) return options + + return findEthereumUsdtReceiveOption(options) +} + const getIbexCurrencyId = async ( currency: WalletCurrency, ): Promise => { - const token = await getIbexToken() - if (token instanceof IbexError) return token - - const data = await ibexGet<{ currencies: IbexCurrency[] }>(token, "/currency/all") - if (data instanceof IbexError) return data - const currencyId = data.currencies.find((c) => c.name === currency)?.id - if (!currencyId) return new IbexError(new Error(`Currency ${currency} not found`)) - return currencyId + return (Ibex.getCurrencyId(currency) as Promise).then(errorHandler) } // const sendBetweenAccounts = async ( From e5b464eba958bff088712dd6df6004f0e48b900e Mon Sep 17 00:00:00 2001 From: heyolaniran Date: Mon, 29 Jun 2026 23:22:37 +0100 Subject: [PATCH 2/3] chore: update yarn.lock for ibex-client 3.1.x --- yarn.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yarn.lock b/yarn.lock index 753a51ffb..3fec12f6f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8867,10 +8867,10 @@ i18n@^0.15.1: math-interval-parser "^2.0.1" mustache "^4.2.0" -ibex-client@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/ibex-client/-/ibex-client-3.0.0.tgz#963ced9561b1e2cea0cec876ebf282f62ef69540" - integrity sha512-ATfB1qptJLv2C7K0bzzZCjTSYgJO/ihx059FCT+DjngfSkijJLOdFdFepQTcy7Cadh1ij5TdFa5+jYbr3ZiViw== +ibex-client@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/ibex-client/-/ibex-client-3.1.1.tgz#8fe11b40f2b51d03fb6f5f613f558a06097d525b" + integrity sha512-9L2aYU+40GU1u0fQ1Ag0C1f3ncfJL0+d7YzkBEDSw1uqfaILc+Zeg23B9U3jssurJZJ+pJN2QFCWN0Ww0bsJZg== dependencies: api "^6.1.2" node-cache "^5.1.2" From ddf62b5768f2196a330bf97936967cc7108d0483 Mon Sep 17 00:00:00 2001 From: heyolaniran Date: Mon, 29 Jun 2026 23:29:16 +0100 Subject: [PATCH 3/3] style(ibex): fix prettier formatting in findEthereumUsdtReceiveOption Co-authored-by: Cursor --- src/services/ibex/client.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/services/ibex/client.ts b/src/services/ibex/client.ts index f91f4fee9..fe22ec264 100644 --- a/src/services/ibex/client.ts +++ b/src/services/ibex/client.ts @@ -462,7 +462,8 @@ const findEthereumUsdtReceiveOption = ( ): CryptoReceiveOption | IbexError => { const ethereumUsdt = options.find( (opt) => - opt.currencyId === USDTAmount.currencyId && opt.network.toLowerCase() === "ethereum", + opt.currencyId === USDTAmount.currencyId && + opt.network.toLowerCase() === "ethereum", ) if (!ethereumUsdt) {