diff --git a/.env.example b/.env.example index 333b05d..a48c745 100644 --- a/.env.example +++ b/.env.example @@ -3,6 +3,8 @@ # APIs LTAI_SUBSCRIPTIONS_API_URL=http://localhost:8000 -LTAI_BASE_ADDRESS=92e1d72210429Ce7eE8a0d64D526D4b9752801FF -LTAI_PUBLISHER_ADDRESS=0xae92Dc50115dbBb1CF0BA848e83842daf00CE129 WALLET_CONNECT_PROJECT_ID= + +# Blockchain addresses (change in development) +# LTAI_BASE_ADDRESS=0x92e1d72210429Ce7eE8a0d64D526D4b9752801FF +# LTAI_PUBLISHER_ADDRESS=0xae92Dc50115dbBb1CF0BA848e83842daf00CE129 diff --git a/src/apis/subscriptions/services.gen.ts b/src/apis/subscriptions/services.gen.ts index 1acce00..3715c5e 100644 --- a/src/apis/subscriptions/services.gen.ts +++ b/src/apis/subscriptions/services.gen.ts @@ -3,7 +3,7 @@ import { createClient, createConfig, type Options } from '@hey-api/client-axios'; import type { GetUserSubscriptionsSubscriptionsGetData, GetUserSubscriptionsSubscriptionsGetError, GetUserSubscriptionsSubscriptionsGetResponse, SubscribeHoldSubscriptionPostData, SubscribeHoldSubscriptionPostError, SubscribeHoldSubscriptionPostResponse, UnsubscribeHoldSubscriptionDeleteData, UnsubscribeHoldSubscriptionDeleteError, UnsubscribeHoldSubscriptionDeleteResponse, RefreshActiveHoldSubscriptionsHoldRefreshPostError, RefreshActiveHoldSubscriptionsHoldRefreshPostResponse, HoldSubscriptionMessagesHoldMessageGetData, HoldSubscriptionMessagesHoldMessageGetError, HoldSubscriptionMessagesHoldMessageGetResponse, RefreshSubsRefreshPostError, RefreshSubsRefreshPostResponse, SubscribeVouchersSubscriptionPostData, SubscribeVouchersSubscriptionPostError, SubscribeVouchersSubscriptionPostResponse, CancelVouchersSubscriptionsVouchersSubscriptionDeleteData, CancelVouchersSubscriptionsVouchersSubscriptionDeleteError, CancelVouchersSubscriptionsVouchersSubscriptionDeleteResponse, RefreshActiveVouchersSubscriptionsVouchersRefreshPostError, RefreshActiveVouchersSubscriptionsVouchersRefreshPostResponse } from './types.gen'; -export const client = createClient(createConfig({baseURL: process.env.LTAI_SUBSCRIPTIONS_API_UR})); +export const client = createClient(createConfig()); /** * Get User Subscriptions @@ -83,4 +83,4 @@ export const cancelVouchersSubscriptionsVouchersSubscriptionDelete = (options?: Options) => { return (options?.client ?? client).post({ ...options, url: '/vouchers/refresh' -}); }; +}); }; \ No newline at end of file diff --git a/src/config/env.ts b/src/config/env.ts new file mode 100644 index 0000000..3de6b6e --- /dev/null +++ b/src/config/env.ts @@ -0,0 +1,13 @@ +import { z } from 'zod'; + +const envSchema = z.object({ + ALEPH_API_URL: z.string().optional(), + LTAI_SUBSCRIPTIONS_API_URL: z.string(), + WALLET_CONNECT_PROJECT_ID: z.string(), + LTAI_BASE_ADDRESS: z.string().startsWith('0x').optional().default('0xF8B1b47AA748F5C7b5D0e80C726a843913EB573a'), + LTAI_PUBLISHER_ADDRESS: z.string().startsWith('0x').optional().default('0xCBFc3EeC41CBBfCAcc50337d712890C47a14ba99'), +}); + +const env = envSchema.parse(process.env); + +export default env; diff --git a/src/pages/AccountSettings.vue b/src/pages/AccountSettings.vue new file mode 100644 index 0000000..87d7f68 --- /dev/null +++ b/src/pages/AccountSettings.vue @@ -0,0 +1,21 @@ + + + diff --git a/src/router/index.ts b/src/router/index.ts index ad1f391..1eddd04 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -29,7 +29,7 @@ export default route(function (/* { store, ssrContext } */) { }); Router.beforeEach(async (_to, _from, next) => { - // @TODO ensure pinia+persist storage ready + // TODO ensure pinia+persist storage ready // something like await storageReady next(); }); diff --git a/src/router/routes.ts b/src/router/routes.ts index 839123f..f93dcd9 100644 --- a/src/router/routes.ts +++ b/src/router/routes.ts @@ -36,6 +36,7 @@ const routes = [ path: 'subscriptions', component: () => import('pages/Subscriptions.vue'), }, + { path: 'account', component: () => import('pages/AccountSettings.vue') }, ], }, diff --git a/src/stores/account.ts b/src/stores/account.ts index 1eefc9c..e72769f 100644 --- a/src/stores/account.ts +++ b/src/stores/account.ts @@ -7,8 +7,9 @@ import { base } from '@wagmi/vue/chains'; import { useTokensStore } from 'stores/tokens'; import { useKnowledgeStore } from 'stores/knowledge'; import { useSubscriptionStore } from 'stores/subscription'; +import env from 'src/config/env'; -const LTAI_BASE_ADDRESS = process.env.LTAI_BASE_ADDRESS || 'F8B1b47AA748F5C7b5D0e80C726a843913EB573a'; +const LTAI_BASE_ADDRESS = env.LTAI_BASE_ADDRESS as `0x${string}`; type AccountStoreState = { alephStorage: AlephPersistentStorage | null; @@ -66,7 +67,7 @@ export const useAccountStore = defineStore('account', { const balance = await getBalance(config, { address: account.address, - token: `0x${LTAI_BASE_ADDRESS}`, + token: LTAI_BASE_ADDRESS, chainId: base.id, }); diff --git a/src/stores/tokens.ts b/src/stores/tokens.ts index b56dc1f..e41eea6 100644 --- a/src/stores/tokens.ts +++ b/src/stores/tokens.ts @@ -1,5 +1,6 @@ import { defineStore } from 'pinia'; import { AlephHttpClient } from '@aleph-sdk/client'; +import env from 'src/config/env'; type TokensStoreState = { tokens: Record; @@ -7,7 +8,7 @@ type TokensStoreState = { estimated_3yr_tokens: Record; }; -const AGGREGATE_PUBLISHER_ADDRESS = process.env.LTAI_PUBLISHER_ADDRESS || '0xCBFc3EeC41CBBfCAcc50337d712890C47a14ba99'; +const AGGREGATE_PUBLISHER_ADDRESS = env.LTAI_PUBLISHER_ADDRESS; const AGGREGATE_KEYS = ['tokens', 'pending_tokens', 'estimated_3yr_tokens']; export const useTokensStore = defineStore('tokens', {