Skip to content

Commit

Permalink
chore: refactor galoy-client
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas Burtey committed Dec 4, 2023
1 parent e011834 commit 1fc66a6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 23 deletions.
16 changes: 4 additions & 12 deletions __tests__/payment-destination/lnurl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,11 @@ import {
} from "@app/screens/send-bitcoin-screen/payment-destination"
import { DestinationDirection } from "@app/screens/send-bitcoin-screen/payment-destination/index.types"
import { ZeroBtcMoneyAmount } from "@app/types/amounts"
import { PaymentType, fetchLnurlPaymentParams } from "@galoymoney/client"
import { PaymentType } from "@galoymoney/client"
import { LNURLPayParams, LNURLResponse, LNURLWithdrawParams, getParams } from "js-lnurl"
import { LnUrlPayServiceResponse } from "lnurl-pay/dist/types/types"
import { defaultPaymentDetailParams } from "./helpers"

jest.mock("@galoymoney/client", () => {
const actualModule = jest.requireActual("@galoymoney/client")

return {
...actualModule,
fetchLnurlPaymentParams: jest.fn(),
}
})
import { requestPayServiceParams } from "lnurl-pay"

jest.mock("js-lnurl", () => {
return {
Expand All @@ -32,8 +24,8 @@ jest.mock("@app/screens/send-bitcoin-screen/payment-details", () => {
}
})

const mockFetchLnurlPaymentParams = fetchLnurlPaymentParams as jest.MockedFunction<
typeof fetchLnurlPaymentParams
const mockFetchLnurlPaymentParams = requestPayServiceParams as jest.MockedFunction<
typeof requestPayServiceParams
>
const mockGetParams = getParams as jest.MockedFunction<typeof getParams>
const mockCreateLnurlPaymentDetail = createLnurlPaymentDetails as jest.MockedFunction<
Expand Down
9 changes: 3 additions & 6 deletions app/screens/send-bitcoin-screen/payment-destination/lnurl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import {
AccountDefaultWalletLazyQueryHookResult,
WalletCurrency,
} from "@app/graphql/generated"
import {
LnurlPaymentDestination,
PaymentType,
fetchLnurlPaymentParams,
} from "@galoymoney/client"
import { LnurlPaymentDestination, PaymentType } from "@galoymoney/client"

import { toBtcMoneyAmount } from "@app/types/amounts"
import { getParams } from "js-lnurl"
Expand All @@ -22,6 +18,7 @@ import {
ResolvedLnurlPaymentDestination,
} from "./index.types"
import { resolveIntraledgerDestination } from "./intraledger"
import { requestPayServiceParams } from "lnurl-pay/dist/types"

export type ResolveLnurlDestinationParams = {
parsedLnurlDestination: LnurlPaymentDestination
Expand Down Expand Up @@ -57,7 +54,7 @@ export const resolveLnurlDestination = async ({

// Check for lnurl pay request
try {
const lnurlPayParams = await fetchLnurlPaymentParams({
const lnurlPayParams = await requestPayServiceParams({
lnUrlOrAddress: parsedLnurlDestination.lnurl,
})

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@formatjs/intl-getcanonicallocales": "^2.3.0",
"@formatjs/intl-locale": "^3.4.3",
"@formatjs/intl-relativetimeformat": "^11.2.10",
"@galoymoney/client": "^0.2.6",
"@galoymoney/client": "^0.2.7",
"@galoymoney/react-native-geetest-module": "^0.1.3",
"@react-native-async-storage/async-storage": "^1.19.3",
"@react-native-clipboard/clipboard": "^1.12.1",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1928,10 +1928,10 @@
"@formatjs/intl-localematcher" "0.5.2"
tslib "^2.4.0"

"@galoymoney/client@^0.2.6":
version "0.2.6"
resolved "https://registry.npmjs.org/@galoymoney/client/-/client-0.2.6.tgz#c90416755d8bf55f0e8bc11694de3ac7f8dc8f99"
integrity sha512-HCYMB39EO1/2RJ6Dz9ZJkRDCKd5b3IyaajfR2db4i4hQZ6i4z1nuEFT/04ERu27Mlrxrb0qjHfYmAPTRR20xdg==
"@galoymoney/client@^0.2.7":
version "0.2.7"
resolved "https://registry.npmjs.org/@galoymoney/client/-/client-0.2.7.tgz#eaf985365b014aa6ddfb5061db5ff43d6d9ae2a7"
integrity sha512-eQfuYzY9hBKgKQOysZmKQo5th27ZPdCSSPuZCyKlPRlwaqyrtcWsAAOtVZs1EPbY3rwQvMUrTSk5ljEBkAwFsw==

"@galoymoney/react-native-geetest-module@^0.1.3":
version "0.1.5"
Expand Down

0 comments on commit 1fc66a6

Please sign in to comment.