@xyo-network/react-wallet 7.5.8 → 7.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/components/WalletAccountDetails/WalletAccountDetails.d.ts.map +1 -1
- package/dist/browser/contexts/SeedPhrase/Provider.d.ts.map +1 -1
- package/dist/browser/index.mjs +656 -566
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +112 -46
- package/src/components/MaxAccounts/MaxAccountsTableRow.tsx +0 -75
- package/src/components/MaxAccounts/OutOfBoundsSnackBar.tsx +0 -41
- package/src/components/MaxAccounts/index.ts +0 -1
- package/src/components/SeedPhrase/DefaultSeedPhrase.stories.tsx +0 -27
- package/src/components/SeedPhrase/DefaultSeedPhrase.tsx +0 -52
- package/src/components/SeedPhrase/_shared/SeedPhraseIconButton.tsx +0 -53
- package/src/components/SeedPhrase/_shared/index.ts +0 -1
- package/src/components/SeedPhrase/dialog/SeedPhraseDialog.stories.tsx +0 -33
- package/src/components/SeedPhrase/dialog/SeedPhraseDialog.tsx +0 -84
- package/src/components/SeedPhrase/dialog/components/DialogActionButtons.tsx +0 -33
- package/src/components/SeedPhrase/dialog/components/OverwriteWarning.tsx +0 -28
- package/src/components/SeedPhrase/dialog/components/fields/NewPhraseTextField.tsx +0 -45
- package/src/components/SeedPhrase/dialog/components/fields/PhraseDialogActions.stories.tsx +0 -29
- package/src/components/SeedPhrase/dialog/components/fields/PhraseDialogActions.tsx +0 -38
- package/src/components/SeedPhrase/dialog/components/fields/SavedPhraseTextField.tsx +0 -113
- package/src/components/SeedPhrase/dialog/components/fields/index.ts +0 -4
- package/src/components/SeedPhrase/dialog/components/fields/validation-messages/InvalidPhrase.tsx +0 -14
- package/src/components/SeedPhrase/dialog/components/fields/validation-messages/PhraseHeaderBox.tsx +0 -50
- package/src/components/SeedPhrase/dialog/components/fields/validation-messages/colorParser.ts +0 -14
- package/src/components/SeedPhrase/dialog/components/fields/validation-messages/index.ts +0 -3
- package/src/components/SeedPhrase/dialog/components/index.ts +0 -3
- package/src/components/SeedPhrase/dialog/index.ts +0 -2
- package/src/components/SeedPhrase/index.ts +0 -4
- package/src/components/SeedPhrase/settings/SeedPhraseTableRow.stories.tsx +0 -31
- package/src/components/SeedPhrase/settings/SeedPhraseTableRow.tsx +0 -48
- package/src/components/SeedPhrase/settings/index.ts +0 -1
- package/src/components/WalletAccountDetails/WalletAccountDetails.stories.tsx +0 -27
- package/src/components/WalletAccountDetails/WalletAccountDetails.tsx +0 -37
- package/src/components/WalletAccountDetails/WalletAccountDetailsWithProvider.stories.tsx +0 -33
- package/src/components/WalletAccountDetails/index.ts +0 -1
- package/src/components/WalletAccountSelect/RenderedMenuItem.tsx +0 -52
- package/src/components/WalletAccountSelect/Select.tsx +0 -84
- package/src/components/WalletAccountSelect/SelectBar.tsx +0 -44
- package/src/components/WalletAccountSelect/WalletAccountSelect.stories.tsx +0 -45
- package/src/components/WalletAccountSelect/WalletAccountSelectBar.stories.tsx +0 -61
- package/src/components/WalletAccountSelect/WalletAccountSelectWithProvider.stories.tsx +0 -43
- package/src/components/WalletAccountSelect/WalletInfo.tsx +0 -121
- package/src/components/WalletAccountSelect/index.ts +0 -2
- package/src/components/WalletAccountSelect/stories/WalletProviderDecorator.tsx +0 -31
- package/src/components/WalletAccountSelect/stories/index.ts +0 -1
- package/src/components/index.ts +0 -4
- package/src/contexts/SeedPhrase/Context.ts +0 -6
- package/src/contexts/SeedPhrase/Provider.tsx +0 -103
- package/src/contexts/SeedPhrase/State.ts +0 -19
- package/src/contexts/SeedPhrase/index.ts +0 -4
- package/src/contexts/SeedPhrase/use.ts +0 -6
- package/src/contexts/Wallet/Context.ts +0 -6
- package/src/contexts/Wallet/Provider.tsx +0 -46
- package/src/contexts/Wallet/State.ts +0 -15
- package/src/contexts/Wallet/index.ts +0 -4
- package/src/contexts/Wallet/use.ts +0 -37
- package/src/contexts/index.ts +0 -2
- package/src/hooks/index.ts +0 -4
- package/src/hooks/useAccount.ts +0 -68
- package/src/hooks/useWallet.ts +0 -46
- package/src/hooks/useWallets.ts +0 -22
- package/src/hooks/useWrapperAccount.ts +0 -36
- package/src/index.ts +0 -3
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Table, TableBody } from '@mui/material'
|
|
2
|
-
import type { Meta, StoryFn } from '@storybook/react-vite'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
|
|
5
|
-
import { SeedPhraseTableRow } from './SeedPhraseTableRow.tsx'
|
|
6
|
-
|
|
7
|
-
const changeSeedPhrase = (phrase?: string) => alert(`Changed Seed Phrase to: ${phrase}`)
|
|
8
|
-
|
|
9
|
-
export default {
|
|
10
|
-
component: SeedPhraseTableRow,
|
|
11
|
-
title: 'Wallet/SeedPhraseTableRow',
|
|
12
|
-
} as Meta
|
|
13
|
-
|
|
14
|
-
const Template: StoryFn<typeof SeedPhraseTableRow> = props => (
|
|
15
|
-
<Table>
|
|
16
|
-
<TableBody>
|
|
17
|
-
<SeedPhraseTableRow {...props} />
|
|
18
|
-
</TableBody>
|
|
19
|
-
</Table>
|
|
20
|
-
)
|
|
21
|
-
|
|
22
|
-
const Default = Template.bind({})
|
|
23
|
-
Default.args = { changeSeedPhrase }
|
|
24
|
-
|
|
25
|
-
const WithSeedPhrase = Template.bind({})
|
|
26
|
-
WithSeedPhrase.args = {
|
|
27
|
-
changeSeedPhrase,
|
|
28
|
-
seedPhrase: 'test me',
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { Default, WithSeedPhrase }
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { Cancel as CancelIcon, RadioButtonChecked as RadioButtonCheckedIcon } from '@mui/icons-material'
|
|
2
|
-
import type { TableRowProps } from '@mui/material'
|
|
3
|
-
import {
|
|
4
|
-
Button, ButtonGroup, TableCell, TableRow,
|
|
5
|
-
} from '@mui/material'
|
|
6
|
-
import React, { useState } from 'react'
|
|
7
|
-
|
|
8
|
-
import { SeedPhraseIconButton } from '../_shared/index.ts'
|
|
9
|
-
import { SeedPhraseDialog } from '../dialog/index.ts'
|
|
10
|
-
|
|
11
|
-
/** @public */
|
|
12
|
-
export interface SeedPhraseTableRowProps extends TableRowProps {
|
|
13
|
-
changeSeedPhrase?: (seedPhrase: string) => void
|
|
14
|
-
seedPhrase?: string
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** @public */
|
|
18
|
-
export const SeedPhraseTableRow: React.FC<SeedPhraseTableRowProps> = ({
|
|
19
|
-
changeSeedPhrase, seedPhrase, ...props
|
|
20
|
-
}) => {
|
|
21
|
-
const [open, setOpen] = useState(false)
|
|
22
|
-
|
|
23
|
-
const handleOpen = () => {
|
|
24
|
-
setOpen(true)
|
|
25
|
-
}
|
|
26
|
-
return (
|
|
27
|
-
<TableRow {...props}>
|
|
28
|
-
<TableCell>
|
|
29
|
-
Seed Phrase
|
|
30
|
-
{' '}
|
|
31
|
-
<SeedPhraseIconButton />
|
|
32
|
-
</TableCell>
|
|
33
|
-
<TableCell align="center">
|
|
34
|
-
{seedPhrase
|
|
35
|
-
? <RadioButtonCheckedIcon color="success" />
|
|
36
|
-
: <CancelIcon color="error" />}
|
|
37
|
-
</TableCell>
|
|
38
|
-
<TableCell>
|
|
39
|
-
<SeedPhraseDialog changeSeedPhrase={changeSeedPhrase} open={open} onClose={() => setOpen(false)} seedPhrase={seedPhrase} />
|
|
40
|
-
<ButtonGroup fullWidth>
|
|
41
|
-
<Button variant="contained" size="small" onClick={handleOpen}>
|
|
42
|
-
Update
|
|
43
|
-
</Button>
|
|
44
|
-
</ButtonGroup>
|
|
45
|
-
</TableCell>
|
|
46
|
-
</TableRow>
|
|
47
|
-
)
|
|
48
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './SeedPhraseTableRow.tsx'
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryFn } from '@storybook/react-vite'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
import { BrowserRouter } from 'react-router-dom'
|
|
4
|
-
|
|
5
|
-
import { WalletAccountDetails } from './WalletAccountDetails.tsx'
|
|
6
|
-
|
|
7
|
-
const StorybookEntry = {
|
|
8
|
-
argTypes: {},
|
|
9
|
-
component: WalletAccountDetails,
|
|
10
|
-
parameters: { docs: { page: null } },
|
|
11
|
-
title: 'wallet/WalletAccountDetails',
|
|
12
|
-
} as Meta<typeof WalletAccountDetails>
|
|
13
|
-
|
|
14
|
-
const Template: StoryFn<typeof WalletAccountDetails> = (args) => {
|
|
15
|
-
return (
|
|
16
|
-
<BrowserRouter>
|
|
17
|
-
<WalletAccountDetails {...args}></WalletAccountDetails>
|
|
18
|
-
</BrowserRouter>
|
|
19
|
-
)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const Default = Template.bind({})
|
|
23
|
-
Default.args = {}
|
|
24
|
-
|
|
25
|
-
export { Default }
|
|
26
|
-
|
|
27
|
-
export default StorybookEntry
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { EthAddressWrapper } from '@xylabs/eth-address'
|
|
2
|
-
import { EthAccountButton } from '@xylabs/react-crypto'
|
|
3
|
-
import type { FlexBoxProps } from '@xylabs/react-flexbox'
|
|
4
|
-
import { FlexCol, FlexRow } from '@xylabs/react-flexbox'
|
|
5
|
-
import { NumberStatus } from '@xylabs/react-number-status'
|
|
6
|
-
import { useNetwork } from '@xyo-network/react-network'
|
|
7
|
-
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
8
|
-
import React from 'react'
|
|
9
|
-
|
|
10
|
-
import { useAccount } from '../../hooks/index.ts'
|
|
11
|
-
|
|
12
|
-
/** @public */
|
|
13
|
-
export interface WalletAccountDetailsProps extends FlexBoxProps {
|
|
14
|
-
account?: WalletInstance
|
|
15
|
-
exploreUrl?: string
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** @public */
|
|
19
|
-
export const WalletAccountDetails: React.FC<WalletAccountDetailsProps> = ({
|
|
20
|
-
exploreUrl = 'https://explore.xyo.network', account, ...props
|
|
21
|
-
}) => {
|
|
22
|
-
const [accountToUse] = useAccount({ account })
|
|
23
|
-
const { network } = useNetwork()
|
|
24
|
-
const exploreAddressUrl = `${exploreUrl}/recent?account=${accountToUse?.address}&network=${network?.name ?? 'main'}`
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<FlexCol {...props}>
|
|
28
|
-
<EthAccountButton address={EthAddressWrapper.fromString(accountToUse?.address)} />
|
|
29
|
-
<FlexRow gap={1}>
|
|
30
|
-
<NumberStatus rounded title="Tokens" value={0} to={`${exploreAddressUrl}&schema=network.xyo.account.tokens`} target="_blank" />
|
|
31
|
-
<NumberStatus rounded title="NFTs" value={0} to={`${exploreAddressUrl}&schema=network.xyo.account.nfts`} target="_blank" />
|
|
32
|
-
<NumberStatus rounded title="Signatures" value={0} to={`${exploreAddressUrl}&schema=network.xyo.account.signatures`} target="_blank" />
|
|
33
|
-
<NumberStatus rounded title="Signins" value={0} to={`${exploreAddressUrl}&schema=network.xyo.account.signins`} target="_blank" />
|
|
34
|
-
</FlexRow>
|
|
35
|
-
</FlexCol>
|
|
36
|
-
)
|
|
37
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryFn } from '@storybook/react-vite'
|
|
2
|
-
import { DefaultSeedPhrase } from '@xyo-network/react-storybook'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
import { BrowserRouter } from 'react-router-dom'
|
|
5
|
-
|
|
6
|
-
import { WalletProvider } from '../../contexts/index.ts'
|
|
7
|
-
import { useWallet } from '../../hooks/index.ts'
|
|
8
|
-
import { WalletAccountDetails } from './WalletAccountDetails.tsx'
|
|
9
|
-
|
|
10
|
-
const StorybookEntry = {
|
|
11
|
-
argTypes: {},
|
|
12
|
-
component: WalletAccountDetails,
|
|
13
|
-
parameters: { docs: { page: null } },
|
|
14
|
-
title: 'wallet/WalletAccountDetailsWithProvider',
|
|
15
|
-
} as Meta<typeof WalletAccountDetails>
|
|
16
|
-
|
|
17
|
-
const Template: StoryFn<typeof WalletAccountDetails> = (args) => {
|
|
18
|
-
const [wallet] = useWallet({ mnemonic: DefaultSeedPhrase })
|
|
19
|
-
return (
|
|
20
|
-
<BrowserRouter>
|
|
21
|
-
<WalletProvider rootWallet={wallet}>
|
|
22
|
-
<WalletAccountDetails {...args}></WalletAccountDetails>
|
|
23
|
-
</WalletProvider>
|
|
24
|
-
</BrowserRouter>
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const Default = Template.bind({})
|
|
29
|
-
Default.args = {}
|
|
30
|
-
|
|
31
|
-
export { Default }
|
|
32
|
-
|
|
33
|
-
export default StorybookEntry
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './WalletAccountDetails.tsx'
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { MenuItem, type MenuItemProps } from '@mui/material'
|
|
2
|
-
import { AddressRenderRowBox } from '@xyo-network/react-address-render'
|
|
3
|
-
import type { WalletInstance } from '@xyo-network/wallet-model'
|
|
4
|
-
import React from 'react'
|
|
5
|
-
|
|
6
|
-
import { useWallet } from '../../hooks/index.ts'
|
|
7
|
-
|
|
8
|
-
/** @public */
|
|
9
|
-
export interface RenderedAccountMenuItemProps extends MenuItemProps {
|
|
10
|
-
addressNames?: Record<string, string | undefined>
|
|
11
|
-
iconOnly?: boolean
|
|
12
|
-
iconSize?: number
|
|
13
|
-
icons?: boolean
|
|
14
|
-
rootWallet: WalletInstance
|
|
15
|
-
selectedAccountIndex?: number
|
|
16
|
-
showFavorite?: boolean
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** @public */
|
|
20
|
-
export const RenderedAccountMenuItem: React.FC<RenderedAccountMenuItemProps> = ({
|
|
21
|
-
selectedAccountIndex,
|
|
22
|
-
rootWallet,
|
|
23
|
-
addressNames,
|
|
24
|
-
iconOnly,
|
|
25
|
-
iconSize,
|
|
26
|
-
icons,
|
|
27
|
-
showFavorite,
|
|
28
|
-
}) => {
|
|
29
|
-
const [selectedAccount] = useWallet({ path: selectedAccountIndex?.toString(), wallet: rootWallet })
|
|
30
|
-
const customName = selectedAccount ? addressNames?.[selectedAccount.address] : undefined
|
|
31
|
-
const favorite = !!selectedAccount && selectedAccount.address in (addressNames ?? {})
|
|
32
|
-
return (
|
|
33
|
-
<MenuItem
|
|
34
|
-
value={selectedAccountIndex}
|
|
35
|
-
sx={{
|
|
36
|
-
minHeight: 0, paddingBottom: 0, paddingTop: 0,
|
|
37
|
-
}}
|
|
38
|
-
>
|
|
39
|
-
<AddressRenderRowBox
|
|
40
|
-
disableSharedRef={true}
|
|
41
|
-
flexGrow={1}
|
|
42
|
-
address={selectedAccount?.address}
|
|
43
|
-
iconOnly={iconOnly}
|
|
44
|
-
iconSize={iconSize}
|
|
45
|
-
icons={icons}
|
|
46
|
-
name={customName}
|
|
47
|
-
favorite={favorite}
|
|
48
|
-
showFavorite={showFavorite}
|
|
49
|
-
/>
|
|
50
|
-
</MenuItem>
|
|
51
|
-
)
|
|
52
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import type { SelectProps } from '@mui/material'
|
|
2
|
-
import { CircularProgress } from '@mui/material'
|
|
3
|
-
import { SelectEx } from '@xylabs/react-select'
|
|
4
|
-
import type { AddressRenderRowBoxProps } from '@xyo-network/react-address-render'
|
|
5
|
-
import React from 'react'
|
|
6
|
-
|
|
7
|
-
import { useWalletContext } from '../../contexts/index.ts'
|
|
8
|
-
import { RenderedAccountMenuItem } from './RenderedMenuItem.tsx'
|
|
9
|
-
|
|
10
|
-
type SharedAddressRenderRowBoxProps = Pick<AddressRenderRowBoxProps, 'iconOnly' | 'iconSize' | 'icons' | 'showFavorite'>
|
|
11
|
-
|
|
12
|
-
/** @public */
|
|
13
|
-
export type WalletAccountSelectProps = SharedAddressRenderRowBoxProps
|
|
14
|
-
& Omit<SelectProps<number>, 'variant'>
|
|
15
|
-
& Partial<SelectProps<number>> & {
|
|
16
|
-
addressNames?: Record<string, string | undefined>
|
|
17
|
-
maxAccounts?: number
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const arrayRange = (length: number, start = 0) => {
|
|
21
|
-
return [...Array.from({ length }).keys()].map(x => x + start)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** @public */
|
|
25
|
-
export const WalletAccountSelect: React.FC<WalletAccountSelectProps> = ({
|
|
26
|
-
addressNames,
|
|
27
|
-
iconOnly,
|
|
28
|
-
iconSize = 24,
|
|
29
|
-
icons,
|
|
30
|
-
maxAccounts = 1,
|
|
31
|
-
showFavorite = false,
|
|
32
|
-
size,
|
|
33
|
-
variant = 'outlined',
|
|
34
|
-
...props
|
|
35
|
-
}) => {
|
|
36
|
-
const {
|
|
37
|
-
activeAccountIndex, setActiveAccountIndex, rootWallet,
|
|
38
|
-
} = useWalletContext()
|
|
39
|
-
const disabled = !rootWallet || activeAccountIndex === undefined
|
|
40
|
-
|
|
41
|
-
return (
|
|
42
|
-
<>
|
|
43
|
-
{rootWallet
|
|
44
|
-
? (
|
|
45
|
-
<SelectEx
|
|
46
|
-
margin="dense"
|
|
47
|
-
disabled={disabled}
|
|
48
|
-
renderValue={(selectedAccountIndex) => {
|
|
49
|
-
return (
|
|
50
|
-
<RenderedAccountMenuItem
|
|
51
|
-
addressNames={addressNames}
|
|
52
|
-
iconOnly={iconOnly}
|
|
53
|
-
iconSize={iconSize}
|
|
54
|
-
icons={icons}
|
|
55
|
-
rootWallet={rootWallet}
|
|
56
|
-
selectedAccountIndex={selectedAccountIndex}
|
|
57
|
-
showFavorite={showFavorite}
|
|
58
|
-
/>
|
|
59
|
-
)
|
|
60
|
-
}}
|
|
61
|
-
value={activeAccountIndex === undefined ? '' : activeAccountIndex}
|
|
62
|
-
onChange={event => setActiveAccountIndex?.(Number.parseInt(`${event.target.value}`))}
|
|
63
|
-
size={size}
|
|
64
|
-
variant={variant}
|
|
65
|
-
{...props}
|
|
66
|
-
>
|
|
67
|
-
{rootWallet && arrayRange(maxAccounts).map(index => (
|
|
68
|
-
<RenderedAccountMenuItem
|
|
69
|
-
key={index}
|
|
70
|
-
addressNames={addressNames}
|
|
71
|
-
iconOnly={iconOnly}
|
|
72
|
-
iconSize={iconSize}
|
|
73
|
-
icons={icons}
|
|
74
|
-
rootWallet={rootWallet}
|
|
75
|
-
selectedAccountIndex={index}
|
|
76
|
-
showFavorite={showFavorite}
|
|
77
|
-
/>
|
|
78
|
-
))}
|
|
79
|
-
</SelectEx>
|
|
80
|
-
)
|
|
81
|
-
: <CircularProgress size={24} />}
|
|
82
|
-
</>
|
|
83
|
-
)
|
|
84
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { FlexBoxProps } from '@xylabs/react-flexbox'
|
|
2
|
-
import { FlexCol } from '@xylabs/react-flexbox'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
|
|
5
|
-
import { WalletAccountSelect } from './Select.tsx'
|
|
6
|
-
|
|
7
|
-
/** @public */
|
|
8
|
-
export interface WalletAccountSelectBarProps extends FlexBoxProps {
|
|
9
|
-
addressNames?: Record<string, string | undefined>
|
|
10
|
-
iconOnly?: boolean
|
|
11
|
-
iconSize?: number
|
|
12
|
-
icons?: boolean
|
|
13
|
-
maxAccounts?: number
|
|
14
|
-
showFavorite?: boolean
|
|
15
|
-
size?: 'small' | 'medium'
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/** @public */
|
|
19
|
-
export const WalletAccountSelectBar: React.FC<WalletAccountSelectBarProps> = ({
|
|
20
|
-
addressNames,
|
|
21
|
-
iconOnly,
|
|
22
|
-
iconSize,
|
|
23
|
-
icons,
|
|
24
|
-
maxAccounts = 1,
|
|
25
|
-
showFavorite = false,
|
|
26
|
-
size = 'small',
|
|
27
|
-
...props
|
|
28
|
-
}) => {
|
|
29
|
-
return (
|
|
30
|
-
<FlexCol alignItems="stretch" {...props}>
|
|
31
|
-
<WalletAccountSelect
|
|
32
|
-
addressNames={addressNames}
|
|
33
|
-
fullWidth
|
|
34
|
-
showFavorite={showFavorite}
|
|
35
|
-
iconSize={iconSize}
|
|
36
|
-
iconOnly={iconOnly}
|
|
37
|
-
icons={icons}
|
|
38
|
-
maxAccounts={maxAccounts}
|
|
39
|
-
size={size ?? 'small'}
|
|
40
|
-
variant="outlined"
|
|
41
|
-
/>
|
|
42
|
-
</FlexCol>
|
|
43
|
-
)
|
|
44
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Stack } from '@mui/material'
|
|
2
|
-
import type { Meta, StoryFn } from '@storybook/react-vite'
|
|
3
|
-
import React from 'react'
|
|
4
|
-
|
|
5
|
-
import { WalletAccountSelect } from './Select.tsx'
|
|
6
|
-
import { WalletProviderDecorator } from './stories/index.ts'
|
|
7
|
-
import {
|
|
8
|
-
AccountInfo, RootWalletInfo, SelectedWalletInfo, WalletInfo,
|
|
9
|
-
} from './WalletInfo.tsx'
|
|
10
|
-
|
|
11
|
-
const StorybookEntry = {
|
|
12
|
-
argTypes: {},
|
|
13
|
-
component: WalletAccountSelect,
|
|
14
|
-
decorators: [WalletProviderDecorator],
|
|
15
|
-
parameters: { docs: { page: null } },
|
|
16
|
-
title: 'wallet/WalletAccountSelect',
|
|
17
|
-
} as Meta<typeof WalletAccountSelect>
|
|
18
|
-
|
|
19
|
-
const Template: StoryFn<typeof WalletAccountSelect> = (args) => {
|
|
20
|
-
return <WalletAccountSelect {...args} />
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const WithWalletTemplate: StoryFn<typeof WalletAccountSelect> = (args) => {
|
|
24
|
-
return (
|
|
25
|
-
<>
|
|
26
|
-
<WalletAccountSelect {...args} />
|
|
27
|
-
<Stack direction="row" position="absolute" right={0} top={0} bgcolor="black" height={16}>
|
|
28
|
-
<RootWalletInfo />
|
|
29
|
-
<SelectedWalletInfo />
|
|
30
|
-
<WalletInfo />
|
|
31
|
-
<AccountInfo />
|
|
32
|
-
</Stack>
|
|
33
|
-
</>
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const Default = Template.bind({})
|
|
38
|
-
Default.args = {}
|
|
39
|
-
|
|
40
|
-
const WithWallet = WithWalletTemplate.bind({})
|
|
41
|
-
WithWallet.args = {}
|
|
42
|
-
|
|
43
|
-
export { Default, WithWallet }
|
|
44
|
-
|
|
45
|
-
export default StorybookEntry
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryFn } from '@storybook/react-vite'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
import { useWallets } from '../../hooks/index.ts'
|
|
5
|
-
import { WalletAccountSelectBar } from './SelectBar.tsx'
|
|
6
|
-
import { WalletProviderDecorator } from './stories/index.ts'
|
|
7
|
-
|
|
8
|
-
const PATHS = { paths: ['0', '3', '5'] }
|
|
9
|
-
|
|
10
|
-
const StorybookEntry = {
|
|
11
|
-
argTypes: {},
|
|
12
|
-
component: WalletAccountSelectBar,
|
|
13
|
-
decorators: [WalletProviderDecorator],
|
|
14
|
-
parameters: { docs: { page: null } },
|
|
15
|
-
title: 'wallet/WalletAccountSelectBar',
|
|
16
|
-
} as Meta<typeof WalletAccountSelectBar>
|
|
17
|
-
|
|
18
|
-
const Template: StoryFn<typeof WalletAccountSelectBar> = (args) => {
|
|
19
|
-
return <WalletAccountSelectBar {...args}></WalletAccountSelectBar>
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const WithFavoritesTemplate: StoryFn<typeof WalletAccountSelectBar> = (args) => {
|
|
23
|
-
const [wallets] = useWallets(PATHS)
|
|
24
|
-
return (
|
|
25
|
-
<WalletAccountSelectBar
|
|
26
|
-
addressNames={
|
|
27
|
-
wallets
|
|
28
|
-
? {
|
|
29
|
-
[wallets[0]?.address]: 'first address',
|
|
30
|
-
[wallets[1]?.address]: undefined,
|
|
31
|
-
[wallets[2]?.address]: 'sixth address',
|
|
32
|
-
}
|
|
33
|
-
: {}
|
|
34
|
-
}
|
|
35
|
-
icons={true}
|
|
36
|
-
maxAccounts={10}
|
|
37
|
-
showFavorite
|
|
38
|
-
{...args}
|
|
39
|
-
/>
|
|
40
|
-
)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const Default = Template.bind({})
|
|
44
|
-
Default.args = {}
|
|
45
|
-
|
|
46
|
-
const WithWallet = Template.bind({})
|
|
47
|
-
WithWallet.args = {}
|
|
48
|
-
|
|
49
|
-
const WithWalletIcon = Template.bind({})
|
|
50
|
-
WithWalletIcon.args = { icons: true }
|
|
51
|
-
|
|
52
|
-
const WithAdditionalAccounts = Template.bind({})
|
|
53
|
-
WithAdditionalAccounts.args = { icons: true, maxAccounts: 10 }
|
|
54
|
-
|
|
55
|
-
const WithAccountFavorites = WithFavoritesTemplate.bind({})
|
|
56
|
-
|
|
57
|
-
export {
|
|
58
|
-
Default, WithAccountFavorites, WithAdditionalAccounts, WithWallet, WithWalletIcon,
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export default StorybookEntry
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type { Meta, StoryFn } from '@storybook/react-vite'
|
|
2
|
-
import React from 'react'
|
|
3
|
-
|
|
4
|
-
import { WalletAccountSelect } from './Select.tsx'
|
|
5
|
-
import { WalletProviderDecorator } from './stories/index.ts'
|
|
6
|
-
|
|
7
|
-
const StorybookEntry = {
|
|
8
|
-
argTypes: {},
|
|
9
|
-
component: WalletAccountSelect,
|
|
10
|
-
decorators: [WalletProviderDecorator],
|
|
11
|
-
parameters: { docs: { page: null } },
|
|
12
|
-
title: 'wallet/WalletAccountSelectWithProvider',
|
|
13
|
-
} as Meta<typeof WalletAccountSelect>
|
|
14
|
-
|
|
15
|
-
const Template: StoryFn<typeof WalletAccountSelect> = (args) => {
|
|
16
|
-
return <WalletAccountSelect {...args}></WalletAccountSelect>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const Default = Template.bind({})
|
|
20
|
-
Default.args = {}
|
|
21
|
-
|
|
22
|
-
const DefaultIcons = Template.bind({})
|
|
23
|
-
DefaultIcons.args = { icons: true }
|
|
24
|
-
|
|
25
|
-
const DefaultSmall = Template.bind({})
|
|
26
|
-
DefaultSmall.args = { size: 'small' }
|
|
27
|
-
|
|
28
|
-
const DefaultSmallIcon = Template.bind({})
|
|
29
|
-
DefaultSmallIcon.args = { icons: true, size: 'small' }
|
|
30
|
-
|
|
31
|
-
const IconsOnly = Template.bind({})
|
|
32
|
-
IconsOnly.args = { iconOnly: true, icons: true }
|
|
33
|
-
|
|
34
|
-
const IconsOnlySmall = Template.bind({})
|
|
35
|
-
IconsOnlySmall.args = {
|
|
36
|
-
iconOnly: true, icons: true, size: 'small',
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export {
|
|
40
|
-
Default, DefaultIcons, DefaultSmall, DefaultSmallIcon, IconsOnly, IconsOnlySmall,
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export default StorybookEntry
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { Circle as LoadingIcon, ErrorOutlined as ErrorIcon } from '@mui/icons-material'
|
|
2
|
-
import type { FlexBoxProps } from '@xylabs/react-flexbox'
|
|
3
|
-
import { FlexCol } from '@xylabs/react-flexbox'
|
|
4
|
-
import { Identicon } from '@xylabs/react-identicon'
|
|
5
|
-
import { QuickTipButton } from '@xylabs/react-quick-tip-button'
|
|
6
|
-
import type { AccountInstance } from '@xyo-network/account-model'
|
|
7
|
-
import React from 'react'
|
|
8
|
-
|
|
9
|
-
import { useRootWallet, useSelectedWalletAccount } from '../../contexts/index.ts'
|
|
10
|
-
import { useAccount, useWallet } from '../../hooks/index.ts'
|
|
11
|
-
|
|
12
|
-
/** @public */
|
|
13
|
-
export interface WalletErrorProps {
|
|
14
|
-
error?: Error
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** @public */
|
|
18
|
-
export const WalletError: React.FC<WalletErrorProps> = ({ error }) => {
|
|
19
|
-
return error
|
|
20
|
-
? (
|
|
21
|
-
<div>
|
|
22
|
-
<ErrorIcon
|
|
23
|
-
style={{ fontSize: '12px', position: 'absolute' }}
|
|
24
|
-
color="error"
|
|
25
|
-
/>
|
|
26
|
-
<QuickTipButton
|
|
27
|
-
size="small"
|
|
28
|
-
style={{
|
|
29
|
-
color: '#ffffff00', fontSize: '12px', padding: 0, position: 'absolute',
|
|
30
|
-
}}
|
|
31
|
-
hoverText={error.message}
|
|
32
|
-
disableDialog
|
|
33
|
-
/>
|
|
34
|
-
</div>
|
|
35
|
-
)
|
|
36
|
-
: null
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/** @public */
|
|
40
|
-
export interface WalletIdenticonProps {
|
|
41
|
-
account?: AccountInstance | null
|
|
42
|
-
name: string
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** @public */
|
|
46
|
-
export const WalletIdenticon: React.FC<WalletIdenticonProps> = ({ account, name }) => {
|
|
47
|
-
return (
|
|
48
|
-
<div style={{ width: 20 }}>
|
|
49
|
-
{account
|
|
50
|
-
? (
|
|
51
|
-
<Identicon
|
|
52
|
-
size={8}
|
|
53
|
-
value={account.address}
|
|
54
|
-
style={{
|
|
55
|
-
position: 'absolute', right: 2, top: 2,
|
|
56
|
-
}}
|
|
57
|
-
/>
|
|
58
|
-
)
|
|
59
|
-
: (
|
|
60
|
-
<LoadingIcon
|
|
61
|
-
style={{
|
|
62
|
-
fontSize: '10px', padding: 0, position: 'absolute', right: 2, top: 2,
|
|
63
|
-
}}
|
|
64
|
-
color="disabled"
|
|
65
|
-
/>
|
|
66
|
-
)}
|
|
67
|
-
<QuickTipButton
|
|
68
|
-
size="small"
|
|
69
|
-
style={{
|
|
70
|
-
color: '#ffffff00', fontSize: '12px', padding: 0, position: 'absolute',
|
|
71
|
-
}}
|
|
72
|
-
hoverText={`${name ?? ''}: ${account?.address ?? 'no address'}`}
|
|
73
|
-
disableDialog
|
|
74
|
-
/>
|
|
75
|
-
</div>
|
|
76
|
-
)
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/** @public */
|
|
80
|
-
export const RootWalletInfo: React.FC<FlexBoxProps> = (props) => {
|
|
81
|
-
const [wallet, error] = useRootWallet()
|
|
82
|
-
return (
|
|
83
|
-
<FlexCol width={12} {...props}>
|
|
84
|
-
{error ? null : <WalletIdenticon name="Root" account={wallet} />}
|
|
85
|
-
<WalletError error={error} />
|
|
86
|
-
</FlexCol>
|
|
87
|
-
)
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/** @public */
|
|
91
|
-
export const SelectedWalletInfo: React.FC<FlexBoxProps> = (props) => {
|
|
92
|
-
const [wallet, error] = useSelectedWalletAccount()
|
|
93
|
-
return (
|
|
94
|
-
<FlexCol width={12} {...props}>
|
|
95
|
-
{error ? null : <WalletIdenticon name="Selected" account={wallet} />}
|
|
96
|
-
<WalletError error={error} />
|
|
97
|
-
</FlexCol>
|
|
98
|
-
)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/** @public */
|
|
102
|
-
export const WalletInfo: React.FC<FlexBoxProps> = (props) => {
|
|
103
|
-
const [wallet, error] = useWallet()
|
|
104
|
-
return (
|
|
105
|
-
<FlexCol width={12} {...props}>
|
|
106
|
-
{error ? null : <WalletIdenticon name="Wallet" account={wallet} />}
|
|
107
|
-
<WalletError error={error} />
|
|
108
|
-
</FlexCol>
|
|
109
|
-
)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/** @public */
|
|
113
|
-
export const AccountInfo: React.FC<FlexBoxProps> = (props) => {
|
|
114
|
-
const [account, error] = useAccount()
|
|
115
|
-
return (
|
|
116
|
-
<FlexCol width={12} {...props}>
|
|
117
|
-
{error ? null : <WalletIdenticon name="Account" account={account} />}
|
|
118
|
-
<WalletError error={error} />
|
|
119
|
-
</FlexCol>
|
|
120
|
-
)
|
|
121
|
-
}
|