Skip to content

Commit a38cf77

Browse files
committed
refactor: split out walletd-types
1 parent d05be17 commit a38cf77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+573
-209
lines changed

apps/walletd-e2e/src/fixtures/createWallet.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import {
44
Wallet,
55
WalletAddressesResponse,
66
WalletBalanceResponse,
7-
WalletFundResponse,
7+
WalletFundSiacoinResponse,
88
WalletOutputsSiacoinResponse,
9-
} from '@siafoundation/walletd-react'
9+
} from '@siafoundation/walletd-types'
1010

1111
export async function createWallet({
1212
page,
@@ -21,7 +21,7 @@ export async function createWallet({
2121
responses?: {
2222
balance?: WalletBalanceResponse
2323
outputsSiacoin?: WalletOutputsSiacoinResponse
24-
fund?: WalletFundResponse
24+
fundSiacoin?: WalletFundSiacoinResponse
2525
addresses?: WalletAddressesResponse
2626
}
2727
expects?: {

apps/walletd-e2e/src/specs/seedSendSiacoin.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ test('errors if the input to sign is not found on the transaction', async ({
8787
mnemonic,
8888
responses: {
8989
...getDefaultMockWalletResponses(mocks),
90-
fund: mockFundInvalid,
90+
fundSiacoin: mockFundInvalid,
9191
},
9292
expects: {
9393
fundSiacoinPost: (data) =>

apps/walletd/contexts/addresses/dataset.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
import {
66
WalletAddressMetadata,
77
WalletAddressesResponse,
8-
useWalletAddresses,
9-
} from '@siafoundation/walletd-react'
8+
} from '@siafoundation/walletd-types'
9+
import { useWalletAddresses } from '@siafoundation/walletd-react'
1010
import { useMemo } from 'react'
1111
import { AddressData } from './types'
1212
import { OpenDialog, useDialog } from '../dialog'

apps/walletd/contexts/addresses/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
WalletAddress,
33
WalletAddressMetadata,
4-
} from '@siafoundation/walletd-react'
4+
} from '@siafoundation/walletd-types'
55

66
export type CellContext = {
77
siascanUrl: string

apps/walletd/contexts/wallets/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ import {
44
useClientFilters,
55
useClientFilteredDataset,
66
} from '@siafoundation/design-system'
7-
import {
8-
WalletMetadata,
9-
useWallets as useWalletsData,
10-
} from '@siafoundation/walletd-react'
7+
import { WalletMetadata } from '@siafoundation/walletd-types'
8+
import { useWallets as useWalletsData } from '@siafoundation/walletd-react'
119
import { createContext, useContext, useEffect, useMemo } from 'react'
1210
import {
1311
WalletData,

apps/walletd/contexts/wallets/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Wallet, WalletMetadata } from '@siafoundation/walletd-react'
1+
import { Wallet, WalletMetadata } from '@siafoundation/walletd-types'
22

33
export type WalletData = {
44
id: string

apps/walletd/dialogs/WalletAddLedgerDialog/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ import { useForm } from 'react-hook-form'
1515
import {
1616
WalletAddressMetadata,
1717
WalletMetadata,
18-
useWalletAdd,
19-
useWalletAddressAdd,
20-
} from '@siafoundation/walletd-react'
18+
} from '@siafoundation/walletd-types'
19+
import { useWalletAdd, useWalletAddressAdd } from '@siafoundation/walletd-react'
2120
import { useDialog } from '../../contexts/dialog'
2221
import { useWallets } from '../../contexts/wallets'
2322
import { walletAddTypes } from '../../config/walletTypes'

apps/walletd/dialogs/WalletAddNewDialog/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import {
1313
import { Redo16, Copy16 } from '@siafoundation/react-icons'
1414
import { MouseEvent, useCallback, useEffect } from 'react'
1515
import { useForm } from 'react-hook-form'
16-
import { WalletMetadata, useWalletAdd } from '@siafoundation/walletd-react'
16+
import { WalletMetadata } from '@siafoundation/walletd-types'
17+
import { useWalletAdd } from '@siafoundation/walletd-react'
1718
import { useDialog } from '../../contexts/dialog'
1819
import { useWallets } from '../../contexts/wallets'
1920
import { walletAddTypes } from '../../config/walletTypes'

apps/walletd/dialogs/WalletAddRecoverDialog/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ import { useCallback } from 'react'
1212
import { useForm } from 'react-hook-form'
1313
import { useDialog } from '../../contexts/dialog'
1414
import { useWallets } from '../../contexts/wallets'
15-
import { WalletMetadata, useWalletAdd } from '@siafoundation/walletd-react'
15+
import { WalletMetadata } from '@siafoundation/walletd-types'
16+
import { useWalletAdd } from '@siafoundation/walletd-react'
1617
import { blake2bHex } from 'blakejs'
1718
import { SeedLayout } from '../SeedLayout'
1819
import { SeedIcon } from '@siafoundation/react-icons'

apps/walletd/dialogs/WalletAddWatchDialog/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import {
1111
} from '@siafoundation/design-system'
1212
import { useCallback } from 'react'
1313
import { useForm } from 'react-hook-form'
14-
import { WalletMetadata, useWalletAdd } from '@siafoundation/walletd-react'
14+
import { WalletMetadata } from '@siafoundation/walletd-types'
15+
import { useWalletAdd } from '@siafoundation/walletd-react'
1516
import { useDialog } from '../../contexts/dialog'
1617
import { useWallets } from '../../contexts/wallets'
1718
import { walletAddTypes } from '../../config/walletTypes'

apps/walletd/dialogs/WalletAddressesAddDialog.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ import {
99
triggerSuccessToast,
1010
useDialogFormHelpers,
1111
} from '@siafoundation/design-system'
12-
import {
13-
WalletAddressMetadata,
14-
useWalletAddressAdd,
15-
} from '@siafoundation/walletd-react'
12+
import { WalletAddressMetadata } from '@siafoundation/walletd-types'
13+
import { useWalletAddressAdd } from '@siafoundation/walletd-react'
1614
import { useCallback } from 'react'
1715
import { useForm } from 'react-hook-form'
1816
import { useWallets } from '../contexts/wallets'

apps/walletd/dialogs/WalletAddressesGenerateLedgerDialog/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ import {
1111
triggerSuccessToast,
1212
useDialogFormHelpers,
1313
} from '@siafoundation/design-system'
14-
import {
15-
WalletAddressMetadata,
16-
useWalletAddressAdd,
17-
} from '@siafoundation/walletd-react'
14+
import { WalletAddressMetadata } from '@siafoundation/walletd-types'
15+
import { useWalletAddressAdd } from '@siafoundation/walletd-react'
1816
import { useCallback, useEffect, useMemo, useState } from 'react'
1917
import { useForm } from 'react-hook-form'
2018
import { useWallets } from '../../contexts/wallets'

apps/walletd/dialogs/WalletAddressesGenerateSeedDialog/index.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ import {
77
triggerSuccessToast,
88
useDialogFormHelpers,
99
} from '@siafoundation/design-system'
10-
import {
11-
WalletAddressMetadata,
12-
useWalletAddressAdd,
13-
} from '@siafoundation/walletd-react'
10+
import { WalletAddressMetadata } from '@siafoundation/walletd-types'
11+
import { useWalletAddressAdd } from '@siafoundation/walletd-react'
1412
import { useCallback, useEffect, useState } from 'react'
1513
import { useForm } from 'react-hook-form'
1614
import { useWallets } from '../../contexts/wallets'

apps/walletd/lib/testMocks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Sia from '@siacentral/ledgerjs-sia'
22
import { LedgerDevice } from '../contexts/ledger/types'
33
import { transformAddressesResponse } from '../contexts/addresses/dataset'
4-
import { Wallet, WalletAddressesResponse } from '@siafoundation/walletd-react'
4+
import { Wallet, WalletAddressesResponse } from '@siafoundation/walletd-types'
55

66
export function getMockDevice() {
77
return {

libs/walletd-mock/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"license": "MIT",
66
"dependencies": {
77
"@siafoundation/types": "0.2.0",
8-
"@siafoundation/walletd-react": "4.0.0",
98
"@siafoundation/sia-central-mock": "0.0.0",
109
"@siafoundation/units": "3.0.0",
11-
"playwright": "^1.42.1"
10+
"playwright": "^1.42.1",
11+
"@siafoundation/walletd-types": "0.0.0"
1212
},
1313
"types": "./src/index.d.ts"
1414
}

libs/walletd-mock/src/mocks/consensusTip.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ConsensusTipResponse } from '@siafoundation/walletd-react'
1+
import { ConsensusTipResponse } from '@siafoundation/walletd-types'
22
import { Page } from 'playwright'
33

44
export function getMockConsensusTipResponse(): ConsensusTipResponse {

libs/walletd-mock/src/mocks/defaults.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { mockApiWallets } from './wallets'
88
import { mockApiTxPoolBroadcast } from './txPoolBroadcast'
99
import { mockApiWallet } from './wallet'
1010
import { mockApiRescan } from './rescan'
11-
import { RescanResponse } from '@siafoundation/walletd-react'
11+
import { RescanResponse } from '@siafoundation/walletd-types'
1212

1313
type Responses = {
1414
rescan?: RescanResponse

libs/walletd-mock/src/mocks/peers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { SyncerPeersResponse } from '@siafoundation/walletd-react'
1+
import { SyncerPeersResponse } from '@siafoundation/walletd-types'
22
import { Page } from 'playwright'
33

44
export function getMockPeersResponse(): SyncerPeersResponse {

libs/walletd-mock/src/mocks/rescan.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { RescanResponse } from '@siafoundation/walletd-react'
1+
import { RescanResponse } from '@siafoundation/walletd-types'
22
import { Page } from 'playwright'
33

44
export function getMockRescanResponse(): RescanResponse {

libs/walletd-mock/src/mocks/wallet.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import {
33
Wallet,
44
WalletAddressesResponse,
55
WalletBalanceResponse,
6-
WalletFundResponse,
6+
WalletFundSiacoinResponse,
77
WalletOutputsSiacoinResponse,
8-
} from '@siafoundation/walletd-react'
8+
} from '@siafoundation/walletd-types'
99
import { mockApiWalletBalance } from './walletBalance'
1010
import { mockApiWalletAddresses } from './walletAddresses'
1111
import { mockApiWalletEvents } from './walletEvents'
@@ -27,7 +27,7 @@ export async function mockApiWallet({
2727
responses?: {
2828
balance?: WalletBalanceResponse
2929
outputsSiacoin?: WalletOutputsSiacoinResponse
30-
fund?: WalletFundResponse
30+
fundSiacoin?: WalletFundSiacoinResponse
3131
addresses?: WalletAddressesResponse
3232
}
3333
expects?: {
@@ -59,7 +59,7 @@ export async function mockApiWallet({
5959
await mockApiWalletFundSiacoin({
6060
page,
6161
walletId: wallet.id,
62-
response: responses.fund,
62+
response: responses.fundSiacoin,
6363
expectPost: expects.fundSiacoinPost,
6464
})
6565
await mockApiWalletRelease({

libs/walletd-mock/src/mocks/walletAddresses.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
22
WalletAddress,
33
WalletAddressesResponse,
4-
} from '@siafoundation/walletd-react'
4+
} from '@siafoundation/walletd-types'
55
import { Page } from 'playwright'
66

77
export function getMockWalletAddressesResponse(): WalletAddressesResponse {

libs/walletd-mock/src/mocks/walletBalance.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { WalletBalanceResponse } from '@siafoundation/walletd-react'
1+
import { WalletBalanceResponse } from '@siafoundation/walletd-types'
22
import { toHastings } from '@siafoundation/units'
33
import { Page } from 'playwright'
44

libs/walletd-mock/src/mocks/walletEvents.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { WalletEventsResponse } from '@siafoundation/walletd-react'
1+
import { WalletEventsResponse } from '@siafoundation/walletd-types'
22
import { Page } from 'playwright'
33

44
export function getMockWalletEventsResponse(): WalletEventsResponse {

libs/walletd-mock/src/mocks/walletFundSiacoin.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { WalletFundResponse } from '@siafoundation/walletd-react'
1+
import { WalletFundSiacoinResponse } from '@siafoundation/walletd-types'
22
import { Page } from 'playwright'
33

4-
export function getMockWalletFundSiacoinResponse(): WalletFundResponse {
4+
export function getMockWalletFundSiacoinResponse(): WalletFundSiacoinResponse {
55
return {
66
transaction: {
77
siacoinInputs: [
@@ -54,7 +54,7 @@ export async function mockApiWalletFundSiacoin({
5454
}: {
5555
page: Page
5656
walletId: string
57-
response?: WalletFundResponse
57+
response?: WalletFundSiacoinResponse
5858
expectPost?: (data: string | null) => void
5959
}) {
6060
const json = response || getMockWalletFundSiacoinResponse()

libs/walletd-mock/src/mocks/walletFundSiafund.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { WalletFundResponse } from '@siafoundation/walletd-react'
1+
import { WalletFundSiafundResponse } from '@siafoundation/walletd-types'
22
import { Page } from 'playwright'
33

4-
export function getMockWalletFundSiafundResponse(): WalletFundResponse {
4+
export function getMockWalletFundSiafundResponse(): WalletFundSiafundResponse {
55
return {
66
transaction: {
77
minerFees: ['3930000000000000000000'],
@@ -19,7 +19,7 @@ export async function mockApiWalletFundSiafund({
1919
}: {
2020
page: Page
2121
walletId: string
22-
response?: WalletFundResponse
22+
response?: WalletFundSiafundResponse
2323
expectPost?: (data: string | null) => void
2424
}) {
2525
const json = response || getMockWalletFundSiafundResponse()

libs/walletd-mock/src/mocks/walletOutputsSiacoin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { WalletOutputsSiacoinResponse } from '@siafoundation/walletd-react'
1+
import { WalletOutputsSiacoinResponse } from '@siafoundation/walletd-types'
22
import { SiacoinElement } from '@siafoundation/types'
33
import { Page } from 'playwright'
44

libs/walletd-mock/src/mocks/walletOutputsSiafund.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { WalletOutputsSiafundResponse } from '@siafoundation/walletd-react'
1+
import { WalletOutputsSiafundResponse } from '@siafoundation/walletd-types'
22
import { Page } from 'playwright'
33

44
export function getMockWalletOutputsSiafundResponse(): WalletOutputsSiafundResponse {

libs/walletd-mock/src/mocks/walletRelease.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { WalletFundResponse } from '@siafoundation/walletd-react'
1+
import { WalletReleaseResponse } from '@siafoundation/walletd-types'
22
import { Page } from 'playwright'
33

44
export async function mockApiWalletRelease({
@@ -7,7 +7,7 @@ export async function mockApiWalletRelease({
77
}: {
88
page: Page
99
walletId: string
10-
response?: WalletFundResponse
10+
response?: WalletReleaseResponse
1111
}) {
1212
await page.route(`**/api/wallets/${walletId}/release*`, async (route) => {
1313
await route.fulfill()

libs/walletd-mock/src/mocks/walletTxPool.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { WalletTxPoolResponse } from '@siafoundation/walletd-react'
1+
import { WalletTxPoolResponse } from '@siafoundation/walletd-types'
22
import { Page } from 'playwright'
33

44
export function getMockWalletTxPoolResponse(): WalletTxPoolResponse {

libs/walletd-mock/src/mocks/wallets.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Wallet, WalletsResponse } from '@siafoundation/walletd-react'
1+
import { Wallet, WalletsResponse } from '@siafoundation/walletd-types'
22
import { Page } from 'playwright'
33

44
export function getMockWalletsResponse(): WalletsResponse {

libs/walletd-mock/src/scenarios/seedWallet.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import {
33
Wallet,
44
WalletAddress,
55
WalletBalanceResponse,
6-
WalletFundResponse,
7-
} from '@siafoundation/walletd-react'
6+
WalletFundSiacoinResponse,
7+
} from '@siafoundation/walletd-types'
88
import { toHastings } from '@siafoundation/units'
99
import { getMockConsensusNetworkResponse } from '../mocks/consensusNetwork'
1010
import { getMockConsensusTipStateResponse } from '../mocks/consensusTipState'
@@ -83,7 +83,7 @@ export function getMockScenarioSeedWallet() {
8383

8484
const walletOutputsSiafundResponse: SiafundElement[] = []
8585

86-
const walletFundResponse: WalletFundResponse = {
86+
const walletFundResponse: WalletFundSiacoinResponse = {
8787
transaction: {
8888
siacoinInputs: [
8989
{

libs/walletd-react/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"description": "React hooks for interacting with `walletd`.",
44
"version": "4.0.0",
55
"license": "MIT",
6-
"peerDependencies": {
6+
"dependencies": {
77
"@siafoundation/react-core": "^1.1.0",
8-
"@siafoundation/types": "^0.2.0",
9-
"swr": "^2.1.1"
8+
"swr": "^2.1.1",
9+
"@siafoundation/walletd-types": "0.0.0"
1010
},
1111
"types": "./src/index.d.ts"
1212
}

0 commit comments

Comments
 (0)