Skip to content

Commit

Permalink
cleanup todos
Browse files Browse the repository at this point in the history
kibagateaux committed Dec 11, 2023
1 parent ad428a9 commit c1ff7d1
Showing 11 changed files with 13 additions and 51 deletions.
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -6,9 +6,8 @@
"scripts": {
"test": "jest",
"test:ci": "jest --ci --colors",
"start": "export EXPO_PUBLIC_APP_VARIANT=development; npx expo start;",
"postinstall": "patch-package && rn-nodeify --install all --hack",
"android": "expo run:android",
"android": "export EXPO_PUBLIC_APP_VARIANT=development; expo run:android",
"build:android": "eas build --local --platform android",
"deploy:android": "eas build --platform android",
"deploy:secrets": "eas secret:push --scope jinni-health --env-file ./.env",
2 changes: 1 addition & 1 deletion src/app/inventory/[item].tsx
Original file line number Diff line number Diff line change
@@ -87,7 +87,7 @@ const ItemPage: React.FC<ItemPageProps> = () => {
const result = itemOauthConfig.authorizationEndpoint
? await item.equip(promptAsync)
: await item.equip();
// if result.error = "transceive fai" try majik ritual again
// if result.error = "transceive fail" try majik ritual again
if (result) {
setStatus('post-equip');
// TODO api request to add item to their avatar (:DataProvider or :Resource?)
2 changes: 0 additions & 2 deletions src/assets/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
## Icons

TODO : move to their own subdirectory
https://docs.expo.dev/versions/latest/sdk/svg/

### Convert SVGs -> RN Component
25 changes: 9 additions & 16 deletions src/contexts/AuthContext.tsx
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ export const AuthProvider: React.FC<Props> = ({ children }) => {
const { sentry, segment } = useExternalServices();
const [player, setPlayer] = useState<Avatar | null>(null);
const [anonId, setAnonId] = useState<Identity | null>(null);
const [spellbook, setSpellbook] = useState<Wallet | null>(null); // TODO siger type
const [spellbook, setSpellbook] = useState<Wallet | null>(null);

const login = useCallback(
(id: string) => {
@@ -69,33 +69,26 @@ export const AuthProvider: React.FC<Props> = ({ children }) => {
// console.log("anon id save", _anon_);
setAnonId(_anon_);
saveId(ID_ANON_SLOT, _anon_);
// start tracking anon analytics for user if not logged in
segment?.identify(_anon_._commitment.toString());
} else {
setAnonId(id as Identity);
}
});
}
}, [anonId]);

// start tracking anon analytics for user if not logged in
if (anonId && !player?.id) segment?.identify(anonId.getCommitment().toString());
}, [anonId, segment]);

/**
* @desc Generate an anonymous Ethereum identity for the player if they dont already have one
* Save to local storage on the phone for later use and for authentication
*/
const getSpellBook = () => {
const getSpellBook = useCallback(async () => {
console.log('hydrate spellbook', spellbook);
if (spellbook?.address) return spellbook;
// blocks thread and makes app load super slow.
// ideally lazy load when we need it to cast spells.
// TODO add method to load and save when required and add to context
getSpells()
.then((w: Wallet) => {
if (!player?.id) login(w.address);
setSpellbook(w);
})
.catch((e: unknown) => sentry?.captureException(e));
};
const book = await getSpells();
if (!player?.id) login(book.address);
setSpellbook(book);
}, [spellbook, player, login]);

return (
<AuthContext.Provider value={{ player, anonId, spellbook, getSpellBook }}>
20 changes: 0 additions & 20 deletions src/inventory/__tests__/maliks-majik.test.ts
Original file line number Diff line number Diff line change
@@ -7,26 +7,6 @@
import { getStorage, saveStorage, PROOF_MALIKS_MAJIK_SLOT } from 'utils/config';
import maliksMajik from '../maliks-majik';

// TODO figure out how to stub NFC manager

const mockNfcManager = jest.fn();

jest.mock('react-native-nfc-manager', () => ({
// https://github.com/revtel/react-native-nfc-manager/__mocks__
NfcManagerModule: { start: mockNfcManager },
// NfcTech: { IsoDep: 'IsoDep' },
// Ndef: { uriRecord: jest.fn() },
// requestTechnology: jest.fn(),
// getTag: jest.fn(),
// setEventListener: jest.fn(),
// registerTagEventEx: jest.fn(),
// unregisterTagEventEx: jest.fn(),
// unregisterTagEvent: jest.fn(),
// registerTagEvent: jest.fn(),
// writeNdefMessage: jest.fn(),
// requestNdefWrite: jest.fn(),
}));

describe('item inventory', () => {
describe('Item Status', () => {
test('is unequipped if no proof in local storage', async () => {
4 changes: 0 additions & 4 deletions src/inventory/android-health-connect.ts
Original file line number Diff line number Diff line change
@@ -148,10 +148,6 @@ const checkStatus = async () => {
console.log('Inv:AndroidHealthConnect:checkStatus: equipped?', isEquipped);
if (isEquipped) return 'equipped';

// if getPermissions() permissions have been revoked
// return 'destroyed';
// TODO
// see if health connect is installed
console.log('Inv:AndroidHealthConnect:checkStatus: unequipped!', isEquipped);
return 'unequipped';
};
1 change: 0 additions & 1 deletion src/inventory/phone-location-background.ts
Original file line number Diff line number Diff line change
@@ -58,7 +58,6 @@
// // actions: [],
// };

// // TODO should we abstract NFC Manager out of SignWithID so we can request permissions separately?
// const initPermissions = () => {};
// const getPermissions = () => {};

1 change: 0 additions & 1 deletion src/inventory/phone-location-foreground.ts
Original file line number Diff line number Diff line change
@@ -58,7 +58,6 @@
// // actions: [],
// };

// // TODO should we abstract NFC Manager out of SignWithID so we can request permissions separately?
// const initPermissions = () => {};
// const getPermissions = () => {};

2 changes: 1 addition & 1 deletion src/types/GameMechanics.ts
Original file line number Diff line number Diff line change
@@ -123,8 +123,8 @@ export interface InventoryItem {
// helper function passes in contextdual data, user input, react hook, etc. that we cant hardcode in equip()
equip?: HoF;
unequip?: HoF;

// TODO refactor to object with ids as keys
//
abilities?: ItemAbility[]; // things user can do with the item
// dont know if widget on item page will be same as WidgetConfig.
// Might just be content and the id so only need list of ID strings here
1 change: 0 additions & 1 deletion src/utils/logging.ts
Original file line number Diff line number Diff line change
@@ -74,7 +74,6 @@ export const getSegment = () => {
* @returns if event tracking was sent or not
*/
export const track = (eventName: string, data: JsonMap) =>
// TODO add EAS_BUILD_PROFILE for tracking in test/prod
!__DEV__ &&
getSegment()?.track(eventName, {
...data,
3 changes: 1 addition & 2 deletions src/utils/zkpid.ts
Original file line number Diff line number Diff line change
@@ -72,7 +72,6 @@ export const _delete_id = async (idType: string): Promise<void> => {

/** TODO figure out return types from HaLo lib */
export const signWithId = async (id: string | Identity): Promise<object | null> => {
// if (!id) throw new Error(`ZK:HaLo: No id found for ${idType}`);
console.log('sign anon id with majik', id, typeof id);

try {
@@ -85,7 +84,7 @@ export const signWithId = async (id: string | Identity): Promise<object | null>
name: 'sign',
message: msg,
format: 'text',
keyNo: 1, // TODO do we want to use primary wallet for signing?
keyNo: 1,
});
console.log('ZK:HaLo: signature response: ', result);
return !result ? null : result;

0 comments on commit c1ff7d1

Please sign in to comment.