Skip to content

Commit

Permalink
Initial ios library
Browse files Browse the repository at this point in the history
  • Loading branch information
223880 committed Nov 18, 2024
1 parent d06baa1 commit 5404b7c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ios/ios.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Foundation

@objc(YourLibrary)
class YourLibrary: NSObject {
@objc
func sampleMethod(_ input: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
resolve("iOS: " + input)
}
}
14 changes: 14 additions & 0 deletions ios/library.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#import <React/RCTBridgeModule.h>

@interface YourLibrary : NSObject <RCTBridgeModule>
@end

@implementation YourLibrary

RCT_EXPORT_MODULE();

RCT_EXPORT_METHOD(sampleMethod:(NSString *)input resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
resolve([@"iOS: " stringByAppendingString:input]);
}

@end
12 changes: 12 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import bitcoin from 'bitcoinjs-lib';
import axios from 'axios';
import { NativeModules, Platform } from 'react-native';

// Define types for UTXO and PayJoin response
interface Utxo {
Expand Down Expand Up @@ -79,5 +80,16 @@ function fetchUtxos(senderAddress: string): Utxo[] | PromiseLike<Utxo[]> {
throw new Error('Function not implemented.');
}


const { YourLibrary } = NativeModules;

const sampleMethod = async (input: string): Promise<string> => {
return await YourLibrary.sampleMethod(input);
};

export default {
sampleMethod,
};

export { createInitialPayJoinTx, sendPayJoinRequest, finalizeAndBroadcast, broadcastTransaction };

0 comments on commit 5404b7c

Please sign in to comment.