mirror of
https://github.com/andrei0x309/clear-wallet.git
synced 2024-11-18 23:41:10 +00:00
chore: changes for 1.4.2
This commit is contained in:
parent
f5d8d8ba8d
commit
76c0ffa422
@ -1,5 +1,9 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Manifest Version 1.4.3
|
||||||
|
|
||||||
|
- changed sign in with farcaster to work with new type of QR code
|
||||||
|
|
||||||
## Manifest Version 1.4.2
|
## Manifest Version 1.4.2
|
||||||
|
|
||||||
- better show farcaster wallet acion button
|
- better show farcaster wallet acion button
|
||||||
|
12
CI/index.ts
12
CI/index.ts
@ -68,9 +68,9 @@ const main = async () => {
|
|||||||
const VERSION = GithubEvent.inputs.version;
|
const VERSION = GithubEvent.inputs.version;
|
||||||
const FCONLY = GithubEvent.inputs.fconly;
|
const FCONLY = GithubEvent.inputs.fconly;
|
||||||
const message = `Clear Wallet - New version ${VERSION} released! \n
|
const message = `Clear Wallet - New version ${VERSION} released! \n
|
||||||
ChangeLog: https://bit.ly/clw-cl \n
|
- ChromeStore: https://bit.ly/clw-evm \n
|
||||||
ChromeStore: https://bit.ly/clw-evm \n
|
- ChangeLog: https://bit.ly/clw-cl \n
|
||||||
`
|
- Submited by @andrei0x309 \n`
|
||||||
if (ENABLED) {
|
if (ENABLED) {
|
||||||
if (!FCONLY) {
|
if (!FCONLY) {
|
||||||
await yupAPI.sendPost({
|
await yupAPI.sendPost({
|
||||||
@ -103,9 +103,9 @@ const main = async () => {
|
|||||||
if (ENABLED && !GithubEvent.forced && GithubEvent?.head_commit?.message.includes('chore:') && !GithubEvent?.head_commit?.message.includes('!')) {
|
if (ENABLED && !GithubEvent.forced && GithubEvent?.head_commit?.message.includes('chore:') && !GithubEvent?.head_commit?.message.includes('!')) {
|
||||||
const commiter = GithubEvent?.head_commit?.author.username || GithubEvent?.head_commit?.committer?.username || ''
|
const commiter = GithubEvent?.head_commit?.author.username || GithubEvent?.head_commit?.committer?.username || ''
|
||||||
const message = `Github ClearWallet new repo commit!\n
|
const message = `Github ClearWallet new repo commit!\n
|
||||||
ChromeStore: https://bit.ly/clw-evm \n
|
- ChromeStore: https://bit.ly/clw-evm \n
|
||||||
Commit: ${GithubEvent.head_commit.url} \n
|
- Commit: ${GithubEvent.head_commit.url} \n
|
||||||
${commiter ? `By: ${commiter}` : ''}
|
${commiter ? `- Commiter: @${commiter}` : ''}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
await yupAPI.sendPost({
|
await yupAPI.sendPost({
|
||||||
|
@ -3,11 +3,40 @@ import { FARCASTER_PARTIAL_KEY_ABI } from './abis'
|
|||||||
import { ethers } from 'ethers'
|
import { ethers } from 'ethers'
|
||||||
import { getUrl } from './platform'
|
import { getUrl } from './platform'
|
||||||
import { generateApiToken } from './warpcast-auth'
|
import { generateApiToken } from './warpcast-auth'
|
||||||
|
export interface TChannelTokenStatusResponse {
|
||||||
|
state: string;
|
||||||
|
nonce: string;
|
||||||
|
signatureParams: {
|
||||||
|
siweUri: string;
|
||||||
|
domain: string;
|
||||||
|
nonce: string;
|
||||||
|
notBefore: string;
|
||||||
|
expirationTime: string;
|
||||||
|
}
|
||||||
|
;
|
||||||
|
metadata: {
|
||||||
|
userAgent: string;
|
||||||
|
ip: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const TOKEN_STATUS_ENDPOINT = 'https://relay.farcaster.xyz/v1/channel/status'
|
||||||
const WARPCAST_BASE = 'https://client.warpcast.com/v2/'
|
const WARPCAST_BASE = 'https://client.warpcast.com/v2/'
|
||||||
const EP_SIGNIN = `${WARPCAST_BASE}sign-in-with-farcaster`
|
const EP_SIGNIN = `${WARPCAST_BASE}sign-in-with-farcaster`
|
||||||
const FC_ID_REGISTRY_CONTRACT = '0x00000000fc6c5f01fc30151999387bb99a9f489b'
|
const FC_ID_REGISTRY_CONTRACT = '0x00000000fc6c5f01fc30151999387bb99a9f489b'
|
||||||
|
|
||||||
|
|
||||||
|
const getChannelTokenStatus = async (channelToken: string) => {
|
||||||
|
const response = await fetch(`${TOKEN_STATUS_ENDPOINT}`, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': `Bearer ${channelToken}`
|
||||||
|
},
|
||||||
|
})
|
||||||
|
return response.json() as Promise<TChannelTokenStatusResponse>
|
||||||
|
}
|
||||||
|
|
||||||
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');
|
||||||
@ -34,9 +63,26 @@ export const extractLinkData = (link: string) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const extractResponseData = async (channelToken: string) => {
|
||||||
|
try {
|
||||||
|
const response = await getChannelTokenStatus(channelToken);
|
||||||
|
let { siweUri, domain, nonce, notBefore, expirationTime } = response.signatureParams;
|
||||||
|
nonce = nonce || (Math.random() + 1).toString(36).substring(7);
|
||||||
|
return {
|
||||||
|
siweUri,
|
||||||
|
domain,
|
||||||
|
nonce,
|
||||||
|
notBefore,
|
||||||
|
expirationTime
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export const validateLinkData = (link: string) => {
|
export const validateLinkData = (link: string) => {
|
||||||
const { channelToken, nonce, siweUri, domain} = extractLinkData(link);
|
const { channelToken} = extractLinkData(link);
|
||||||
if (!channelToken || !siweUri || !domain || !nonce) {
|
if (!channelToken) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -118,12 +164,21 @@ export const doSignInWithFarcaster = async ({
|
|||||||
}: {
|
}: {
|
||||||
link: string
|
link: string
|
||||||
}) => {
|
}) => {
|
||||||
const { channelToken, nonce, siweUri, domain, notBefore, expirationTime } = extractLinkData(link);
|
const { channelToken } = extractLinkData(link);
|
||||||
const custodyAddress = (await getSelectedAddress())?.[0] || '';
|
const custodyAddress = (await getSelectedAddress())?.[0] || '';
|
||||||
const fid = custodyAddress && await getFidFromAddress(custodyAddress);
|
const fid = custodyAddress && await getFidFromAddress(custodyAddress);
|
||||||
if (!fid) {
|
if (!fid) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const extractResult = await extractResponseData(channelToken);
|
||||||
|
|
||||||
|
if (!extractResult) {
|
||||||
|
return -3;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { siweUri, domain, nonce, notBefore, expirationTime } = extractResult
|
||||||
|
|
||||||
const message = constructWarpcastSWIEMsg({
|
const message = constructWarpcastSWIEMsg({
|
||||||
siweUri,
|
siweUri,
|
||||||
domain,
|
domain,
|
||||||
|
@ -344,6 +344,12 @@ export default defineComponent({
|
|||||||
alertOpen.value = true;
|
alertOpen.value = true;
|
||||||
swloading.value = false;
|
swloading.value = false;
|
||||||
return;
|
return;
|
||||||
|
} else if (result === -3) {
|
||||||
|
alertMsg.value =
|
||||||
|
"Error could not get signer params from farcaster relay, try again";
|
||||||
|
alertOpen.value = true;
|
||||||
|
swloading.value = false;
|
||||||
|
return;
|
||||||
} else {
|
} else {
|
||||||
alertHeader.value = "OK";
|
alertHeader.value = "OK";
|
||||||
alertMsg.value =
|
alertMsg.value =
|
||||||
|
Loading…
Reference in New Issue
Block a user