mirror of
https://github.com/Reckless-Satoshi/robosats.git
synced 2024-08-16 15:20:55 +03:00
Generate Builds
This commit is contained in:
parent
9ab8381eaf
commit
28cc3d6715
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,9 +1,6 @@
|
||||
*.py[cod]
|
||||
__pycache__
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Packages
|
||||
*.egg
|
||||
*.egg-info
|
||||
|
@ -1,14 +1,17 @@
|
||||
import { sha256 } from 'js-sha256';
|
||||
import { Robot, type Order } from '.';
|
||||
// import { robohash } from '../components/RobotAvatar/RobohashGenerator';
|
||||
// import { generate_roboname } from 'robo-identities-wasm';
|
||||
import { roboidentitiesClient } from '../services/Roboidentities';
|
||||
|
||||
class Slot {
|
||||
constructor(token: string, shortAliases: string[], robotAttributes: Record<any, any>) {
|
||||
this.token = token;
|
||||
|
||||
this.hashId = sha256(sha256(this.token));
|
||||
this.nickname = 'No Nick Display (WIP)';
|
||||
this.nickname = '';
|
||||
roboidentitiesClient.generateRoboname(this.hashId).then((nickname) => {
|
||||
this.nickname = nickname;
|
||||
});
|
||||
// trigger RoboHash avatar generation in webworker and store in RoboHash class cache.
|
||||
// void robohash.generate(this.hashId, 'small');
|
||||
// void robohash.generate(this.hashId, 'large');
|
||||
|
14
frontend/src/services/Native/index.d.ts
vendored
14
frontend/src/services/Native/index.d.ts
vendored
@ -30,7 +30,19 @@ export interface NativeWebViewMessageSystem {
|
||||
detail?: string;
|
||||
}
|
||||
|
||||
export declare type NativeWebViewMessage = NativeWebViewMessageHttp | NativeWebViewMessageSystem;
|
||||
export interface NativeWebViewMessageRoboidentities {
|
||||
id?: number;
|
||||
category: 'roboidentities';
|
||||
type: 'roboname' | 'robohash';
|
||||
string?: string;
|
||||
size?: string;
|
||||
}
|
||||
|
||||
export declare type NativeWebViewMessage =
|
||||
| NativeWebViewMessageHttp
|
||||
| NativeWebViewMessageSystem
|
||||
| NativeWebViewMessageRoboidentities
|
||||
| NA;
|
||||
|
||||
export interface NativeRobosatsPromise {
|
||||
resolve: (value: object | PromiseLike<object>) => void;
|
||||
|
@ -0,0 +1,21 @@
|
||||
import { type RoboidentitiesClient } from '..';
|
||||
import NativeRobosats from '../../Native';
|
||||
|
||||
class RoboidentitiesNativeClient implements RoboidentitiesClient {
|
||||
constructor() {
|
||||
window.NativeRobosats = new NativeRobosats();
|
||||
}
|
||||
|
||||
public loading = true;
|
||||
|
||||
public generateRoboname: (initialString: string) => Promise<string> = async (initialString) => {
|
||||
const response = await window.NativeRobosats?.postMessage({
|
||||
category: 'roboIdentities',
|
||||
type: 'roboname',
|
||||
detail: initialString,
|
||||
});
|
||||
return response ? Object.values(response)[0] : '';
|
||||
};
|
||||
}
|
||||
|
||||
export default RoboidentitiesNativeClient;
|
@ -0,0 +1,12 @@
|
||||
import { type RoboidentitiesClient } from '..';
|
||||
// import { generate_roboname } from 'robo-identities-wasm';
|
||||
|
||||
class RoboidentitiesClientWebClient implements RoboidentitiesClient {
|
||||
public generateRoboname: (initialString: string) => Promise<string> = async (initialString) => {
|
||||
return new Promise<string>(async (resolve, _reject) => {
|
||||
// resolve(generate_roboname(initialString))
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
export default RoboidentitiesClientWebClient;
|
13
frontend/src/services/Roboidentities/index.ts
Normal file
13
frontend/src/services/Roboidentities/index.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import RoboidentitiesClientNativeClient from './RoboidentitiesNativeClient';
|
||||
import RoboidentitiesClientWebClient from './RoboidentitiesWebClient';
|
||||
|
||||
export interface RoboidentitiesClient {
|
||||
generateRoboname: (initialString: string) => Promise<string>;
|
||||
}
|
||||
|
||||
export const roboidentitiesClient: RoboidentitiesClient =
|
||||
// If userAgent has "RoboSats", we assume the app is running inside of the
|
||||
// react-native-web view of the RoboSats Android app.
|
||||
window.navigator.userAgent.includes('robosats')
|
||||
? new RoboidentitiesClientNativeClient()
|
||||
: new RoboidentitiesClientWebClient();
|
@ -6,6 +6,7 @@ import Clipboard from '@react-native-clipboard/clipboard';
|
||||
import EncryptedStorage from 'react-native-encrypted-storage';
|
||||
import { name as app_name, version as app_version } from './package.json';
|
||||
import TorModule from './native/TorModule';
|
||||
import RoboIdentitiesModule from './native/RoboIdentitiesModule';
|
||||
|
||||
const backgroundColors = {
|
||||
light: 'white',
|
||||
@ -129,6 +130,11 @@ const App = () => {
|
||||
} else if (data.type === 'deleteCookie') {
|
||||
EncryptedStorage.removeItem(data.key);
|
||||
}
|
||||
} else if (data.category === 'roboidentities') {
|
||||
if (data.type === 'roboname') {
|
||||
const roboname = RoboIdentitiesModule.generateRoboname(data.detail);
|
||||
injectMessageResolve(data.id, roboname);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -0,0 +1,14 @@
|
||||
package com.robosats;
|
||||
|
||||
public class RoboIdentities {
|
||||
static {
|
||||
System.loadLibrary("robonames");
|
||||
}
|
||||
|
||||
public String generateRoboname(String initial_string) {
|
||||
return nativeGenerateRoboname(initial_string);
|
||||
}
|
||||
|
||||
// Native functions implemented in Rust.
|
||||
private static native String nativeGenerateRoboname(String initial_string);
|
||||
}
|
@ -4,6 +4,7 @@ import com.facebook.react.ReactPackage;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.uimanager.ViewManager;
|
||||
import com.robosats.modules.RoboIdentitiesModule;
|
||||
import com.robosats.modules.TorModule;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -22,6 +23,7 @@ public class RobosatsPackage implements ReactPackage {
|
||||
List<NativeModule> modules = new ArrayList<>();
|
||||
|
||||
modules.add(new TorModule(reactContext));
|
||||
modules.add(new RoboIdentitiesModule(reactContext));
|
||||
|
||||
return modules;
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.robosats.modules;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.robosats.RoboIdentities;
|
||||
|
||||
public class RoboIdentitiesModule extends ReactContextBaseJavaModule {
|
||||
private ReactApplicationContext context;
|
||||
|
||||
public RoboIdentitiesModule(ReactApplicationContext reactContext) {
|
||||
context = reactContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "RoboIdentitiesModule";
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public String generateRoboname(String initial_string) {
|
||||
return new RoboIdentities().generateRoboname(initial_string);
|
||||
}
|
||||
}
|
BIN
mobile/android/app/src/main/jniLibs/arm64-v8a/librobonames.so
Executable file
BIN
mobile/android/app/src/main/jniLibs/arm64-v8a/librobonames.so
Executable file
Binary file not shown.
BIN
mobile/android/app/src/main/jniLibs/armeabi-v7a/librobonames.so
Executable file
BIN
mobile/android/app/src/main/jniLibs/armeabi-v7a/librobonames.so
Executable file
Binary file not shown.
8
mobile/native/RoboIdentitiesModule.ts
Normal file
8
mobile/native/RoboIdentitiesModule.ts
Normal file
@ -0,0 +1,8 @@
|
||||
import { NativeModules } from 'react-native';
|
||||
const { RoboIdentitiesModule } = NativeModules;
|
||||
|
||||
interface RoboIdentitiesModuleInterface {
|
||||
generateRoboname: (initialString: String) => String;
|
||||
}
|
||||
|
||||
export default RoboIdentitiesModule as RoboIdentitiesModuleInterface;
|
Loading…
Reference in New Issue
Block a user