Skip to content
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

refactor: split out walletd-types #578

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/clean-hairs-tell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@siafoundation/walletd-types': minor
---

Introduced new library for walletd types.
6 changes: 3 additions & 3 deletions apps/walletd-e2e/src/fixtures/createWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
Wallet,
WalletAddressesResponse,
WalletBalanceResponse,
WalletFundResponse,
WalletFundSiacoinResponse,
WalletOutputsSiacoinResponse,
} from '@siafoundation/walletd-react'
} from '@siafoundation/walletd-types'

export async function createWallet({
page,
Expand All @@ -21,7 +21,7 @@ export async function createWallet({
responses?: {
balance?: WalletBalanceResponse
outputsSiacoin?: WalletOutputsSiacoinResponse
fund?: WalletFundResponse
fundSiacoin?: WalletFundSiacoinResponse
addresses?: WalletAddressesResponse
}
expects?: {
Expand Down
2 changes: 1 addition & 1 deletion apps/walletd-e2e/src/specs/seedSendSiacoin.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ test('errors if the input to sign is not found on the transaction', async ({
mnemonic,
responses: {
...getDefaultMockWalletResponses(mocks),
fund: mockFundInvalid,
fundSiacoin: mockFundInvalid,
},
expects: {
fundSiacoinPost: (data) =>
Expand Down
4 changes: 2 additions & 2 deletions apps/walletd/contexts/addresses/dataset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
import {
WalletAddressMetadata,
WalletAddressesResponse,
useWalletAddresses,
} from '@siafoundation/walletd-react'
} from '@siafoundation/walletd-types'
import { useWalletAddresses } from '@siafoundation/walletd-react'
import { useMemo } from 'react'
import { AddressData } from './types'
import { OpenDialog, useDialog } from '../dialog'
Expand Down
2 changes: 1 addition & 1 deletion apps/walletd/contexts/addresses/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
WalletAddress,
WalletAddressMetadata,
} from '@siafoundation/walletd-react'
} from '@siafoundation/walletd-types'

export type CellContext = {
siascanUrl: string
Expand Down
6 changes: 2 additions & 4 deletions apps/walletd/contexts/wallets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import {
useClientFilters,
useClientFilteredDataset,
} from '@siafoundation/design-system'
import {
WalletMetadata,
useWallets as useWalletsData,
} from '@siafoundation/walletd-react'
import { WalletMetadata } from '@siafoundation/walletd-types'
import { useWallets as useWalletsData } from '@siafoundation/walletd-react'
import { createContext, useContext, useEffect, useMemo } from 'react'
import {
WalletData,
Expand Down
2 changes: 1 addition & 1 deletion apps/walletd/contexts/wallets/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Wallet, WalletMetadata } from '@siafoundation/walletd-react'
import { Wallet, WalletMetadata } from '@siafoundation/walletd-types'

export type WalletData = {
id: string
Expand Down
5 changes: 2 additions & 3 deletions apps/walletd/dialogs/WalletAddLedgerDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import { useForm } from 'react-hook-form'
import {
WalletAddressMetadata,
WalletMetadata,
useWalletAdd,
useWalletAddressAdd,
} from '@siafoundation/walletd-react'
} from '@siafoundation/walletd-types'
import { useWalletAdd, useWalletAddressAdd } from '@siafoundation/walletd-react'
import { useDialog } from '../../contexts/dialog'
import { useWallets } from '../../contexts/wallets'
import { walletAddTypes } from '../../config/walletTypes'
Expand Down
3 changes: 2 additions & 1 deletion apps/walletd/dialogs/WalletAddNewDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import {
import { Redo16, Copy16 } from '@siafoundation/react-icons'
import { MouseEvent, useCallback, useEffect } from 'react'
import { useForm } from 'react-hook-form'
import { WalletMetadata, useWalletAdd } from '@siafoundation/walletd-react'
import { WalletMetadata } from '@siafoundation/walletd-types'
import { useWalletAdd } from '@siafoundation/walletd-react'
import { useDialog } from '../../contexts/dialog'
import { useWallets } from '../../contexts/wallets'
import { walletAddTypes } from '../../config/walletTypes'
Expand Down
3 changes: 2 additions & 1 deletion apps/walletd/dialogs/WalletAddRecoverDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import { useCallback } from 'react'
import { useForm } from 'react-hook-form'
import { useDialog } from '../../contexts/dialog'
import { useWallets } from '../../contexts/wallets'
import { WalletMetadata, useWalletAdd } from '@siafoundation/walletd-react'
import { WalletMetadata } from '@siafoundation/walletd-types'
import { useWalletAdd } from '@siafoundation/walletd-react'
import { blake2bHex } from 'blakejs'
import { SeedLayout } from '../SeedLayout'
import { SeedIcon } from '@siafoundation/react-icons'
Expand Down
3 changes: 2 additions & 1 deletion apps/walletd/dialogs/WalletAddWatchDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
} from '@siafoundation/design-system'
import { useCallback } from 'react'
import { useForm } from 'react-hook-form'
import { WalletMetadata, useWalletAdd } from '@siafoundation/walletd-react'
import { WalletMetadata } from '@siafoundation/walletd-types'
import { useWalletAdd } from '@siafoundation/walletd-react'
import { useDialog } from '../../contexts/dialog'
import { useWallets } from '../../contexts/wallets'
import { walletAddTypes } from '../../config/walletTypes'
Expand Down
6 changes: 2 additions & 4 deletions apps/walletd/dialogs/WalletAddressesAddDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ import {
triggerSuccessToast,
useDialogFormHelpers,
} from '@siafoundation/design-system'
import {
WalletAddressMetadata,
useWalletAddressAdd,
} from '@siafoundation/walletd-react'
import { WalletAddressMetadata } from '@siafoundation/walletd-types'
import { useWalletAddressAdd } from '@siafoundation/walletd-react'
import { useCallback } from 'react'
import { useForm } from 'react-hook-form'
import { useWallets } from '../contexts/wallets'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ import {
triggerSuccessToast,
useDialogFormHelpers,
} from '@siafoundation/design-system'
import {
WalletAddressMetadata,
useWalletAddressAdd,
} from '@siafoundation/walletd-react'
import { WalletAddressMetadata } from '@siafoundation/walletd-types'
import { useWalletAddressAdd } from '@siafoundation/walletd-react'
import { useCallback, useEffect, useMemo, useState } from 'react'
import { useForm } from 'react-hook-form'
import { useWallets } from '../../contexts/wallets'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ import {
triggerSuccessToast,
useDialogFormHelpers,
} from '@siafoundation/design-system'
import {
WalletAddressMetadata,
useWalletAddressAdd,
} from '@siafoundation/walletd-react'
import { WalletAddressMetadata } from '@siafoundation/walletd-types'
import { useWalletAddressAdd } from '@siafoundation/walletd-react'
import { useCallback, useEffect, useState } from 'react'
import { useForm } from 'react-hook-form'
import { useWallets } from '../../contexts/wallets'
Expand Down
2 changes: 1 addition & 1 deletion apps/walletd/lib/testMocks.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Sia from '@siacentral/ledgerjs-sia'
import { LedgerDevice } from '../contexts/ledger/types'
import { transformAddressesResponse } from '../contexts/addresses/dataset'
import { Wallet, WalletAddressesResponse } from '@siafoundation/walletd-react'
import { Wallet, WalletAddressesResponse } from '@siafoundation/walletd-types'

export function getMockDevice() {
return {
Expand Down
4 changes: 2 additions & 2 deletions libs/walletd-mock/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"license": "MIT",
"dependencies": {
"@siafoundation/types": "0.2.0",
"@siafoundation/walletd-react": "4.0.0",
"@siafoundation/sia-central-mock": "0.0.0",
"@siafoundation/units": "3.0.0",
"playwright": "^1.42.1"
"playwright": "^1.42.1",
"@siafoundation/walletd-types": "0.0.0"
},
"types": "./src/index.d.ts"
}
2 changes: 1 addition & 1 deletion libs/walletd-mock/src/mocks/consensusTip.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConsensusTipResponse } from '@siafoundation/walletd-react'
import { ConsensusTipResponse } from '@siafoundation/walletd-types'
import { Page } from 'playwright'

export function getMockConsensusTipResponse(): ConsensusTipResponse {
Expand Down
2 changes: 1 addition & 1 deletion libs/walletd-mock/src/mocks/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { mockApiWallets } from './wallets'
import { mockApiTxPoolBroadcast } from './txPoolBroadcast'
import { mockApiWallet } from './wallet'
import { mockApiRescan } from './rescan'
import { RescanResponse } from '@siafoundation/walletd-react'
import { RescanResponse } from '@siafoundation/walletd-types'

type Responses = {
rescan?: RescanResponse
Expand Down
2 changes: 1 addition & 1 deletion libs/walletd-mock/src/mocks/peers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SyncerPeersResponse } from '@siafoundation/walletd-react'
import { SyncerPeersResponse } from '@siafoundation/walletd-types'
import { Page } from 'playwright'

export function getMockPeersResponse(): SyncerPeersResponse {
Expand Down
2 changes: 1 addition & 1 deletion libs/walletd-mock/src/mocks/rescan.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RescanResponse } from '@siafoundation/walletd-react'
import { RescanResponse } from '@siafoundation/walletd-types'
import { Page } from 'playwright'

export function getMockRescanResponse(): RescanResponse {
Expand Down
8 changes: 4 additions & 4 deletions libs/walletd-mock/src/mocks/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {
Wallet,
WalletAddressesResponse,
WalletBalanceResponse,
WalletFundResponse,
WalletFundSiacoinResponse,
WalletOutputsSiacoinResponse,
} from '@siafoundation/walletd-react'
} from '@siafoundation/walletd-types'
import { mockApiWalletBalance } from './walletBalance'
import { mockApiWalletAddresses } from './walletAddresses'
import { mockApiWalletEvents } from './walletEvents'
Expand All @@ -27,7 +27,7 @@ export async function mockApiWallet({
responses?: {
balance?: WalletBalanceResponse
outputsSiacoin?: WalletOutputsSiacoinResponse
fund?: WalletFundResponse
fundSiacoin?: WalletFundSiacoinResponse
addresses?: WalletAddressesResponse
}
expects?: {
Expand Down Expand Up @@ -59,7 +59,7 @@ export async function mockApiWallet({
await mockApiWalletFundSiacoin({
page,
walletId: wallet.id,
response: responses.fund,
response: responses.fundSiacoin,
expectPost: expects.fundSiacoinPost,
})
await mockApiWalletRelease({
Expand Down
2 changes: 1 addition & 1 deletion libs/walletd-mock/src/mocks/walletAddresses.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
WalletAddress,
WalletAddressesResponse,
} from '@siafoundation/walletd-react'
} from '@siafoundation/walletd-types'
import { Page } from 'playwright'

export function getMockWalletAddressesResponse(): WalletAddressesResponse {
Expand Down
2 changes: 1 addition & 1 deletion libs/walletd-mock/src/mocks/walletBalance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WalletBalanceResponse } from '@siafoundation/walletd-react'
import { WalletBalanceResponse } from '@siafoundation/walletd-types'
import { toHastings } from '@siafoundation/units'
import { Page } from 'playwright'

Expand Down
2 changes: 1 addition & 1 deletion libs/walletd-mock/src/mocks/walletEvents.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WalletEventsResponse } from '@siafoundation/walletd-react'
import { WalletEventsResponse } from '@siafoundation/walletd-types'
import { Page } from 'playwright'

export function getMockWalletEventsResponse(): WalletEventsResponse {
Expand Down
6 changes: 3 additions & 3 deletions libs/walletd-mock/src/mocks/walletFundSiacoin.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { WalletFundResponse } from '@siafoundation/walletd-react'
import { WalletFundSiacoinResponse } from '@siafoundation/walletd-types'
import { Page } from 'playwright'

export function getMockWalletFundSiacoinResponse(): WalletFundResponse {
export function getMockWalletFundSiacoinResponse(): WalletFundSiacoinResponse {
return {
transaction: {
siacoinInputs: [
Expand Down Expand Up @@ -54,7 +54,7 @@ export async function mockApiWalletFundSiacoin({
}: {
page: Page
walletId: string
response?: WalletFundResponse
response?: WalletFundSiacoinResponse
expectPost?: (data: string | null) => void
}) {
const json = response || getMockWalletFundSiacoinResponse()
Expand Down
6 changes: 3 additions & 3 deletions libs/walletd-mock/src/mocks/walletFundSiafund.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { WalletFundResponse } from '@siafoundation/walletd-react'
import { WalletFundSiafundResponse } from '@siafoundation/walletd-types'
import { Page } from 'playwright'

export function getMockWalletFundSiafundResponse(): WalletFundResponse {
export function getMockWalletFundSiafundResponse(): WalletFundSiafundResponse {
return {
transaction: {
minerFees: ['3930000000000000000000'],
Expand All @@ -19,7 +19,7 @@ export async function mockApiWalletFundSiafund({
}: {
page: Page
walletId: string
response?: WalletFundResponse
response?: WalletFundSiafundResponse
expectPost?: (data: string | null) => void
}) {
const json = response || getMockWalletFundSiafundResponse()
Expand Down
2 changes: 1 addition & 1 deletion libs/walletd-mock/src/mocks/walletOutputsSiacoin.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WalletOutputsSiacoinResponse } from '@siafoundation/walletd-react'
import { WalletOutputsSiacoinResponse } from '@siafoundation/walletd-types'
import { SiacoinElement } from '@siafoundation/types'
import { Page } from 'playwright'

Expand Down
2 changes: 1 addition & 1 deletion libs/walletd-mock/src/mocks/walletOutputsSiafund.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WalletOutputsSiafundResponse } from '@siafoundation/walletd-react'
import { WalletOutputsSiafundResponse } from '@siafoundation/walletd-types'
import { Page } from 'playwright'

export function getMockWalletOutputsSiafundResponse(): WalletOutputsSiafundResponse {
Expand Down
4 changes: 2 additions & 2 deletions libs/walletd-mock/src/mocks/walletRelease.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WalletFundResponse } from '@siafoundation/walletd-react'
import { WalletReleaseResponse } from '@siafoundation/walletd-types'
import { Page } from 'playwright'

export async function mockApiWalletRelease({
Expand All @@ -7,7 +7,7 @@ export async function mockApiWalletRelease({
}: {
page: Page
walletId: string
response?: WalletFundResponse
response?: WalletReleaseResponse
}) {
await page.route(`**/api/wallets/${walletId}/release*`, async (route) => {
await route.fulfill()
Expand Down
2 changes: 1 addition & 1 deletion libs/walletd-mock/src/mocks/walletTxPool.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { WalletTxPoolResponse } from '@siafoundation/walletd-react'
import { WalletTxPoolResponse } from '@siafoundation/walletd-types'
import { Page } from 'playwright'

export function getMockWalletTxPoolResponse(): WalletTxPoolResponse {
Expand Down
2 changes: 1 addition & 1 deletion libs/walletd-mock/src/mocks/wallets.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Wallet, WalletsResponse } from '@siafoundation/walletd-react'
import { Wallet, WalletsResponse } from '@siafoundation/walletd-types'
import { Page } from 'playwright'

export function getMockWalletsResponse(): WalletsResponse {
Expand Down
6 changes: 3 additions & 3 deletions libs/walletd-mock/src/scenarios/seedWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
Wallet,
WalletAddress,
WalletBalanceResponse,
WalletFundResponse,
} from '@siafoundation/walletd-react'
WalletFundSiacoinResponse,
} from '@siafoundation/walletd-types'
import { toHastings } from '@siafoundation/units'
import { getMockConsensusNetworkResponse } from '../mocks/consensusNetwork'
import { getMockConsensusTipStateResponse } from '../mocks/consensusTipState'
Expand Down Expand Up @@ -83,7 +83,7 @@ export function getMockScenarioSeedWallet() {

const walletOutputsSiafundResponse: SiafundElement[] = []

const walletFundResponse: WalletFundResponse = {
const walletFundResponse: WalletFundSiacoinResponse = {
transaction: {
siacoinInputs: [
{
Expand Down
6 changes: 3 additions & 3 deletions libs/walletd-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"description": "React hooks for interacting with `walletd`.",
"version": "4.0.0",
"license": "MIT",
"peerDependencies": {
"dependencies": {
"@siafoundation/react-core": "^1.1.0",
"@siafoundation/types": "^0.2.0",
"swr": "^2.1.1"
"swr": "^2.1.1",
"@siafoundation/walletd-types": "0.0.0"
},
"types": "./src/index.d.ts"
}
Loading
Loading