Skip to content

Commit

Permalink
Rename: addressOrEnsName → accountId
Browse files Browse the repository at this point in the history
  • Loading branch information
darrylyeo committed Apr 15, 2023
1 parent f4ab26a commit d8b6b1f
Show file tree
Hide file tree
Showing 22 changed files with 110 additions and 55 deletions.
4 changes: 2 additions & 2 deletions $houdini/types/src/routes/$houdini.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ type EnsureDefined<T> = T extends null | undefined ? {} : T;
type OptionalUnion<U extends Record<string, any>, A extends keyof U = U extends U ? keyof U : never> = U extends unknown ? { [P in Exclude<A, keyof U>]?: never } & U : never;
export type Snapshot<T = any> = Kit.Snapshot<T>;
type PageParentData = EnsureDefined<LayoutData>;
type LayoutRouteId = RouteId | "/" | "/apps" | "/apps/[web3AppSlug=isWeb3AppSlug]" | "/apps/[web3AppSlug=isWeb3AppSlug]/address/[addressOrEnsName]" | "/apps/audius" | "/apps/audius/playlist/[audiusPlaylistId]" | "/apps/audius/search/[audiusQuery]" | "/apps/audius/track/[audiusTrackId]" | "/apps/audius/user/[audiusUserId]" | "/apps/ens/address/[addressOrEnsName]" | "/explorer" | "/explorer/[networkSlug=isNetworkSlug]" | "/explorer/[networkSlug=isNetworkSlug]/[query=isBlockNumber]" | "/explorer/[networkSlug=isNetworkSlug]/[query=isEnsName]" | "/explorer/[networkSlug=isNetworkSlug]/[query=isEthereumAddress]" | "/explorer/[networkSlug=isNetworkSlug]/[query=isEthereumTransaction]" | "/explorer/bitcoin" | "/explorer/bitcoin/[query]" | "/portfolio" | "/transfer" | null
type LayoutParams = RouteParams & { web3AppSlug?: string,addressOrEnsName?: string,audiusPlaylistId?: string,audiusQuery?: string,audiusTrackId?: string,audiusUserId?: string,networkSlug?: string,query?: string }
type LayoutRouteId = RouteId | "/" | "/apps" | "/apps/[web3AppSlug=isWeb3AppSlug]" | "/apps/[web3AppSlug=isWeb3AppSlug]/address/[accountId]" | "/apps/audius" | "/apps/audius/playlist/[audiusPlaylistId]" | "/apps/audius/search/[audiusQuery]" | "/apps/audius/track/[audiusTrackId]" | "/apps/audius/user/[audiusUserId]" | "/apps/ens/address/[accountId]" | "/explorer" | "/explorer/[networkSlug=isNetworkSlug]" | "/explorer/[networkSlug=isNetworkSlug]/[query=isBlockNumber]" | "/explorer/[networkSlug=isNetworkSlug]/[query=isEnsName]" | "/explorer/[networkSlug=isNetworkSlug]/[query=isEthereumAddress]" | "/explorer/[networkSlug=isNetworkSlug]/[query=isEthereumTransaction]" | "/explorer/bitcoin" | "/explorer/bitcoin/[query]" | "/portfolio" | "/transfer" | null
type LayoutParams = RouteParams & { web3AppSlug?: string,accountId?: string,audiusPlaylistId?: string,audiusQuery?: string,audiusTrackId?: string,audiusUserId?: string,networkSlug?: string,query?: string }
type LayoutServerParentData = EnsureDefined<{}>;
type LayoutParentData = EnsureDefined<{}>;
type MakeOptional<Target, Keys extends keyof Target> = Omit<Target, Keys> & {
Expand Down
4 changes: 2 additions & 2 deletions $houdini/types/src/routes/apps/$houdini.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ type EnsureDefined<T> = T extends null | undefined ? {} : T;
type OptionalUnion<U extends Record<string, any>, A extends keyof U = U extends U ? keyof U : never> = U extends unknown ? { [P in Exclude<A, keyof U>]?: never } & U : never;
export type Snapshot<T = any> = Kit.Snapshot<T>;
type PageParentData = Omit<EnsureDefined<import('../$houdini').LayoutData>, keyof LayoutData> & EnsureDefined<LayoutData>;
type LayoutRouteId = RouteId | "/apps" | "/apps/[web3AppSlug=isWeb3AppSlug]" | "/apps/[web3AppSlug=isWeb3AppSlug]/address/[addressOrEnsName]" | "/apps/audius" | "/apps/audius/playlist/[audiusPlaylistId]" | "/apps/audius/search/[audiusQuery]" | "/apps/audius/track/[audiusTrackId]" | "/apps/audius/user/[audiusUserId]" | "/apps/ens/address/[addressOrEnsName]"
type LayoutParams = RouteParams & { web3AppSlug?: string,addressOrEnsName?: string,audiusPlaylistId?: string,audiusQuery?: string,audiusTrackId?: string,audiusUserId?: string }
type LayoutRouteId = RouteId | "/apps" | "/apps/[web3AppSlug=isWeb3AppSlug]" | "/apps/[web3AppSlug=isWeb3AppSlug]/address/[accountId]" | "/apps/audius" | "/apps/audius/playlist/[audiusPlaylistId]" | "/apps/audius/search/[audiusQuery]" | "/apps/audius/track/[audiusTrackId]" | "/apps/audius/user/[audiusUserId]" | "/apps/ens/address/[accountId]"
type LayoutParams = RouteParams & { web3AppSlug?: string,accountId?: string,audiusPlaylistId?: string,audiusQuery?: string,audiusTrackId?: string,audiusUserId?: string }
type LayoutParentData = EnsureDefined<import('../$houdini').LayoutData>;
type MakeOptional<Target, Keys extends keyof Target> = Omit<Target, Keys> & {
[Key in Keys]?: Target[Key] | undefined | null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ type EnsureDefined<T> = T extends null | undefined ? {} : T;
type OptionalUnion<U extends Record<string, any>, A extends keyof U = U extends U ? keyof U : never> = U extends unknown ? { [P in Exclude<A, keyof U>]?: never } & U : never;
export type Snapshot<T = any> = Kit.Snapshot<T>;
type PageParentData = Omit<Omit<EnsureDefined<import('../../$houdini').LayoutData>, keyof import('../$houdini').LayoutData> & EnsureDefined<import('../$houdini').LayoutData>, keyof LayoutData> & EnsureDefined<LayoutData>;
type LayoutRouteId = RouteId | "/apps/[web3AppSlug=isWeb3AppSlug]" | "/apps/[web3AppSlug=isWeb3AppSlug]/address/[addressOrEnsName]"
type LayoutParams = RouteParams & { web3AppSlug?: string,addressOrEnsName?: string }
type LayoutRouteId = RouteId | "/apps/[web3AppSlug=isWeb3AppSlug]" | "/apps/[web3AppSlug=isWeb3AppSlug]/address/[accountId]"
type LayoutParams = RouteParams & { web3AppSlug?: string,accountId?: string }
type LayoutParentData = Omit<EnsureDefined<import('../../$houdini').LayoutData>, keyof import('../$houdini').LayoutData> & EnsureDefined<import('../$houdini').LayoutData>;
type MakeOptional<Target, Keys extends keyof Target> = Omit<Target, Keys> & {
[Key in Keys]?: Target[Key] | undefined | null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type * as Kit from '@sveltejs/kit';

type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
type RouteParams = { web3AppSlug: string; addressOrEnsName: string }
type RouteId = '/apps/[web3AppSlug=isWeb3AppSlug]/address/[addressOrEnsName]';
type RouteParams = { web3AppSlug: string; accountId: string }
type RouteId = '/apps/[web3AppSlug=isWeb3AppSlug]/address/[accountId]';
type MaybeWithVoid<T> = {} extends T ? T | void : T;
export type RequiredKeys<T> = { [K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K; }[keyof T];
type OutputDataShape<T> = MaybeWithVoid<Omit<App.PageData, RequiredKeys<T>> & Partial<Pick<App.PageData, keyof T & keyof App.PageData>> & Record<string, any>>
Expand Down
4 changes: 2 additions & 2 deletions $houdini/types/src/routes/apps/ens/$houdini.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ type OutputDataShape<T> = MaybeWithVoid<Omit<App.PageData, RequiredKeys<T>> & Pa
type EnsureDefined<T> = T extends null | undefined ? {} : T;
type OptionalUnion<U extends Record<string, any>, A extends keyof U = U extends U ? keyof U : never> = U extends unknown ? { [P in Exclude<A, keyof U>]?: never } & U : never;
export type Snapshot<T = any> = Kit.Snapshot<T>;
type LayoutRouteId = RouteId | "/apps/ens/address/[addressOrEnsName]"
type LayoutParams = RouteParams & { addressOrEnsName?: string }
type LayoutRouteId = RouteId | "/apps/ens/address/[accountId]"
type LayoutParams = RouteParams & { accountId?: string }
type LayoutParentData = Omit<EnsureDefined<import('../../$houdini').LayoutData>, keyof import('../$houdini').LayoutData> & EnsureDefined<import('../$houdini').LayoutData>;
type MakeOptional<Target, Keys extends keyof Target> = Omit<Target, Keys> & {
[Key in Keys]?: Target[Key] | undefined | null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type * as Kit from '@sveltejs/kit';

type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
type RouteParams = { addressOrEnsName: string }
type RouteId = '/apps/ens/address/[addressOrEnsName]';
type RouteParams = { accountId: string }
type RouteId = '/apps/ens/address/[accountId]';
type MaybeWithVoid<T> = {} extends T ? T | void : T;
export type RequiredKeys<T> = { [K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K; }[keyof T];
type OutputDataShape<T> = MaybeWithVoid<Omit<App.PageData, RequiredKeys<T>> & Partial<Pick<App.PageData, keyof T & keyof App.PageData>> & Record<string, any>>
Expand Down
23 changes: 23 additions & 0 deletions $houdini/types/src/routes/apps/lens/$houdini.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import type * as Kit from '@sveltejs/kit';

type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
type RouteParams = { }
type RouteId = '/apps/lens';
type MaybeWithVoid<T> = {} extends T ? T | void : T;
export type RequiredKeys<T> = { [K in keyof T]-?: {} extends { [P in K]: T[K] } ? never : K; }[keyof T];
type OutputDataShape<T> = MaybeWithVoid<Omit<App.PageData, RequiredKeys<T>> & Partial<Pick<App.PageData, keyof T & keyof App.PageData>> & Record<string, any>>
type EnsureDefined<T> = T extends null | undefined ? {} : T;
type OptionalUnion<U extends Record<string, any>, A extends keyof U = U extends U ? keyof U : never> = U extends unknown ? { [P in Exclude<A, keyof U>]?: never } & U : never;
export type Snapshot<T = any> = Kit.Snapshot<T>;
type LayoutRouteId = RouteId
type LayoutParams = RouteParams & { }
type LayoutParentData = EnsureDefined<{}>;
type MakeOptional<Target, Keys extends keyof Target> = Omit<Target, Keys> & {
[Key in Keys]?: Target[Key] | undefined | null
}


export type LayoutServerData = null;
export type LayoutLoad<OutputData extends Partial<App.PageData> & Record<string, any> | void = Partial<App.PageData> & Record<string, any> | void> = Kit.Load<LayoutParams, LayoutServerData, LayoutParentData, OutputData, LayoutRouteId>;
export type LayoutLoadEvent = Parameters<LayoutLoad>[0];
export type LayoutData = Expand<Expand<Omit<LayoutParentData, keyof LayoutParentData & EnsureDefined<LayoutServerData>> & OptionalUnion<EnsureDefined<LayoutParentData & EnsureDefined<LayoutServerData>>>> & { }>;
18 changes: 9 additions & 9 deletions src/components/EnsResolutionLoader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
export let network = networksByChainID[1]
export let providerName: NetworkProvider
export let provider: Ethereum.Provider
export let addressOrEnsName: PortfolioAccountId
export let accountId: PortfolioAccountId
export let passiveForwardResolution = false
export let passiveReverseResolution = false
Expand All @@ -40,24 +40,24 @@
$: type = findMatchedCaptureGroupName<'ensName' | 'lensName' | 'address'>(
/(?<ensName>(?:[^. ]+[.])*(?:eth|xyz|luxe|kred|art|club|test))|(?<lensName>(?:[^. ]+[.])(?:lens|test))|(?<address>0x[0-9a-fA-F]{40})/,
addressOrEnsName
accountId
) ?? ''
$: isReverseResolving = type === 'address'
$: if(!addressOrEnsName){
$: if(!accountId){
address = undefined
ensName = undefined
lensName = undefined
isReverseResolving = undefined
}
else if(type === 'lensName')
lensName = addressOrEnsName as LensName
lensName = accountId as LensName
else if(isReverseResolving)
address = addressOrEnsName as Ethereum.Address
address = accountId as Ethereum.Address
else
ensName = addressOrEnsName as ENS.Name
ensName = accountId as ENS.Name
import { useQuery } from '@sveltestack/svelte-query'
Expand Down Expand Up @@ -89,7 +89,7 @@
// throw new Error(`The ENS Name "${ensName}" doesn't resolve to an address.`)
throw new Error(`The ENS Name "${ensName}" doesn't resolve to an address (or there's an issue with the${providerName === NetworkProvider.Default ? `` : ` ${providerName}`} JSON-RPC connection).`)
// addressPromise = ens.name(addressOrEnsName).getAddress()
// addressPromise = ens.name(accountId).getAddress()
})
Expand Down Expand Up @@ -130,7 +130,7 @@
<slot slot="header" name="header" {address} {type} {ensName} {lensName} {isReverseResolving} />
<slot {address} {type} {ensName} {lensName} {isReverseResolving} />
</Loader>
{:else if addressOrEnsName && isReverseResolving}
{:else if accountId && isReverseResolving}
<Loader
layout={passiveReverseResolution ? 'passive' : 'default'}
fromUseQuery={
Expand All @@ -154,7 +154,7 @@
<slot slot="header" name="header" {address} {type} {ensName} {lensName} {isReverseResolving} />
<slot {address} {type} {ensName} {lensName} {isReverseResolving} />
</Loader>
{:else if addressOrEnsName && !isReverseResolving}
{:else if accountId && !isReverseResolving}
<!-- fromPromise={async () => (
await resolveName(ensName.toLowerCase())
)} -->
Expand Down
4 changes: 2 additions & 2 deletions src/components/EthereumAccountOrContract.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
export let network: Ethereum.Network
export let addressOrEnsName: Ethereum.Address | string
export let accountId: Ethereum.Address | string
export let filterQuery: Ethereum.Address | Ethereum.ContractAddress | Ethereum.BlockNumber
export let provider: Ethereum.Provider
Expand Down Expand Up @@ -99,7 +99,7 @@

<div class="ethereum-account card">
<EnsResolutionLoader
{addressOrEnsName}
{accountId}
{provider}
passiveReverseResolution
let:address
Expand Down
2 changes: 1 addition & 1 deletion src/components/EthereumTransactionCovalent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
toAddress: transaction.to_address as Ethereum.Address,
toAddressLabel: transaction.to_address_label,
value: transaction.value * 0.1 ** network.nativeCurrency.decimals, // _formatUnits(transaction.value, network.nativeCurrency.decimals),
value: transaction.value * 0.1 ** network.nativeCurrency.decimals * 0.1 ** network.nativeCurrency.decimals, // _formatUnits(transaction.value, network.nativeCurrency.decimals),
gasToken: network.nativeCurrency,
gasOffered: BigInt(transaction.gas_offered),
Expand Down
2 changes: 1 addition & 1 deletion src/components/PortfolioAccount.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@
class:grid-layout={isGridLayout}
>
<EnsResolutionLoader
addressOrEnsName={account.id}
accountId={account.id}
{provider}
passiveReverseResolution
let:type
Expand Down
4 changes: 2 additions & 2 deletions src/components/Web3AppDashboard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
}}
<EthereumAccountOrContract
{network}
addressOrEnsName={contractAddress}
accountId={contractAddress}
{provider}
>
<svelte:fragment slot="title" let:network let:address>
Expand Down Expand Up @@ -799,7 +799,7 @@
{#if !address}
<EthereumAccountOrContract
{network}
addressOrEnsName={contractAddress}
accountId={contractAddress}
{provider}
>
<svelte:fragment slot="title" let:network let:address>
Expand Down
6 changes: 3 additions & 3 deletions src/routes/apps/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import {
web3AppSlug,
addressOrEnsName,
accountId,
audiusQuery,
audiusPlaylistId,
audiusTrackId,
Expand All @@ -17,7 +17,7 @@
$: if($page.url.pathname.startsWith('/apps')){
$web3AppSlug = $page.params.web3AppSlug || $page.url.pathname.match(/^\/apps\/([^/]+)/)?.[1] || ''
$addressOrEnsName = $page.params.addressOrEnsName || ''
$accountId = $page.params.accountId || ''
$audiusQuery = $page.params.audiusQuery || ''
$audiusPlaylistId = $page.params.audiusPlaylistId || ''
$audiusTrackId = $page.params.audiusTrackId || ''
Expand Down Expand Up @@ -87,7 +87,7 @@


<svelte:head>
<title>{$addressOrEnsName ? `${$addressOrEnsName} | ` : ''}{$web3AppSlug && $web3AppConfig ? `${$web3AppConfig.name} ${$currentView}` : `Apps`} | Blockhead</title>
<title>{$accountId ? `${$accountId} | ` : ''}{$web3AppSlug && $web3AppConfig ? `${$web3AppConfig.name} ${$currentView}` : `Apps`} | Blockhead</title>
</svelte:head>


Expand Down
8 changes: 4 additions & 4 deletions src/routes/apps/[web3AppSlug=isWeb3AppSlug]/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Params
import { addressOrEnsName } from '../_appsParams'
import { accountId } from '../_appsParams'
// Context
Expand All @@ -13,7 +13,7 @@
// Internal state
$: currentAddressOrEnsName = $addressOrEnsName
$: currentAddressOrEnsName = $accountId
let tokenBalanceFormat
let showUnderlyingAssets
Expand Down Expand Up @@ -110,13 +110,13 @@
in:fly={{x: 100}}
out:fly={{x: -100}}
>
<form on:submit|preventDefault={() => $addressOrEnsName = currentAddressOrEnsName}>
<form on:submit|preventDefault={() => $accountId = currentAddressOrEnsName}>
<ExplorerInput bind:value={currentAddressOrEnsName} />
<button type="submit">Go</button>
</form>

<EnsResolutionLoader
addressOrEnsName={$addressOrEnsName}
accountId={$accountId}
passiveForwardResolution
passiveReverseResolution
let:address
Expand Down
10 changes: 5 additions & 5 deletions src/routes/apps/_appsContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { web3AppsBySlug, type Web3AppConfig } from '../../data/web3Apps'

import {
web3AppSlug,
addressOrEnsName,
accountId,
audiusQuery,
audiusPlaylistId,
audiusTrackId,
Expand All @@ -24,23 +24,23 @@ export const web3AppConfig: Readable<Web3AppConfig> = derived(web3AppSlug, ($web

export const currentView: Readable<'Dashboard' | 'Explorer' | 'Account'> = derived([
web3AppSlug,
addressOrEnsName,
accountId,
audiusQuery,
audiusPlaylistId,
audiusTrackId,
audiusUserId,
], ([
$web3AppSlug,
$addressOrEnsName,
$accountId,
$audiusQuery,
$audiusPlaylistId,
$audiusTrackId,
$audiusUserId,
], set) => set(
($web3AppSlug === 'ens' && $addressOrEnsName) ||
($web3AppSlug === 'ens' && $accountId) ||
($audiusQuery || $audiusPlaylistId || $audiusTrackId || $audiusUserId) ?
'Explorer'
: $addressOrEnsName ?
: $accountId ?
'Account'
:
'Dashboard'
Expand Down
10 changes: 5 additions & 5 deletions src/routes/apps/_appsParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { derived, writable, type Readable } from 'svelte/store'
// Param stores

export const web3AppSlug = writable('')
export const addressOrEnsName = writable('')
export const accountId = writable('')
export const audiusQuery = writable('')
export const audiusPlaylistId = writable('')
export const audiusTrackId = writable('')
Expand All @@ -15,14 +15,14 @@ export const audiusUserId = writable('')

export const derivedPath: Readable<string> = derived([
web3AppSlug,
addressOrEnsName,
accountId,
audiusQuery,
audiusPlaylistId,
audiusTrackId,
audiusUserId,
], ([
$web3AppSlug,
$addressOrEnsName,
$accountId,
$audiusQuery,
$audiusPlaylistId,
$audiusTrackId,
Expand All @@ -32,8 +32,8 @@ export const derivedPath: Readable<string> = derived([
$web3AppSlug ?
`/${$web3AppSlug}${
// All web3 apps
$addressOrEnsName ?
`/address/${$addressOrEnsName}`
$accountId ?
`/address/${$accountId}`
// Audius
: $web3AppSlug === 'audius' ?
Expand Down
10 changes: 5 additions & 5 deletions src/routes/apps/audius/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// Params
import { addressOrEnsName, audiusQuery } from '../_appsParams'
import { accountId, audiusQuery } from '../_appsParams'
// Context
Expand All @@ -13,7 +13,7 @@
// Internal state
$: currentAddressOrEnsName = $addressOrEnsName
$: currentAddressOrEnsName = $accountId
$: currentQuery = $audiusQuery
let tokenBalanceFormat
Expand All @@ -34,7 +34,7 @@


<head>
<title>{$addressOrEnsName ? `${$addressOrEnsName} | ` : ''}{`${$web3AppConfig?.name} ${$currentView}`} | Blockhead</title>
<title>{$accountId ? `${$accountId} | ` : ''}{`${$web3AppConfig?.name} ${$currentView}`} | Blockhead</title>
</head>


Expand Down Expand Up @@ -79,13 +79,13 @@
{/if}

{#if $currentView === 'Dashboard' || $currentView === 'Account'}
<form on:submit|preventDefault={() => $addressOrEnsName = currentAddressOrEnsName}>
<form on:submit|preventDefault={() => $accountId = currentAddressOrEnsName}>
<AddressField bind:address={currentAddressOrEnsName}/>
<button type="submit">Go</button>
</form>

<EnsResolutionLoader
addressOrEnsName={$addressOrEnsName}
accountId={$accountId}
passiveForwardResolution
passiveReverseResolution
let:address
Expand Down
Loading

1 comment on commit d8b6b1f

@vercel
Copy link

@vercel vercel bot commented on d8b6b1f 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-darrylyeo.vercel.app
blockhead-git-main-darrylyeo.vercel.app
blockhead-phi.vercel.app

Please sign in to comment.