@xyo-network/react-chain-provider 1.16.9 → 1.16.11

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.
Files changed (79) hide show
  1. package/dist/browser/components/connected/ConnectAccountsStack.d.ts +1 -1
  2. package/dist/browser/components/connected/ConnectAccountsStack.d.ts.map +1 -1
  3. package/dist/browser/components/index.d.ts +0 -1
  4. package/dist/browser/components/index.d.ts.map +1 -1
  5. package/dist/browser/{types/account/BalanceHistoryItemRow.d.ts → hooks/account/BalanceHistoryItemFormatted.d.ts} +5 -4
  6. package/dist/browser/hooks/account/BalanceHistoryItemFormatted.d.ts.map +1 -0
  7. package/dist/browser/hooks/account/index.d.ts +3 -0
  8. package/dist/browser/hooks/account/index.d.ts.map +1 -0
  9. package/dist/browser/hooks/{useAccountBalanceHistory.d.ts → account/useAccountBalanceHistory.d.ts} +4 -4
  10. package/dist/browser/hooks/account/useAccountBalanceHistory.d.ts.map +1 -0
  11. package/dist/browser/hooks/client/helpers/findCaveat.d.ts +1 -1
  12. package/dist/browser/hooks/helpers/transaction/Confirmation.d.ts +1 -2
  13. package/dist/browser/hooks/helpers/transaction/Confirmation.d.ts.map +1 -1
  14. package/dist/browser/hooks/index.d.ts +1 -1
  15. package/dist/browser/hooks/index.d.ts.map +1 -1
  16. package/dist/browser/hooks/useAddressBalance.d.ts +2 -4
  17. package/dist/browser/hooks/useAddressBalance.d.ts.map +1 -1
  18. package/dist/browser/hooks/useConfirmTransactionBase.d.ts +1 -1
  19. package/dist/browser/hooks/useConfirmTransactionBase.d.ts.map +1 -1
  20. package/dist/browser/hooks/useConnectAccount.d.ts +3 -6
  21. package/dist/browser/hooks/useConnectAccount.d.ts.map +1 -1
  22. package/dist/browser/hooks/viewer/useCheckRpc.d.ts.map +1 -1
  23. package/dist/browser/index.d.ts +0 -1
  24. package/dist/browser/index.d.ts.map +1 -1
  25. package/dist/browser/index.mjs +157 -270
  26. package/dist/browser/index.mjs.map +1 -1
  27. package/dist/browser/lib/balanceForRange.d.ts +1 -1
  28. package/dist/browser/lib/balanceForRange.d.ts.map +1 -1
  29. package/package.json +11 -19
  30. package/src/components/connected/ConnectAccountsStack.tsx +2 -2
  31. package/src/components/connected/account/Connected.tsx +1 -1
  32. package/src/components/index.ts +0 -1
  33. package/src/{types/account/BalanceHistoryItemRow.ts → hooks/account/BalanceHistoryItemFormatted.ts} +5 -3
  34. package/src/hooks/account/index.ts +2 -0
  35. package/src/hooks/{useAccountBalanceHistory.ts → account/useAccountBalanceHistory.ts} +7 -7
  36. package/src/hooks/client/helpers/findCaveat.ts +1 -1
  37. package/src/hooks/client/permissions/usePermissionsAccounts.ts +1 -1
  38. package/src/hooks/client/useClient.ts +1 -1
  39. package/src/hooks/client/useGateway.ts +1 -1
  40. package/src/hooks/helpers/getXyoClient.ts +1 -1
  41. package/src/hooks/helpers/transaction/Confirmation.ts +4 -6
  42. package/src/hooks/index.ts +1 -1
  43. package/src/hooks/useAddressBalance.ts +2 -2
  44. package/src/hooks/useConfirmTransactionBase.ts +4 -4
  45. package/src/hooks/useConnectAccount.ts +3 -3
  46. package/src/hooks/useCurrentBlock.ts +1 -1
  47. package/src/hooks/useHttpRpcRunner.ts +1 -1
  48. package/src/hooks/useNetwork.ts +1 -1
  49. package/src/hooks/viewer/UseStepRewardWeightTest.stories.tsx +2 -2
  50. package/src/hooks/viewer/useCheckRpc.ts +4 -3
  51. package/src/hooks/viewer/useHttpRpcViewer.stories.tsx +2 -2
  52. package/src/hooks/viewer/useHttpRpcViewer.ts +1 -1
  53. package/src/hooks/viewer/useViewerFromWallet.stories.tsx +2 -2
  54. package/src/hooks/viewer/useViewerFromWallet.ts +1 -1
  55. package/src/index.ts +0 -1
  56. package/src/lib/balanceForRange.ts +5 -3
  57. package/dist/browser/components/account/BalanceHistoryFlexbox.d.ts +0 -11
  58. package/dist/browser/components/account/BalanceHistoryFlexbox.d.ts.map +0 -1
  59. package/dist/browser/components/account/BalanceHistoryFlexbox.stories.d.ts +0 -6
  60. package/dist/browser/components/account/BalanceHistoryFlexbox.stories.d.ts.map +0 -1
  61. package/dist/browser/components/account/BalanceHistoryTable.d.ts +0 -8
  62. package/dist/browser/components/account/BalanceHistoryTable.d.ts.map +0 -1
  63. package/dist/browser/components/account/index.d.ts +0 -3
  64. package/dist/browser/components/account/index.d.ts.map +0 -1
  65. package/dist/browser/hooks/useAccountBalanceHistory.d.ts.map +0 -1
  66. package/dist/browser/types/account/BalanceHistoryItemRow.d.ts.map +0 -1
  67. package/dist/browser/types/account/Table.d.ts +0 -7
  68. package/dist/browser/types/account/Table.d.ts.map +0 -1
  69. package/dist/browser/types/account/index.d.ts +0 -3
  70. package/dist/browser/types/account/index.d.ts.map +0 -1
  71. package/dist/browser/types/index.d.ts +0 -2
  72. package/dist/browser/types/index.d.ts.map +0 -1
  73. package/src/components/account/BalanceHistoryFlexbox.stories.tsx +0 -25
  74. package/src/components/account/BalanceHistoryFlexbox.tsx +0 -65
  75. package/src/components/account/BalanceHistoryTable.tsx +0 -78
  76. package/src/components/account/index.ts +0 -2
  77. package/src/types/account/Table.ts +0 -14
  78. package/src/types/account/index.ts +0 -2
  79. package/src/types/index.ts +0 -1
@@ -6,8 +6,8 @@ import type { StoryFn } from '@storybook/react-vite'
6
6
  import { ButtonEx } from '@xylabs/react-button'
7
7
  import {
8
8
  isDefined, isDefinedNotNull, isUndefined,
9
- } from '@xylabs/typeof'
10
- import { LocalNetwork } from '@xyo-network/chain-network-model'
9
+ } from '@xylabs/sdk-js'
10
+ import { LocalNetwork } from '@xyo-network/xl1-network-model'
11
11
  import {
12
12
  asXL1BlockNumber, XL1Amount, XL1Places,
13
13
  } from '@xyo-network/xl1-protocol'
@@ -1,6 +1,7 @@
1
- import { delay } from '@xylabs/delay'
2
- import { isDefined, isUndefined } from '@xylabs/typeof'
3
- import { LocalNetwork, SequenceNetwork } from '@xyo-network/chain-network-model'
1
+ import {
2
+ delay, isDefined, isUndefined,
3
+ } from '@xylabs/sdk-js'
4
+ import { LocalNetwork, SequenceNetwork } from '@xyo-network/xl1-network-model'
4
5
  import {
5
6
  HttpRpcTransport, JsonRpcNetworkStakeViewer, JsonRpcXyoViewer, NetworkStakeViewerRpcSchemas, XyoViewerRpcSchemas,
6
7
  } from '@xyo-network/xl1-rpc'
@@ -2,9 +2,9 @@ import {
2
2
  Alert, Button, Stack,
3
3
  } from '@mui/material'
4
4
  import type { Meta, StoryFn } from '@storybook/react-vite'
5
- import { isDefined } from '@xylabs/typeof'
6
- import { SequenceNetwork } from '@xyo-network/chain-network-model'
5
+ import { isDefined } from '@xylabs/sdk-js'
7
6
  import { isXyoGlobal } from '@xyo-network/react-chain-model'
7
+ import { SequenceNetwork } from '@xyo-network/xl1-network-model'
8
8
  import type { HydratedBlock } from '@xyo-network/xl1-protocol'
9
9
  import React, { useState } from 'react'
10
10
 
@@ -1,4 +1,4 @@
1
- import { isUndefined } from '@xylabs/typeof'
1
+ import { isUndefined } from '@xylabs/sdk-js'
2
2
  import {
3
3
  HttpRpcTransport, JsonRpcNetworkStakeViewer, JsonRpcXyoViewer, NetworkStakeViewerRpcSchemas, XyoViewerRpcSchemas,
4
4
  } from '@xyo-network/xl1-rpc'
@@ -1,9 +1,9 @@
1
1
  import { Alert, Stack } from '@mui/material'
2
2
  import type { StoryFn } from '@storybook/react-vite'
3
3
  import { ButtonEx } from '@xylabs/react-button'
4
- import { isDefined, isDefinedNotNull } from '@xylabs/typeof'
5
- import { MainNetwork } from '@xyo-network/chain-network-model'
4
+ import { isDefined, isDefinedNotNull } from '@xylabs/sdk-js'
6
5
  import { isXyoGlobal } from '@xyo-network/react-chain-model'
6
+ import { MainNetwork } from '@xyo-network/xl1-network-model'
7
7
  import type { HydratedBlock } from '@xyo-network/xl1-protocol'
8
8
  import React, { useState } from 'react'
9
9
 
@@ -1,7 +1,7 @@
1
1
  import { usePromise } from '@xylabs/react-promise'
2
2
  import {
3
3
  isDefined, isDefinedNotNull, isNull,
4
- } from '@xylabs/typeof'
4
+ } from '@xylabs/sdk-js'
5
5
  import type { GatewayName } from '@xyo-network/xl1-protocol'
6
6
 
7
7
  import { useGateway } from '../client/index.ts'
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './components/index.ts'
2
2
  export * from './hooks/index.ts'
3
3
  export * from './lib/index.ts'
4
- export * from './types/index.ts'
@@ -1,5 +1,7 @@
1
- import type { Address } from '@xylabs/hex'
2
- import { hexToBigInt, toHex } from '@xylabs/hex'
1
+ import type { Address } from '@xylabs/sdk-js'
2
+ import {
3
+ hexToBigInt, isHex, toHex,
4
+ } from '@xylabs/sdk-js'
3
5
  import type { AttoXL1 } from '@xyo-network/xl1-protocol'
4
6
  import type { AccountBalanceHistoryItem } from '@xyo-network/xl1-protocol-sdk'
5
7
 
@@ -9,7 +11,7 @@ export const balanceForRange = (address: Address, results: AccountBalanceHistory
9
11
  }, 0n)
10
12
  // eslint-disable-next-line unicorn/no-array-reduce
11
13
  const totalSentBalance = results?.reduce((a, [_block, _tx, transfer]) => {
12
- return (transfer.from === address) ? a + Object.values(transfer.transfers).reduce((a, v) => a + (v ? hexToBigInt(v) : 0n), 0n) : a
14
+ return (transfer.from === address) ? a + Object.values(transfer.transfers).reduce((a, v) => a + (isHex(v) ? hexToBigInt(v) : 0n), 0n) : a
13
15
  }, 0n)
14
16
  return [totalReceivedBalance, totalSentBalance] as [AttoXL1, AttoXL1]
15
17
  }
@@ -1,11 +0,0 @@
1
- import { type Address } from '@xylabs/hex';
2
- import type { FlexBoxProps } from '@xylabs/react-flexbox';
3
- import type { XyoViewer } from '@xyo-network/xl1-protocol-sdk';
4
- import React from 'react';
5
- export interface AccountBalanceHistoryFlexBoxProps extends FlexBoxProps {
6
- address?: Address;
7
- refresh?: number;
8
- viewer?: XyoViewer;
9
- }
10
- export declare const AccountBalanceHistoryFlexBox: React.FC<AccountBalanceHistoryFlexBoxProps>;
11
- //# sourceMappingURL=BalanceHistoryFlexbox.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BalanceHistoryFlexbox.d.ts","sourceRoot":"","sources":["../../../../src/components/account/BalanceHistoryFlexbox.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAKzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,KAAK,MAAM,OAAO,CAAA;AAKzB,MAAM,WAAW,iCAAkC,SAAQ,YAAY;IACrE,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,CAAC,EAAE,SAAS,CAAA;CACnB;AAED,eAAO,MAAM,4BAA4B,EAAE,KAAK,CAAC,EAAE,CAAC,iCAAiC,CA6CpF,CAAA"}
@@ -1,6 +0,0 @@
1
- import type { Meta } from '@storybook/react-vite';
2
- declare const _default: Meta;
3
- export default _default;
4
- declare const Default: import("storybook/internal/csf").AnnotatedStoryFn<import("@storybook/react").ReactRenderer, import("./BalanceHistoryFlexbox.tsx").AccountBalanceHistoryFlexBoxProps>;
5
- export { Default };
6
- //# sourceMappingURL=BalanceHistoryFlexbox.stories.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BalanceHistoryFlexbox.stories.d.ts","sourceRoot":"","sources":["../../../../src/components/account/BalanceHistoryFlexbox.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAW,MAAM,uBAAuB,CAAA;wBAWrD,IAAI;AAHT,wBAGS;AAOT,QAAA,MAAM,OAAO,sKAAoB,CAAA;AAMjC,OAAO,EAAE,OAAO,EAAE,CAAA"}
@@ -1,8 +0,0 @@
1
- import type { TableProps } from '@mui/material';
2
- import React from 'react';
3
- import type { AccountBalanceHistoryItemRow } from '../../types/index.ts';
4
- export interface AccountBalanceHistoryTableProps extends TableProps {
5
- history?: AccountBalanceHistoryItemRow[];
6
- }
7
- export declare const AccountBalanceHistoryTable: React.FC<AccountBalanceHistoryTableProps>;
8
- //# sourceMappingURL=BalanceHistoryTable.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BalanceHistoryTable.d.ts","sourceRoot":"","sources":["../../../../src/components/account/BalanceHistoryTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAY/C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAA;AAGxE,MAAM,WAAW,+BAAgC,SAAQ,UAAU;IACjE,OAAO,CAAC,EAAE,4BAA4B,EAAE,CAAA;CACzC;AAED,eAAO,MAAM,0BAA0B,EAAE,KAAK,CAAC,EAAE,CAAC,+BAA+B,CAwDhF,CAAA"}
@@ -1,3 +0,0 @@
1
- export * from './BalanceHistoryFlexbox.tsx';
2
- export * from './BalanceHistoryTable.tsx';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/account/index.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA;AAC3C,cAAc,2BAA2B,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useAccountBalanceHistory.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAccountBalanceHistory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EAEb,MAAM,aAAa,CAAA;AAIpB,OAAO,KAAK,EAAE,yBAAyB,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAA;AAGzF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAA;AAErE,eAAO,MAAM,2BAA2B,GAAI,SAAS,OAAO,EAAE,SAAS,yBAAyB,EAAE,KAAG,4BAA4B,EAiChI,CAAA;AAED,eAAO,MAAM,wBAAwB,GAAI,UAAU,OAAO,EAAE,SAAS,SAAS,EAAE,UAAU,MAAM;;;;8FAqC/F,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"BalanceHistoryItemRow.d.ts","sourceRoot":"","sources":["../../../../src/types/account/BalanceHistoryItemRow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAChD,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAA;AAE9E,MAAM,WAAW,4BAA4B;IAC3C,MAAM,EAAE,MAAM,CAAA;IACd,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,yBAAyB,CAAA;IAChC,IAAI,EAAE,OAAO,CAAA;IACb,GAAG,EAAE,MAAM,CAAA;IACX,SAAS,EAAE,MAAM,CAAA;IACjB,EAAE,EAAE,OAAO,CAAA;IACX,MAAM,EAAE,IAAI,GAAG,SAAS,CAAA;IACxB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAA;CACzB"}
@@ -1,7 +0,0 @@
1
- import type { AccountBalanceHistoryItemRow } from './BalanceHistoryItemRow.ts';
2
- export type TableHeadingLabels = 'Tx Hash' | 'BlockNumber' | 'Timestamp' | 'From' | 'To' | 'Amount' | 'Debug';
3
- export type TableHeadings = {
4
- [key in keyof AccountBalanceHistoryItemRow]: TableHeadingLabels;
5
- };
6
- export declare const TableHeadingLabels: TableHeadingLabels[];
7
- //# sourceMappingURL=Table.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../../src/types/account/Table.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAA;AAE9E,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,aAAa,GAAG,WAAW,GAAG,MAAM,GAAG,IAAI,GAAG,QAAQ,GAAG,OAAO,CAAA;AAC7G,MAAM,MAAM,aAAa,GAAG;KAAG,GAAG,IAAI,MAAM,4BAA4B,GAAG,kBAAkB;CAAE,CAAA;AAE/F,eAAO,MAAM,kBAAkB,EAAE,kBAAkB,EAQzC,CAAA"}
@@ -1,3 +0,0 @@
1
- export * from './BalanceHistoryItemRow.ts';
2
- export * from './Table.ts';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/account/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAA;AAC1C,cAAc,YAAY,CAAA"}
@@ -1,2 +0,0 @@
1
- export * from './account/index.ts';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA"}
@@ -1,25 +0,0 @@
1
- import type { Meta, StoryFn } from '@storybook/react-vite'
2
- import type { Address } from '@xylabs/hex'
3
- import { LocalNetwork } from '@xyo-network/chain-network-model'
4
- import React from 'react'
5
-
6
- import { useHttpRpcViewer } from '../../hooks/index.ts'
7
- import { AccountBalanceHistoryFlexBox } from './BalanceHistoryFlexbox.tsx'
8
-
9
- export default {
10
- title: 'Provider/Components/Account/BalanceHistoryFlexBox',
11
- component: AccountBalanceHistoryFlexBox,
12
- } as Meta
13
-
14
- const Template: StoryFn<typeof AccountBalanceHistoryFlexBox> = (args) => {
15
- const viewer = useHttpRpcViewer(LocalNetwork.url)
16
- return <AccountBalanceHistoryFlexBox viewer={viewer} {...args} />
17
- }
18
-
19
- const Default = Template.bind({})
20
- Default.args = {
21
- address: '2b1a21d8c90e658d8bf1e2aad31c8dc892c353c1' as Address,
22
- refresh: 0,
23
- }
24
-
25
- export { Default }
@@ -1,65 +0,0 @@
1
- import { Typography } from '@mui/material'
2
- import { type Address } from '@xylabs/hex'
3
- import type { FlexBoxProps } from '@xylabs/react-flexbox'
4
- import { FlexCol } from '@xylabs/react-flexbox'
5
- import { isDefined } from '@xylabs/typeof'
6
- import { ErrorRender } from '@xyo-network/react-error'
7
- import { AttoXL1, XL1Amount } from '@xyo-network/xl1-protocol'
8
- import type { XyoViewer } from '@xyo-network/xl1-protocol-sdk'
9
- import React from 'react'
10
-
11
- import { useAccountBalanceHistory } from '../../hooks/index.ts'
12
- import { AccountBalanceHistoryTable } from './BalanceHistoryTable.tsx'
13
-
14
- export interface AccountBalanceHistoryFlexBoxProps extends FlexBoxProps {
15
- address?: Address
16
- refresh?: number
17
- viewer?: XyoViewer
18
- }
19
-
20
- export const AccountBalanceHistoryFlexBox: React.FC<AccountBalanceHistoryFlexBoxProps> = ({
21
- address, refresh, viewer, ...props
22
- }) => {
23
- const [results, error] = useAccountBalanceHistory(address, viewer, refresh)
24
- const {
25
- history, balance, truncated,
26
- } = results || { balance: [AttoXL1(0n), AttoXL1(0n)], history: undefined }
27
-
28
- const formatBalance = (balance: bigint) => {
29
- const xl1Amount = new XL1Amount(balance)
30
- return xl1Amount.toString(undefined, {
31
- places: 18, maxDecimal: 12, maxCharacters: 12, minDecimals: 1, locale: navigator.language,
32
- })
33
- }
34
-
35
- const formatBalanceMagnitude = (set: [AttoXL1, AttoXL1]) => {
36
- const [received, sent] = set
37
- const netBalance = received - sent
38
- return netBalance < 0n ? `-${formatBalance(sent - received)}` : formatBalance(netBalance)
39
- }
40
-
41
- return isDefined(history) && isDefined(address)
42
- ? (
43
- <FlexCol {...props}>
44
- <ErrorRender error={error} scope="AccountBalanceHistoryTable" />
45
- <Typography variant="h6" gutterBottom>
46
- {formatBalanceMagnitude(balance)}
47
- </Typography>
48
- {truncated
49
- ? (
50
- <Typography variant="caption" gutterBottom>
51
- Ranged Balance from
52
- {' '}
53
- {history.at(-1)!.blockNumber}
54
- {' '}
55
- -
56
- {' '}
57
- {history[0].blockNumber}
58
- </Typography>
59
- )
60
- : null}
61
- <AccountBalanceHistoryTable history={history} />
62
- </FlexCol>
63
- )
64
- : null
65
- }
@@ -1,78 +0,0 @@
1
- import type { TableProps } from '@mui/material'
2
- import {
3
- Table, TableBody, TableCell, TableHead, TableRow,
4
- Tooltip,
5
- } from '@mui/material'
6
- import { isDefined } from '@xylabs/typeof'
7
- import {
8
- BlockAddressChip, BlockEpochTableCellInner, BlockNumberTableCellInner,
9
- } from '@xyo-network/react-chain-blockchain'
10
- import { RawInfoIconButton } from '@xyo-network/react-payload-raw-info'
11
- import { XL1Amount } from '@xyo-network/xl1-protocol'
12
- import type { JsonValue } from '@xyo-network/xl1-rpc'
13
- import React from 'react'
14
-
15
- import type { AccountBalanceHistoryItemRow } from '../../types/index.ts'
16
- import { TableHeadingLabels } from '../../types/index.ts'
17
-
18
- export interface AccountBalanceHistoryTableProps extends TableProps {
19
- history?: AccountBalanceHistoryItemRow[]
20
- }
21
-
22
- export const AccountBalanceHistoryTable: React.FC<AccountBalanceHistoryTableProps> = ({ history, ...props }) => {
23
- const formatAmount = (amount?: bigint) => {
24
- if (!isDefined(amount)) {
25
- return 'N/A'
26
- }
27
- const xl1Amount = new XL1Amount(amount)
28
- return xl1Amount.toString(undefined, {
29
- places: 18, maxDecimal: 12, maxCharacters: 12, minDecimals: 1, locale: navigator.language,
30
- })
31
- }
32
-
33
- return isDefined(history)
34
- ? (
35
- <Table {...props}>
36
- <TableHead>
37
- <TableRow>
38
- {TableHeadingLabels.map(heading => (
39
- <TableCell key={heading}>{heading}</TableCell>
40
- ))}
41
- </TableRow>
42
- </TableHead>
43
- <TableBody>
44
- {history?.map(({
45
- amount, blockNumber, debug, from, key, timestamp, to, type, txHash,
46
- }) => (
47
- <TableRow key={key}>
48
- <TableCell>{txHash || 'N/A'}</TableCell>
49
- <BlockNumberTableCellInner blockNumber={blockNumber} />
50
- <BlockEpochTableCellInner epoch={timestamp} />
51
- <TableCell>
52
- <Tooltip title={`From Address: ${from}`}>
53
- <BlockAddressChip address={from} toolTipTitle={`From: ${from}`} />
54
- </Tooltip>
55
- </TableCell>
56
- <TableCell>
57
- <Tooltip title={`To Address: ${to}`}>
58
- <BlockAddressChip address={to} toolTipTitle={`To: ${to}`} />
59
- </Tooltip>
60
- </TableCell>
61
- <TableCell>
62
- <Tooltip title={`Raw Amount: ${amount}`}>
63
- <span>
64
- {type === 'send' ? '-' : ''}
65
- {formatAmount(amount)}
66
- </span>
67
- </Tooltip>
68
- </TableCell>
69
- <TableCell>
70
- <RawInfoIconButton rawValue={debug as JsonValue} />
71
- </TableCell>
72
- </TableRow>
73
- ))}
74
- </TableBody>
75
- </Table>
76
- )
77
- : null
78
- }
@@ -1,2 +0,0 @@
1
- export * from './BalanceHistoryFlexbox.tsx'
2
- export * from './BalanceHistoryTable.tsx'
@@ -1,14 +0,0 @@
1
- import type { AccountBalanceHistoryItemRow } from './BalanceHistoryItemRow.ts'
2
-
3
- export type TableHeadingLabels = 'Tx Hash' | 'BlockNumber' | 'Timestamp' | 'From' | 'To' | 'Amount' | 'Debug'
4
- export type TableHeadings = { [key in keyof AccountBalanceHistoryItemRow]: TableHeadingLabels }
5
-
6
- export const TableHeadingLabels: TableHeadingLabels[] = [
7
- 'Tx Hash',
8
- 'BlockNumber',
9
- 'Timestamp',
10
- 'From',
11
- 'To',
12
- 'Amount',
13
- 'Debug',
14
- ] as const
@@ -1,2 +0,0 @@
1
- export * from './BalanceHistoryItemRow.ts'
2
- export * from './Table.ts'
@@ -1 +0,0 @@
1
- export * from './account/index.ts'