Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions quickstart/graphql/public/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ input OnChainUsdPaymentSendInput {
}

type OnChainUsdTxFee {
amount: CentAmount!
amount: FractionalCentAmount!
}

type OneDayAccountLimit implements AccountLimit {
Expand Down Expand Up @@ -1009,7 +1009,7 @@ type Query {
me: User
mobileVersions: [MobileVersions]
onChainTxFee(address: OnChainAddress!, amount: SatAmount!, speed: PayoutSpeed = FAST, walletId: WalletId!): OnChainTxFee!
onChainUsdTxFee(address: OnChainAddress!, amount: CentAmount!, speed: PayoutSpeed = FAST, walletId: WalletId!): OnChainUsdTxFee!
onChainUsdTxFee(address: OnChainAddress!, amount: FractionalCentAmount!, speed: PayoutSpeed = FAST, walletId: WalletId!): OnChainUsdTxFee!
onChainUsdTxFeeAsBtcDenominated(address: OnChainAddress!, amount: SatAmount!, speed: PayoutSpeed = FAST, walletId: WalletId!): OnChainUsdTxFee!
quizQuestions: [QuizQuestion] @deprecated(reason: "TODO: remove. we don't need a non authenticated version of this query. the users can only do the query while authenticated")

Expand Down
13 changes: 4 additions & 9 deletions src/graphql/public/root/query/on-chain-usd-tx-fee-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { paymentAmountFromNumber, USDAmount, ValidationError, WalletCurrency } f
import { GT } from "@graphql/index"
import { mapError } from "@graphql/error-map"

import CentAmount from "@graphql/public/types/scalar/cent-amount"
import FractionalCentAmount from "@graphql/public/types/scalar/cent-amount-fraction"
import OnChainAddress from "@graphql/shared/types/scalar/on-chain-address"
import PayoutSpeed from "@graphql/public/types/scalar/payout-speed"
import WalletId from "@graphql/shared/types/scalar/wallet-id"
Expand All @@ -25,7 +25,7 @@ const OnChainUsdTxFeeQuery = GT.Field<null, GraphQLPublicContextAuth>({
args: {
walletId: { type: GT.NonNull(WalletId) },
address: { type: GT.NonNull(OnChainAddress) },
amount: { type: GT.NonNull(CentAmount) },
amount: { type: GT.NonNull(FractionalCentAmount) },
speed: {
type: PayoutSpeed,
defaultValue: DomainPayoutSpeed.Fast,
Expand All @@ -46,20 +46,15 @@ const OnChainUsdTxFeeQuery = GT.Field<null, GraphQLPublicContextAuth>({
// speed,
// })

const send = USDAmount.cents(amount)
const send = USDAmount.cents(amount.toString())
if (send instanceof Error) return send
const resp = await Ibex.estimateOnchainFee(send, address)

if (resp instanceof IbexError) return resp
if (resp.fee === undefined) return new UnexpectedIbexResponse("Missing fee field")

const fee: PaymentAmount<WalletCurrency> = {
amount: BigInt(Math.round(resp.fee * 100)),
currency: WalletCurrency.Usd,
}

return {
amount: normalizePaymentAmount(fee).amount,
amount: resp.fee,
}
},
})
Expand Down
4 changes: 2 additions & 2 deletions src/graphql/public/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ input OnChainUsdPaymentSendInput {
}

type OnChainUsdTxFee {
amount: CentAmount!
amount: FractionalCentAmount!
}

type OneDayAccountLimit implements AccountLimit {
Expand Down Expand Up @@ -1134,7 +1134,7 @@ type Query {
mobileVersions: [MobileVersions]
npubByUsername(username: Username!): npubByUsername
onChainTxFee(address: OnChainAddress!, amount: SatAmount!, speed: PayoutSpeed = FAST, walletId: WalletId!): OnChainTxFee!
onChainUsdTxFee(address: OnChainAddress!, amount: CentAmount!, speed: PayoutSpeed = FAST, walletId: WalletId!): OnChainUsdTxFee!
onChainUsdTxFee(address: OnChainAddress!, amount: FractionalCentAmount!, speed: PayoutSpeed = FAST, walletId: WalletId!): OnChainUsdTxFee!
onChainUsdTxFeeAsBtcDenominated(address: OnChainAddress!, amount: SatAmount!, speed: PayoutSpeed = FAST, walletId: WalletId!): OnChainUsdTxFee!
quizQuestions: [QuizQuestion] @deprecated(reason: "TODO: remove. we don't need a non authenticated version of this query. the users can only do the query while authenticated")

Expand Down
4 changes: 2 additions & 2 deletions src/graphql/public/types/object/onchain-usd-tx-fee.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { GT } from "@graphql/index"

import CentAmount from "../scalar/cent-amount"
import FractionalCentAmount from "../scalar/cent-amount-fraction"

const OnChainUsdTxFee = GT.Object({
name: "OnChainUsdTxFee",
fields: () => ({
amount: { type: GT.NonNull(CentAmount) },
amount: { type: GT.NonNull(FractionalCentAmount) },
}),
})

Expand Down