@ocap/types 1.28.9 → 1.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ // Protobuf generated types
1
2
  export * from './lib/enum_pb';
2
3
  export * from './lib/rpc_pb';
3
4
  export * from './lib/service_pb';
@@ -5,4 +6,25 @@ export * from './lib/state_pb';
5
6
  export * from './lib/trace-type_pb';
6
7
  export * from './lib/tx_pb';
7
8
  export * from './lib/type_pb';
8
- export * from './lib/vendor_pb';
9
+
10
+ // vendor_pb types - explicit exports to avoid conflicts with type_pb
11
+ // (TConsensusParams, TValidator, TEvidence are defined in both files)
12
+ export type {
13
+ TKVPair,
14
+ TBlockParams,
15
+ TEvidenceParams,
16
+ TValidatorParams,
17
+ TLastCommitInfo,
18
+ TVersion,
19
+ TBlockID,
20
+ TPartSetHeader,
21
+ TValidatorUpdate,
22
+ TVoteInfo,
23
+ TPubKey,
24
+ THeader,
25
+ TRequestBeginBlock,
26
+ TRequestEndBlock,
27
+ } from './lib/vendor_pb';
28
+
29
+ // Interface types (I* that extend proto types)
30
+ export * from './interfaces';
@@ -0,0 +1,38 @@
1
+ // core/types/interfaces/base.ts
2
+
3
+ import type BaseBN from 'bn.js';
4
+
5
+ // BN type definition - implementation is in @ocap/util
6
+ export interface BN extends BaseBN {}
7
+
8
+ export type { BaseBN };
9
+
10
+ export type Promisable<T> = T | Promise<T>;
11
+ export type BytesType = string | Buffer | Uint8Array;
12
+ export type Timestamp = string | number | Date;
13
+ export type Address = string;
14
+ export type Hash = string;
15
+
16
+ export interface IAny {
17
+ typeUrl: string;
18
+ value: Uint8Array;
19
+ }
20
+
21
+ export type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
22
+ export type RequiredBy<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
23
+ export type DeepPartial<T> = {
24
+ [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
25
+ };
26
+
27
+ /**
28
+ * Make specific keys required (keeps all other fields, makes K required and non-nullable)
29
+ * Useful for pipeline context types where certain fields become guaranteed after specific phases
30
+ */
31
+ export type RequiredFields<T, K extends keyof T> = T & Required<Pick<T, K>>;
32
+
33
+ /**
34
+ * Make all properties in T non-nullable (remove undefined from each property)
35
+ */
36
+ export type NonNullableFields<T> = {
37
+ [P in keyof T]: NonNullable<T[P]>;
38
+ };
@@ -0,0 +1,166 @@
1
+ // core/types/interfaces/config.ts
2
+ // Chain configuration types, aligned with Proto types from type_pb.d.ts
3
+
4
+ import type {
5
+ TAccountConfig,
6
+ TCurveConfig,
7
+ TDelegateConfig,
8
+ TForeignToken,
9
+ TForgeToken,
10
+ TTransactionConfig,
11
+ TTxFeeConfig,
12
+ TTxGasConfig,
13
+ TTxStakeConfig,
14
+ TVaultConfig,
15
+ } from '../lib/type_pb';
16
+ import type { DeepPartial } from './base';
17
+
18
+ // ============ Direct Re-exports (Proto compatible) ============
19
+
20
+ export type { TDelegateConfig, TForeignToken, TTxFeeConfig, TCurveConfig };
21
+
22
+ // ============ Config-specific Types ============
23
+
24
+ /** Transaction type URL pattern like 'fg:t:transfer' */
25
+ export type TxTypeUrl = `fg:t:${string}`;
26
+
27
+ /** Map of transaction type URL to number value (size, fee, etc.) */
28
+ export type TxTypeMap = { default: number } & Partial<Record<TxTypeUrl, number>>;
29
+
30
+ // ============ Extended Types (with differences noted) ============
31
+
32
+ /**
33
+ * Account configuration
34
+ * Diff from TAccountConfig: pk is string (not Uint8Array), added moniker
35
+ */
36
+ export interface IAccountConfig extends Omit<TAccountConfig, 'pk' | 'balance'> {
37
+ pk: string;
38
+ balance?: number;
39
+ moniker?: string;
40
+ }
41
+
42
+ /**
43
+ * Transaction gas configuration
44
+ * Diff from TTxGasConfig: minStake/maxStake are number (Proto uses string)
45
+ */
46
+ export interface ITxGasConfig extends Omit<TTxGasConfig, 'minStake' | 'maxStake'> {
47
+ minStake: number;
48
+ maxStake: number;
49
+ }
50
+
51
+ /**
52
+ * Transaction stake configuration
53
+ * Diff from TTxStakeConfig: added createCreditToken field
54
+ */
55
+ export interface ITxStakeConfig extends TTxStakeConfig {
56
+ createCreditToken: number;
57
+ }
58
+
59
+ /**
60
+ * Transaction configuration
61
+ * Diff from TTransactionConfig:
62
+ * - txFee: TxTypeMap (Proto uses TTxFeeConfig[])
63
+ * - txGas: ITxGasConfig (Proto uses TTxGasConfig)
64
+ * - txStake: ITxStakeConfig (Proto uses TTxStakeConfig)
65
+ * - added: maxTxSize, supportedTxs, multiSignV2Txs
66
+ */
67
+ export interface ITransactionConfig extends Omit<TTransactionConfig, 'txFee' | 'txGas' | 'txStake' | 'delegate'> {
68
+ maxTxSize: TxTypeMap;
69
+ txFee: TxTypeMap;
70
+ txGas: ITxGasConfig;
71
+ txStake: ITxStakeConfig;
72
+ delegate: TDelegateConfig;
73
+ supportedTxs: string[];
74
+ multiSignV2Txs: string[];
75
+ }
76
+
77
+ /**
78
+ * Token configuration
79
+ * Diff from TForgeToken:
80
+ * - icon: string (Proto uses Uint8Array | string)
81
+ * - initialSupply/totalSupply: number (Proto uses string)
82
+ * - added: website, metadata, foreignToken
83
+ */
84
+ export interface ITokenConfig extends Omit<TForgeToken, 'icon' | 'initialSupply' | 'totalSupply'> {
85
+ icon: string;
86
+ initialSupply: number;
87
+ totalSupply: number;
88
+ website?: string | null;
89
+ /** Token metadata - format varies by token type (JSON structure kept flexible) */
90
+ metadata?: unknown;
91
+ foreignToken?: TForeignToken | null;
92
+ }
93
+
94
+ /**
95
+ * Vault addresses configuration
96
+ * Diff from TVaultConfig: all fields optional, added txFees array
97
+ */
98
+ export interface IVaultsConfig extends Partial<TVaultConfig> {
99
+ txFees?: string[];
100
+ }
101
+
102
+ /**
103
+ * Consensus configuration (no Proto equivalent)
104
+ * Index signature allows for chain-specific extensions
105
+ */
106
+ export interface IConsensusConfig {
107
+ maxValidators?: number;
108
+ minValidatorStake?: string;
109
+ blockTime?: number;
110
+ maxBlockSize?: number;
111
+ /** Extension point for chain-specific consensus config */
112
+ [key: string]: unknown;
113
+ }
114
+
115
+ // ============ Composite Config Types ============
116
+
117
+ /** Default configuration (without required fields like address) */
118
+ export interface IDefaultConfig {
119
+ transaction: ITransactionConfig;
120
+ vaults: IVaultsConfig;
121
+ accounts: IAccountConfig[];
122
+ reservedSymbols: string[];
123
+ token: Omit<ITokenConfig, 'description' | 'address'> & { description?: string; address?: string };
124
+ }
125
+
126
+ /** Full chain configuration */
127
+ export interface IChainConfig {
128
+ chainId: string;
129
+ chainName?: string;
130
+ version: string;
131
+ transaction: ITransactionConfig;
132
+ moderator: IAccountConfig;
133
+ accounts: IAccountConfig[];
134
+ vaults: IVaultsConfig;
135
+ token: ITokenConfig;
136
+ consensus?: IConsensusConfig;
137
+ reservedSymbols?: string[];
138
+ }
139
+
140
+ /** Partial chain configuration for create() input - uses DeepPartial since create() merges with defaults */
141
+ export type IChainConfigInput = DeepPartial<IChainConfig> & {
142
+ chainId: string;
143
+ version: string;
144
+ moderator: IAccountConfig;
145
+ };
146
+
147
+ /**
148
+ * Token ITX (inner transaction) for token creation
149
+ * Similar to TTokenInfo but with string amounts
150
+ */
151
+ export interface ITokenItx {
152
+ name: string;
153
+ description: string;
154
+ symbol: string;
155
+ unit: string;
156
+ decimal: number;
157
+ totalSupply: string;
158
+ initialSupply: string;
159
+ issuer: string;
160
+ address: string;
161
+ foreignToken?: TForeignToken | null;
162
+ /** Token metadata - format varies by token type (JSON structure kept flexible) */
163
+ metadata?: unknown;
164
+ website?: string | null;
165
+ icon: string;
166
+ }
@@ -0,0 +1,254 @@
1
+ // core/types/interfaces/index.ts
2
+ //
3
+ // NOTE: Proto types (T*) are exported directly from core/types/index.d.ts via lib/*_pb.d.ts
4
+ // This file only exports interface types (I*) that extend or complement proto types
5
+ // DO NOT re-export proto types here to avoid "already exported" errors
6
+
7
+ // Base types
8
+ export type {
9
+ BN,
10
+ BaseBN,
11
+ Promisable,
12
+ BytesType,
13
+ Timestamp,
14
+ Address,
15
+ Hash,
16
+ IAny,
17
+ PartialBy,
18
+ RequiredBy,
19
+ DeepPartial,
20
+ RequiredFields,
21
+ NonNullableFields,
22
+ } from './base';
23
+
24
+ // State types (extended Proto T*State interfaces)
25
+ export type {
26
+ IStateContext,
27
+ IStateContextInput,
28
+ IState,
29
+ IStateWithOwner,
30
+ StateChangeType,
31
+ StateKind,
32
+ IStateChangeEvent,
33
+ TokenBalanceMap,
34
+ // Account and Asset
35
+ IAccountState,
36
+ IAssetState,
37
+ IForeignToken,
38
+ ITokenMetadata,
39
+ ITokenState,
40
+ // Factory types
41
+ IFactoryHook,
42
+ IFactoryInput,
43
+ IAssetFactoryState,
44
+ IStakeState,
45
+ // Delegation types
46
+ IDelegationTokenLimit,
47
+ IDelegationAssetLimit,
48
+ IDelegationOpLimit,
49
+ IDelegationOps,
50
+ IDelegateState,
51
+ // Rollup types
52
+ IRollupValidator,
53
+ IRollupState,
54
+ IBlockSignature,
55
+ IRollupBlock,
56
+ IEvidenceState,
57
+ ITokenFactoryCurve,
58
+ ITokenFactoryState,
59
+ } from './state';
60
+
61
+ // Config types (interface types only - proto types exported from lib/*_pb.d.ts)
62
+ export type {
63
+ // Config-specific types
64
+ TxTypeUrl,
65
+ TxTypeMap,
66
+ // Extended types
67
+ IAccountConfig,
68
+ ITxGasConfig,
69
+ ITxStakeConfig,
70
+ ITransactionConfig,
71
+ ITokenConfig,
72
+ IVaultsConfig,
73
+ IConsensusConfig,
74
+ // Composite types
75
+ IDefaultConfig,
76
+ IChainConfig,
77
+ IChainConfigInput,
78
+ ITokenItx,
79
+ } from './config';
80
+
81
+ // StateDB
82
+ export type {
83
+ HookFunction,
84
+ StateEventHandler,
85
+ IOperationContext,
86
+ IChainTokenInfo,
87
+ IChainState,
88
+ ITxData,
89
+ ITxState,
90
+ IBalanceState,
91
+ IStateTable,
92
+ IBalanceTable,
93
+ ITokenTable,
94
+ IRollupTable,
95
+ IReady,
96
+ IStateDB,
97
+ StateDBTableName,
98
+ } from './statedb';
99
+
100
+ // IndexDB (interface types only - proto types T* exported from lib/*_pb.d.ts)
101
+ export type {
102
+ // Token format conversion types
103
+ TokenConversionInput,
104
+ // Unified indexed state type (local union type)
105
+ TIndexedState,
106
+ // IndexDB type mappings
107
+ IndexTableTypeMap,
108
+ IndexTableType,
109
+ IndexedTypeFor,
110
+ // State to indexed type mappings
111
+ StateToIndexedMap,
112
+ StateTypeOf,
113
+ IndexedTypeOf,
114
+ // IIndexTable interface
115
+ IndexTableHookFn,
116
+ IIndexTable,
117
+ // List result types
118
+ IListTransactionsResult,
119
+ IListAssetsResult,
120
+ IListAccountsResult,
121
+ IListTokensResult,
122
+ IListFactoriesResult,
123
+ IListStakesResult,
124
+ IListDelegationsResult,
125
+ IListRollupsResult,
126
+ IListRollupBlocksResult,
127
+ IListRollupValidatorsResult,
128
+ IListTokenFactoriesResult,
129
+ ListResultTypeMap,
130
+ ListResultFor,
131
+ // IIndexDB interface
132
+ IIndexDB,
133
+ } from './indexdb';
134
+
135
+ // Pipeline context types
136
+ export type {
137
+ // Common interfaces
138
+ IPipelineLogger,
139
+ IDecodedTransaction,
140
+ IMultiSigData,
141
+ IAccountUpdate,
142
+ ILockedState,
143
+ IInputChange,
144
+ IValidatedItx,
145
+ IGasStake,
146
+ ITokenCondition,
147
+ IOutput,
148
+ IInput,
149
+ // Phase context types (new 5-phase hierarchy)
150
+ IBaseContext,
151
+ ITxOnlyContext,
152
+ IDecodedContext,
153
+ IGasContext,
154
+ IReadyContext,
155
+ IExecutedContext,
156
+ // Mixin interfaces: Account states
157
+ IWithSender,
158
+ IWithReceiver,
159
+ IWithDelegator,
160
+ IWithDelegators,
161
+ IWithOwner,
162
+ IWithIssuer,
163
+ IWithIssuers,
164
+ IWithLocker,
165
+ IWithSigners,
166
+ IWithReceivers,
167
+ IWithSenders,
168
+ // Mixin interfaces: Protocol states
169
+ IWithAsset,
170
+ IWithAssets,
171
+ IWithToken,
172
+ IWithTokens,
173
+ IWithFactory,
174
+ IWithTokenFactory,
175
+ IWithStake,
176
+ IWithStakes,
177
+ IWithDelegation,
178
+ IWithRollup,
179
+ IWithRollupBlock,
180
+ IWithEvidence,
181
+ IWithLocked,
182
+ FinalizedContext,
183
+ } from './pipeline';
184
+
185
+ // Testing utility types
186
+ export type {
187
+ // Error types
188
+ ITestError,
189
+ PipeNextFn,
190
+ // Context types
191
+ PartialTransactionContext,
192
+ MockStateDB,
193
+ MockChainConfig,
194
+ // State types
195
+ MockAccountState,
196
+ MockAssetState,
197
+ MockTokenState,
198
+ MockStakeState,
199
+ MockDelegateState,
200
+ MockTxState,
201
+ // Full context
202
+ TestContext,
203
+ // Pipe function types
204
+ MockPipeFunction,
205
+ MockErrorPipeFunction,
206
+ // Result types
207
+ IExecuteResult,
208
+ IPipeTestResult,
209
+ } from './testing';
210
+
211
+ // Resolver types (shared between @ocap/gql and @ocap/resolver)
212
+ export type {
213
+ // Context and args
214
+ IResolverContext,
215
+ IGetAccountStateArgs,
216
+ IGetAccountTokensArgs,
217
+ IAddressArgs,
218
+ // Token and state types
219
+ ITokenInfo,
220
+ IResolverAccountState,
221
+ IResolverStakeState,
222
+ IResolverRollupState,
223
+ IResolverFactoryState,
224
+ // Paging
225
+ IResolverPaging,
226
+ // Transaction types
227
+ IResolverTxItxJson,
228
+ IResolverTransaction,
229
+ // List result types
230
+ IResolverListTransactionsResult,
231
+ IResolverListAssetsResult,
232
+ IResolverListAccountsResult,
233
+ IResolverListTokensResult,
234
+ IResolverListFactoriesResult,
235
+ IResolverListStakesResult,
236
+ IResolverListDelegationsResult,
237
+ IResolverListRollupsResult,
238
+ IResolverListRollupBlocksResult,
239
+ IResolverListRollupValidatorsResult,
240
+ IResolverListTokenFactoriesResult,
241
+ // Info types
242
+ IResolverChainInfo,
243
+ IResolverNodeInfo,
244
+ IResolverNetInfo,
245
+ IResolverValidatorsInfo,
246
+ IResolverForgeStats,
247
+ // Response wrappers
248
+ ITokenFlowsResult,
249
+ ISearchResult,
250
+ IEstimateGasResult,
251
+ IBlocksResult,
252
+ // Main interface
253
+ IResolver,
254
+ } from './resolver';