mirror of
https://github.com/mosip/inji-wallet.git
synced 2026-01-09 13:38:01 -05:00
chore: update lint fixes after rebase
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -77,4 +77,5 @@ dist/
|
||||
# @end expo-cli
|
||||
|
||||
.vscode/
|
||||
temp/
|
||||
temp/
|
||||
.eslintcache
|
||||
@@ -1,7 +1,7 @@
|
||||
import SmartShare from '@idpass/smartshare-react-native';
|
||||
import BluetoothStateManager from 'react-native-bluetooth-state-manager';
|
||||
import { EmitterSubscription } from 'react-native';
|
||||
import { EventFrom, send, sendParent, StateFrom } from 'xstate';
|
||||
import { assign, EventFrom, send, sendParent, StateFrom } from 'xstate';
|
||||
import { createModel } from 'xstate/lib/model';
|
||||
import { DeviceInfo } from '../components/DeviceInfoList';
|
||||
import { Message } from '../shared/Message';
|
||||
@@ -9,10 +9,7 @@ import { getDeviceNameSync } from 'react-native-device-info';
|
||||
import { StoreEvents } from './store';
|
||||
import { VC } from '../types/vc';
|
||||
import { AppServices } from '../shared/GlobalContext';
|
||||
import {
|
||||
RECEIVED_VCS_STORE_KEY,
|
||||
VC_ITEM_STORE_KEY,
|
||||
} from '../shared/constants';
|
||||
import { RECEIVED_VCS_STORE_KEY, VC_ITEM_STORE_KEY } from '../shared/constants';
|
||||
import { ActivityLogEvents } from './activityLog';
|
||||
import { VcEvents } from './vc';
|
||||
|
||||
@@ -41,10 +38,10 @@ const model = createModel(
|
||||
BLUETOOTH_ENABLED: () => ({}),
|
||||
BLUETOOTH_DISABLED: () => ({}),
|
||||
STORE_READY: () => ({}),
|
||||
STORE_RESPONSE: (response: any) => ({ response }),
|
||||
STORE_RESPONSE: (response: unknown) => ({ response }),
|
||||
RECEIVE_DEVICE_INFO: (info: DeviceInfo) => ({ info }),
|
||||
RECEIVED_VCS_UPDATED: () => ({}),
|
||||
VC_RESPONSE: (response: any) => ({ response }),
|
||||
VC_RESPONSE: (response: unknown) => ({ response }),
|
||||
},
|
||||
}
|
||||
);
|
||||
@@ -245,7 +242,7 @@ export const requestMachine = model.createMachine(
|
||||
}
|
||||
},
|
||||
|
||||
generateConnectionParams: model.assign({
|
||||
generateConnectionParams: assign({
|
||||
connectionParams: () => SmartShare.getConnectionParameters(),
|
||||
}),
|
||||
|
||||
@@ -257,7 +254,7 @@ export const requestMachine = model.createMachine(
|
||||
incomingVc: (_, event) => event.vc,
|
||||
}),
|
||||
|
||||
registerLoggers: model.assign({
|
||||
registerLoggers: assign({
|
||||
loggers: () => {
|
||||
if (__DEV__) {
|
||||
return [
|
||||
@@ -282,7 +279,7 @@ export const requestMachine = model.createMachine(
|
||||
},
|
||||
}),
|
||||
|
||||
removeLoggers: model.assign({
|
||||
removeLoggers: assign({
|
||||
loggers: ({ loggers }) => {
|
||||
loggers?.forEach((logger) => logger.remove());
|
||||
return null;
|
||||
@@ -322,9 +319,7 @@ export const requestMachine = model.createMachine(
|
||||
|
||||
sendVcReceived: send(
|
||||
(context) => {
|
||||
return VcEvents.VC_RECEIVED(
|
||||
VC_ITEM_STORE_KEY(context.incomingVc)
|
||||
);
|
||||
return VcEvents.VC_RECEIVED(VC_ITEM_STORE_KEY(context.incomingVc));
|
||||
},
|
||||
{ to: (context) => context.serviceRefs.vc }
|
||||
),
|
||||
@@ -408,7 +403,7 @@ export const requestMachine = model.createMachine(
|
||||
|
||||
guards: {
|
||||
hasExistingVc: (context, event) => {
|
||||
const receivedVcs: string[] = event.response;
|
||||
const receivedVcs = event.response as string[];
|
||||
const vcKey = VC_ITEM_STORE_KEY(context.incomingVc);
|
||||
return receivedVcs.includes(vcKey);
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import SmartShare from '@idpass/smartshare-react-native';
|
||||
import LocationEnabler from 'react-native-location-enabler';
|
||||
import SystemSetting from 'react-native-system-setting';
|
||||
import { EventFrom, send, sendParent, StateFrom } from 'xstate';
|
||||
import { assign, EventFrom, send, sendParent, StateFrom } from 'xstate';
|
||||
import { createModel } from 'xstate/lib/model';
|
||||
import { EmitterSubscription, Linking, PermissionsAndroid } from 'react-native';
|
||||
import { DeviceInfo } from '../components/DeviceInfoList';
|
||||
@@ -50,7 +50,7 @@ const model = createModel(
|
||||
FLIGHT_REQUEST: () => ({}),
|
||||
LOCATION_REQUEST: () => ({}),
|
||||
UPDATE_VC_NAME: (vcName: string) => ({ vcName }),
|
||||
STORE_RESPONSE: (response: any) => ({ response }),
|
||||
STORE_RESPONSE: (response: unknown) => ({ response }),
|
||||
APP_ACTIVE: () => ({}),
|
||||
},
|
||||
}
|
||||
@@ -298,7 +298,7 @@ export const scanMachine = model.createMachine(
|
||||
reason: (_, event) => event.reason,
|
||||
}),
|
||||
|
||||
clearReason: model.assign({ reason: '' }),
|
||||
clearReason: assign({ reason: '' }),
|
||||
|
||||
setSelectedVc: model.assign({
|
||||
selectedVc: (context, event) => {
|
||||
@@ -309,7 +309,7 @@ export const scanMachine = model.createMachine(
|
||||
},
|
||||
}),
|
||||
|
||||
registerLoggers: model.assign({
|
||||
registerLoggers: assign({
|
||||
loggers: () => {
|
||||
if (__DEV__) {
|
||||
return [
|
||||
@@ -334,7 +334,7 @@ export const scanMachine = model.createMachine(
|
||||
},
|
||||
}),
|
||||
|
||||
removeLoggers: model.assign({
|
||||
removeLoggers: assign({
|
||||
loggers: ({ loggers }) => {
|
||||
loggers?.forEach((logger) => logger.remove());
|
||||
return [];
|
||||
@@ -400,7 +400,7 @@ export const scanMachine = model.createMachine(
|
||||
return () => listener.remove();
|
||||
},
|
||||
|
||||
checkAirplaneMode: (context) => (callback) => {
|
||||
checkAirplaneMode: () => (callback) => {
|
||||
SystemSetting.isAirplaneEnabled().then((enable) => {
|
||||
if (enable) {
|
||||
callback(model.events.FLIGHT_ENABLED());
|
||||
|
||||
@@ -342,9 +342,8 @@ export const vcItemMachine =
|
||||
},
|
||||
|
||||
guards: {
|
||||
hasCredential: (_, event) => {
|
||||
const vc =
|
||||
event.type === 'GET_VC_RESPONSE' ? event.vc : event.response;
|
||||
hasCredential: (_, event) => {
|
||||
const vc = event.type === 'GET_VC_RESPONSE' ? event.vc : event.response;
|
||||
|
||||
return vc?.credential != null && vc?.verifiableCredential != null;
|
||||
},
|
||||
@@ -359,7 +358,7 @@ export const createVcItemMachine = (
|
||||
serviceRefs: AppServices,
|
||||
vcKey: string
|
||||
) => {
|
||||
const [_, idType, id, requestId] = vcKey.split(':');
|
||||
const [, idType, id, requestId] = vcKey.split(':');
|
||||
return vcItemMachine.withContext({
|
||||
...vcItemMachine.context,
|
||||
serviceRefs,
|
||||
|
||||
211
machines/vid.ts
211
machines/vid.ts
@@ -1,211 +0,0 @@
|
||||
import { EventFrom, StateFrom, send, sendParent } from 'xstate';
|
||||
import { createModel } from 'xstate/lib/model';
|
||||
import { StoreEvents } from './store';
|
||||
import { VC } from '../types/vc';
|
||||
import { AppServices } from '../shared/GlobalContext';
|
||||
import { respond } from 'xstate/lib/actions';
|
||||
import { VidItemEvents } from './vidItem';
|
||||
import {
|
||||
MY_VIDS_STORE_KEY,
|
||||
RECEIVED_VIDS_STORE_KEY,
|
||||
VID_ITEM_STORE_KEY,
|
||||
} from '../shared/constants';
|
||||
|
||||
const model = createModel(
|
||||
{
|
||||
serviceRefs: {} as AppServices,
|
||||
myVids: [] as string[],
|
||||
receivedVids: [] as string[],
|
||||
vids: {} as Record<string, VC>,
|
||||
},
|
||||
{
|
||||
events: {
|
||||
VIEW_VID: (vid: VC) => ({ vid }),
|
||||
GET_VID_ITEM: (vidKey: string) => ({ vidKey }),
|
||||
STORE_RESPONSE: (response: unknown) => ({ response }),
|
||||
STORE_ERROR: (error: Error) => ({ error }),
|
||||
VID_ADDED: (vidKey: string) => ({ vidKey }),
|
||||
VID_RECEIVED: (vidKey: string) => ({ vidKey }),
|
||||
VID_DOWNLOADED: (vid: VC) => ({ vid }),
|
||||
REFRESH_MY_VIDS: () => ({}),
|
||||
REFRESH_RECEIVED_VIDS: () => ({}),
|
||||
GET_RECEIVED_VIDS: () => ({}),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
export const VidEvents = model.events;
|
||||
|
||||
export const vidMachine = model.createMachine(
|
||||
{
|
||||
tsTypes: {} as import('./vid.typegen').Typegen0,
|
||||
schema: {
|
||||
context: model.initialContext,
|
||||
events: {} as EventFrom<typeof model>,
|
||||
},
|
||||
id: 'vid',
|
||||
initial: 'init',
|
||||
states: {
|
||||
init: {
|
||||
initial: 'myVids',
|
||||
states: {
|
||||
myVids: {
|
||||
entry: ['loadMyVids'],
|
||||
on: {
|
||||
STORE_RESPONSE: {
|
||||
target: 'receivedVids',
|
||||
actions: ['setMyVids'],
|
||||
},
|
||||
},
|
||||
},
|
||||
receivedVids: {
|
||||
entry: ['loadReceivedVids'],
|
||||
on: {
|
||||
STORE_RESPONSE: {
|
||||
target: '#ready',
|
||||
actions: ['setReceivedVids'],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
ready: {
|
||||
id: 'ready',
|
||||
entry: [sendParent('READY')],
|
||||
on: {
|
||||
GET_RECEIVED_VIDS: {
|
||||
actions: ['getReceivedVidsResponse'],
|
||||
},
|
||||
GET_VID_ITEM: {
|
||||
actions: ['getVidItemResponse'],
|
||||
},
|
||||
VID_ADDED: {
|
||||
actions: ['prependToMyVids'],
|
||||
},
|
||||
VID_DOWNLOADED: {
|
||||
actions: ['setDownloadedVid'],
|
||||
},
|
||||
VID_RECEIVED: {
|
||||
actions: ['prependToReceivedVids'],
|
||||
},
|
||||
},
|
||||
type: 'parallel',
|
||||
states: {
|
||||
myVids: {
|
||||
initial: 'idle',
|
||||
states: {
|
||||
idle: {
|
||||
on: {
|
||||
REFRESH_MY_VIDS: 'refreshing',
|
||||
},
|
||||
},
|
||||
refreshing: {
|
||||
entry: ['loadMyVids'],
|
||||
on: {
|
||||
STORE_RESPONSE: {
|
||||
target: 'idle',
|
||||
actions: ['setMyVids'],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
receivedVids: {
|
||||
initial: 'idle',
|
||||
states: {
|
||||
idle: {
|
||||
on: {
|
||||
REFRESH_RECEIVED_VIDS: 'refreshing',
|
||||
},
|
||||
},
|
||||
refreshing: {
|
||||
entry: ['loadReceivedVids'],
|
||||
on: {
|
||||
STORE_RESPONSE: {
|
||||
target: 'idle',
|
||||
actions: ['setReceivedVids'],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
actions: {
|
||||
getReceivedVidsResponse: respond((context) => ({
|
||||
type: 'VID_RESPONSE',
|
||||
response: context.receivedVids,
|
||||
})),
|
||||
|
||||
getVidItemResponse: respond((context, event) => {
|
||||
const vid = context.vids[event.vidKey];
|
||||
return VidItemEvents.GET_VID_RESPONSE(vid);
|
||||
}),
|
||||
|
||||
loadMyVids: send(StoreEvents.GET(MY_VIDS_STORE_KEY), {
|
||||
to: (context) => context.serviceRefs.store,
|
||||
}),
|
||||
|
||||
loadReceivedVids: send(StoreEvents.GET(RECEIVED_VIDS_STORE_KEY), {
|
||||
to: (context) => context.serviceRefs.store,
|
||||
}),
|
||||
|
||||
setMyVids: model.assign({
|
||||
myVids: (_, event) => (event.response || []) as string[],
|
||||
}),
|
||||
|
||||
setReceivedVids: model.assign({
|
||||
receivedVids: (_, event) => (event.response || []) as string[],
|
||||
}),
|
||||
|
||||
setDownloadedVid: (context, event) => {
|
||||
context.vids[VID_ITEM_STORE_KEY(event.vid)] = event.vid;
|
||||
},
|
||||
|
||||
prependToMyVids: model.assign({
|
||||
myVids: (context, event) => [event.vidKey, ...context.myVids],
|
||||
}),
|
||||
|
||||
prependToReceivedVids: model.assign({
|
||||
receivedVids: (context, event) => [
|
||||
event.vidKey,
|
||||
...context.receivedVids,
|
||||
],
|
||||
}),
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
export function createVidMachine(serviceRefs: AppServices) {
|
||||
return vidMachine.withContext({
|
||||
...vidMachine.context,
|
||||
serviceRefs,
|
||||
});
|
||||
}
|
||||
|
||||
type State = StateFrom<typeof vidMachine>;
|
||||
|
||||
export function selectMyVids(state: State) {
|
||||
return state.context.myVids;
|
||||
}
|
||||
|
||||
export function selectShareableVids(state: State) {
|
||||
return state.context.myVids.filter(
|
||||
(vidKey) => state.context.vids[vidKey]?.credential != null
|
||||
);
|
||||
}
|
||||
|
||||
export function selectReceivedVids(state: State) {
|
||||
return state.context.receivedVids;
|
||||
}
|
||||
|
||||
export function selectIsRefreshingMyVids(state: State) {
|
||||
return state.matches('ready.myVids.refreshing');
|
||||
}
|
||||
|
||||
export function selectIsRefreshingReceivedVids(state: State) {
|
||||
return state.matches('ready.receivedVids.refreshing');
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
// This file was automatically generated. Edits will be overwritten
|
||||
|
||||
export interface Typegen0 {
|
||||
'@@xstate/typegen': true;
|
||||
'eventsCausingActions': {
|
||||
setMyVids: 'STORE_RESPONSE';
|
||||
setReceivedVids: 'STORE_RESPONSE';
|
||||
getReceivedVidsResponse: 'GET_RECEIVED_VIDS';
|
||||
getVidItemResponse: 'GET_VID_ITEM';
|
||||
prependToMyVids: 'VID_ADDED';
|
||||
setDownloadedVid: 'VID_DOWNLOADED';
|
||||
prependToReceivedVids: 'VID_RECEIVED';
|
||||
loadMyVids: 'REFRESH_MY_VIDS';
|
||||
loadReceivedVids: 'STORE_RESPONSE' | 'REFRESH_RECEIVED_VIDS';
|
||||
};
|
||||
'internalEvents': {
|
||||
'xstate.init': { type: 'xstate.init' };
|
||||
};
|
||||
'invokeSrcNameMap': {};
|
||||
'missingImplementations': {
|
||||
actions: never;
|
||||
services: never;
|
||||
guards: never;
|
||||
delays: never;
|
||||
};
|
||||
'eventsCausingServices': {};
|
||||
'eventsCausingGuards': {};
|
||||
'eventsCausingDelays': {};
|
||||
'matchesStates':
|
||||
| 'init'
|
||||
| 'init.myVids'
|
||||
| 'init.receivedVids'
|
||||
| 'ready'
|
||||
| 'ready.myVids'
|
||||
| 'ready.myVids.idle'
|
||||
| 'ready.myVids.refreshing'
|
||||
| 'ready.receivedVids'
|
||||
| 'ready.receivedVids.idle'
|
||||
| 'ready.receivedVids.refreshing'
|
||||
| {
|
||||
init?: 'myVids' | 'receivedVids';
|
||||
ready?:
|
||||
| 'myVids'
|
||||
| 'receivedVids'
|
||||
| {
|
||||
myVids?: 'idle' | 'refreshing';
|
||||
receivedVids?: 'idle' | 'refreshing';
|
||||
};
|
||||
};
|
||||
'tags': never;
|
||||
}
|
||||
@@ -72,4 +72,4 @@ export const SendVcModal: React.FC<SendVcModalProps> = (props) => {
|
||||
);
|
||||
};
|
||||
|
||||
interface SendVcModalProps extends ModalProps {}
|
||||
type SendVcModalProps = ModalProps;
|
||||
|
||||
Reference in New Issue
Block a user