-
Notifications
You must be signed in to change notification settings - Fork 415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bako ID integration #1180
Draft
luisburigo
wants to merge
7
commits into
FuelLabs:master
Choose a base branch
from
luisburigo:lb/feat/bako-id
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Bako ID integration #1180
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dae6e3c
feat(bako-id): add search address by bako id
luisburigo d43a3fd
feat(bako-id): refactor input yup validation and fetch bako handle
luisburigo a46b7b5
feat(bako-id): refactor pre-fetch transaction to get address
luisburigo cc28a1b
feat(bako-id): get handle name by resolver address
luisburigo f0e58f0
feat(bako-id): show handle name in tx recipient
luisburigo d0580cb
feat(bako-id): implement test sending a transaction with bako handle
luisburigo ffa196a
feat(bako-id): add bako id sdk
luisburigo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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 |
---|---|---|
@@ -1,10 +1,19 @@ | ||
import { cssObj } from '@fuel-ui/css'; | ||
import { Avatar, Box, Card, Heading, Icon, Text } from '@fuel-ui/react'; | ||
import { | ||
Avatar, | ||
Box, | ||
Card, | ||
ContentLoader, | ||
Heading, | ||
Icon, | ||
Text, | ||
} from '@fuel-ui/react'; | ||
import type { OperationTransactionAddress } from 'fuels'; | ||
import { Address, AddressType, ChainName, isB256, isBech32 } from 'fuels'; | ||
import type { FC } from 'react'; | ||
import { type FC, useEffect, useState } from 'react'; | ||
import { EthAddress, FuelAddress, useAccounts } from '~/systems/Account'; | ||
|
||
import { config, reverseResolver } from '@bako-id/sdk'; | ||
import { TxRecipientCardLoader } from './TxRecipientCardLoader'; | ||
|
||
export type TxRecipientCardProps = { | ||
|
@@ -21,6 +30,8 @@ export const TxRecipientCard: TxRecipientCardComponent = ({ | |
isReceiver, | ||
}) => { | ||
const { accounts } = useAccounts(); | ||
const [name, setName] = useState(''); | ||
|
||
const address = recipient?.address || ''; | ||
const isValidAddress = isB256(address) || isBech32(address); | ||
const fuelAddress = isValidAddress | ||
|
@@ -29,8 +40,41 @@ export const TxRecipientCard: TxRecipientCardComponent = ({ | |
const isContract = recipient?.type === AddressType.contract; | ||
const isEthChain = recipient?.chain === ChainName.ethereum; | ||
const isNetwork = address === 'Network'; | ||
const name = | ||
accounts?.find((a) => a.address === fuelAddress)?.name || 'unknown'; | ||
|
||
// biome-ignore lint/correctness/useExhaustiveDependencies: <explanation> | ||
useEffect(() => { | ||
const setAccountName = () => { | ||
const accountName = | ||
accounts?.find((a) => a.address === fuelAddress)?.name || 'unknown'; | ||
setName(accountName); | ||
}; | ||
|
||
const resolveAddressName = async () => { | ||
const handleName = await reverseResolver(fuelAddress); | ||
|
||
if (handleName) { | ||
return setName(`@${handleName}`); | ||
} | ||
|
||
setAccountName(); | ||
}; | ||
|
||
if (!name && isReceiver) { | ||
resolveAddressName(); | ||
} | ||
|
||
if (!isReceiver) { | ||
setAccountName(); | ||
} | ||
}, [isReceiver, name]); | ||
|
||
const Name = !name ? ( | ||
<ContentLoader width={100} height={17} viewBox="0 0 80 17"> | ||
<ContentLoader.Rect x="0" y="0" width="100" height="17" rx="4" /> | ||
</ContentLoader> | ||
) : ( | ||
`${name}` | ||
); | ||
Comment on lines
+71
to
+77
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added a loader to the name to avoid screen flickering when the search is completed. |
||
|
||
return ( | ||
<Card | ||
|
@@ -77,7 +121,7 @@ export const TxRecipientCard: TxRecipientCardComponent = ({ | |
)} | ||
<Box.Flex css={styles.info}> | ||
<Heading as="h6" css={styles.name}> | ||
{isNetwork ? address : name} | ||
{isNetwork ? address : Name} | ||
</Heading> | ||
{!isNetwork && ( | ||
<FuelAddress address={fuelAddress} css={styles.address} /> | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 added it only to show in the receiver, thinking about the transaction sending flow, what do you think?
If they're not a receiver, there could be a conflict with the wallet name.