Skip to content

Commit

Permalink
🐛 fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
arihantbansal committed Aug 16, 2022
2 parents 4258f21 + f6fdcfe commit 62d5454
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 6 deletions.
16 changes: 10 additions & 6 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "react-native-url-polyfill/auto";
import { Buffer } from "buffer";
global.Buffer = global.Buffer || Buffer;
import React, { useCallback, useEffect, useRef, useState } from "react";
import { View } from "react-native";
import { StatusBar } from "expo-status-bar";
import * as SplashScreen from "expo-splash-screen";
import * as Linking from "expo-linking";
Expand All @@ -16,6 +17,7 @@ import { NativeBaseProvider, Button, VStack } from "native-base";
import MintImageStack from "./routes/MintImageStack";
import { useFonts } from "expo-font";
import Drawer from "./routes/Drawer";
import { NiftyAppProvider } from "./utils/context";

SplashScreen.preventAutoHideAsync();

Expand Down Expand Up @@ -134,11 +136,13 @@ export default function App() {
return null;
}
return (
<NativeBaseProvider>
<View onLayout={onLayoutRootView}>
<Drawer />
<StatusBar style="dark" />
</View>
</NativeBaseProvider>
<NiftyAppProvider>
<NativeBaseProvider>
<View onLayout={onLayoutRootView}>
<Drawer />
<StatusBar style="dark" />
</View>
</NativeBaseProvider>
</NiftyAppProvider>
);
}
27 changes: 27 additions & 0 deletions utils/context.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { PublicKey } from "@solana/web3.js";
import React, { useState } from "react";
import nacl from "tweetnacl";
import { NiftyContext, NiftyState } from "./types";

export const NiftyAppContext = React.createContext<NiftyContext>(null);

export const NiftyAppProvider: React.FC<React.ReactNode> = ({ children }) => {
const initialState: NiftyState = {
dappkeypair: nacl.box.keyPair(),
sharedsecret: new Uint8Array([]),
phantomWalletPublicKey: "",
session: PublicKey.default,
};
const [state, setState] = useState(initialState);

const updateState = (newState: NiftyState) => {
setState({
...newState,
...state,
});
};

return (
<NiftyAppContext.Provider value={{ state, updateState }}>{children}</NiftyAppContext.Provider>
);
};
14 changes: 14 additions & 0 deletions utils/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { BoxKeyPair } from "tweetnacl";
import { PublicKey } from "@solana/web3.js";

export interface NiftyState {
dappkeypair: BoxKeyPair;
sharedsecret: Uint8Array;
phantomWalletPublicKey: string;
session: PublicKey;
}

export type NiftyContext = {
state: NiftyState;
updateState: (newState: NiftyState) => void;
};

0 comments on commit 62d5454

Please sign in to comment.