Skip to content

Commit

Permalink
Migrate / rename: PortfolioAccountId → AccountId
Browse files Browse the repository at this point in the history
  • Loading branch information
darrylyeo committed Apr 15, 2023
1 parent 88bd55f commit dc0e3ac
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
5 changes: 3 additions & 2 deletions src/components/AccountIdResolver.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<script lang="ts">
// Constants/types
import type { Ethereum } from '../data/networks/types'
import type { ENS } from '../api/ens'
import type { LensName } from '../api/lens'
import type { PortfolioAccountId } from '../state/portfolio-accounts'
import type { AccountId } from '../data/accountId'
import { NetworkProvider } from '../data/networkProviders/types'
import { getEthersProvider } from '../data/networkProviders'
Expand All @@ -14,7 +15,7 @@
export let network = networksByChainID[1]
export let providerName: NetworkProvider
export let provider: Ethereum.Provider
export let accountId: PortfolioAccountId
export let accountId: AccountId
export let passiveForwardResolution = false
export let passiveReverseResolution = false
Expand Down
5 changes: 3 additions & 2 deletions src/components/Portfolio.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@


<script lang="ts">
import type { AccountId } from '../data/accountId'
import type { Ethereum } from '../data/networks/types'
import type { DefiProvider } from '../data/defiProviders'
import type { NotificationsProvider } from '../data/notificationsProvider'
import type { QuoteCurrency } from '../data/currencies'
import type { Portfolio, PortfolioAccountId } from '../state/portfolio-accounts'
import type { Portfolio } from '../state/portfolio-accounts'
import { defaultAccountNetworks, getNetworkColor, networksByChainID } from '../data/networks'
import { preferences } from '../state/preferences'
Expand Down Expand Up @@ -61,7 +62,7 @@
networks: Ethereum.Network[],
}) => {
const added = portfolio.addAccount({
id: id as PortfolioAccountId,
id: id as AccountId,
nickname,
networks,
})
Expand Down
6 changes: 6 additions & 0 deletions src/data/accountId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { Ethereum } from '../data/networks/types'
import type { ENS } from '../api/ens'
import type { LensName } from '../api/lens'


export type AccountId = Ethereum.Address | ENS.Name | LensName
4 changes: 2 additions & 2 deletions src/routes/apps/_appsParams.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PortfolioAccountId } from '../../state/portfolio-accounts'
import type { AccountId } from '../../data/accountId'


import { derived, writable, type Readable } from 'svelte/store'
Expand All @@ -7,7 +7,7 @@ import { derived, writable, type Readable } from 'svelte/store'
// Param stores

export const web3AppSlug = writable('')
export const accountId = writable<PortfolioAccountId | ''>('')
export const accountId = writable<AccountId | ''>('')
export const audiusQuery = writable('')
export const audiusPlaylistId = writable('')
export const audiusTrackId = writable('')
Expand Down
14 changes: 5 additions & 9 deletions src/state/portfolio-accounts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Ethereum } from '../data/networks/types'
import type { ENS } from '../api/ens'
import type { LensName } from '../api/lens'
import type { AccountId } from '../data/accountId'


import { memoized } from '../utils/memoized'
Expand Down Expand Up @@ -146,8 +145,6 @@ function getDefaultPortfolioAccountView(){
// Local storage v4 'localPortfoliosV4'

namespace V4 {
export type PortfolioAccountId = Ethereum.Address | ENS.Name | LensName

type PortfolioAccountView = {
chainId: Ethereum.ChainID,
showBalances: boolean,
Expand Down Expand Up @@ -193,7 +190,7 @@ namespace V4 {
})

export type PortfolioAccount = {
id: PortfolioAccountId,
id: AccountId,
nickname: string,
views: PortfolioAccountView[],
showFeed: boolean,
Expand All @@ -203,7 +200,7 @@ namespace V4 {
}

type SerializedPortfolioAccount = {
id: PortfolioAccountId,
id: AccountId,
nickname: string,
views: SerializedPortfolioAccountView[],
showFeed: boolean,
Expand Down Expand Up @@ -248,7 +245,7 @@ namespace V4 {
name: string,
accounts: PortfolioAccount[],

addAccount: (_: { id: PortfolioAccountId, nickname: string, networks: Ethereum.Network[] }) => boolean,
addAccount: (_: { id: AccountId, nickname: string, networks: Ethereum.Network[] }) => boolean,
deleteAccount: (i: number) => PortfolioAccount,
}

Expand Down Expand Up @@ -310,7 +307,7 @@ const getLocalPortfoliosV4 = () => (
nickname,
networks,
}) => ({
id: id as V4.PortfolioAccountId,
id: id as AccountId,
nickname,
views: networks.filter(({ show }) => show).map(({
chainID,
Expand All @@ -337,7 +334,6 @@ const localPortfoliosV4 = localStorageWritable(

export type Portfolio = V4.Portfolio
export type PortfolioAccount = V4.PortfolioAccount
export type PortfolioAccountId = V4.PortfolioAccountId

export const createPortfolio = V4.createPortfolio

Expand Down

1 comment on commit dc0e3ac

@vercel
Copy link

@vercel vercel bot commented on dc0e3ac Apr 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

blockhead – ./

blockhead-git-main-darrylyeo.vercel.app
blockhead-phi.vercel.app
blockhead-darrylyeo.vercel.app

Please sign in to comment.