Skip to content

Commit 167692e

Browse files
authored
feat: persist user evm address (#374)
* feat: persist user evm address * bump shinkai app 0.7.22
1 parent 105398f commit 167692e

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

apps/shinkai-desktop/src/pages/galxe-subscriptions.tsx

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
import { cn } from '@shinkai_network/shinkai-ui/utils';
1616
import { ExternalLinkIcon } from 'lucide-react';
1717
import { useEffect } from 'react';
18-
import { useForm } from 'react-hook-form';
18+
import { useForm, useWatch } from 'react-hook-form';
1919
import { Link } from 'react-router-dom';
2020
import { toast } from 'sonner';
2121
import { z } from 'zod';
@@ -25,6 +25,7 @@ import {
2525
useGalxeRegisterShinkaiDesktopInstallationMutation,
2626
} from '../lib/galxe/galxe-client';
2727
import { useAuth } from '../store/auth';
28+
import { useSettings } from '../store/settings';
2829

2930
export const RegisterShinkaiDesktopInstallationFormSchema = z.object({
3031
address: z.string().min(42),
@@ -40,6 +41,8 @@ const SUBSCRIPTION_PATH = '/My Subscriptions';
4041
export const GalxeSusbcriptions = () => {
4142
const { t } = useTranslation();
4243
const auth = useAuth((store) => store.auth);
44+
const evmAddress = useSettings((store) => store.evmAddress);
45+
const setEvmAddress = useSettings((store) => store.setEvmAddress);
4346

4447
const { inboxes } = useGetInboxes({
4548
nodeAddress: auth?.node_address ?? '',
@@ -103,7 +106,7 @@ export const GalxeSusbcriptions = () => {
103106
const form = useForm<RegisterShinkaiDesktopInstallationForm>({
104107
resolver: zodResolver(RegisterShinkaiDesktopInstallationFormSchema),
105108
defaultValues: {
106-
address: '',
109+
address: evmAddress,
107110
signature: subscriptionsProof?.[0],
108111
combined: subscriptionsProof?.[1],
109112
},
@@ -125,6 +128,17 @@ export const GalxeSusbcriptions = () => {
125128
validateQuest({ ...values });
126129
};
127130

131+
const currentEvmAddress = useWatch({
132+
control: form.control,
133+
name: 'address',
134+
});
135+
136+
useEffect(() => {
137+
if (currentEvmAddress) {
138+
setEvmAddress(currentEvmAddress);
139+
}
140+
}, [currentEvmAddress]);
141+
128142
useEffect(() => {
129143
form.setValue('signature', subscriptionsProof?.[0] ?? '');
130144
form.setValue('combined', subscriptionsProof?.[1] ?? '');
@@ -196,9 +210,7 @@ export const GalxeSusbcriptions = () => {
196210
name="address"
197211
render={({ field }) => (
198212
<TextField
199-
classes={{
200-
input: 'font-mono',
201-
}}
213+
classes={{ input: 'font-mono' }}
202214
endAdornment={
203215
<div className="w-8">
204216
<CopyToClipboardIcon

apps/shinkai-desktop/src/store/settings.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ type SettingsStore = {
1818
setOptInExperimental: (optInExperimental: boolean) => void;
1919
userLanguage: LocaleMode;
2020
setUserLanguage: (userLanguage: LocaleMode) => void;
21+
evmAddress: string;
22+
setEvmAddress: (evmAddress: string) => void;
2123
};
2224

2325
export const useSettings = create<SettingsStore>()(
@@ -62,6 +64,11 @@ export const useSettings = create<SettingsStore>()(
6264
set({ userLanguage });
6365
switchLanguage(userLanguage);
6466
},
67+
68+
evmAddress: '',
69+
setEvmAddress: (evmAddress) => {
70+
set({ evmAddress });
71+
},
6572
}),
6673
{
6774
name: 'settings',

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@shinkai/source",
3-
"version": "0.7.21",
3+
"version": "0.7.22",
44
"license": "SEE LICENSE IN LICENSE",
55
"files": [
66
"LICENSE"

0 commit comments

Comments
 (0)