|
| 1 | +import * as t from 'io-ts'; |
| 2 | + |
| 3 | +/** |
| 4 | + * Wallet user with permissions |
| 5 | + */ |
| 6 | +export const WalletUser = t.type({ |
| 7 | + user: t.string, |
| 8 | + permissions: t.array(t.string), |
| 9 | +}); |
| 10 | + |
| 11 | +/** |
| 12 | + * Address balance information |
| 13 | + */ |
| 14 | +export const AddressBalance = t.type({ |
| 15 | + updated: t.string, |
| 16 | + balance: t.number, |
| 17 | + balanceString: t.string, |
| 18 | + totalReceived: t.number, |
| 19 | + totalSent: t.number, |
| 20 | + confirmedBalanceString: t.string, |
| 21 | + spendableBalanceString: t.string, |
| 22 | +}); |
| 23 | + |
| 24 | +/** |
| 25 | + * Address information |
| 26 | + */ |
| 27 | +export const ReceiveAddress = t.partial({ |
| 28 | + /** Address ID */ |
| 29 | + id: t.string, |
| 30 | + /** The actual address string */ |
| 31 | + address: t.string, |
| 32 | + /** Chain index (0 for external, 1 for internal) */ |
| 33 | + chain: t.number, |
| 34 | + /** Address index */ |
| 35 | + index: t.number, |
| 36 | + /** Coin type */ |
| 37 | + coin: t.string, |
| 38 | + /** Wallet ID this address belongs to */ |
| 39 | + wallet: t.string, |
| 40 | + /** Last nonce used */ |
| 41 | + lastNonce: t.number, |
| 42 | + /** Coin-specific address data */ |
| 43 | + coinSpecific: t.UnknownRecord, |
| 44 | + /** Address balance information */ |
| 45 | + balance: AddressBalance, |
| 46 | + /** Address label */ |
| 47 | + label: t.string, |
| 48 | + /** Address type (e.g., 'p2sh', 'p2wsh') */ |
| 49 | + addressType: t.string, |
| 50 | +}); |
| 51 | + |
| 52 | +/** |
| 53 | + * Policy rule for wallet |
| 54 | + */ |
| 55 | +export const PolicyRule = t.partial({ |
| 56 | + /** Rule ID */ |
| 57 | + id: t.string, |
| 58 | + /** Rule type */ |
| 59 | + type: t.string, |
| 60 | + /** Date when rule becomes locked */ |
| 61 | + lockDate: t.string, |
| 62 | + /** Mutability constraint */ |
| 63 | + mutabilityConstraint: t.string, |
| 64 | + /** Coin this rule applies to */ |
| 65 | + coin: t.string, |
| 66 | + /** Rule condition */ |
| 67 | + condition: t.UnknownRecord, |
| 68 | + /** Rule action */ |
| 69 | + action: t.UnknownRecord, |
| 70 | +}); |
| 71 | + |
| 72 | +/** |
| 73 | + * Wallet policy |
| 74 | + */ |
| 75 | +export const WalletPolicy = t.partial({ |
| 76 | + /** Policy ID */ |
| 77 | + id: t.string, |
| 78 | + /** Policy creation date */ |
| 79 | + date: t.string, |
| 80 | + /** Policy version number */ |
| 81 | + version: t.number, |
| 82 | + /** Policy label */ |
| 83 | + label: t.string, |
| 84 | + /** Whether this is the latest version */ |
| 85 | + latest: t.boolean, |
| 86 | + /** Policy rules */ |
| 87 | + rules: t.array(PolicyRule), |
| 88 | +}); |
| 89 | + |
| 90 | +/** |
| 91 | + * Admin settings for wallet |
| 92 | + */ |
| 93 | +export const WalletAdmin = t.partial({ |
| 94 | + policy: WalletPolicy, |
| 95 | +}); |
| 96 | + |
| 97 | +/** |
| 98 | + * Freeze information |
| 99 | + */ |
| 100 | +export const WalletFreeze = t.partial({ |
| 101 | + time: t.string, |
| 102 | + expires: t.string, |
| 103 | +}); |
| 104 | + |
| 105 | +/** |
| 106 | + * Build defaults for wallet transactions |
| 107 | + */ |
| 108 | +export const BuildDefaults = t.partial({ |
| 109 | + minFeeRate: t.number, |
| 110 | + maxFeeRate: t.number, |
| 111 | + feeMultiplier: t.number, |
| 112 | + changeAddressType: t.string, |
| 113 | + txFormat: t.string, |
| 114 | +}); |
| 115 | + |
| 116 | +/** |
| 117 | + * Custom change key signatures |
| 118 | + */ |
| 119 | +export const CustomChangeKeySignatures = t.partial({ |
| 120 | + user: t.string, |
| 121 | + backup: t.string, |
| 122 | + bitgo: t.string, |
| 123 | +}); |
| 124 | + |
| 125 | +/** |
| 126 | + * Wallet response data |
| 127 | + * Comprehensive wallet information returned from wallet operations |
| 128 | + * Based on WalletData interface from sdk-core |
| 129 | + */ |
| 130 | +export const WalletResponse = t.partial({ |
| 131 | + /** Wallet ID */ |
| 132 | + id: t.string, |
| 133 | + /** Wallet label/name */ |
| 134 | + label: t.string, |
| 135 | + /** Coin type (e.g., btc, tlnbtc, lnbtc) */ |
| 136 | + coin: t.string, |
| 137 | + /** Array of keychain IDs */ |
| 138 | + keys: t.array(t.string), |
| 139 | + /** Number of signatures required (m in m-of-n) */ |
| 140 | + m: t.number, |
| 141 | + /** Total number of keys (n in m-of-n) */ |
| 142 | + n: t.number, |
| 143 | + /** Number of approvals required for transactions */ |
| 144 | + approvalsRequired: t.number, |
| 145 | + /** Wallet balance as number */ |
| 146 | + balance: t.number, |
| 147 | + /** Confirmed balance as number */ |
| 148 | + confirmedBalance: t.number, |
| 149 | + /** Spendable balance as number */ |
| 150 | + spendableBalance: t.number, |
| 151 | + /** Wallet balance as string */ |
| 152 | + balanceString: t.string, |
| 153 | + /** Confirmed balance as string */ |
| 154 | + confirmedBalanceString: t.string, |
| 155 | + /** Spendable balance as string */ |
| 156 | + spendableBalanceString: t.string, |
| 157 | + /** Number of unspent outputs */ |
| 158 | + unspentCount: t.number, |
| 159 | + /** Enterprise ID this wallet belongs to */ |
| 160 | + enterprise: t.string, |
| 161 | + /** Wallet type (e.g., 'hot', 'cold', 'custodial') */ |
| 162 | + type: t.string, |
| 163 | + /** Wallet subtype (e.g., 'lightningSelfCustody') */ |
| 164 | + subType: t.string, |
| 165 | + /** Multisig type ('onchain' or 'tss') */ |
| 166 | + multisigType: t.union([t.literal('onchain'), t.literal('tss')]), |
| 167 | + /** Multisig type version (e.g., 'MPCv2') */ |
| 168 | + multisigTypeVersion: t.string, |
| 169 | + /** Coin-specific wallet data */ |
| 170 | + coinSpecific: t.UnknownRecord, |
| 171 | + /** Admin settings including policy */ |
| 172 | + admin: WalletAdmin, |
| 173 | + /** Users with access to this wallet */ |
| 174 | + users: t.array(WalletUser), |
| 175 | + /** Receive address information */ |
| 176 | + receiveAddress: ReceiveAddress, |
| 177 | + /** Whether the wallet can be recovered */ |
| 178 | + recoverable: t.boolean, |
| 179 | + /** Tags associated with the wallet */ |
| 180 | + tags: t.array(t.string), |
| 181 | + /** Whether backup key signing is allowed */ |
| 182 | + allowBackupKeySigning: t.boolean, |
| 183 | + /** Build defaults for transactions */ |
| 184 | + buildDefaults: BuildDefaults, |
| 185 | + /** Whether the wallet is cold storage */ |
| 186 | + isCold: t.boolean, |
| 187 | + /** Custodial wallet information */ |
| 188 | + custodialWallet: t.UnknownRecord, |
| 189 | + /** Custodial wallet ID */ |
| 190 | + custodialWalletId: t.string, |
| 191 | + /** Whether the wallet is deleted */ |
| 192 | + deleted: t.boolean, |
| 193 | + /** Whether transaction notifications are disabled */ |
| 194 | + disableTransactionNotifications: t.boolean, |
| 195 | + /** Freeze status */ |
| 196 | + freeze: WalletFreeze, |
| 197 | + /** Node ID for lightning wallets */ |
| 198 | + nodeId: t.string, |
| 199 | + /** Pending approvals for this wallet */ |
| 200 | + pendingApprovals: t.array(t.UnknownRecord), |
| 201 | + /** Start date information */ |
| 202 | + startDate: t.UnknownRecord, |
| 203 | + /** Custom change key signatures */ |
| 204 | + customChangeKeySignatures: CustomChangeKeySignatures, |
| 205 | + /** Wallet which this was migrated from */ |
| 206 | + migratedFrom: t.string, |
| 207 | + /** EVM keyring reference wallet ID */ |
| 208 | + evmKeyRingReferenceWalletId: t.string, |
| 209 | + /** Whether this is a parent wallet */ |
| 210 | + isParent: t.boolean, |
| 211 | + /** Enabled child chains */ |
| 212 | + enabledChildChains: t.array(t.string), |
| 213 | + /** Wallet flags */ |
| 214 | + walletFlags: t.array( |
| 215 | + t.type({ |
| 216 | + name: t.string, |
| 217 | + value: t.string, |
| 218 | + }) |
| 219 | + ), |
| 220 | + /** Token balances */ |
| 221 | + tokens: t.array(t.UnknownRecord), |
| 222 | + /** NFT balances */ |
| 223 | + nfts: t.record(t.string, t.UnknownRecord), |
| 224 | + /** Unsupported NFT balances */ |
| 225 | + unsupportedNfts: t.record(t.string, t.UnknownRecord), |
| 226 | +}); |
0 commit comments