From 181c72d913cd054927d73886af8ae1c340677750 Mon Sep 17 00:00:00 2001 From: AuroraHuang22 Date: Wed, 18 Sep 2024 20:52:59 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E2=9C=A8=20Supporting=20signArbitrary?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- store/wallet.ts | 39 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/store/wallet.ts b/store/wallet.ts index 1f2d646c..9169df79 100644 --- a/store/wallet.ts +++ b/store/wallet.ts @@ -1,7 +1,6 @@ /* eslint-disable import/no-extraneous-dependencies */ import { Module, VuexModule, Mutation, Action } from 'vuex-module-decorators' import axios from 'axios' -import { OfflineSigner } from '@cosmjs/proto-signing' import stringify from 'fast-json-stable-stringify'; import { catchAxiosError } from '~/utils/misc' import { LIKECOIN_WALLET_CONNECTOR_CONFIG } from '~/constant/network' @@ -39,7 +38,7 @@ async function getConnector() { export default class Wallet extends VuexModule { type = '' address = '' - signer: OfflineSigner | null = null + signer: any = null isShowKeplrWarning = false isOpenSnackbar = false likerInfo = null @@ -251,6 +250,40 @@ export default class Wallet extends VuexModule { sequence: '0', account_number: '0', } + + if (this.signer?.signArbitrary) { + const { signature, pub_key: publicKey } = + await this.signer?.signArbitrary( + LIKECOIN_WALLET_CONNECTOR_CONFIG.chainId, + this.address, + payload, + ) + const signDoc = { + msgs: [{ + type: 'sign/MsgSignData', + value: { + signer: this.address, + data: window.btoa(payload), + }, + }], + account_number: '0', + sequence: '0', + fee: { + gas: '0', + amount: [], + }, + memo: '', + chain_id: '', + } + return { + signature, + signMethod: 'ADR-036', + publicKey: publicKey.value, + message: stringify(signDoc), + wallet: this.address, + expiresIn: '7d', + } + } if ('signAmino' in this.signer) { const { signed, signature } = await this.signer.signAmino( this.address, @@ -262,7 +295,7 @@ export default class Wallet extends VuexModule { message: stringify(signed), wallet: this.address, signMethod: 'memo', - expiresIn: '1d', + expiresIn: '7d', } } throw new Error('SIGNER_NOT_SUPPORT_AMINO') From 1015cedfc26cdcf0cd51c3bd319f4994d2b0e3a1 Mon Sep 17 00:00:00 2001 From: AuroraHuang22 Date: Wed, 18 Sep 2024 20:55:35 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=8E=A8=20Remove=20duplicate=20expires?= =?UTF-8?q?In?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- store/book-api.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/store/book-api.ts b/store/book-api.ts index 7865accc..302f7914 100644 --- a/store/book-api.ts +++ b/store/book-api.ts @@ -37,7 +37,6 @@ export default class BookAPI extends VuexModule { const { data } = await axios.post( API_POST_AUTHORIZE, { - expiresIn: '7d', ...signature, }, ) From e6861c5e5254346b34d2cc1adef7a12f1f2ae05c Mon Sep 17 00:00:00 2001 From: AuroraHuang22 Date: Wed, 18 Sep 2024 21:29:53 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=9A=B8=20Improve=20login=20UX=20flow?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/AppHeader.vue | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/components/AppHeader.vue b/components/AppHeader.vue index 4fb7d70d..de9b2ee4 100644 --- a/components/AppHeader.vue +++ b/components/AppHeader.vue @@ -82,7 +82,13 @@ ]" >
+ +
+