Skip to content

Commit

Permalink
✨ arsnap: Display a native notification when initializing Arsnap
Browse files Browse the repository at this point in the history
  • Loading branch information
noomly committed Jul 13, 2023
1 parent 25e87c1 commit cd79f43
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 2 additions & 1 deletion packages/arsnap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/pianity/arsnap.git"
},
"source": {
"shasum": "lh9Yp7fLTUGVOq9EtDqiRtac27qI50iaTUONJN/2z+E=",
"shasum": "M2oeOPKqhtdHPNG6nOKGxkEqoVqebAn76WbGWOUE05U=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand All @@ -20,6 +20,7 @@
"initialPermissions": {
"snap_manageState": {},
"snap_dialog": {},
"snap_notify": {},
"snap_getBip32Entropy": [
{
"path": [
Expand Down
10 changes: 9 additions & 1 deletion packages/arsnap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import * as handlers from "@/handlers";
import { getState, initializeState, replaceState, State } from "@/state";
import { exhaustive, ownerToAddress } from "@/utils";
import { guard } from "@/permissions";
import { RpcMessageHandler } from "@/metamask";
import { notify, RpcMessageHandler } from "@/metamask";

async function getLogInfo(request: RpcParam): Promise<RpcLogInfo> {
const { method, params } = request;
Expand Down Expand Up @@ -84,8 +84,16 @@ async function registerLog(state: State, origin: string, request: RpcParam) {
const handler: RpcMessageHandler = async ({ origin, request }): Promise<RpcResponse> => {
const [maybeState, releaseState] = await getState();

if (!maybeState) {
await notify("Initializing Arsnap, please allow up to 2 mins...");
}

const state = maybeState || (await initializeState());

if (!maybeState) {
await notify("Arsnap is ready.");
}

let response;

try {
Expand Down

0 comments on commit cd79f43

Please sign in to comment.