-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ENS Searching * Revert "ENS Searching" This reverts commit 710e262. * search by ens * copy fix on address input * add EOA address and ENS * fix EOA calc from kwenta and poly, show ENS on top * Resolve ens optionally * Renames * Fix deps * Simplify useEnsName * Lint harder --------- Co-authored-by: Steve Rogers <[email protected]>
- Loading branch information
Showing
6 changed files
with
145 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 17 additions & 4 deletions
21
v2/perps-v2/ui/src/components/AddressInput/AddressInput.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { useGlobalProvidersWithFallback } from '@snx-v2/useGlobalProvidersWithFallback'; | ||
|
||
export const useEnsName = (address?: string | null) => { | ||
const { globalProviders } = useGlobalProvidersWithFallback(); | ||
|
||
const [addressEnsName, setAddressEnsName] = useState<string | null>(null); | ||
|
||
useEffect(() => { | ||
async function resolve() { | ||
if (!address || !globalProviders.mainnet) { | ||
setAddressEnsName(null); | ||
return; | ||
} | ||
const name = await globalProviders.mainnet.lookupAddress(address); | ||
setAddressEnsName(name); | ||
} | ||
resolve(); | ||
}, [address, globalProviders]); | ||
|
||
return { addressEnsName }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { z } from 'zod'; | ||
import { KWENTA_SUBGRAPH_URL, POLYNOMIAL_SUBGRAPH_URL } from '../utils'; | ||
import { ApolloClient, gql, InMemoryCache, useQuery } from '@apollo/client'; | ||
|
||
const kwentaClient = new ApolloClient({ | ||
uri: KWENTA_SUBGRAPH_URL, | ||
cache: new InMemoryCache(), | ||
}); | ||
|
||
const polyClient = new ApolloClient({ | ||
uri: POLYNOMIAL_SUBGRAPH_URL, | ||
cache: new InMemoryCache(), | ||
}); | ||
|
||
const AccountBySmartIdQuery = gql` | ||
query Account($id: String!) { | ||
smartMarginAccount(id: $id) { | ||
owner | ||
} | ||
} | ||
`; | ||
|
||
const AccountQuery = gql` | ||
query SmAccounts($account: String) { | ||
logAccountCreateds(where: { account: $account }) { | ||
owner | ||
account | ||
} | ||
} | ||
`; | ||
|
||
const SmartMarginAccountSchema = z.object({ | ||
owner: z.string(), | ||
}); | ||
|
||
const ResponseSchema = z | ||
.object({ | ||
smartMarginAccount: SmartMarginAccountSchema, | ||
}) | ||
.optional(); | ||
|
||
const OwnerByPolyAccountSchema = z.array( | ||
z.object({ | ||
owner: z.string(), | ||
account: z.string(), | ||
}) | ||
); | ||
|
||
const ResponseSchemaOwnerByPoly = z | ||
.object({ | ||
logAccountCreateds: OwnerByPolyAccountSchema, | ||
}) | ||
.optional(); | ||
|
||
export const useOwnerKwenta = (smartAccountId?: string) => { | ||
const { data, ...rest } = useQuery(AccountBySmartIdQuery, { | ||
client: kwentaClient, | ||
variables: { id: smartAccountId }, | ||
skip: !smartAccountId, | ||
}); | ||
|
||
const parsedResult = ResponseSchema.safeParse(data); | ||
const kwentaOwner = parsedResult.success ? parsedResult.data?.smartMarginAccount?.owner : null; | ||
|
||
return { ...rest, kwentaOwner }; | ||
}; | ||
|
||
export const useOwnerPolynomial = (polynomialAccount?: string) => { | ||
const { data, ...rest } = useQuery(AccountQuery, { | ||
client: polyClient, | ||
variables: { account: polynomialAccount }, | ||
skip: !polynomialAccount, | ||
}); | ||
|
||
const parsedResult = ResponseSchemaOwnerByPoly.safeParse(data); | ||
const polynomialOwner = parsedResult.success | ||
? parsedResult.data?.logAccountCreateds?.[0]?.owner | ||
: null; | ||
|
||
return { ...rest, polynomialOwner }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
467df74
There was a problem hiding this comment.
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:
v2-storybook – ./v2/ui
v2-storybook-synthetixio.vercel.app
staking-storybook.vercel.app
v2-storybook-git-master-synthetixio.vercel.app
467df74
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @noisekit
It seems that search by ENS does not work.
I saw that some components code, compared to my PR, has been modified (as you had commented to me).
How can we coordinate to resolve?
The search bar in the test site with the PR code works. You can see it from here:
I am available to give support if needed.
467df74
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@noisekit It was also reported to me that "Largest open position" is not working correctly. But if I'm not mistaken, no part of the code that has been merged pertains to that.
467df74
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have more info? When I checked search it worked fine. Where are you testing right now? The change is not released yet
467df74
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah those things are going to be fixed soon.
467df74
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm testing here: https://watcher.synthetix.io/
467df74
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah. Change was not released to main site yet. Just merged.
467df74
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I'm doing some testing locally as well and it seems to work even with these changes and it actually seems to work :).
I was told it was not working, and I reported what I was told.
467df74
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries. We will release some time later. More fixes incoming.