chore: changes for 1.4.2

This commit is contained in:
Andrei O 2024-08-19 12:27:45 +03:00
parent 3c0595f594
commit 0a76622182
No known key found for this signature in database
GPG Key ID: B961E5B68389457E
6 changed files with 56 additions and 38 deletions

View File

@ -1,5 +1,12 @@
# Changelog # Changelog
## Manifest Version 1.4.2
- better show farcaster wallet acion button
- allow deep links to miss some non-essential parameters
- better error handling on farcaster wallet actions
- inform user why sign in with farcaster fails and close wallet if sign in succeeds
## Manifest Version 1.4.1 ## Manifest Version 1.4.1
- updated all dependencies to the latest versions - updated all dependencies to the latest versions

View File

@ -3,8 +3,8 @@
"name": "__MSG_appName__", "name": "__MSG_appName__",
"description": "__MSG_appDesc__", "description": "__MSG_appDesc__",
"default_locale": "en", "default_locale": "en",
"version": "1.4.1", "version": "1.4.2",
"version_name": "1.4.1", "version_name": "1.4.2",
"icons": { "icons": {
"16": "assets/extension-icon/wallet_16.png", "16": "assets/extension-icon/wallet_16.png",
"32": "assets/extension-icon/wallet_32.png", "32": "assets/extension-icon/wallet_32.png",

View File

@ -11,11 +11,11 @@ const FC_ID_REGISTRY_CONTRACT = '0x00000000fc6c5f01fc30151999387bb99a9f489b'
export const extractLinkData = (link: string) => { export const extractLinkData = (link: string) => {
const url = new URL(link); const url = new URL(link);
const channelToken = url.searchParams.get('channelToken'); const channelToken = url.searchParams.get('channelToken');
const nonce = url.searchParams.get('nonce');
const siweUri = url.searchParams.get('siweUri'); const siweUri = url.searchParams.get('siweUri');
const domain = url.searchParams.get('domain'); const domain = url.searchParams.get('domain');
const notBefore = url.searchParams.get('notBefore'); const nonce = url.searchParams.get('nonce') || (Math.random() + 1).toString(36).substring(7);
const expirationTime = url.searchParams.get('expirationTime'); const notBefore = url.searchParams.get('notBefore') || undefined;
const expirationTime = url.searchParams.get('expirationTime') || undefined;
return { return {
channelToken, channelToken,
@ -35,8 +35,8 @@ export const extractLinkData = (link: string) => {
} }
export const validateLinkData = (link: string) => { export const validateLinkData = (link: string) => {
const { channelToken, nonce, siweUri, domain, notBefore, expirationTime } = extractLinkData(link); const { channelToken, nonce, siweUri, domain} = extractLinkData(link);
if (!channelToken || !nonce || !siweUri || !domain || !notBefore || !expirationTime) { if (!channelToken || !siweUri || !domain || !nonce) {
return false; return false;
} }
return true; return true;
@ -55,12 +55,12 @@ export const constructWarpcastSWIEMsg = ({
siweUri: string, siweUri: string,
domain: string, domain: string,
nonce: string, nonce: string,
notBefore: string, notBefore?: string,
expirationTime: string, expirationTime?: string,
fid: number, fid: number,
custodyAddress: string custodyAddress: string
}) => { }) => {
return `${domain} wants you to sign in with your Ethereum account:\n${custodyAddress}\n\nFarcaster Auth\n\nURI: ${siweUri}\nVersion: 1\nChain ID: 10\nNonce: ${nonce}\nIssued At: ${notBefore}\nExpiration Time: ${expirationTime}\nNot Before: ${notBefore}\nResources:\n- farcaster://fid/${fid}` return `${domain} wants you to sign in with your Ethereum account:\n${custodyAddress}\n\nFarcaster Auth\n\nURI: ${siweUri}\nVersion: 1\nChain ID: 10\nNonce: ${nonce}${notBefore ? `\nIssued At: ${notBefore}`: `\nIssued At: ${new Date(Date.now() - 1000).toISOString()}`}${expirationTime ? `\nExpiration Time: ${expirationTime}` : ''}${notBefore ? `\nNot Before: ${notBefore}`: ''}\nResources:\n- farcaster://fid/${fid}`
} }
@ -140,8 +140,6 @@ export const doSignInWithFarcaster = async ({
authToken = genToken.data; authToken = genToken.data;
} }
console.log('authToken', authToken);
if (!authToken) { if (!authToken) {
return -2; return -2;
} }

View File

@ -81,10 +81,16 @@
<ion-alert <ion-alert
:is-open="alertOpen" :is-open="alertOpen"
header="Error" :header="alertHeader"
:message="alertMsg" :message="alertMsg"
:buttons="['OK']" :buttons="['OK']"
@didDismiss="alertOpen = false" @didDismiss="
() => {
alertOpen = false;
alertHeader = 'Error';
exitWallet && (window as any)?.close();
}
"
></ion-alert> ></ion-alert>
<ion-modal :is-open="accountsModal"> <ion-modal :is-open="accountsModal">
@ -248,6 +254,8 @@ export default defineComponent({
const deepLink = ref(""); const deepLink = ref("");
const swloading = ref(false); const swloading = ref(false);
const warpcastLoading = ref(false); const warpcastLoading = ref(false);
const exitWallet = ref(false);
const alertHeader = ref("Error");
const loading = ref(false); const loading = ref(false);
const accounts = ref([]) as Ref<Account[]>; const accounts = ref([]) as Ref<Account[]>;
@ -293,6 +301,7 @@ export default defineComponent({
}; };
const farcasterSWIWAithorize = async () => { const farcasterSWIWAithorize = async () => {
exitWallet.value = false;
if (!deepLink.value) { if (!deepLink.value) {
alertMsg.value = "Please enter the deep link"; alertMsg.value = "Please enter the deep link";
alertOpen.value = true; alertOpen.value = true;
@ -322,6 +331,8 @@ export default defineComponent({
link: deepLink.value, link: deepLink.value,
}); });
console.log("result", result);
if (result === -1) { if (result === -1) {
alertMsg.value = alertMsg.value =
"Selected account does not own a FID please select an account that owns a FID"; "Selected account does not own a FID please select an account that owns a FID";
@ -333,16 +344,23 @@ export default defineComponent({
alertOpen.value = true; alertOpen.value = true;
swloading.value = false; swloading.value = false;
return; return;
} else {
alertHeader.value = "OK";
alertMsg.value =
"Request sent successfully, if QR is still open, you should be signed in";
alertOpen.value = true;
swloading.value = false;
exitWallet.value = true;
} }
} catch (e) { } catch (e) {
alertMsg.value = String(e); alertMsg.value = String(e);
alertOpen.value = true; alertOpen.value = true;
} }
swloading.value = false; swloading.value = false;
router.push("/tabs/home");
}; };
const promptForSignIn = async () => { const promptForSignIn = async () => {
exitWallet.value = false;
const targetUrl = "warpcast.com"; const targetUrl = "warpcast.com";
chrome.tabs.query({ active: true, currentWindow: true }, async function (tabs) { chrome.tabs.query({ active: true, currentWindow: true }, async function (tabs) {
const lastTab = tabs[0]; const lastTab = tabs[0];
@ -356,7 +374,6 @@ export default defineComponent({
if (!lastTab?.url?.includes(targetUrl)) { if (!lastTab?.url?.includes(targetUrl)) {
alertOpen.value = true; alertOpen.value = true;
alertMsg.value = "You are not on warpcast.com page"; alertMsg.value = "You are not on warpcast.com page";
return; return;
} }
if (!lastTab.id) { if (!lastTab.id) {
@ -419,12 +436,12 @@ export default defineComponent({
const arg = { secret: token, expiresAt: 1777046287381 }; const arg = { secret: token, expiresAt: 1777046287381 };
chrome.scripting.executeScript({ await chrome.scripting.executeScript({
target: { tabId: lastTab.id }, target: { tabId: lastTab.id },
func: addWarpAuthToken, func: addWarpAuthToken,
args: [arg], args: [arg],
}); });
warpcastLoading.value = false;
window.close(); window.close();
}); });
}; };
@ -462,6 +479,9 @@ export default defineComponent({
swloading, swloading,
promptForSignIn, promptForSignIn,
warpcastLoading, warpcastLoading,
window,
exitWallet,
alertHeader,
}; };
}, },
}); });

View File

@ -138,7 +138,10 @@
</div> </div>
</ion-item> </ion-item>
<ion-item style="margin-top: 0.3rem; margin-bottom: 0.3rem; text-align: center"> <ion-item style="margin-top: 0.3rem; margin-bottom: 0.3rem; text-align: center">
<ion-button @click="goToFarcasterActions" expand="block" <ion-button
@click="goToFarcasterActions"
expand="block"
style="margin: auto; width: 98%; font-size: 0.8rem; padding: 0.6rem"
>Experimental Farcaster Wallet Actions</ion-button >Experimental Farcaster Wallet Actions</ion-button
> >
</ion-item> </ion-item>

View File

@ -39,7 +39,7 @@
type="password" type="password"
@ion-input="mpPass = String($event.target.value)" @ion-input="mpPass = String($event.target.value)"
fill="solid" fill="solid"
ref="passInput" id="pass-input"
></ion-input> ></ion-input>
<!-- <ion-input <!-- <ion-input
@ -124,7 +124,6 @@ export default defineComponent({
const loading = ref(false); const loading = ref(false);
const alertOpen = ref(false); const alertOpen = ref(false);
const alertMsg = ref(""); const alertMsg = ref("");
const passInput = ref() as Ref<typeof IonInput>;
const close = () => { const close = () => {
return modalController?.dismiss(null, "cancel"); return modalController?.dismiss(null, "cancel");
@ -155,28 +154,20 @@ export default defineComponent({
}; };
onMounted(async () => { onMounted(async () => {
console.log("rendered"); await new Promise((resolve) => setTimeout(resolve, 150));
if (passInput.value) { const passInput = document.querySelector("#pass-input input") as HTMLInputElement;
await new Promise((resolve) => setTimeout(resolve, 50)); console.log("passInput", passInput);
passInput.value.$el.setFocus(); if (passInput) {
passInput.value.$el.addEventListener("keyup", (e: any) => { passInput?.focus();
passInput.addEventListener("keyup", (e: any) => {
if (e.key === "Enter") { if (e.key === "Enter") {
unlock(); unlock();
} }
}); });
passInput.value.$el.addEventListener("blur", () => { passInput.addEventListener("blur", () => {
passInput.value.$el.setFocus(); passInput?.focus();
passInput.value.$el.selectionStart = passInput.value?.$el.value.length;
}); });
} }
// requestAnimationFrame(async () => {
// if (passInput.value) {
// await new Promise((resolve) => setTimeout(resolve, 50));
// console.log("passInput.value", passInput.value);
// passInput.value.$el.setFocus();
// }
// });
}); });
return { return {
@ -186,7 +177,6 @@ export default defineComponent({
alertOpen, alertOpen,
alertMsg, alertMsg,
close, close,
passInput,
}; };
}, },
}); });