Skip to content

refactor: split out walletd-types #578

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

Merged
merged 1 commit into from
Apr 15, 2024
Merged
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
@@ -4,9 +4,9 @@ import {
Wallet,
WalletAddressesResponse,
WalletBalanceResponse,
WalletFundResponse,
WalletFundSiacoinResponse,
WalletOutputsSiacoinResponse,
} from '@siafoundation/walletd-react'
} from '@siafoundation/walletd-types'

export async function createWallet({
page,
@@ -21,7 +21,7 @@ export async function createWallet({
responses?: {
balance?: WalletBalanceResponse
outputsSiacoin?: WalletOutputsSiacoinResponse
fund?: WalletFundResponse
fundSiacoin?: WalletFundSiacoinResponse
addresses?: WalletAddressesResponse
}
expects?: {
2 changes: 1 addition & 1 deletion apps/walletd-e2e/src/specs/seedSendSiacoin.spec.ts
Original file line number Diff line number Diff line change
@@ -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) =>
4 changes: 2 additions & 2 deletions apps/walletd/contexts/addresses/dataset.tsx
Original file line number Diff line number Diff line change
@@ -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'
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
6 changes: 2 additions & 4 deletions apps/walletd/contexts/wallets/index.tsx
Original file line number Diff line number Diff line change
@@ -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,
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
5 changes: 2 additions & 3 deletions apps/walletd/dialogs/WalletAddLedgerDialog/index.tsx
Original file line number Diff line number Diff line change
@@ -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'
3 changes: 2 additions & 1 deletion apps/walletd/dialogs/WalletAddNewDialog/index.tsx
Original file line number Diff line number Diff line change
@@ -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'
3 changes: 2 additions & 1 deletion apps/walletd/dialogs/WalletAddRecoverDialog/index.tsx
Original file line number Diff line number Diff line change
@@ -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'
3 changes: 2 additions & 1 deletion apps/walletd/dialogs/WalletAddWatchDialog/index.tsx
Original file line number Diff line number Diff line change
@@ -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'
6 changes: 2 additions & 4 deletions apps/walletd/dialogs/WalletAddressesAddDialog.tsx
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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'
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 {
4 changes: 2 additions & 2 deletions libs/walletd-mock/package.json
Original file line number Diff line number Diff line change
@@ -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 {
2 changes: 1 addition & 1 deletion libs/walletd-mock/src/mocks/defaults.ts
Original file line number Diff line number Diff line change
@@ -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
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 {
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 {
8 changes: 4 additions & 4 deletions libs/walletd-mock/src/mocks/wallet.ts
Original file line number Diff line number Diff line change
@@ -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'
@@ -27,7 +27,7 @@ export async function mockApiWallet({
responses?: {
balance?: WalletBalanceResponse
outputsSiacoin?: WalletOutputsSiacoinResponse
fund?: WalletFundResponse
fundSiacoin?: WalletFundSiacoinResponse
addresses?: WalletAddressesResponse
}
expects?: {
@@ -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({
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 {
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'

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 {
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: [
@@ -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()
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'],
@@ -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()
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'

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 {
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({
@@ -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()
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 {
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 {
6 changes: 3 additions & 3 deletions libs/walletd-mock/src/scenarios/seedWallet.ts
Original file line number Diff line number Diff line change
@@ -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'
@@ -83,7 +83,7 @@ export function getMockScenarioSeedWallet() {

const walletOutputsSiafundResponse: SiafundElement[] = []

const walletFundResponse: WalletFundResponse = {
const walletFundResponse: WalletFundSiacoinResponse = {
transaction: {
siacoinInputs: [
{
6 changes: 3 additions & 3 deletions libs/walletd-react/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
282 changes: 136 additions & 146 deletions libs/walletd-react/src/api.ts

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion libs/walletd-react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './api'
export * from './siaTypes'
12 changes: 12 additions & 0 deletions libs/walletd-types/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"presets": [
[
"@nx/react/babel",
{
"runtime": "automatic",
"useBuiltIns": "usage"
}
]
],
"plugins": []
}
21 changes: 21 additions & 0 deletions libs/walletd-types/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"extends": ["plugin:@nx/react", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"rules": {
"@nx/dependency-checks": [
"error",
{
"ignoredFiles": ["libs/walletd-types/rollup.config.js"]
}
]
},
"overrides": [
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": "error"
}
}
]
}
3 changes: 3 additions & 0 deletions libs/walletd-types/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# walletd-types

Types for `walletd`.
17 changes: 17 additions & 0 deletions libs/walletd-types/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* eslint-disable */
export default {
displayName: 'walletd-types',
preset: '../../jest.preset.js',
transform: {
'^(?!.*\\.(js|jsx|ts|tsx|css|json)$)': '@nx/react/plugins/jest',
'^.+\\.[tj]sx?$': [
'babel-jest',
{
presets: ['@nx/next/babel'],
plugins: ['@babel/plugin-transform-private-methods'],
},
],
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
coverageDirectory: '../../coverage/libs/walletd-types',
}
10 changes: 10 additions & 0 deletions libs/walletd-types/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "@siafoundation/walletd-types",
"description": "Types for `walletd`.",
"version": "0.0.0",
"license": "MIT",
"dependencies": {
"@siafoundation/types": "^0.2.0"
},
"types": "./src/index.d.ts"
}
42 changes: 42 additions & 0 deletions libs/walletd-types/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "walletd-types",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/walletd-types/src",
"projectType": "library",
"tags": [],
"targets": {
"build": {
"executor": "@nx/rollup:rollup",
"outputs": ["{options.outputPath}"],
"options": {
"outputPath": "dist/libs/walletd-types",
"tsConfig": "libs/walletd-types/tsconfig.lib.json",
"project": "libs/walletd-types/package.json",
"entryFile": "libs/walletd-types/src/index.ts",
"external": ["react/jsx-runtime"],
"compiler": "tsc",
"outputFileName": "index.js",
"rollupConfig": "libs/walletd-types/rollup.config.js",
"assets": [
{
"glob": "libs/walletd-types/*.md",
"input": ".",
"output": "."
}
]
},
"configurations": {}
},
"lint": {
"executor": "@nx/eslint:lint",
"outputs": ["{options.outputFile}"]
},
"test": {
"executor": "@nx/jest:jest",
"outputs": ["{workspaceRoot}/coverage/libs/walletd-types"],
"options": {
"jestConfig": "libs/walletd-types/jest.config.ts"
}
}
}
}
18 changes: 18 additions & 0 deletions libs/walletd-types/rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// eslint-disable-next-line @typescript-eslint/no-var-requires
const preserveDirectives = require('rollup-plugin-preserve-directives')

// https://github.com/rollup/rollup/issues/4699#issuecomment-1465302665
function getRollupOptions(options) {
return {
...options,
output: {
...options.output,
preserveModules: true,
format: 'esm',
sourcemap: true,
},
plugins: options.plugins.concat(preserveDirectives.default()),
}
}

module.exports = getRollupOptions
189 changes: 189 additions & 0 deletions libs/walletd-types/src/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
import {
ConsensusState,
ConsensusNetwork,
Currency,
BlockHeight,
ChainIndex,
SiacoinOutputID,
SiafundOutputID,
SiacoinElement,
SiafundElement,
Transaction,
V2Transaction,
} from '@siafoundation/types'
import {
PoolTransaction,
WalletEvent,
GatewayPeer,
Wallet,
WalletAddress,
WalletMetadata,
} from './types'

// state

export type StateParams = void
export type StateResponse = {
version: string
commit: string
os: string
buildTime: string
startTime: string
}

// consensus

export type ConsensusTipParams = void
export type ConsensusTipResponse = ChainIndex

export type ConsensusTipStateParams = void
export type ConsensusTipStateResponse = ConsensusState

export type ConsensusNetworkParams = void
export type ConsensusNetworkResponse = ConsensusNetwork

// syncer

export type SyncerPeersParams = void
export type SyncerPeersResponse = GatewayPeer[]

export type SyncerConnectParams = void
export type SyncerConnectPayload = string
export type SyncerConnectResponse = never

// txpool

export type TxPoolTransactionsParams = void
export type TxPoolTransactionsResponse = {
transactions: Transaction[]
v2transactions: V2Transaction[]
}

export type TxPoolFeeParams = void
export type TxPoolFeeResponse = Currency

export type TxPoolBroadcastParams = void
export type TxPoolBroadcastPayload = {
transactions: Transaction[]
v2transactions: V2Transaction[]
}
export type TxPoolBroadcastResponse = unknown

// rescan

export type RescanStartParams = void
export type RescanStartPayload = BlockHeight
export type RescanStartResponse = void

export type RescanParams = void
export type RescanResponse = {
startIndex: ChainIndex
index: ChainIndex
startTime: string
error?: string
}

// wallet

export type WalletsParams = void
export type WalletsResponse = Wallet[]

export type WalletAddParams = void
export type WalletAddPayload = {
name: string
description: string
metadata: WalletMetadata
}
export type WalletAddResponse = Wallet

export type WalletUpdateParams = { id: string }
export type WalletUpdatePayload = {
name: string
description: string
metadata: WalletMetadata
}
export type WalletUpdateResponse = Wallet

export type WalletDeleteParams = { id: string }
export type WalletDeletePayload = void
export type WalletDeleteResponse = never

// addresses

export type WalletAddressesParams = { id: string }
export type WalletAddressesResponse = WalletAddress[]

export type WalletAddressAddParams = { id: string }
export type WalletAddressAddPayload = WalletAddress
export type WalletAddressAddResponse = void

export type WalletAddressDeleteParams = { id: string; addr: string }
export type WalletAddressDeletePayload = void
export type WalletAddressDeleteResponse = never

export type WalletBalanceParams = { id: string }
export type WalletBalanceResponse = {
siacoins: Currency
immatureSiacoins: Currency
siafunds: number
}

export type WalletEventsParams = { id: string; offset: number; limit: number }
export type WalletEventsResponse = WalletEvent[]

export type WalletTxPoolParams = { id: string }
export type WalletTxPoolResponse = PoolTransaction[]

export type WalletOutputsSiacoinParams = { id: string }
export type WalletOutputsSiacoinResponse = SiacoinElement[]

export type WalletOutputsSiafundParams = { id: string }
export type WalletOutputsSiafundResponse = SiafundElement[]

export type WalletFundSiacoinParams = {
id: string
}
export type WalletFundSiacoinPayload = {
transaction: Transaction
amount: Currency
changeAddress: string
}
export type WalletFundSiacoinResponse = {
transaction: Transaction
toSign: string[]
dependsOn: Transaction[] | null
}

export type WalletFundSiafundParams = {
id: string
}
export type WalletFundSiafundPayload = {
transaction: Transaction
amount: number
changeAddress: string
claimAddress: string
}
export type WalletFundSiafundResponse = {
transaction: Transaction
toSign: string[]
dependsOn: Transaction[] | null
}

export type WalletReserveParams = {
id: string
}
export type WalletReservePayload = {
siacoinOutputs?: SiacoinOutputID[]
siafundOutputs?: SiafundOutputID[]
duration: number
}
export type WalletReserveResponse = void

export type WalletReleaseParams = {
id: string
}
export type WalletReleasePayload = {
siacoinOutputs?: SiacoinOutputID[]
siafundOutputs?: SiafundOutputID[]
}
export type WalletReleaseResponse = void
2 changes: 2 additions & 0 deletions libs/walletd-types/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './api'
export * from './types'
File renamed without changes.
25 changes: 25 additions & 0 deletions libs/walletd-types/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"jsx": "react-jsx",
"allowJs": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.lib.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}
22 changes: 22 additions & 0 deletions libs/walletd-types/tsconfig.lib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"types": [
"node",
"@nx/react/typings/cssmodule.d.ts",
"@nx/react/typings/image.d.ts"
]
},
"exclude": [
"**/*.spec.ts",
"**/*.test.ts",
"**/*.spec.tsx",
"**/*.test.tsx",
"**/*.spec.js",
"**/*.test.js",
"**/*.spec.jsx",
"**/*.test.jsx"
],
"include": ["src/**/*.js", "src/**/*.jsx", "src/**/*.ts", "src/**/*.tsx"]
}
19 changes: 19 additions & 0 deletions libs/walletd-types/tsconfig.spec.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "../../dist/out-tsc",
"module": "commonjs",
"types": ["jest", "node"]
},
"include": [
"src/**/*.test.ts",
"src/**/*.spec.ts",
"src/**/*.test.tsx",
"src/**/*.spec.tsx",
"src/**/*.test.js",
"src/**/*.spec.js",
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts"
]
}
1 change: 1 addition & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -28,6 +28,7 @@
"@siafoundation/sia-central-react": [
"libs/sia-central-react/src/index.ts"
],
"@siafoundation/walletd-types": ["libs/walletd-types/src/index.ts"],
"@siafoundation/walletd-react": ["libs/walletd-react/src/index.ts"],
// "buildLibsFromSource": false does not work with the next executor
// this is a very annoying workaround