Skip to content

Commit

Permalink
WLT-1736 (#7)
Browse files Browse the repository at this point in the history
* feat: bump android native version and bridge version

* WLT-1736: fix example ui

---------

Co-authored-by: valeriaFireblocks <[email protected]>
  • Loading branch information
ofbarzilay and valeriaFireblocks authored Nov 14, 2024
1 parent 758daa4 commit 6349dd5
Show file tree
Hide file tree
Showing 11 changed files with 14,109 additions and 11,255 deletions.
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "com.fireblocks.sdk:ncw:2.5.0"
implementation "com.fireblocks.sdk:ncw:2.9.2"
}

if (isNewArchitectureEnabled()) {
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ dependencies {
// The version of react-native is set by the React Native Gradle Plugin
implementation("com.facebook.react:react-android")
implementation("com.facebook.react:flipper-integration")
implementation("com.fireblocks.sdk:ncw:2.5.0")
implementation("com.fireblocks.sdk:ncw:2.9.2")

if (hermesEnabled.toBoolean()) {
implementation("com.facebook.react:hermes-android")
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ PODS:
- GoogleUtilities/Environment (~> 7.8)
- GoogleUtilities/UserDefaults (~> 7.8)
- PromisesObjC (~> 2.1)
- fireblocks-react-native-ncw-sdk (1.0.0):
- fireblocks-react-native-ncw-sdk (1.0.2):
- glog
- RCT-Folly (= 2022.05.16.00)
- React-Core
Expand Down Expand Up @@ -1545,7 +1545,7 @@ SPEC CHECKSUMS:
FirebaseCore: 28045c1560a2600d284b9c45a904fe322dc890b6
FirebaseCoreInternal: bca337352024b18424a61e478460547d46c4c753
FirebaseInstallations: 763814908793c0da14c18b3dcffdec71e29ed55e
fireblocks-react-native-ncw-sdk: 867882b558c0a3ef1c7a79d2e21af7db40a5a88e
fireblocks-react-native-ncw-sdk: 049d245e206189c1b411de132ff6052a8ba32914
Flipper: c7a0093234c4bdd456e363f2f19b2e4b27652d44
Flipper-Boost-iOSX: fd1e2b8cbef7e662a122412d7ac5f5bea715403c
Flipper-DoubleConversion: 2dc99b02f658daf147069aad9dbd29d8feb06d30
Expand Down Expand Up @@ -1622,7 +1622,7 @@ SPEC CHECKSUMS:
RNSVG: 50cf2c7018e57cf5d3522d98d0a3a4dd6bf9d093
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
VisionCamera: 36c460338692788a0d377dce7d32f8ba049fb4f2
Yoga: 805bf71192903b20fc14babe48080582fee65a80
Yoga: d17d2cc8105eed528474683b42e2ea310e1daf61

PODFILE CHECKSUM: 39734b197bfc91ffdfa5baa43576530a5725c6dd

Expand Down
7 changes: 4 additions & 3 deletions example/src/AppStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import { ApiService, type ITransactionData, type IWalletAsset, type TPassphraseL
import { PasswordEncryptedLocalStorage } from "./services/PasswordEncryptedLocalStorage";
import type { IAuthManager } from "./auth/IAuthManager";
import { FirebaseAuthManager } from "./auth/FirebaseAuthManager";
import { decode, version } from "js-base64";
import { decode } from "js-base64";
import type { IEventsHandler, IFireblocksNCW, IJoinWalletEvent, IKeyBackupEvent, IKeyDescriptor, IKeyRecoveryEvent, IMessagesHandler } from "@fireblocks/react-native-ncw-sdk";
import type { TEvent, TMPCAlgorithm, TEnv } from "@fireblocks/react-native-ncw-sdk";
import { FireblocksNCWFactory } from "@fireblocks/react-native-ncw-sdk";
import { ACCESSIBLE, ACCESS_CONTROL, type Options, getGenericPassword, setGenericPassword } from "react-native-keychain";
import { randomPassPhrase } from "./services/randomPassPhrase";
import packageJson from '../../package.json';

export type TAsyncActionStatus = "not_started" | "started" | "success" | "failed";
export type TFireblocksNCWStatus = "sdk_not_ready" | "initializing_sdk" | "sdk_available" | "sdk_initialization_failed";
Expand All @@ -38,7 +39,7 @@ export const useAppStore = create<IAppState>()((set, get) => {
};

return {
fireblocksNCWSdkVersion: version,
fireblocksNCWSdkVersion: packageJson.version,
automateInitialization: ENV_CONFIG.AUTOMATE_INITIALIZATION,
joinExistingWalletMode: false,
loggedUser: authManager.loggedUser,
Expand Down Expand Up @@ -529,7 +530,7 @@ export const useAppStore = create<IAppState>()((set, get) => {
}
// TODO: consolidate
// const ALGORITHMS = new Set<TMPCAlgorithm>(["MPC_CMP_ECDSA_SECP256K1"]);
const ALGORITHMS = new Set<TMPCAlgorithm>(["MPC_ECDSA_SECP256K1"]);
const ALGORITHMS = new Set<TMPCAlgorithm>(["MPC_ECDSA_SECP256K1","MPC_EDDSA_ED25519"]);
await fireblocksNCW.generateMPCKeys(ALGORITHMS);
},
stopMpcDeviceSetup: async () => {
Expand Down
32 changes: 0 additions & 32 deletions example/src/components/AssetRow.tsx

This file was deleted.

18 changes: 12 additions & 6 deletions example/src/components/Assets.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React, { useRef } from "react";
import { useAppStore } from "../AppStore";
import { AssetRow } from "./AssetRow";
// import { Autocomplete } from "./ui/Autocomplete";
import { Card } from "./ui/Card";
import { IActionButtonProps } from "./ui/ActionButton";
import { Row, Table } from "react-native-reanimated-table";
import { Button, Text, View } from "react-native";
import { AutocompleteDropdown, AutocompleteDropdownRef } from "react-native-autocomplete-dropdown";
import { SvgUri } from "react-native-svg";
import { Copyable } from "./ui/Copyable";

export const Assets: React.FC = () => {
const { accounts, refreshAccounts, addAsset, refreshSupportedAssets, supportedAssets } = useAppStore();
Expand Down Expand Up @@ -67,17 +67,23 @@ export const Assets: React.FC = () => {
{hasAccounts &&
accounts.map((account, index) => (
<View key={`asset_account_${index}`}>
<Table key={`account${index}`}>
<Table key={`account${index}`}>
<Row data={[
"Asset",
"Name",
"Type",
"Address",
"Balance"
]} />
{Object.entries(account).map(([assetId, assetInfo]) =>
<Row key={`asset_account_row_${index}_${assetId}`} data={[assetId, assetInfo.asset.name, assetInfo.asset.type, assetInfo.address?.address, assetInfo.balance?.total]} />
)}
{Object.entries(account).map(([assetId, assetInfo]) => (
<React.Fragment key={`asset_account_row_${index}_${assetId}`}>
<Row data={[
assetId,
assetInfo.asset.name,
<Copyable value={assetInfo.address?.address ?? ""} />,
<Text style={{ textAlign: 'center' }}>{assetInfo.balance?.total}</Text>

Check warning on line 83 in example/src/components/Assets.tsx

View workflow job for this annotation

GitHub Actions / lint

Inline style: { textAlign: 'center' }
]} />
</React.Fragment>
))}
</Table>
<View style={{
justifyContent: "space-between",
Expand Down
5 changes: 4 additions & 1 deletion example/src/components/DeriveAssetsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ export const DeriveAssetsList: React.FC<IProps> = ({ privateKey }) => {
<Table>
<Row data={["Asset", "Name", "Derrived Key"]}></Row>
{assetsListItems.map((assetListItem) => (
<Row key={`derrived_${assetListItem.id}`} data={[assetListItem.assetId, assetListItem.name, assetListItem.derivedAssetKey]} />
<Row key={`derrived_${assetListItem.id}`} data={[
assetListItem.assetId,
assetListItem.name,
<Copyable value={assetListItem.derivedAssetKey} />]} />
// <tr key={assetListItem.id}>
// <td className="flex items-center gap-2">
// {assetListItem.iconUrl ? <img src={assetListItem.iconUrl} className="w-8 h-8"></img> : missingIcon}
Expand Down
19 changes: 16 additions & 3 deletions example/src/components/GenerateMPCKeys.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ export const GenerateMPCKeys: React.FC = () => {
};

const secP256K1Status = keysStatus?.MPC_ECDSA_SECP256K1?.keyStatus ?? null;
const ed25519Status = keysStatus?.MPC_EDDSA_ED25519?.keyStatus ?? null;

const statusToProgress = (status: TKeyStatus | null) => {
switch (status) {
case "INITIATED":
Expand All @@ -76,12 +78,13 @@ export const GenerateMPCKeys: React.FC = () => {
return 0;
}
};
const secP256K1Ready = secP256K1Status === "READY";

const secP256K1Ready = secP256K1Status === "READY";
const ed25519Ready = ed25519Status === "READY";
const generateAction: IActionButtonProps = {
label: "Generate MPC Keys",
action: doGenerateMPCKeys,
isDisabled: isGenerateInProgress || secP256K1Ready,
isDisabled: isGenerateInProgress || (secP256K1Ready && ed25519Ready),
isInProgress: isGenerateInProgress,
};

Expand All @@ -95,7 +98,7 @@ export const GenerateMPCKeys: React.FC = () => {
const approveJoinWalletAction: IActionButtonProps = {
label: "Approve Join Wallet",
action: () => setShowScanQr(true),
isDisabled: (isStopInProgress || isGenerateInProgress) && secP256K1Ready,
isDisabled: (isStopInProgress || isGenerateInProgress) && (secP256K1Ready || ed25519Ready),
};
const stopApproveWalletAction: IActionButtonProps = {
label: "Stop Approve Join Wallet",
Expand All @@ -119,13 +122,23 @@ export const GenerateMPCKeys: React.FC = () => {
"ECDSA SECP256K1",
secP256K1Status ?? "N/A",
]}/>
<Row data={[
"EDDSA_ED25519",
ed25519Status ?? "N/A",
]}/>
</Table>
</View>
{ secP256K1Status && (
<View>
<Bar progress={statusToProgress(secP256K1Status)/100} width={null} />
</View>
)}
<View style={{ height: 10 }} />
{ ed25519Status && (
<View>
<Bar progress={statusToProgress(ed25519Status)/100} width={null} />
</View>
)}
{ generateMPCKeysResult && (
<View>
<Text>Result: {generateMPCKeysResult}</Text>
Expand Down
5 changes: 5 additions & 0 deletions example/src/components/ui/Copyable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from "react";
import { StyleSheet, Text, View } from "react-native";
import Clipboard from '@react-native-clipboard/clipboard';
import Svg, { Path } from "react-native-svg";
import { Alert } from "react-native";
import { Platform } from "react-native";

function writeToClipboard(value: string) {
Clipboard.setString(value);
Expand Down Expand Up @@ -31,6 +33,9 @@ const styles = StyleSheet.create({
export const Copyable: React.FC<{ value: string }> = ({ value }) => {
const doCopy = () => {
writeToClipboard(value);
if (Platform.OS === 'ios') {
Alert.alert("Copied to Clipboard", "The text has been copied to your clipboard.");
}
};

const clipboardIcon = (
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fireblocks/react-native-ncw-sdk",
"version": "1.0.1",
"version": "1.0.2",
"description": "NCW SDK Native bridge",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
Loading

0 comments on commit 6349dd5

Please sign in to comment.