diff --git a/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKMapper.kt b/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKMapper.kt index 725af7430..690573b8f 100644 --- a/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKMapper.kt +++ b/libs/sdk-react-native/android/src/main/java/com/breezsdk/BreezSDKMapper.kt @@ -3913,7 +3913,7 @@ fun asBreezEventList(arr: ReadableArray): List { return list } -fun asBuyBitcoinProvider(type: String): BuyBitcoinProvider = BuyBitcoinProvider.valueOf(camelToUpperSnakeCase(type)) +fun asBuyBitcoinProvider(type: String): BuyBitcoinProvider = BuyBitcoinProvider.valueOf(type.uppercase()) fun asBuyBitcoinProviderList(arr: ReadableArray): List { val list = ArrayList() @@ -3926,7 +3926,7 @@ fun asBuyBitcoinProviderList(arr: ReadableArray): List { return list } -fun asChannelState(type: String): ChannelState = ChannelState.valueOf(camelToUpperSnakeCase(type)) +fun asChannelState(type: String): ChannelState = ChannelState.valueOf(type.uppercase()) fun asChannelStateList(arr: ReadableArray): List { val list = ArrayList() @@ -3939,7 +3939,7 @@ fun asChannelStateList(arr: ReadableArray): List { return list } -fun asEnvironmentType(type: String): EnvironmentType = EnvironmentType.valueOf(camelToUpperSnakeCase(type)) +fun asEnvironmentType(type: String): EnvironmentType = EnvironmentType.valueOf(type.uppercase()) fun asEnvironmentTypeList(arr: ReadableArray): List { val list = ArrayList() @@ -3952,7 +3952,7 @@ fun asEnvironmentTypeList(arr: ReadableArray): List { return list } -fun asFeeratePreset(type: String): FeeratePreset = FeeratePreset.valueOf(camelToUpperSnakeCase(type)) +fun asFeeratePreset(type: String): FeeratePreset = FeeratePreset.valueOf(type.uppercase()) fun asFeeratePresetList(arr: ReadableArray): List { val list = ArrayList() @@ -3965,7 +3965,7 @@ fun asFeeratePresetList(arr: ReadableArray): List { return list } -fun asHealthCheckStatus(type: String): HealthCheckStatus = HealthCheckStatus.valueOf(camelToUpperSnakeCase(type)) +fun asHealthCheckStatus(type: String): HealthCheckStatus = HealthCheckStatus.valueOf(type.uppercase()) fun asHealthCheckStatusList(arr: ReadableArray): List { val list = ArrayList() @@ -4058,9 +4058,7 @@ fun asInputTypeList(arr: ReadableArray): List { return list } -fun asLevelFilter(type: String): LevelFilter { - return LevelFilter.valueOf(type.uppercase()) -} +fun asLevelFilter(type: String): LevelFilter = LevelFilter.valueOf(type.uppercase()) fun asLevelFilterList(arr: ReadableArray): List { val list = ArrayList() @@ -4200,7 +4198,7 @@ fun asLnUrlWithdrawResultList(arr: ReadableArray): List { return list } -fun asNetwork(type: String): Network = Network.valueOf(camelToUpperSnakeCase(type)) +fun asNetwork(type: String): Network = Network.valueOf(type.uppercase()) fun asNetworkList(arr: ReadableArray): List { val list = ArrayList() @@ -4313,7 +4311,7 @@ fun asPaymentDetailsList(arr: ReadableArray): List { return list } -fun asPaymentStatus(type: String): PaymentStatus = PaymentStatus.valueOf(camelToUpperSnakeCase(type)) +fun asPaymentStatus(type: String): PaymentStatus = PaymentStatus.valueOf(type.uppercase()) fun asPaymentStatusList(arr: ReadableArray): List { val list = ArrayList() @@ -4326,7 +4324,7 @@ fun asPaymentStatusList(arr: ReadableArray): List { return list } -fun asPaymentType(type: String): PaymentType = PaymentType.valueOf(camelToUpperSnakeCase(type)) +fun asPaymentType(type: String): PaymentType = PaymentType.valueOf(type.uppercase()) fun asPaymentTypeList(arr: ReadableArray): List { val list = ArrayList() @@ -4339,7 +4337,7 @@ fun asPaymentTypeList(arr: ReadableArray): List { return list } -fun asPaymentTypeFilter(type: String): PaymentTypeFilter = PaymentTypeFilter.valueOf(camelToUpperSnakeCase(type)) +fun asPaymentTypeFilter(type: String): PaymentTypeFilter = PaymentTypeFilter.valueOf(type.uppercase()) fun asPaymentTypeFilterList(arr: ReadableArray): List { val list = ArrayList() @@ -4383,7 +4381,7 @@ fun asReportIssueRequestList(arr: ReadableArray): List { return list } -fun asReverseSwapStatus(type: String): ReverseSwapStatus = ReverseSwapStatus.valueOf(camelToUpperSnakeCase(type)) +fun asReverseSwapStatus(type: String): ReverseSwapStatus = ReverseSwapStatus.valueOf(type.uppercase()) fun asReverseSwapStatusList(arr: ReadableArray): List { val list = ArrayList() @@ -4441,7 +4439,7 @@ fun asSuccessActionProcessedList(arr: ReadableArray): List { val list = ArrayList() @@ -4454,7 +4452,7 @@ fun asSwapAmountTypeList(arr: ReadableArray): List { return list } -fun asSwapStatus(type: String): SwapStatus = SwapStatus.valueOf(camelToUpperSnakeCase(type)) +fun asSwapStatus(type: String): SwapStatus = SwapStatus.valueOf(type.uppercase()) fun asSwapStatusList(arr: ReadableArray): List { val list = ArrayList() @@ -4530,7 +4528,6 @@ fun pushToMap( is Boolean -> map.putBoolean(key, value) is Byte -> map.putInt(key, value.toInt()) is Double -> map.putDouble(key, value) - is Float -> map.putDouble(key, value.toDouble()) is Int -> map.putInt(key, value) is Long -> map.putDouble(key, value.toDouble()) is ReadableArray -> map.putArray(key, value) @@ -4586,8 +4583,3 @@ fun errMissingMandatoryField( fun errUnexpectedType(typeName: String): String = "Unexpected type $typeName" fun errUnexpectedValue(fieldName: String): String = "Unexpected value for optional field $fieldName" - -fun camelToUpperSnakeCase(str: String): String { - val pattern = "(?<=.)[A-Z]".toRegex() - return str.replace(pattern, "_$0").uppercase() -} diff --git a/libs/sdk-react-native/ios/BreezSDKMapper.swift b/libs/sdk-react-native/ios/BreezSDKMapper.swift index 61562b8a8..d49c8e585 100644 --- a/libs/sdk-react-native/ios/BreezSDKMapper.swift +++ b/libs/sdk-react-native/ios/BreezSDKMapper.swift @@ -4902,7 +4902,7 @@ enum BreezSDKMapper { } static func arrayOf(levelFilterList: [LevelFilter]) -> [String] { - return levelFilterList.map { v -> String in valueOf(levelFilter: v) } + return levelFilterList.map { v -> String in return valueOf(levelFilter: v) } } static func asLevelFilterList(arr: [Any]) throws -> [LevelFilter] { diff --git a/libs/sdk-react-native/src/index.ts b/libs/sdk-react-native/src/index.ts index edf824ad7..e8b13fe32 100644 --- a/libs/sdk-react-native/src/index.ts +++ b/libs/sdk-react-native/src/index.ts @@ -19,21 +19,21 @@ const BreezSDK = NativeModules.RNBreezSDK const BreezSDKEmitter = new NativeEventEmitter(BreezSDK) -export interface AesSuccessActionDataDecrypted { +export type AesSuccessActionDataDecrypted = { description: string plaintext: string } -export interface BackupFailedData { +export type BackupFailedData = { error: string } -export interface BackupStatus { +export type BackupStatus = { backedUp: boolean lastBackupTime?: number } -export interface BitcoinAddressData { +export type BitcoinAddressData = { address: string network: Network amountSat?: number @@ -41,35 +41,35 @@ export interface BitcoinAddressData { message?: string } -export interface BuyBitcoinRequest { +export type BuyBitcoinRequest = { provider: BuyBitcoinProvider openingFeeParams?: OpeningFeeParams redirectUrl?: string } -export interface BuyBitcoinResponse { +export type BuyBitcoinResponse = { url: string openingFeeParams?: OpeningFeeParams } -export interface CheckMessageRequest { +export type CheckMessageRequest = { message: string pubkey: string signature: string } -export interface CheckMessageResponse { +export type CheckMessageResponse = { isValid: boolean } -export interface ClosedChannelPaymentDetails { +export type ClosedChannelPaymentDetails = { state: ChannelState fundingTxid: string shortChannelId?: string closingTxid?: string } -export interface Config { +export type Config = { breezserver: string chainnotifierUrl: string mempoolspaceUrl?: string @@ -83,17 +83,17 @@ export interface Config { nodeConfig: NodeConfig } -export interface ConfigureNodeRequest { +export type ConfigureNodeRequest = { closeToAddress?: string } -export interface ConnectRequest { +export type ConnectRequest = { config: Config seed: number[] restoreOnly?: boolean } -export interface CurrencyInfo { +export type CurrencyInfo = { name: string fractionSize: number spacing?: number @@ -103,32 +103,32 @@ export interface CurrencyInfo { localeOverrides: LocaleOverrides[] } -export interface FiatCurrency { +export type FiatCurrency = { id: string info: CurrencyInfo } -export interface GreenlightCredentials { +export type GreenlightCredentials = { developerKey: number[] developerCert: number[] } -export interface GreenlightDeviceCredentials { +export type GreenlightDeviceCredentials = { device: number[] } -export interface GreenlightNodeConfig { +export type GreenlightNodeConfig = { partnerCredentials?: GreenlightCredentials inviteCode?: string } -export interface InvoicePaidDetails { +export type InvoicePaidDetails = { paymentHash: string bolt11: string payment?: Payment } -export interface LnInvoice { +export type LnInvoice = { bolt11: string network: Network payeePubkey: string @@ -143,7 +143,7 @@ export interface LnInvoice { minFinalCltvExpiryDelta: number } -export interface ListPaymentsRequest { +export type ListPaymentsRequest = { filters?: PaymentTypeFilter[] metadataFilters?: MetadataFilter[] fromTimestamp?: number @@ -153,7 +153,7 @@ export interface ListPaymentsRequest { limit?: number } -export interface LnPaymentDetails { +export type LnPaymentDetails = { paymentHash: string label: string destinationPubkey: string @@ -172,23 +172,23 @@ export interface LnPaymentDetails { pendingExpirationBlock?: number } -export interface LnUrlAuthRequestData { +export type LnUrlAuthRequestData = { k1: string domain: string url: string action?: string } -export interface LnUrlErrorData { +export type LnUrlErrorData = { reason: string } -export interface LnUrlPayErrorData { +export type LnUrlPayErrorData = { paymentHash: string reason: string } -export interface LnUrlPayRequest { +export type LnUrlPayRequest = { data: LnUrlPayRequestData amountMsat: number useTrampoline: boolean @@ -197,7 +197,7 @@ export interface LnUrlPayRequest { validateSuccessActionUrl?: boolean } -export interface LnUrlPayRequestData { +export type LnUrlPayRequestData = { callback: string minSendable: number maxSendable: number @@ -209,18 +209,18 @@ export interface LnUrlPayRequestData { lnAddress?: string } -export interface LnUrlPaySuccessData { +export type LnUrlPaySuccessData = { successAction?: SuccessActionProcessed payment: Payment } -export interface LnUrlWithdrawRequest { +export type LnUrlWithdrawRequest = { data: LnUrlWithdrawRequestData amountMsat: number description?: string } -export interface LnUrlWithdrawRequestData { +export type LnUrlWithdrawRequestData = { callback: string k1: string defaultDescription: string @@ -228,27 +228,27 @@ export interface LnUrlWithdrawRequestData { maxWithdrawable: number } -export interface LnUrlWithdrawSuccessData { +export type LnUrlWithdrawSuccessData = { invoice: LnInvoice } -export interface LocaleOverrides { +export type LocaleOverrides = { locale: string spacing?: number symbol: SymbolType } -export interface LocalizedName { +export type LocalizedName = { locale: string name: string } -export interface LogEntry { +export type LogEntry = { line: string level: string } -export interface LspInformation { +export type LspInformation = { id: string name: string widgetUrl: string @@ -262,25 +262,25 @@ export interface LspInformation { openingFeeParamsList: OpeningFeeParamsMenu } -export interface MaxReverseSwapAmountResponse { +export type MaxReverseSwapAmountResponse = { totalSat: number } -export interface MessageSuccessActionData { +export type MessageSuccessActionData = { message: string } -export interface MetadataFilter { +export type MetadataFilter = { jsonPath: string jsonValue: string } -export interface MetadataItem { +export type MetadataItem = { key: string value: string } -export interface NodeState { +export type NodeState = { id: string blockHeight: number channelsBalanceMsat: number @@ -296,23 +296,23 @@ export interface NodeState { totalInboundLiquidityMsats: number } -export interface OnchainPaymentLimitsResponse { +export type OnchainPaymentLimitsResponse = { minSat: number maxSat: number maxPayableSat: number } -export interface OpenChannelFeeRequest { +export type OpenChannelFeeRequest = { amountMsat?: number expiry?: number } -export interface OpenChannelFeeResponse { +export type OpenChannelFeeResponse = { feeMsat?: number feeParams: OpeningFeeParams } -export interface OpeningFeeParams { +export type OpeningFeeParams = { minMsat: number proportional: number validUntil: string @@ -321,20 +321,20 @@ export interface OpeningFeeParams { promise: string } -export interface OpeningFeeParamsMenu { +export type OpeningFeeParamsMenu = { values: OpeningFeeParams[] } -export interface PayOnchainRequest { +export type PayOnchainRequest = { recipientAddress: string prepareRes: PrepareOnchainPaymentResponse } -export interface PayOnchainResponse { +export type PayOnchainResponse = { reverseSwapInfo: ReverseSwapInfo } -export interface Payment { +export type Payment = { id: string paymentType: PaymentType paymentTime: number @@ -347,20 +347,20 @@ export interface Payment { metadata?: string } -export interface PaymentFailedData { +export type PaymentFailedData = { error: string nodeId: string invoice?: LnInvoice label?: string } -export interface PrepareOnchainPaymentRequest { +export type PrepareOnchainPaymentRequest = { amountSat: number amountType: SwapAmountType claimTxFeerate: number } -export interface PrepareOnchainPaymentResponse { +export type PrepareOnchainPaymentResponse = { feesHash: string feesPercentage: number feesLockup: number @@ -370,37 +370,37 @@ export interface PrepareOnchainPaymentResponse { totalFees: number } -export interface PrepareRedeemOnchainFundsRequest { +export type PrepareRedeemOnchainFundsRequest = { toAddress: string satPerVbyte: number } -export interface PrepareRedeemOnchainFundsResponse { +export type PrepareRedeemOnchainFundsResponse = { txWeight: number txFeeSat: number } -export interface PrepareRefundRequest { +export type PrepareRefundRequest = { swapAddress: string toAddress: string satPerVbyte: number } -export interface PrepareRefundResponse { +export type PrepareRefundResponse = { refundTxWeight: number refundTxFeeSat: number } -export interface Rate { +export type Rate = { coin: string value: number } -export interface ReceiveOnchainRequest { +export type ReceiveOnchainRequest = { openingFeeParams?: OpeningFeeParams } -export interface ReceivePaymentRequest { +export type ReceivePaymentRequest = { amountMsat: number description: string preimage?: number[] @@ -410,13 +410,13 @@ export interface ReceivePaymentRequest { cltv?: number } -export interface ReceivePaymentResponse { +export type ReceivePaymentResponse = { lnInvoice: LnInvoice openingFeeParams?: OpeningFeeParams openingFeeMsat?: number } -export interface RecommendedFees { +export type RecommendedFees = { fastestFee: number halfHourFee: number hourFee: number @@ -424,36 +424,36 @@ export interface RecommendedFees { minimumFee: number } -export interface RedeemOnchainFundsRequest { +export type RedeemOnchainFundsRequest = { toAddress: string satPerVbyte: number } -export interface RedeemOnchainFundsResponse { +export type RedeemOnchainFundsResponse = { txid: number[] } -export interface RefundRequest { +export type RefundRequest = { swapAddress: string toAddress: string satPerVbyte: number } -export interface RefundResponse { +export type RefundResponse = { refundTxId: string } -export interface ReportPaymentFailureDetails { +export type ReportPaymentFailureDetails = { paymentHash: string comment?: string } -export interface ReverseSwapFeesRequest { +export type ReverseSwapFeesRequest = { sendAmountSat?: number claimTxFeerate?: number } -export interface ReverseSwapInfo { +export type ReverseSwapInfo = { id: string claimPubkey: string lockupTxid?: string @@ -462,7 +462,7 @@ export interface ReverseSwapInfo { status: ReverseSwapStatus } -export interface ReverseSwapPairInfo { +export type ReverseSwapPairInfo = { min: number max: number feesHash: string @@ -472,11 +472,11 @@ export interface ReverseSwapPairInfo { totalFees?: number } -export interface RouteHint { +export type RouteHint = { hops: RouteHintHop[] } -export interface RouteHintHop { +export type RouteHintHop = { srcNodeId: string shortChannelId: string feesBaseMsat: number @@ -486,56 +486,56 @@ export interface RouteHintHop { htlcMaximumMsat?: number } -export interface SendOnchainRequest { +export type SendOnchainRequest = { amountSat: number onchainRecipientAddress: string pairHash: string satPerVbyte: number } -export interface SendOnchainResponse { +export type SendOnchainResponse = { reverseSwapInfo: ReverseSwapInfo } -export interface SendPaymentRequest { +export type SendPaymentRequest = { bolt11: string useTrampoline: boolean amountMsat?: number label?: string } -export interface SendPaymentResponse { +export type SendPaymentResponse = { payment: Payment } -export interface SendSpontaneousPaymentRequest { +export type SendSpontaneousPaymentRequest = { nodeId: string amountMsat: number extraTlvs?: TlvEntry[] label?: string } -export interface ServiceHealthCheckResponse { +export type ServiceHealthCheckResponse = { status: HealthCheckStatus } -export interface SignMessageRequest { +export type SignMessageRequest = { message: string } -export interface SignMessageResponse { +export type SignMessageResponse = { signature: string } -export interface StaticBackupRequest { +export type StaticBackupRequest = { workingDir: string } -export interface StaticBackupResponse { +export type StaticBackupResponse = { backup?: string[] } -export interface SwapInfo { +export type SwapInfo = { bitcoinAddress: string createdAt: number lockHeight: number @@ -562,19 +562,19 @@ export interface SwapInfo { confirmedAt?: number } -export interface SymbolType { +export type SymbolType = { grapheme?: string template?: string rtl?: boolean position?: number } -export interface TlvEntry { +export type TlvEntry = { fieldNumber: number value: number[] } -export interface UnspentTransactionOutput { +export type UnspentTransactionOutput = { txid: number[] outnum: number amountMillisatoshi: number @@ -582,7 +582,7 @@ export interface UnspentTransactionOutput { reserved: boolean } -export interface UrlSuccessActionData { +export type UrlSuccessActionData = { description: string url: string matchesCallbackDomain: boolean @@ -774,7 +774,7 @@ export enum NodeConfigVariant { GREENLIGHT = "greenlight" } -export interface NodeConfig { +export type NodeConfig = { type: NodeConfigVariant.GREENLIGHT, config: GreenlightNodeConfig } @@ -783,7 +783,7 @@ export enum NodeCredentialsVariant { GREENLIGHT = "greenlight" } -export interface NodeCredentials { +export type NodeCredentials = { type: NodeCredentialsVariant.GREENLIGHT, credentials: GreenlightDeviceCredentials } @@ -823,7 +823,7 @@ export enum ReportIssueRequestVariant { PAYMENT_FAILURE = "paymentFailure" } -export interface ReportIssueRequest { +export type ReportIssueRequest = { type: ReportIssueRequestVariant.PAYMENT_FAILURE, data: ReportPaymentFailureDetails } @@ -872,7 +872,7 @@ export type LogStream = (logEntry: LogEntry) => void export const connect = async (req: ConnectRequest, listener: EventListener): Promise => { const subscription = BreezSDKEmitter.addListener("breezSdkEvent", listener) - + await BreezSDK.connect(req) return subscription