88import com .facebook .react .bridge .ReactApplicationContext ;
99import com .facebook .react .bridge .ReactContextBaseJavaModule ;
1010import com .facebook .react .bridge .ReactMethod ;
11+ import com .facebook .react .bridge .WritableMap ;
12+ import com .facebook .react .bridge .WritableNativeMap ;
1113import com .facebook .react .module .annotations .ReactModule ;
1214
1315import org .jetbrains .annotations .Contract ;
@@ -30,6 +32,7 @@ public class FulaModule extends ReactContextBaseJavaModule {
3032 @ Override
3133 public void initialize () {
3234 System .loadLibrary ("wnfslib" );
35+ System .loadLibrary ("gojni" );
3336 }
3437
3538
@@ -48,15 +51,15 @@ public class Client implements land.fx.wnfslib.Datastore {
4851 private final fulamobile .Client internalClient ;
4952
5053 Client (fulamobile .Client clientInput ) {
51- internalClient = clientInput ;
54+ this . internalClient = clientInput ;
5255 }
5356
5457 @ NonNull
5558 @ Override
5659 public byte [] get (@ NonNull byte [] cid ) {
5760 try {
5861 Log .d ("ReactNative" , Arrays .toString (cid ));
59- return internalClient .get (cid );
62+ return this . internalClient .get (cid );
6063 } catch (Exception e ) {
6164 e .printStackTrace ();
6265 }
@@ -69,7 +72,7 @@ public byte[] get(@NonNull byte[] cid) {
6972 public byte [] put (@ NonNull byte [] data , long codec ) {
7073 try {
7174 //Log.d("ReactNative", "data="+ Arrays.toString(data) +" ;codec="+codec);
72- return client .put (data , codec );
75+ return this . internalClient .put (data , codec );
7376 } catch (Exception e ) {
7477 Log .d ("ReactNative" , "put Error=" +e .getMessage ());
7578 e .printStackTrace ();
@@ -146,15 +149,19 @@ public void init(String identityString, String storePath, String bloxAddr, Strin
146149 Log .d ("ReactNative" , "init started" );
147150 ThreadUtils .runOnExecutor (() -> {
148151 try {
152+ WritableMap resultData = new WritableNativeMap ();
149153 Log .d ("ReactNative" , "init storePath= " + storePath );
150154 byte [] identity = toByte (identityString );
151155 Log .d ("ReactNative" , "init identity= " + identityString );
152156 String [] obj = initInternal (identity , storePath , bloxAddr , exchange );
153- Log .d ("ReactNative" , "init object created: [ " + obj [0 ] + ", " + obj [1 ] + ", " + obj [2 ] + " ]" );
154- promise .resolve (obj );
157+ Log .d ("ReactNative" , "init object created: [ " + obj [0 ].toString () + ", " + obj [1 ].toString () + ", " + obj [2 ].toString () + " ]" );
158+ resultData .putString ("peerId" , obj [0 ]);
159+ resultData .putString ("rootCid" , obj [1 ]);
160+ resultData .putString ("private_ref" , obj [2 ]);
161+ promise .resolve (resultData );
155162 } catch (Exception e ) {
156- Log .d ("ReactNative" , "init failed with Error: " + e .getMessage ());
157- promise .reject (e );
163+ Log .d ("ReactNative" , "init failed with Error: " + e .getMessage (). toString () );
164+ promise .reject ("Error" , e . getMessage (). toString () );
158165 }
159166 });
160167 }
@@ -206,6 +213,15 @@ private String[] initInternal(byte[] identity, String storePath, String bloxAddr
206213 if (this .rootConfig == null ) {
207214 Log .d ("ReactNative" , "creating rootConfig" );
208215
216+ /*byte[] testbyte = convertStringToByte("-104,40,24,-93,24,100,24,114,24,111,24,111,24,116,24,-126,24,-126,0,0,24,-128,24,103,24,118,24,101,24,114,24,115,24,105,24,111,24,110,24,101,24,48,24,46,24,49,24,46,24,48,24,105,24,115,24,116,24,114,24,117,24,99,24,116,24,117,24,114,24,101,24,100,24,104,24,97,24,109,24,116");
217+ long testcodec = 85;
218+ byte[] testputcid = this.client.put(testbyte, testcodec);
219+ Log.d("ReactNative", "client.put test done"+ Arrays.toString(testputcid));
220+ byte[] testfetchedcid = convertStringToByte("1,113,18,32,-6,-63,-128,79,-102,-89,57,77,-8,67,-98,8,-81,40,-87,123,122,29,-52,-124,-60,-53,100,105,125,123,-5,-99,41,106,-124,-64");
221+ byte[] testfetchedbytes = this.client.get(testfetchedcid);
222+ Log.d("ReactNative", "client.get test done"+ Arrays.toString(testfetchedbytes));
223+ */
224+
209225 this .privateForest = Fs .createPrivateForest (this .client );
210226 Log .d ("ReactNative" , "privateForest is created: " + this .privateForest );
211227 this .rootConfig = Fs .createRootDir (this .client , this .privateForest );
0 commit comments