-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.tsx
36 lines (33 loc) · 797 Bytes
/
api.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import { WindowPostMessageStream } from '@metamask/post-message-stream';
import { addApp, removeApp, list } from "./providers/apps";
import appsData from "./apps.json";
const api = async (stream: WindowPostMessageStream, data: any) => {
console.log("lw api request", data);
switch (data.type + "/" + data.method) {
case "apps/data":
stream.write({
id: data.id,
res: appsData
});
break
case "apps/addApp":
addApp(data.args[0]);
stream.write({
id: data.id,
})
break
case "apps/removeApp":
removeApp(data.args[0]);
stream.write({
id: data.id,
})
break
case "apps/list":
stream.write({
id: data.id,
res: list()
})
break
}
}
export default api;