-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: walletd api changes and app updates
- Loading branch information
1 parent
1053c50
commit d66e310
Showing
46 changed files
with
912 additions
and
603 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@siafoundation/types': minor | ||
--- | ||
|
||
The library now includes v2 types. |
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,5 @@ | ||
--- | ||
'walletd': minor | ||
--- | ||
|
||
The UI now uses the new daemon endpoints and changes. Closes https://github.com/SiaFoundation/walletd/issues/73 |
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,5 @@ | ||
--- | ||
'@siafoundation/react-walletd': minor | ||
--- | ||
|
||
The React hooks have been updated for the daemon endpoint changes. Closes https://github.com/SiaFoundation/walletd/issues/73 |
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
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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { | ||
useDatasetEmptyState, | ||
ClientFilterItem, | ||
} from '@siafoundation/design-system' | ||
import { useWalletAddresses } from '@siafoundation/react-walletd' | ||
import { useMemo } from 'react' | ||
import { AddressData } from './types' | ||
import { useDialog } from '../dialog' | ||
|
||
export function useDataset({ | ||
walletId, | ||
response, | ||
filters, | ||
}: { | ||
walletId: string | ||
response: ReturnType<typeof useWalletAddresses> | ||
filters: ClientFilterItem<AddressData>[] | ||
}) { | ||
const { openDialog } = useDialog() | ||
const dataset = useMemo<AddressData[] | null>(() => { | ||
if (!response.data) { | ||
return null | ||
} | ||
const data: AddressData[] = response.data.map((addressObject) => { | ||
const { address, description, metadata, spendPolicy } = addressObject | ||
return { | ||
id: address, | ||
address, | ||
description: description, | ||
spendPolicy: spendPolicy, | ||
metadata: { | ||
index: metadata?.index as number, | ||
publicKey: metadata?.publicKey as string, | ||
}, | ||
walletId, | ||
onClick: () => | ||
openDialog('addressUpdate', { | ||
walletId: walletId, | ||
address, | ||
}), | ||
raw: addressObject, | ||
} | ||
}) | ||
return data | ||
}, [response.data, openDialog, walletId]) | ||
|
||
const dataState = useDatasetEmptyState( | ||
dataset, | ||
response.isValidating, | ||
response.error, | ||
filters | ||
) | ||
|
||
const lastIndex = (dataset || []).reduce( | ||
(highest, { metadata }) => | ||
metadata.index > highest ? metadata.index : highest, | ||
-1 | ||
) | ||
|
||
return { | ||
dataset, | ||
dataState, | ||
error: response.error, | ||
lastIndex, | ||
filters, | ||
} | ||
} |
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
Oops, something went wrong.